diff options
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit')
5 files changed, 119 insertions, 242 deletions
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 c9d38c7d..3e879539 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 | |||
@@ -41,6 +41,7 @@ class GenerationTaskExecutor { | |||
41 | def executeGenerationTask( | 41 | def executeGenerationTask( |
42 | GenerationTask task, | 42 | GenerationTask task, |
43 | ScriptExecutor scriptExecutor, | 43 | ScriptExecutor scriptExecutor, |
44 | ScriptConsole.Factory scriptConsoleFactory, | ||
44 | IProgressMonitor monitor) | 45 | IProgressMonitor monitor) |
45 | { | 46 | { |
46 | monitor.subTask('''Collecting all resources''') | 47 | monitor.subTask('''Collecting all resources''') |
@@ -62,7 +63,7 @@ class GenerationTaskExecutor { | |||
62 | val memoryLimit = scriptExecutor.getMemoryLimit(configSpecification) | 63 | val memoryLimit = scriptExecutor.getMemoryLimit(configSpecification) |
63 | 64 | ||
64 | // 2. create console | 65 | // 2. create console |
65 | val console = new ScriptConsole(true,false, | 66 | val console = scriptConsoleFactory.createScriptConsole(false, |
66 | if(messageFile!==null) URI.createURI(messageFile.path) else null, | 67 | if(messageFile!==null) URI.createURI(messageFile.path) else null, |
67 | if(debugFolder!==null) URI.createURI('''«debugFolder.path»/errors.txt''') else null, | 68 | if(debugFolder!==null) URI.createURI('''«debugFolder.path»/errors.txt''') else null, |
68 | if(statisticsFile!==null) URI.createURI(statisticsFile.path) else null | 69 | if(statisticsFile!==null) URI.createURI(statisticsFile.path) else null |
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 91d3d286..0f89ba1e 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 | |||
@@ -9,128 +9,108 @@ import java.util.LinkedHashSet | |||
9 | import java.util.LinkedList | 9 | import java.util.LinkedList |
10 | import java.util.List | 10 | import java.util.List |
11 | import java.util.Map | 11 | import java.util.Map |
12 | import java.util.concurrent.CompletableFuture | ||
13 | import javax.swing.text.BadLocationException | ||
14 | import org.eclipse.emf.common.util.URI | 12 | import org.eclipse.emf.common.util.URI |
15 | import org.eclipse.jface.text.DocumentEvent | ||
16 | import org.eclipse.jface.text.IDocumentListener | ||
17 | import org.eclipse.swt.graphics.Color | ||
18 | import org.eclipse.ui.console.ConsolePlugin | ||
19 | import org.eclipse.ui.console.MessageConsole | ||
20 | import org.eclipse.ui.console.MessageConsoleStream | ||
21 | import org.eclipse.xtend.lib.annotations.Data | 13 | import org.eclipse.xtend.lib.annotations.Data |
22 | 14 | ||
23 | //import org.eclipse.ui.console.MessageConsole | 15 | abstract class ScriptConsole { |
24 | |||
25 | class ScriptConsole { | ||
26 | /** | ||
27 | * Console is identified with the name of this class. | ||
28 | */ | ||
29 | val final consoleID = ScriptConsole.name | ||
30 | val boolean printToConsole | 16 | val boolean printToConsole |
31 | val MessageConsole runtimeConsole; | ||
32 | val ReasonerWorkspace messageWorkspace; | 17 | val ReasonerWorkspace messageWorkspace; |
33 | val String messageFileName; | 18 | val String messageFileName; |
34 | val ReasonerWorkspace errorWorkspace; | 19 | val ReasonerWorkspace errorWorkspace; |
35 | val String errorFileName; | 20 | val String errorFileName; |
36 | val ReasonerWorkspace statisticsWorkspace; | 21 | val ReasonerWorkspace statisticsWorkspace; |
37 | val String statisticsFileName; | 22 | val String statisticsFileName; |
38 | 23 | val List<String> errorMessagesDuringInitialisation = new LinkedList; | |
24 | |||
39 | val statisticsHeaderBuffer = new LinkedHashSet<String> | 25 | val statisticsHeaderBuffer = new LinkedHashSet<String> |
40 | val statisticsDataBuffer = new LinkedList<Map<String,? extends Object>> | 26 | val statisticsDataBuffer = new LinkedList<Map<String, ? extends Object>> |
41 | 27 | ||
42 | static val delimier = ';' | 28 | static val delimier = ';' |
43 | static val empty = "" | 29 | static val empty = "" |
44 | 30 | ||
45 | public new( | 31 | new(boolean printToConsole, boolean cleanFiles, URI messageConsoleURI, URI errorConsoleURI, |
46 | boolean printToRuntimeConsole, | 32 | URI statisticsConsoleURI) { |
47 | boolean cleanFiles, | 33 | this.messageWorkspace = prepareWorkspace(messageConsoleURI, errorMessagesDuringInitialisation) |
48 | URI messageConsoleURI, | ||
49 | URI errorConsoleURI, | ||
50 | URI statisticsConsoleURI) | ||
51 | { | ||
52 | val List<String> errorMessagesDuringInitialisation = new LinkedList | ||
53 | |||
54 | this.messageWorkspace = prepareWorkspace(messageConsoleURI,errorMessagesDuringInitialisation) | ||
55 | this.messageFileName = prepareFileName(messageConsoleURI) | 34 | this.messageFileName = prepareFileName(messageConsoleURI) |
56 | this.errorWorkspace = prepareWorkspace(errorConsoleURI,errorMessagesDuringInitialisation) | 35 | this.errorWorkspace = prepareWorkspace(errorConsoleURI, errorMessagesDuringInitialisation) |
57 | this.errorFileName = prepareFileName(errorConsoleURI) | 36 | this.errorFileName = prepareFileName(errorConsoleURI) |
58 | this.statisticsWorkspace = prepareWorkspace(statisticsConsoleURI,errorMessagesDuringInitialisation) | 37 | this.statisticsWorkspace = prepareWorkspace(statisticsConsoleURI, errorMessagesDuringInitialisation) |
59 | this.statisticsFileName = prepareFileName(statisticsConsoleURI) | 38 | this.statisticsFileName = prepareFileName(statisticsConsoleURI) |
60 | 39 | ||
61 | this.printToConsole = (ConsolePlugin.getDefault() === null) | 40 | this.printToConsole = printToConsole |
62 | this.runtimeConsole = if(printToRuntimeConsole) { prepareRuntimeConsole } else { null } | 41 | } |
63 | 42 | ||
64 | errorMessagesDuringInitialisation.forEach[ | 43 | /** |
44 | * Writes any error messages that occurred during console initialization. | ||
45 | * | ||
46 | * Should be called by implementations at the end of their constructors. | ||
47 | */ | ||
48 | protected final def writeErrorMessagesDuringInitialisation() { | ||
49 | errorMessagesDuringInitialisation.forEach [ | ||
65 | this.writeError('''Error during console initialisation: "«it»"''') | 50 | this.writeError('''Error during console initialisation: "«it»"''') |
66 | ] | 51 | ] |
52 | errorMessagesDuringInitialisation.clear | ||
67 | } | 53 | } |
68 | 54 | ||
69 | public def writeMessage(CharSequence message, String separator, ScriptConsoleDecorator[] decorators) { | 55 | def void writeMessage(CharSequence message, String separator, ScriptConsoleDecorator[] decorators) { |
70 | val resolvedText = this.resolveToText(message, separator, decorators) | 56 | val resolvedText = this.resolveToText(message, separator, decorators) |
71 | if(messageWorkspace!==null) { | 57 | if (messageWorkspace !== null) { |
72 | messageWorkspace.writeText(messageFileName,resolvedText); | 58 | messageWorkspace.writeText(messageFileName, resolvedText); |
73 | } | 59 | } |
74 | if(printToConsole) { | 60 | if (printToConsole) { |
75 | println(resolvedText) | 61 | println(resolvedText) |
76 | } | 62 | } |
77 | if(runtimeConsole!==null) { | ||
78 | writeToRuntimeConsole(message, separator, decorators) | ||
79 | } | ||
80 | } | 63 | } |
81 | public def writeMessage(String message) { | 64 | |
82 | if(messageWorkspace!==null) { | 65 | def void writeMessage(String message) { |
83 | messageWorkspace.writeText(messageFileName,message); | 66 | if (messageWorkspace !== null) { |
67 | messageWorkspace.writeText(messageFileName, message); | ||
84 | } | 68 | } |
85 | if(printToConsole) { | 69 | if (printToConsole) { |
86 | println(message) | 70 | println(message) |
87 | } | 71 | } |
88 | if(runtimeConsole!==null) { | ||
89 | writeToRuntimeConsole(message) | ||
90 | } | ||
91 | } | 72 | } |
92 | public def writeError(CharSequence message, String separator, ScriptConsoleDecorator[] decorators) { | 73 | |
74 | def void writeError(CharSequence message, String separator, ScriptConsoleDecorator[] decorators) { | ||
93 | val resolvedText = this.resolveToText(message, separator, decorators) | 75 | val resolvedText = this.resolveToText(message, separator, decorators) |
94 | if(errorWorkspace!==null) { | 76 | if (errorWorkspace !== null) { |
95 | errorWorkspace.writeText(errorFileName,resolvedText); | 77 | errorWorkspace.writeText(errorFileName, resolvedText); |
96 | } | 78 | } |
97 | println(message) | 79 | println(message) |
98 | if(runtimeConsole!==null) { | ||
99 | writeToRuntimeConsole(message, separator, decorators) | ||
100 | } | ||
101 | } | 80 | } |
102 | public def writeError(String message) { | 81 | |
103 | if(errorWorkspace!==null) { | 82 | def void writeError(String message) { |
104 | errorWorkspace.writeText(errorFileName,message); | 83 | if (errorWorkspace !== null) { |
84 | errorWorkspace.writeText(errorFileName, message); | ||
105 | } | 85 | } |
106 | println(message) | 86 | println(message) |
107 | if(runtimeConsole!==null) { | ||
108 | writeToRuntimeConsole(message) | ||
109 | } | ||
110 | } | 87 | } |
111 | public def writeStatistics(LinkedHashMap<String,? extends Object> statistics) { | 88 | |
112 | if(statisticsWorkspace!==null) { | 89 | def writeStatistics(LinkedHashMap<String, ? extends Object> statistics) { |
90 | if (statisticsWorkspace !== null) { | ||
113 | val message = ''' | 91 | val message = ''' |
114 | «FOR key : statistics.keySet SEPARATOR delimier»«key»«ENDFOR» | 92 | «FOR key : statistics.keySet SEPARATOR delimier»«key»«ENDFOR» |
115 | «FOR value : statistics.values SEPARATOR delimier»«value»«ENDFOR»''' | 93 | «FOR value : statistics.values SEPARATOR delimier»«value»«ENDFOR»''' |
116 | statisticsWorkspace.writeText(statisticsFileName,message); | 94 | statisticsWorkspace.writeText(statisticsFileName, message); |
117 | } | 95 | } |
118 | } | 96 | } |
119 | public def addStatistics(LinkedHashMap<String,? extends Object> statistics) { | 97 | |
120 | for(key : statistics.keySet) { | 98 | def addStatistics(LinkedHashMap<String, ? extends Object> statistics) { |
99 | for (key : statistics.keySet) { | ||
121 | this.statisticsHeaderBuffer.add(key); | 100 | this.statisticsHeaderBuffer.add(key); |
122 | } | 101 | } |
123 | this.statisticsDataBuffer.add(statistics) | 102 | this.statisticsDataBuffer.add(statistics) |
124 | } | 103 | } |
125 | public def flushStatistics() { | 104 | |
126 | if(statisticsWorkspace!==null) { | 105 | def flushStatistics() { |
106 | if (statisticsWorkspace !== null) { | ||
127 | val message = ''' | 107 | val message = ''' |
128 | «FOR key : statisticsHeaderBuffer SEPARATOR delimier»«key»«ENDFOR» | 108 | «FOR key : statisticsHeaderBuffer SEPARATOR delimier»«key»«ENDFOR» |
129 | «FOR line : statisticsDataBuffer» | 109 | «FOR line : statisticsDataBuffer» |
130 | «FOR key : statisticsHeaderBuffer SEPARATOR delimier»«IF line.containsKey(key)»«line.get(key)»«ELSE»«empty»«ENDIF»«ENDFOR» | 110 | «FOR key : statisticsHeaderBuffer SEPARATOR delimier»«IF line.containsKey(key)»«line.get(key)»«ELSE»«empty»«ENDIF»«ENDFOR» |
131 | «ENDFOR» | 111 | «ENDFOR» |
132 | ''' | 112 | ''' |
133 | statisticsWorkspace.writeText(statisticsFileName,message); | 113 | statisticsWorkspace.writeText(statisticsFileName, message); |
134 | statisticsHeaderBuffer.clear | 114 | statisticsHeaderBuffer.clear |
135 | statisticsDataBuffer.clear | 115 | statisticsDataBuffer.clear |
136 | } | 116 | } |
@@ -140,143 +120,66 @@ class ScriptConsole { | |||
140 | if (uri === null) { | 120 | if (uri === null) { |
141 | return null | 121 | return null |
142 | } else { | 122 | } else { |
143 | try{ | 123 | try { |
144 | val folderURI = uri.trimSegments(1) | 124 | val folderURI = uri.trimSegments(1) |
145 | if(folderURI.isFile) { | 125 | if (folderURI.isFile) { |
146 | return new FileSystemWorkspace(folderURI.toString,"")=>[init] | 126 | return new FileSystemWorkspace(folderURI.toString, "") => [init] |
147 | } else if(folderURI.isPlatformResource) { | 127 | } else if (folderURI.isPlatformResource) { |
148 | return new ProjectWorkspace(folderURI.toString,"")=>[init] | 128 | return new ProjectWorkspace(folderURI.toString, "") => [init] |
149 | } else { | 129 | } else { |
150 | throw new UnsupportedOperationException('''Unsupported file usi: "«uri»"!''') | 130 | throw new UnsupportedOperationException('''Unsupported file usi: "«uri»"!''') |
151 | } | 131 | } |
152 | } catch(Exception e) { | 132 | } catch (Exception e) { |
153 | errors += e.message | 133 | errors += e.message |
154 | return null | 134 | return null |
155 | } | 135 | } |
156 | } | 136 | } |
157 | } | 137 | } |
138 | |||
158 | private def prepareFileName(URI uri) { | 139 | private def prepareFileName(URI uri) { |
159 | if(uri!==null) { | 140 | if (uri !== null) { |
160 | return uri.lastSegment | 141 | return uri.lastSegment |
161 | } else { | 142 | } else { |
162 | null | 143 | null |
163 | } | 144 | } |
164 | } | 145 | } |
165 | 146 | ||
166 | private def MessageConsole prepareRuntimeConsole() { | ||
167 | val plugin = ConsolePlugin.getDefault(); | ||
168 | if(plugin === null) { | ||
169 | return null | ||
170 | } else { | ||
171 | val conMan = plugin.getConsoleManager(); | ||
172 | val existingConsoles = conMan.getConsoles(); | ||
173 | val existingConsolesWithID = existingConsoles.filter[it.name.equals(consoleID)] | ||
174 | if(existingConsolesWithID.empty) { | ||
175 | val MessageConsole res = new MessageConsole(consoleID,null) | ||
176 | conMan.addConsoles(#[res]); | ||
177 | |||
178 | return res | ||
179 | } else { | ||
180 | return existingConsolesWithID.head as MessageConsole | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | private def resolveToText(CharSequence message, String separator, ScriptConsoleDecorator[] decorators) { | 147 | private def resolveToText(CharSequence message, String separator, ScriptConsoleDecorator[] decorators) { |
185 | val messageString = message.toString | 148 | val messageString = message.toString |
186 | // 0. split the message | 149 | // 0. split the message |
187 | val separatedMessage = if(messageString.startsWith(separator,-1)) { | 150 | val separatedMessage = if (messageString.startsWith(separator, -1)) { |
188 | #[""]+messageString.split(separator,-1) | 151 | #[""] + messageString.split(separator, -1) |
189 | } else { | 152 | } else { |
190 | messageString.split(separator,-1).toList | 153 | messageString.split(separator, -1).toList |
191 | } | 154 | } |
192 | if(separatedMessage.size-1 !== decorators.size) { | 155 | if (separatedMessage.size - 1 !== decorators.size) { |
193 | throw new IllegalArgumentException | 156 | throw new IllegalArgumentException |
194 | } | 157 | } |
195 | 158 | ||
196 | return '''«FOR i : 0..<decorators.size»«separatedMessage.get(i)»[«decorators.get(i).text»]«ENDFOR»«separatedMessage.last»''' | 159 | return '''«FOR i : 0..<decorators.size»«separatedMessage.get(i)»[«decorators.get(i).text»]«ENDFOR»«separatedMessage.last»''' |
197 | } | 160 | } |
198 | private def writeToRuntimeConsole(CharSequence message) { | 161 | |
199 | // 1. reveal the console view | 162 | @FunctionalInterface |
200 | ConsolePlugin.getDefault().getConsoleManager().showConsoleView(this.runtimeConsole); | 163 | interface Factory { |
201 | val stream = this.runtimeConsole.newMessageStream | 164 | def ScriptConsole createScriptConsole(boolean cleanFiles, URI messageConsoleURI, URI errorConsoleURI, |
202 | stream.println(message.toString) | 165 | URI statisticsConsoleURI) |
203 | stream.close | ||
204 | } | 166 | } |
205 | private def writeToRuntimeConsole(CharSequence message, String separator, ScriptConsoleDecorator[] decorators) { | 167 | } |
206 | val messageString = message.toString | 168 | |
207 | // 0. split the message | 169 | class StandardOutputBasedScriptConsole extends ScriptConsole { |
208 | val separatedMessage = if(messageString.startsWith(separator)) { | 170 | new(boolean cleanFiles, URI messageConsoleURI, URI errorConsoleURI, URI statisticsConsoleURI) { |
209 | #[""]+messageString.split(separator,-1) | 171 | super(true, cleanFiles, messageConsoleURI, errorConsoleURI, statisticsConsoleURI) |
210 | } else { | 172 | writeErrorMessagesDuringInitialisation() |
211 | messageString.split(separator,-1).toList | ||
212 | } | ||
213 | if(separatedMessage.size-1 !== decorators.size) { | ||
214 | throw new IllegalArgumentException | ||
215 | } | ||
216 | |||
217 | // 1. reveal the console view | ||
218 | ConsolePlugin.getDefault().getConsoleManager().showConsoleView(this.runtimeConsole); | ||
219 | val stream = this.runtimeConsole.newMessageStream | ||
220 | |||
221 | // 2. print the segments of the view | ||
222 | for(i : 0..<decorators.size) { | ||
223 | stream.print(separatedMessage.get(i)) | ||
224 | writeDecoratedTextToRuntimeConsole(decorators.get(i),stream) | ||
225 | |||
226 | } | ||
227 | // 2.1 write the last segment of | ||
228 | stream.println(separatedMessage.last) | ||
229 | |||
230 | //stream.println(message.toString) | ||
231 | stream.close | ||
232 | } | 173 | } |
233 | private def writeDecoratedTextToRuntimeConsole(ScriptConsoleDecorator message, MessageConsoleStream stream) { | 174 | |
234 | val originalBackgroundColor = this.runtimeConsole.background | 175 | public static val FACTORY = new ScriptConsole.Factory { |
235 | var Color newColor = null; | 176 | override createScriptConsole(boolean cleanFiles, URI messageConsoleURI, URI errorConsoleURI, |
236 | 177 | URI statisticsConsoleURI) { | |
237 | val text = '''[«message.text»]''' | 178 | new StandardOutputBasedScriptConsole(cleanFiles, messageConsoleURI, errorConsoleURI, statisticsConsoleURI) |
238 | if(message.red >= 0 && message.green >= 0 && message.blue >= 0) { | ||
239 | newColor = new Color(originalBackgroundColor.device,message.red,message.green,message.blue) | ||
240 | this.runtimeConsole.setBackground(newColor) | ||
241 | } | ||
242 | stream.flush | ||
243 | val CompletableFuture<Boolean> finished = new CompletableFuture<Boolean> | ||
244 | val listener = new IDocumentListener() { | ||
245 | override documentAboutToBeChanged(DocumentEvent event) { } | ||
246 | override documentChanged(DocumentEvent event) { | ||
247 | //println('''ftext="«event.fText»", message="«message.text»" endswith=«event.fText.endsWith(message.text)»''') | ||
248 | if(event.fText.endsWith(text)) { | ||
249 | val from = event.fDocument.length-text.length+1 | ||
250 | val length = message.text.length | ||
251 | //println('''from: «from» length «length»''') | ||
252 | try{ | ||
253 | runtimeConsole.addHyperlink( | ||
254 | new ScriptConsoleFileHiperlink(message.hyperlink), | ||
255 | from, | ||
256 | length | ||
257 | ) | ||
258 | //println("link added") | ||
259 | } catch(BadLocationException e) { | ||
260 | |||
261 | } finally { | ||
262 | runtimeConsole.document.removeDocumentListener(this) | ||
263 | finished.complete(true) | ||
264 | } | ||
265 | } | ||
266 | |||
267 | } | ||
268 | } | ||
269 | runtimeConsole.document.addDocumentListener(listener) | ||
270 | stream.print(text) | ||
271 | stream.flush | ||
272 | finished.get | ||
273 | //stream.console.new | ||
274 | if(message.red >= 0 && message.green >= 0 && message.blue >= 0) { | ||
275 | newColor.dispose | ||
276 | this.runtimeConsole.setBackground(originalBackgroundColor) | ||
277 | } | 179 | } |
278 | } | 180 | } |
279 | } | 181 | } |
182 | |||
280 | @Data | 183 | @Data |
281 | class ScriptConsoleDecorator { | 184 | class ScriptConsoleDecorator { |
282 | String text | 185 | String text |
@@ -284,33 +187,36 @@ class ScriptConsoleDecorator { | |||
284 | int Red | 187 | int Red |
285 | int Green | 188 | int Green |
286 | int Blue | 189 | int Blue |
287 | 190 | ||
288 | public new(String text) { | 191 | new(String text) { |
289 | this.text = text | 192 | this.text = text |
290 | this.hyperlink = null | 193 | this.hyperlink = null |
291 | this.Red = -1 | 194 | this.Red = -1 |
292 | this.Green = -1 | 195 | this.Green = -1 |
293 | this.Blue = -1 | 196 | this.Blue = -1 |
294 | } | 197 | } |
295 | public new(String text, File hyperlink) { | 198 | |
199 | new(String text, File hyperlink) { | ||
296 | this.text = text | 200 | this.text = text |
297 | this.hyperlink = hyperlink | 201 | this.hyperlink = hyperlink |
298 | this.Red = -1 | 202 | this.Red = -1 |
299 | this.Green = -1 | 203 | this.Green = -1 |
300 | this.Blue = -1 | 204 | this.Blue = -1 |
301 | } | 205 | } |
302 | public new(String text, int red, int green, int blue) { | 206 | |
207 | new(String text, int red, int green, int blue) { | ||
303 | this.text = text | 208 | this.text = text |
304 | this.hyperlink = null | 209 | this.hyperlink = null |
305 | this.Red = red | 210 | this.Red = red |
306 | this.Green = green | 211 | this.Green = green |
307 | this.Blue = blue | 212 | this.Blue = blue |
308 | } | 213 | } |
309 | public new(String text, File hyperlink, int red, int green, int blue) { | 214 | |
215 | new(String text, File hyperlink, int red, int green, int blue) { | ||
310 | this.text = text | 216 | this.text = text |
311 | this.hyperlink = hyperlink | 217 | this.hyperlink = hyperlink |
312 | this.Red = red | 218 | this.Red = red |
313 | this.Green = green | 219 | this.Green = green |
314 | this.Blue = blue | 220 | this.Blue = blue |
315 | } | 221 | } |
316 | } \ No newline at end of file | 222 | } |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptConsoleFileHiperlink.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptConsoleFileHiperlink.xtend deleted file mode 100644 index 25e49c80..00000000 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptConsoleFileHiperlink.xtend +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution | ||
2 | |||
3 | import org.eclipse.ui.console.IHyperlink | ||
4 | import org.eclipse.ui.ide.IDE | ||
5 | import org.eclipse.ui.PlatformUI | ||
6 | import org.eclipse.core.filesystem.EFS | ||
7 | import java.io.File | ||
8 | import java.net.URI | ||
9 | |||
10 | class ScriptConsoleFileHiperlink implements IHyperlink { | ||
11 | |||
12 | private val URI path; | ||
13 | |||
14 | new(File file) { | ||
15 | this.path = file.toURI() | ||
16 | } | ||
17 | |||
18 | override linkActivated() { | ||
19 | //println("open path: "+path.toString) | ||
20 | val page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); | ||
21 | val fileStore = EFS.getStore(path) | ||
22 | IDE.openEditorOnFileStore(page,fileStore) | ||
23 | } | ||
24 | |||
25 | override linkEntered() { } | ||
26 | |||
27 | override linkExited() { } | ||
28 | } \ No newline at end of file | ||
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend index c9ec68bb..0512a5ee 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend | |||
@@ -4,6 +4,7 @@ import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigRef | |||
4 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigSpecification | 4 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigSpecification |
5 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript | 5 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript |
6 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.CustomEntry | 6 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.CustomEntry |
7 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.DocumentLevelSpecification | ||
7 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.DocumentationEntry | 8 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.DocumentationEntry |
8 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.EPackageImport | 9 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.EPackageImport |
9 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.FileReference | 10 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.FileReference |
@@ -24,15 +25,18 @@ import hu.bme.mit.inf.dslreasoner.application.execution.util.ApplicationConfigur | |||
24 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | 25 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel |
25 | import java.util.LinkedHashMap | 26 | import java.util.LinkedHashMap |
26 | import java.util.Optional | 27 | import java.util.Optional |
27 | import org.eclipse.emf.common.util.URI | ||
28 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.DocumentLevelSpecification | ||
29 | import org.eclipse.core.runtime.jobs.Job | ||
30 | import org.eclipse.core.runtime.IProgressMonitor | 28 | import org.eclipse.core.runtime.IProgressMonitor |
31 | import org.eclipse.core.runtime.Status | 29 | import org.eclipse.core.runtime.Status |
30 | import org.eclipse.core.runtime.jobs.Job | ||
31 | import org.eclipse.emf.common.util.URI | ||
32 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
32 | 33 | ||
34 | @FinalFieldsConstructor | ||
33 | class ScriptExecutor { | 35 | class ScriptExecutor { |
34 | val parser = new ApplicationConfigurationParser | 36 | val parser = new ApplicationConfigurationParser |
35 | 37 | ||
38 | val ScriptConsole.Factory scriptConsoleFactory | ||
39 | |||
36 | /** | 40 | /** |
37 | * Executes a script | 41 | * Executes a script |
38 | */ | 42 | */ |
@@ -92,7 +96,7 @@ class ScriptExecutor { | |||
92 | 96 | ||
93 | def public dispatch execute(GenerationTask task, IProgressMonitor monitor) { | 97 | def public dispatch execute(GenerationTask task, IProgressMonitor monitor) { |
94 | val generationTaskExecutor = new GenerationTaskExecutor | 98 | val generationTaskExecutor = new GenerationTaskExecutor |
95 | generationTaskExecutor.executeGenerationTask(task,this,monitor) | 99 | generationTaskExecutor.executeGenerationTask(task,this,scriptConsoleFactory,monitor) |
96 | } | 100 | } |
97 | 101 | ||
98 | def public dispatch execute(Task task, IProgressMonitor monitor) { | 102 | def public dispatch execute(Task task, IProgressMonitor monitor) { |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend index c612f0ea..4ed57903 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend | |||
@@ -1,27 +1,17 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution | 1 | package hu.bme.mit.inf.dslreasoner.application.execution |
2 | 2 | ||
3 | import com.google.inject.Guice | ||
4 | import com.google.inject.Injector | ||
3 | import hu.bme.mit.inf.dslreasoner.application.ApplicationConfigurationStandaloneSetup | 5 | import hu.bme.mit.inf.dslreasoner.application.ApplicationConfigurationStandaloneSetup |
4 | import org.eclipse.emf.common.util.URI | ||
5 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl | ||
6 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript | 6 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript |
7 | import org.eclipse.core.runtime.NullProgressMonitor | 7 | import org.eclipse.core.runtime.NullProgressMonitor |
8 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup | 8 | import org.eclipse.emf.common.util.URI |
9 | import org.eclipse.emf.ecore.util.EcoreUtil | ||
10 | import java.io.FileNotFoundException | ||
11 | import org.eclipse.emf.ecore.resource.Resource | 9 | import org.eclipse.emf.ecore.resource.Resource |
12 | import java.io.IOException | 10 | import org.eclipse.emf.ecore.util.EcoreUtil |
13 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | 11 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl |
14 | import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactoryProvider | 12 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup |
15 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactoryProvider | ||
16 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions | ||
17 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint | ||
18 | import org.eclipse.viatra.query.runtime.rete.util.ReteHintOptions | ||
19 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine | 13 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine |
20 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneCompilerSetup | ||
21 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetupGenerated | ||
22 | import org.eclipse.xtext.resource.XtextResourceSet | 14 | import org.eclipse.xtext.resource.XtextResourceSet |
23 | import com.google.inject.Injector | ||
24 | import com.google.inject.Guice | ||
25 | 15 | ||
26 | class StandaloneScriptExecutor { | 16 | class StandaloneScriptExecutor { |
27 | def static void main(String[] args) { | 17 | def static void main(String[] args) { |
@@ -94,8 +84,12 @@ class StandaloneScriptExecutor { | |||
94 | } | 84 | } |
95 | } | 85 | } |
96 | 86 | ||
97 | def static executeScript(String path){ | 87 | def static executeScript(String path) { |
98 | val executor = new ScriptExecutor | 88 | executeScript(path, StandardOutputBasedScriptConsole.FACTORY) |
89 | } | ||
90 | |||
91 | def static executeScript(String path, ScriptConsole.Factory scriptConsoleFactory){ | ||
92 | val executor = new ScriptExecutor(scriptConsoleFactory) | ||
99 | try{ | 93 | try{ |
100 | val content = loadScript(path) | 94 | val content = loadScript(path) |
101 | executor.executeScript(content,new NullProgressMonitor) | 95 | executor.executeScript(content,new NullProgressMonitor) |