diff options
author | 2018-03-04 02:12:52 -0500 | |
---|---|---|
committer | 2018-03-04 02:12:52 -0500 | |
commit | d53ce571fc2977bcca2d714a7d19a00b42249780 (patch) | |
tree | e5dfc806386602467b90501b26befe9ea36b077e /Application/hu.bme.mit.inf.dslreasoner.application | |
parent | Generation is executed in a job (diff) | |
download | VIATRA-Generator-d53ce571fc2977bcca2d714a7d19a00b42249780.tar.gz VIATRA-Generator-d53ce571fc2977bcca2d714a7d19a00b42249780.tar.zst VIATRA-Generator-d53ce571fc2977bcca2d714a7d19a00b42249780.zip |
Consoles
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application')
3 files changed, 145 insertions, 68 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/META-INF/MANIFEST.MF b/Application/hu.bme.mit.inf.dslreasoner.application/META-INF/MANIFEST.MF index d0ce91c4..b2b0b963 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/META-INF/MANIFEST.MF +++ b/Application/hu.bme.mit.inf.dslreasoner.application/META-INF/MANIFEST.MF | |||
@@ -30,7 +30,10 @@ Require-Bundle: org.eclipse.xtext, | |||
30 | org.eclipse.emf.codegen;bundle-version="2.11.0", | 30 | org.eclipse.emf.codegen;bundle-version="2.11.0", |
31 | org.eclipse.viatra.query.tooling.core;bundle-version="2.0.0", | 31 | org.eclipse.viatra.query.tooling.core;bundle-version="2.0.0", |
32 | hu.bme.mit.inf.dslreasoner.visualisation;bundle-version="1.0.0", | 32 | hu.bme.mit.inf.dslreasoner.visualisation;bundle-version="1.0.0", |
33 | org.eclipse.core.runtime;bundle-version="3.12.0" | 33 | org.eclipse.core.runtime;bundle-version="3.12.0", |
34 | org.eclipse.ui.console;bundle-version="3.6.201", | ||
35 | org.eclipse.jface;bundle-version="3.12.2", | ||
36 | org.eclipse.ui;bundle-version="3.108.1" | ||
34 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | 37 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 |
35 | Export-Package: hu.bme.mit.inf.dslreasoner.application, | 38 | Export-Package: hu.bme.mit.inf.dslreasoner.application, |
36 | hu.bme.mit.inf.dslreasoner.application.applicationConfiguration, | 39 | hu.bme.mit.inf.dslreasoner.application.applicationConfiguration, |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend index 9ffd33c5..05d4e0c0 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend | |||
@@ -16,12 +16,14 @@ import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration | |||
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | 16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic |
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | 18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml |
19 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualisation; | 19 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualisation |
20 | import hu.bme.mit.inf.dslreasoner.workspace.ProjectWorkspace | 20 | import hu.bme.mit.inf.dslreasoner.workspace.ProjectWorkspace |
21 | import java.util.Optional | 21 | import java.util.Optional |
22 | import org.eclipse.emf.common.util.URI | ||
23 | import org.eclipse.core.runtime.IProgressMonitor | 22 | import org.eclipse.core.runtime.IProgressMonitor |
24 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.SolverProgressMonitor | 23 | import org.eclipse.emf.common.util.URI |
24 | import java.util.LinkedHashMap | ||
25 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript | ||
26 | import hu.bme.mit.inf.dslreasoner.logic.model.statistics.StatisticSections2CSV | ||
25 | 27 | ||
26 | class GenerationTaskExecutor { | 28 | class GenerationTaskExecutor { |
27 | val metamodelLoader = new MetamodelLoader | 29 | val metamodelLoader = new MetamodelLoader |
@@ -29,6 +31,7 @@ class GenerationTaskExecutor { | |||
29 | val queryLoader = new QueryLoader | 31 | val queryLoader = new QueryLoader |
30 | val solverLoader = new SolverLoader | 32 | val solverLoader = new SolverLoader |
31 | val scopeLoader = new ScopeLoader | 33 | val scopeLoader = new ScopeLoader |
34 | val statisticsUtil = new StatisticSections2CSV | ||
32 | 35 | ||
33 | val metamodelValidator = new MetamodelValidator | 36 | val metamodelValidator = new MetamodelValidator |
34 | val queryAndMetamodelValidator = new QueryAndMetamodelValidator | 37 | val queryAndMetamodelValidator = new QueryAndMetamodelValidator |
@@ -57,7 +60,7 @@ class GenerationTaskExecutor { | |||
57 | val memoryLimit = scriptExecutor.getMemoryLimit(configSpecification) | 60 | val memoryLimit = scriptExecutor.getMemoryLimit(configSpecification) |
58 | 61 | ||
59 | // 2. create console | 62 | // 2. create console |
60 | val console = new ScriptConsole(true,true, | 63 | val console = new ScriptConsole(false,true,false, |
61 | if(messageFile!==null) URI.createURI(messageFile.path) else null, | 64 | if(messageFile!==null) URI.createURI(messageFile.path) else null, |
62 | if(debugFolder!==null) URI.createURI('''«debugFolder.path»/errors.txt''') else null, | 65 | if(debugFolder!==null) URI.createURI('''«debugFolder.path»/errors.txt''') else null, |
63 | if(statisticsFile!==null) URI.createURI(statisticsFile.path) else null | 66 | if(statisticsFile!==null) URI.createURI(statisticsFile.path) else null |
@@ -98,6 +101,7 @@ class GenerationTaskExecutor { | |||
98 | 101 | ||
99 | // 4. translate all description to a logic problem | 102 | // 4. translate all description to a logic problem |
100 | monitor.subTask('''Translating all resources to logic''') | 103 | monitor.subTask('''Translating all resources to logic''') |
104 | var domain2LogicTransformationTime = System.nanoTime | ||
101 | val Ecore2Logic ecore2Logic = new Ecore2Logic | 105 | val Ecore2Logic ecore2Logic = new Ecore2Logic |
102 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) | 106 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) |
103 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) | 107 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) |
@@ -118,6 +122,7 @@ class GenerationTaskExecutor { | |||
118 | new Viatra2LogicConfiguration | 122 | new Viatra2LogicConfiguration |
119 | ).output | 123 | ).output |
120 | } | 124 | } |
125 | domain2LogicTransformationTime = System.nanoTime-domain2LogicTransformationTime | ||
121 | if(documentationLevel.atLeastNormal) { | 126 | if(documentationLevel.atLeastNormal) { |
122 | reasonerWorkspace.writeModel(problem,"generation.logicproblem") | 127 | reasonerWorkspace.writeModel(problem,"generation.logicproblem") |
123 | } | 128 | } |
@@ -161,7 +166,7 @@ class GenerationTaskExecutor { | |||
161 | solverLoader.setRunIndex(solverConfig,configurationMap,run,console) | 166 | solverLoader.setRunIndex(solverConfig,configurationMap,run,console) |
162 | solverConfig.progressMonitor = new EclipseProgressMonitor(monitor) | 167 | solverConfig.progressMonitor = new EclipseProgressMonitor(monitor) |
163 | val reasonerWorkspaceForRun = if(runs > 1) { | 168 | val reasonerWorkspaceForRun = if(runs > 1) { |
164 | reasonerWorkspace.subWorkspace('''run«run»''',"") => [init] | 169 | reasonerWorkspace.subWorkspace('''run«run»''',"") => [initAndClear] |
165 | } else { | 170 | } else { |
166 | reasonerWorkspace | 171 | reasonerWorkspace |
167 | } | 172 | } |
@@ -171,6 +176,8 @@ class GenerationTaskExecutor { | |||
171 | console.writeMessage(solution.soutionDescription.toString) | 176 | console.writeMessage(solution.soutionDescription.toString) |
172 | 177 | ||
173 | // 8. Solution processing | 178 | // 8. Solution processing |
179 | |||
180 | // 8.1 Visualisation | ||
174 | if(solution instanceof ModelResult) { | 181 | if(solution instanceof ModelResult) { |
175 | val interpretations = solver.getInterpretations(solution) | 182 | val interpretations = solver.getInterpretations(solution) |
176 | val outputWorkspaceForRun = if(runs > 1) { | 183 | val outputWorkspaceForRun = if(runs > 1) { |
@@ -180,7 +187,7 @@ class GenerationTaskExecutor { | |||
180 | } | 187 | } |
181 | 188 | ||
182 | for(interpretationIndex : 0..<interpretations.size) { | 189 | for(interpretationIndex : 0..<interpretations.size) { |
183 | monitor.subTask('''Solving problem«IF runs>0» «run»/«runs»«ENDIF»: Visualising solution «interpretationIndex»/«interpretations.size»''') | 190 | monitor.subTask('''Solving problem«IF runs>0» «run»/«runs»«ENDIF»: Visualising solution «interpretationIndex+1»/«interpretations.size»''') |
184 | val interpretation = interpretations.get(interpretationIndex) | 191 | val interpretation = interpretations.get(interpretationIndex) |
185 | val model = logic2Ecore.transformInterpretation(interpretation,modelGeneration.trace) | 192 | val model = logic2Ecore.transformInterpretation(interpretation,modelGeneration.trace) |
186 | outputWorkspaceForRun.writeModel(model,'''model«IF runs>1»_«run»«ENDIF»_«interpretationIndex+1».xmi''') | 193 | outputWorkspaceForRun.writeModel(model,'''model«IF runs>1»_«run»«ENDIF»_«interpretationIndex+1».xmi''') |
@@ -202,7 +209,20 @@ class GenerationTaskExecutor { | |||
202 | monitor.worked(solverConfig.solutionScope.numberOfRequiredSolution*100) | 209 | monitor.worked(solverConfig.solutionScope.numberOfRequiredSolution*100) |
203 | } | 210 | } |
204 | 211 | ||
212 | // 8.2 Statistics | ||
213 | val statistics = new LinkedHashMap | ||
214 | statistics.put("Task",(task.eContainer as ConfigurationScript).commands.indexOf(task)+1) | ||
215 | statistics.put("Run",run) | ||
216 | statistics.put("Result",solution.class.simpleName) | ||
217 | statistics.put("Domain to logic transformation time",domain2LogicTransformationTime/1000000) | ||
218 | statistics.put("Logic to solver transformation time",solution.statistics.transformationTime) | ||
219 | statistics.put("Solver time",solution.statistics.solverTime) | ||
220 | for(entry: solution.statistics.entries) { | ||
221 | statistics.put(entry.name,statisticsUtil.readValue(entry)) | ||
222 | } | ||
223 | console.addStatistics(statistics) | ||
205 | } | 224 | } |
225 | console.flushStatistics | ||
206 | console.writeMessage("Model generation finished") | 226 | console.writeMessage("Model generation finished") |
207 | } catch(Exception e) { | 227 | } catch(Exception e) { |
208 | console.writeError('''Error occured: «e.message»''') | 228 | console.writeError('''Error occured: «e.message»''') |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptConsole.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptConsole.xtend index 2dc329a0..4bf58c67 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptConsole.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptConsole.xtend | |||
@@ -1,24 +1,38 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution | 1 | package hu.bme.mit.inf.dslreasoner.application.execution |
2 | 2 | ||
3 | import java.io.File | 3 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace |
4 | import java.io.PrintWriter | 4 | import hu.bme.mit.inf.dslreasoner.workspace.ProjectWorkspace |
5 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | ||
6 | import java.util.LinkedHashMap | ||
5 | import java.util.LinkedHashSet | 7 | import java.util.LinkedHashSet |
6 | import java.util.LinkedList | 8 | import java.util.LinkedList |
7 | import java.util.Map | 9 | import java.util.Map |
8 | import org.eclipse.emf.common.util.URI | 10 | import org.eclipse.emf.common.util.URI |
9 | import java.io.Closeable | 11 | import org.eclipse.ui.IWorkbench |
10 | import java.io.IOException | 12 | import org.eclipse.ui.IWorkbenchPage |
11 | import java.util.LinkedHashMap | 13 | import org.eclipse.ui.IWorkbenchWindow |
12 | import java.util.HashMap | 14 | import org.eclipse.ui.PlatformUI |
15 | import org.eclipse.ui.console.ConsolePlugin | ||
16 | import org.eclipse.ui.console.IConsoleConstants | ||
17 | import org.eclipse.ui.console.IConsoleView | ||
18 | import org.eclipse.ui.console.MessageConsole | ||
19 | import java.util.List | ||
13 | 20 | ||
14 | class ScriptConsole implements Closeable { | 21 | //import org.eclipse.ui.console.MessageConsole |
22 | |||
23 | class ScriptConsole { | ||
24 | /** | ||
25 | * Console is identified with the name of this class. | ||
26 | */ | ||
27 | val final consoleID = ScriptConsole.name | ||
15 | val boolean printToConsole | 28 | val boolean printToConsole |
16 | val boolean cleanFiles | 29 | val MessageConsole runtimeConsole; |
17 | 30 | val ReasonerWorkspace messageWorkspace; | |
18 | val File messageConsoleFile | 31 | val String messageFileName; |
19 | val File errorConsoleFile | 32 | val ReasonerWorkspace errorWorkspace; |
20 | val File statisticsConsoleFile | 33 | val String errorFileName; |
21 | val Map<File,PrintWriter> file2Writer = new HashMap | 34 | val ReasonerWorkspace statisticsWorkspace; |
35 | val String statisticsFileName; | ||
22 | 36 | ||
23 | val statisticsHeaderBuffer = new LinkedHashSet<String> | 37 | val statisticsHeaderBuffer = new LinkedHashSet<String> |
24 | val statisticsDataBuffer = new LinkedList<Map<String,? extends Object>> | 38 | val statisticsDataBuffer = new LinkedList<Map<String,? extends Object>> |
@@ -28,29 +42,58 @@ class ScriptConsole implements Closeable { | |||
28 | 42 | ||
29 | public new( | 43 | public new( |
30 | boolean printToConsole, | 44 | boolean printToConsole, |
45 | boolean printToRuntimeConsole, | ||
31 | boolean cleanFiles, | 46 | boolean cleanFiles, |
32 | URI messageConsoleURI, | 47 | URI messageConsoleURI, |
33 | URI errorConsoleURI, | 48 | URI errorConsoleURI, |
34 | URI statisticsConsoleURI) | 49 | URI statisticsConsoleURI) |
35 | { | 50 | { |
51 | val List<String> errorMessagesDuringInitialisation = new LinkedList | ||
52 | |||
53 | this.messageWorkspace = prepareWorkspace(messageConsoleURI,errorMessagesDuringInitialisation) | ||
54 | this.messageFileName = prepareFileName(messageConsoleURI) | ||
55 | this.errorWorkspace = prepareWorkspace(errorConsoleURI,errorMessagesDuringInitialisation) | ||
56 | this.errorFileName = prepareFileName(errorConsoleURI) | ||
57 | this.statisticsWorkspace = prepareWorkspace(statisticsConsoleURI,errorMessagesDuringInitialisation) | ||
58 | this.statisticsFileName = prepareFileName(statisticsConsoleURI) | ||
59 | |||
36 | this.printToConsole = printToConsole | 60 | this.printToConsole = printToConsole |
37 | this.cleanFiles = cleanFiles | 61 | this.runtimeConsole = if(printToRuntimeConsole) { prepareRuntimeConsole } else { null } |
38 | this.messageConsoleFile = messageConsoleURI.prepareFile | 62 | |
39 | this.errorConsoleFile = errorConsoleURI.prepareFile | 63 | errorMessagesDuringInitialisation.forEach[ |
40 | this.statisticsConsoleFile = statisticsConsoleURI.prepareFile | 64 | this.writeError('''Error during console initialisation: "«it»"''') |
65 | ] | ||
41 | } | 66 | } |
42 | 67 | ||
43 | public def writeMessage(String message) { | 68 | public def writeMessage(String message) { |
44 | messageConsoleFile.writeToFile(message) | 69 | if(messageWorkspace!=null) { |
70 | messageWorkspace.writeText(messageFileName,message); | ||
71 | } | ||
72 | if(printToConsole) { | ||
73 | println(message) | ||
74 | } | ||
75 | if(runtimeConsole!==null) { | ||
76 | this.writeToRuntimeConsole(message) | ||
77 | } | ||
45 | } | 78 | } |
46 | public def writeError(String message) { | 79 | public def writeError(String message) { |
47 | errorConsoleFile.writeToFile(message) | 80 | if(errorWorkspace!=null) { |
81 | errorWorkspace.writeText(errorFileName,message); | ||
82 | } | ||
83 | if(printToConsole) { | ||
84 | println(message) | ||
85 | } | ||
86 | if(runtimeConsole!==null) { | ||
87 | this.writeToRuntimeConsole(message) | ||
88 | } | ||
48 | } | 89 | } |
49 | public def writeStatistics(LinkedHashMap<String,? extends Object> statistics) { | 90 | public def writeStatistics(LinkedHashMap<String,? extends Object> statistics) { |
50 | val message = ''' | 91 | if(statisticsWorkspace!==null) { |
92 | val message = ''' | ||
51 | «FOR key : statistics.keySet SEPARATOR delimier»«key»«ENDFOR» | 93 | «FOR key : statistics.keySet SEPARATOR delimier»«key»«ENDFOR» |
52 | «FOR value : statistics.values SEPARATOR delimier»«value»«ENDFOR»''' | 94 | «FOR value : statistics.values SEPARATOR delimier»«value»«ENDFOR»''' |
53 | statisticsConsoleFile.writeToFile(message) | 95 | statisticsWorkspace.writeText(statisticsFileName,message); |
96 | } | ||
54 | } | 97 | } |
55 | public def addStatistics(LinkedHashMap<String,? extends Object> statistics) { | 98 | public def addStatistics(LinkedHashMap<String,? extends Object> statistics) { |
56 | for(key : statistics.keySet) { | 99 | for(key : statistics.keySet) { |
@@ -59,61 +102,72 @@ class ScriptConsole implements Closeable { | |||
59 | this.statisticsDataBuffer.add(statistics) | 102 | this.statisticsDataBuffer.add(statistics) |
60 | } | 103 | } |
61 | public def flushStatistics() { | 104 | public def flushStatistics() { |
62 | val message = ''' | 105 | if(statisticsWorkspace!==null) { |
106 | val message = ''' | ||
63 | «FOR key : statisticsHeaderBuffer SEPARATOR delimier»«key»«ENDFOR» | 107 | «FOR key : statisticsHeaderBuffer SEPARATOR delimier»«key»«ENDFOR» |
64 | «FOR line : statisticsDataBuffer » | 108 | «FOR line : statisticsDataBuffer » |
65 | «FOR key : statisticsHeaderBuffer»«IF line.containsKey(key)»«empty»«ELSE»«line.get(key)»«ENDIF»«ENDFOR» | 109 | «FOR key : statisticsHeaderBuffer»«IF line.containsKey(key)»«empty»«ELSE»«line.get(key)»«ENDIF»«ENDFOR» |
66 | «ENDFOR» | 110 | «ENDFOR» |
67 | ''' | 111 | ''' |
68 | statisticsConsoleFile.writeToFile(message) | 112 | statisticsWorkspace.writeText(statisticsFileName,message); |
113 | } | ||
69 | } | 114 | } |
70 | /** | 115 | |
71 | * Writes a line of text to a file and the console. Initializes a writer to the file for at the first message. | 116 | private def prepareWorkspace(URI uri, List<String> errors) { |
72 | */ | 117 | if (uri === null) { |
73 | private def writeToFile(File file, String text) { | 118 | return null |
74 | if(file != null) { | 119 | } else { |
75 | val writer = if(this.file2Writer.containsKey(file)) { | 120 | try{ |
76 | this.file2Writer.get(file) | 121 | val folderURI = uri.trimSegments(1) |
77 | } else { | 122 | if(folderURI.isFile) { |
78 | if(!file.exists) { | 123 | return new FileSystemWorkspace(folderURI.toString,"")=>[init] |
79 | file.createNewFile | 124 | } else if(folderURI.isPlatformResource) { |
125 | return new ProjectWorkspace(folderURI.toString,"")=>[init] | ||
126 | } else { | ||
127 | throw new UnsupportedOperationException('''Unsupported file usi: "«uri»"!''') | ||
80 | } | 128 | } |
81 | val writer = new PrintWriter(file, "UTF-8"); | 129 | } catch(Exception e) { |
82 | this.file2Writer.put(file,writer) | 130 | errors += e.message |
83 | writer | 131 | return null |
84 | } | 132 | } |
85 | writer.println(text) | ||
86 | } | 133 | } |
87 | if(printToConsole) { | 134 | } |
88 | println(text) | 135 | private def prepareFileName(URI uri) { |
136 | if(uri!==null) { | ||
137 | return uri.lastSegment | ||
138 | } else { | ||
139 | null | ||
89 | } | 140 | } |
90 | } | 141 | } |
91 | 142 | ||
92 | private def prepareFile(URI uri) { | 143 | private def MessageConsole prepareRuntimeConsole() { |
93 | if (uri === null) { | 144 | val plugin = ConsolePlugin.getDefault(); |
94 | return null | 145 | val conMan = plugin.getConsoleManager(); |
146 | val existingConsoles = conMan.getConsoles(); | ||
147 | val existingConsolesWithID = existingConsoles.filter[it.name.equals(consoleID)] | ||
148 | if(existingConsolesWithID.empty) { | ||
149 | val MessageConsole res = new MessageConsole(consoleID,null) | ||
150 | conMan.addConsoles(#[res]); | ||
151 | return res | ||
95 | } else { | 152 | } else { |
96 | if(uri.isFile) { | 153 | return existingConsolesWithID.head as MessageConsole |
97 | val fileString = uri.toFileString | ||
98 | val file = new File(fileString) | ||
99 | if (this.cleanFiles && file.exists) { | ||
100 | file.delete | ||
101 | } | ||
102 | return file | ||
103 | } else if(uri.isPlatformResource) { | ||
104 | val platformString = uri.toPlatformString(true) | ||
105 | val file = new File(platformString) | ||
106 | if (this.cleanFiles && file.exists) { | ||
107 | file.delete | ||
108 | } | ||
109 | return file | ||
110 | } else { | ||
111 | throw new UnsupportedOperationException('''Unksupported file usi: "«uri»"!''') | ||
112 | } | ||
113 | } | 154 | } |
114 | } | 155 | } |
115 | 156 | ||
116 | override close() throws IOException { | 157 | private def writeToRuntimeConsole(CharSequence message) { |
117 | this.file2Writer.values.forEach[close] | 158 | // 1. reveal the console view |
159 | // val IWorkbench wb = PlatformUI.getWorkbench(); | ||
160 | // val IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); | ||
161 | // val IWorkbenchPage page = win.getActivePage(); | ||
162 | // val id = IConsoleConstants.ID_CONSOLE_VIEW; | ||
163 | // val view = page.showView(id) as IConsoleView; | ||
164 | // view.display(this.runtimeConsole); | ||
165 | |||
166 | ConsolePlugin.getDefault().getConsoleManager().showConsoleView(this.runtimeConsole); | ||
167 | |||
168 | // 2. write to the console | ||
169 | val stream = this.runtimeConsole.newMessageStream | ||
170 | stream.println(message.toString) | ||
171 | stream.close | ||
118 | } | 172 | } |
119 | } \ No newline at end of file | 173 | } \ No newline at end of file |