Merge lp:~danilovesky/workcraft/trunk-ui-tools-output into lp:workcraft
- trunk-ui-tools-output
- Merge into trunk
Proposed by
Danil Sokolov
Status: | Merged |
---|---|
Merged at revision: | 713 |
Proposed branch: | lp:~danilovesky/workcraft/trunk-ui-tools-output |
Merge into: | lp:workcraft |
Diff against target: |
2100 lines (+625/-402) 39 files modified
CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java (+2/-2) CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java (+5/-5) CpogsPlugin/src/org/workcraft/plugins/cpog/optimisation/ProcessIO.java (+1/-2) CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/PGMinerTask.java (+1/-1) CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExternalToolTask.java (+2/-4) DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java (+3/-3) DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java (+3/-3) DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java (+4/-4) FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java (+2/-2) MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java (+47/-0) MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisChainTask.java (+3/-3) MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java (+4/-2) MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java (+1/-1) MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java (+47/-1) MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java (+3/-3) MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatCombinedChainTask.java (+3/-3) MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java (+4/-4) MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java (+4/-2) PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java (+2/-1) PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java (+2/-2) PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java (+2/-1) PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java (+47/-1) PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/PetrifyTask.java (+0/-135) PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java (+38/-32) PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java (+113/-54) PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java (+3/-3) PunfPlugin/src/org/workcraft/plugins/punf/PunfUtilitySettings.java (+47/-1) PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java (+5/-2) WorkcraftCore/src/org/workcraft/Config.java (+43/-43) WorkcraftCore/src/org/workcraft/Framework.java (+7/-2) WorkcraftCore/src/org/workcraft/gui/AboutDialog.java (+1/-1) WorkcraftCore/src/org/workcraft/gui/CreateWorkDialog.java (+5/-5) WorkcraftCore/src/org/workcraft/gui/propertyeditor/Settings.java (+2/-2) WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java (+85/-7) WorkcraftCore/src/org/workcraft/interop/ExternalProcess.java (+26/-30) WorkcraftCore/src/org/workcraft/interop/SynchronousExternalProcess.java (+14/-12) WorkcraftCore/src/org/workcraft/plugins/layout/DotLayoutTool.java (+1/-1) WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java (+36/-17) WorkcraftCore/src/org/workcraft/tasks/DummyProgressMonitor.java (+7/-5) |
To merge this branch: | bzr merge lp:~danilovesky/workcraft/trunk-ui-tools-output |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Workcraft core developers | Pending | ||
Review via email: mp+282784@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java' |
2 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java 2016-01-02 22:46:33 +0000 |
3 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java 2016-01-15 17:12:28 +0000 |
4 | @@ -114,7 +114,7 @@ |
5 | } |
6 | |
7 | public static Result<? extends Object> exportStg(STG stg, File stgFile, File directory, |
8 | - ProgressMonitor<? super MpsatChainResult> monitor) throws IOException { |
9 | + ProgressMonitor<? super MpsatChainResult> monitor) { |
10 | |
11 | Framework framework = Framework.getInstance(); |
12 | PluginManager pluginManager = framework.getPluginManager(); |
13 | @@ -123,7 +123,7 @@ |
14 | throw new RuntimeException("Exporter not available: model class " + stg.getClass().getName() + " to .g format."); |
15 | } |
16 | |
17 | - ExportTask exportTask = new ExportTask(stgExporter, stg, stgFile.getCanonicalPath()); |
18 | + ExportTask exportTask = new ExportTask(stgExporter, stg, stgFile.getAbsolutePath()); |
19 | String description = "Exporting " + stgFile.getAbsolutePath(); |
20 | SubtaskMonitor<Object> subtaskMonitor = null; |
21 | if (monitor != null) { |
22 | |
23 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java' |
24 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2016-01-09 22:12:07 +0000 |
25 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2016-01-15 17:12:28 +0000 |
26 | @@ -176,7 +176,7 @@ |
27 | Result<? extends ExternalProcessResult> punfResult = null; |
28 | if (checkDeadlock || checkHazard) { |
29 | unfoldingFile = new File(directory, StgUtils.SYSTEM_FILE_NAME + PunfUtilitySettings.getUnfoldingExtension(true)); |
30 | - punfTask = new PunfTask(sysStgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
31 | + punfTask = new PunfTask(sysStgFile.getAbsolutePath(), unfoldingFile.getAbsolutePath()); |
32 | SubtaskMonitor<Object> punfMonitor = new SubtaskMonitor<Object>(monitor); |
33 | punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", punfMonitor); |
34 | |
35 | @@ -195,7 +195,7 @@ |
36 | if (hasEnvironment && checkConformation) { |
37 | if ((sysStgFile != sysModStgFile) || (unfoldingModFile == null)) { |
38 | unfoldingModFile = new File(directory, StgUtils.SYSTEM_FILE_NAME + StgUtils.MODIFIED_FILE_SUFFIX + PunfUtilitySettings.getUnfoldingExtension(true)); |
39 | - punfModTask = new PunfTask(sysModStgFile.getCanonicalPath(), unfoldingModFile.getCanonicalPath()); |
40 | + punfModTask = new PunfTask(sysModStgFile.getAbsolutePath(), unfoldingModFile.getAbsolutePath()); |
41 | SubtaskMonitor<Object> punfModMonitor = new SubtaskMonitor<Object>(monitor); |
42 | punfModResult = framework.getTaskManager().execute(punfModTask, "Unfolding .g", punfModMonitor); |
43 | |
44 | @@ -214,7 +214,7 @@ |
45 | // Check for deadlock (if requested) |
46 | if (checkDeadlock) { |
47 | MpsatTask mpsatDeadlockTask = new MpsatTask(deadlockSettings.getMpsatArguments(directory), |
48 | - unfoldingFile.getCanonicalPath(), directory, true); |
49 | + unfoldingFile.getAbsolutePath(), directory, true); |
50 | SubtaskMonitor<Object> mpsatMonitor = new SubtaskMonitor<Object>(monitor); |
51 | Result<? extends ExternalProcessResult> mpsatDeadlockResult = framework.getTaskManager().execute( |
52 | mpsatDeadlockTask, "Running deadlock check [MPSat]", mpsatMonitor); |
53 | @@ -240,7 +240,7 @@ |
54 | // Check for hazards (if requested) |
55 | if (checkHazard) { |
56 | MpsatTask mpsatHazardTask = new MpsatTask(hazardSettings.getMpsatArguments(directory), |
57 | - unfoldingFile.getCanonicalPath(), directory, true); |
58 | + unfoldingFile.getAbsolutePath(), directory, true); |
59 | if (MpsatUtilitySettings.getDebugReach()) { |
60 | System.out.println("\nReach expression for the hazard property:"); |
61 | System.out.println(hazardSettings.getReach()); |
62 | @@ -281,7 +281,7 @@ |
63 | MpsatUtilitySettings.getSolutionCount(), reachConformation, true); |
64 | |
65 | MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(directory), |
66 | - unfoldingModFile.getCanonicalPath(), directory, true); |
67 | + unfoldingModFile.getAbsolutePath(), directory, true); |
68 | SubtaskMonitor<Object> mpsatMonitor = new SubtaskMonitor<Object>(monitor); |
69 | Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute( |
70 | mpsatConformationTask, "Running conformation check [MPSat]", mpsatMonitor); |
71 | |
72 | === modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/optimisation/ProcessIO.java' |
73 | --- CpogsPlugin/src/org/workcraft/plugins/cpog/optimisation/ProcessIO.java 2010-11-29 15:02:36 +0000 |
74 | +++ CpogsPlugin/src/org/workcraft/plugins/cpog/optimisation/ProcessIO.java 2016-01-15 17:12:28 +0000 |
75 | @@ -65,7 +65,7 @@ |
76 | |
77 | writeFile(input, inputFile); |
78 | |
79 | - Process minisat = Runtime.getRuntime().exec(new String[]{minisatPath, inputFile.getCanonicalPath(), outputFile.getCanonicalPath()}); |
80 | + Process minisat = Runtime.getRuntime().exec(new String[]{minisatPath, inputFile.getAbsolutePath(), outputFile.getAbsolutePath()}); |
81 | minisat.getOutputStream().close(); |
82 | while(true) { |
83 | int r = minisat.getInputStream().read(); |
84 | @@ -80,7 +80,6 @@ |
85 | } |
86 | |
87 | result = readFile(outputFile); |
88 | - |
89 | } catch (IOException e) { |
90 | throw new RuntimeException(e); |
91 | } |
92 | |
93 | === modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/PGMinerTask.java' |
94 | --- CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/PGMinerTask.java 2015-12-26 23:27:09 +0000 |
95 | +++ CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/PGMinerTask.java 2016-01-15 17:12:28 +0000 |
96 | @@ -42,7 +42,7 @@ |
97 | command.add(inputFile.getAbsolutePath()); |
98 | |
99 | //Call PGMiner |
100 | - ExternalProcessTask task = new ExternalProcessTask(command, new File(".")); |
101 | + ExternalProcessTask task = new ExternalProcessTask(command, new File("."), false, false); |
102 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
103 | |
104 | Result<? extends ExternalProcessResult> result = task.run(mon); |
105 | |
106 | === modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExternalToolTask.java' |
107 | --- CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExternalToolTask.java 2015-11-02 13:37:58 +0000 |
108 | +++ CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExternalToolTask.java 2016-01-15 17:12:28 +0000 |
109 | @@ -2,8 +2,6 @@ |
110 | |
111 | import java.util.ArrayList; |
112 | |
113 | -import javax.swing.JOptionPane; |
114 | - |
115 | import org.workcraft.interop.ExternalProcessListener; |
116 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
117 | import org.workcraft.plugins.shared.tasks.ExternalProcessTask; |
118 | @@ -37,9 +35,9 @@ |
119 | } |
120 | |
121 | // Running the tool through external process interface |
122 | - ExternalProcessTask externalProcessTask = new ExternalProcessTask(args); |
123 | + ExternalProcessTask task = new ExternalProcessTask(args, null, false, false); |
124 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
125 | - Result<? extends ExternalProcessResult> result = externalProcessTask.run(mon); |
126 | + Result<? extends ExternalProcessResult> result = task.run(mon); |
127 | |
128 | // Handling the result |
129 | if (result.getOutcome() == Outcome.CANCELLED) { |
130 | |
131 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java' |
132 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java 2016-01-09 22:12:07 +0000 |
133 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java 2016-01-15 17:12:28 +0000 |
134 | @@ -58,7 +58,7 @@ |
135 | monitor.progressUpdate(0.10); |
136 | |
137 | File netFile = new File(directory, "net" + exporter.getExtenstion()); |
138 | - ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
139 | + ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath()); |
140 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
141 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
142 | exportTask, "Exporting .g", mon); |
143 | @@ -73,7 +73,7 @@ |
144 | monitor.progressUpdate(0.20); |
145 | |
146 | File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true)); |
147 | - PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
148 | + PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath()); |
149 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
150 | punfTask, "Unfolding .g", mon); |
151 | |
152 | @@ -87,7 +87,7 @@ |
153 | monitor.progressUpdate(0.70); |
154 | |
155 | MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), |
156 | - unfoldingFile.getCanonicalPath(), directory, true); |
157 | + unfoldingFile.getAbsolutePath(), directory, true); |
158 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
159 | mpsatTask, "Running deadlock checking [MPSat]", mon); |
160 | |
161 | |
162 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java' |
163 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java 2016-01-09 22:12:07 +0000 |
164 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java 2016-01-15 17:12:28 +0000 |
165 | @@ -58,7 +58,7 @@ |
166 | monitor.progressUpdate(0.10); |
167 | |
168 | File netFile = new File(directory, "net" + exporter.getExtenstion()); |
169 | - ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
170 | + ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath()); |
171 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
172 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
173 | exportTask, "Exporting .g", mon); |
174 | @@ -73,7 +73,7 @@ |
175 | monitor.progressUpdate(0.20); |
176 | |
177 | File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true)); |
178 | - PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
179 | + PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath()); |
180 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
181 | punfTask, "Unfolding .g", mon); |
182 | |
183 | @@ -87,7 +87,7 @@ |
184 | monitor.progressUpdate(0.40); |
185 | |
186 | MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), |
187 | - unfoldingFile.getCanonicalPath(), directory, true); |
188 | + unfoldingFile.getAbsolutePath(), directory, true); |
189 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
190 | mpsatTask, "Running semimodularity checking [MPSat]", mon); |
191 | |
192 | |
193 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java' |
194 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java 2016-01-09 22:12:07 +0000 |
195 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java 2016-01-15 17:12:28 +0000 |
196 | @@ -63,7 +63,7 @@ |
197 | monitor.progressUpdate(0.10); |
198 | |
199 | File netFile = new File(directory, "net" + exporter.getExtenstion()); |
200 | - ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
201 | + ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath()); |
202 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
203 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
204 | exportTask, "Exporting .g", mon); |
205 | @@ -78,7 +78,7 @@ |
206 | monitor.progressUpdate(0.20); |
207 | |
208 | File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true)); |
209 | - PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
210 | + PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath()); |
211 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
212 | punfTask, "Unfolding .g", mon); |
213 | |
214 | @@ -92,7 +92,7 @@ |
215 | monitor.progressUpdate(0.40); |
216 | |
217 | MpsatTask mpsatTask = new MpsatTask(deadlockSettings.getMpsatArguments(directory), |
218 | - unfoldingFile.getCanonicalPath(), directory, true); |
219 | + unfoldingFile.getAbsolutePath(), directory, true); |
220 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
221 | mpsatTask, "Running deadlock checking [MPSat]", mon); |
222 | |
223 | @@ -113,7 +113,7 @@ |
224 | monitor.progressUpdate(0.70); |
225 | |
226 | mpsatTask = new MpsatTask(hazardSettings.getMpsatArguments(directory), |
227 | - unfoldingFile.getCanonicalPath(), directory, true); |
228 | + unfoldingFile.getAbsolutePath(), directory, true); |
229 | mpsatResult = framework.getTaskManager().execute(mpsatTask, "Running semimodularity checking [MPSat]", mon); |
230 | if (mpsatResult.getOutcome() != Outcome.FINISHED) { |
231 | if (mpsatResult.getOutcome() == Outcome.CANCELLED) { |
232 | |
233 | === modified file 'FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java' |
234 | --- FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java 2015-10-13 17:22:00 +0000 |
235 | +++ FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java 2016-01-15 17:12:28 +0000 |
236 | @@ -88,7 +88,7 @@ |
237 | |
238 | // Generating .g file for Petri Net |
239 | pnFile = File.createTempFile("stg_", ".g"); |
240 | - ExportTask pnExportTask = new ExportTask(pnExporter, pn, pnFile.getCanonicalPath()); |
241 | + ExportTask pnExportTask = new ExportTask(pnExporter, pn, pnFile.getAbsolutePath()); |
242 | Result<? extends Object> pnExportResult = framework.getTaskManager().execute( |
243 | pnExportTask, "Exporting .g", subtaskMonitor); |
244 | |
245 | @@ -107,7 +107,7 @@ |
246 | } |
247 | |
248 | while (true) { |
249 | - WriteSgTask writeSgTask = new WriteSgTask(pnFile.getCanonicalPath(), null, writeSgOptions); |
250 | + WriteSgTask writeSgTask = new WriteSgTask(pnFile.getAbsolutePath(), null, writeSgOptions); |
251 | Result<? extends ExternalProcessResult> writeSgResult = framework.getTaskManager().execute( |
252 | writeSgTask, "Building state graph", subtaskMonitor); |
253 | |
254 | |
255 | === modified file 'MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java' |
256 | --- MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java 2015-12-30 23:43:20 +0000 |
257 | +++ MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java 2016-01-15 17:12:28 +0000 |
258 | @@ -35,12 +35,18 @@ |
259 | |
260 | private static final String keyCommand = prefix + ".command"; |
261 | private static final String keyExtraArgs = prefix + ".args"; |
262 | + private static final String keyPrintStdout= prefix + ".printStdout"; |
263 | + private static final String keyPrintStderr= prefix + ".printStderr"; |
264 | |
265 | private static final String defaultCommand = (DesktopApi.getOs().isWindows() ? "tools\\UnfoldingTools\\mpsat.exe" : "tools/UnfoldingTools/mpsat"); |
266 | private static final String defaultExtraArgs = ""; |
267 | + private static final Boolean defaultPrintStdout = true; |
268 | + private static final Boolean defaultPrintStderr = true; |
269 | |
270 | private static String command = defaultCommand; |
271 | private static String extraArgs = defaultExtraArgs; |
272 | + private static Boolean printStdout = defaultPrintStdout; |
273 | + private static Boolean printStderr = defaultPrintStderr; |
274 | |
275 | public MpsatSynthesisUtilitySettings() { |
276 | properties.add(new PropertyDeclaration<MpsatSynthesisUtilitySettings, String>( |
277 | @@ -57,11 +63,32 @@ |
278 | this, "Additional parameters", String.class, true, false, false) { |
279 | protected void setter(MpsatSynthesisUtilitySettings object, String value) { |
280 | setExtraArgs(value); |
281 | + |
282 | } |
283 | protected String getter(MpsatSynthesisUtilitySettings object) { |
284 | return getExtraArgs(); |
285 | } |
286 | }); |
287 | + |
288 | + properties.add(new PropertyDeclaration<MpsatSynthesisUtilitySettings, Boolean>( |
289 | + this, "Output stdout", Boolean.class, true, false, false) { |
290 | + protected void setter(MpsatSynthesisUtilitySettings object, Boolean value) { |
291 | + setPrintStdout(value); |
292 | + } |
293 | + protected Boolean getter(MpsatSynthesisUtilitySettings object) { |
294 | + return getPrintStdout(); |
295 | + } |
296 | + }); |
297 | + |
298 | + properties.add(new PropertyDeclaration<MpsatSynthesisUtilitySettings, Boolean>( |
299 | + this, "Output stderr", Boolean.class, true, false, false) { |
300 | + protected void setter(MpsatSynthesisUtilitySettings object, Boolean value) { |
301 | + setPrintStderr(value); |
302 | + } |
303 | + protected Boolean getter(MpsatSynthesisUtilitySettings object) { |
304 | + return getPrintStderr(); |
305 | + } |
306 | + }); |
307 | } |
308 | |
309 | @Override |
310 | @@ -73,12 +100,16 @@ |
311 | public void load(Config config) { |
312 | setCommand(config.getString(keyCommand, defaultCommand)); |
313 | setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs)); |
314 | + setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout)); |
315 | + setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr)); |
316 | } |
317 | |
318 | @Override |
319 | public void save(Config config) { |
320 | config.set(keyCommand, getCommand()); |
321 | config.set(keyExtraArgs, getExtraArgs()); |
322 | + config.setBoolean(keyPrintStdout, getPrintStdout()); |
323 | + config.setBoolean(keyPrintStderr, getPrintStderr()); |
324 | } |
325 | |
326 | @Override |
327 | @@ -107,4 +138,20 @@ |
328 | extraArgs = value; |
329 | } |
330 | |
331 | + public static Boolean getPrintStdout() { |
332 | + return printStdout; |
333 | + } |
334 | + |
335 | + public static void setPrintStdout(Boolean value) { |
336 | + printStdout = value; |
337 | + } |
338 | + |
339 | + public static Boolean getPrintStderr() { |
340 | + return printStderr; |
341 | + } |
342 | + |
343 | + public static void setPrintStderr(Boolean value) { |
344 | + printStderr = value; |
345 | + } |
346 | + |
347 | } |
348 | |
349 | === modified file 'MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisChainTask.java' |
350 | --- MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisChainTask.java 2016-01-09 22:12:07 +0000 |
351 | +++ MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisChainTask.java 2016-01-15 17:12:28 +0000 |
352 | @@ -49,7 +49,7 @@ |
353 | |
354 | // Generate .g for the model |
355 | File netFile = new File(directory, "net" + exporter.getExtenstion()); |
356 | - ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
357 | + ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath()); |
358 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
359 | exportTask, "Exporting .g", subtaskMonitor); |
360 | |
361 | @@ -65,7 +65,7 @@ |
362 | // Generate unfolding |
363 | boolean tryPnml = settings.getMode().canPnml(); |
364 | File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(tryPnml)); |
365 | - PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
366 | + PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath()); |
367 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", subtaskMonitor); |
368 | |
369 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
370 | @@ -80,7 +80,7 @@ |
371 | // Run MPSat on the generated unfolding |
372 | boolean needLib = settings.getMode().needLib(); |
373 | MpsatSynthesisTask mpsatTask = new MpsatSynthesisTask(settings.getMpsatArguments(directory), |
374 | - unfoldingFile.getCanonicalPath(), directory, tryPnml, needLib); |
375 | + unfoldingFile.getAbsolutePath(), directory, tryPnml, needLib); |
376 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
377 | mpsatTask, "Running synthesis [MPSat]", subtaskMonitor); |
378 | |
379 | |
380 | === modified file 'MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java' |
381 | --- MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java 2016-01-03 21:57:29 +0000 |
382 | +++ MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java 2016-01-15 17:12:28 +0000 |
383 | @@ -87,8 +87,10 @@ |
384 | File outputFile = new File(directory, outputFileName); |
385 | command.add(outputFile.getAbsolutePath()); |
386 | |
387 | - ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, directory); |
388 | - Result<? extends ExternalProcessResult> res = externalProcessTask.run(monitor); |
389 | + boolean printStdout = MpsatSynthesisUtilitySettings.getPrintStdout(); |
390 | + boolean printStderr = MpsatSynthesisUtilitySettings.getPrintStderr(); |
391 | + ExternalProcessTask task = new ExternalProcessTask(command, directory, printStdout, printStderr); |
392 | + Result<? extends ExternalProcessResult> res = task.run(monitor); |
393 | if(res.getOutcome() == Outcome.CANCELLED) { |
394 | return res; |
395 | } |
396 | |
397 | === modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java' |
398 | --- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2016-01-06 16:36:03 +0000 |
399 | +++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2016-01-15 17:12:28 +0000 |
400 | @@ -199,7 +199,7 @@ |
401 | } |
402 | FileUtils.dumpString(reachFile, getReach()); |
403 | args.add("-d"); |
404 | - args.add("@" + reachFile.getCanonicalPath()); |
405 | + args.add("@" + reachFile.getAbsolutePath()); |
406 | } catch (IOException e) { |
407 | throw new RuntimeException(e); |
408 | } |
409 | |
410 | === modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java' |
411 | --- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2015-12-30 23:43:20 +0000 |
412 | +++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2016-01-15 17:12:28 +0000 |
413 | @@ -38,16 +38,22 @@ |
414 | private static final String keyCommand = prefix + ".command"; |
415 | private static final String keySolutionMode = prefix + ".solutionMode"; |
416 | private static final String keyExtraArgs = prefix + ".args"; |
417 | + private static final String keyPrintStdout= prefix + ".printStdout"; |
418 | + private static final String keyPrintStderr= prefix + ".printStderr"; |
419 | private static final String keyDebugReach = prefix + ".debugReach"; |
420 | |
421 | private static final String defaultCommand = (DesktopApi.getOs().isWindows() ? "tools\\UnfoldingTools\\mpsat.exe" : "tools/UnfoldingTools/mpsat"); |
422 | private static final SolutionMode defaultSolutionMode = SolutionMode.MINIMUM_COST; |
423 | private static final String defaultExtraArgs = ""; |
424 | + private static final Boolean defaultPrintStdout = true; |
425 | + private static final Boolean defaultPrintStderr = true; |
426 | private static final Boolean defaultDebugReach = false; |
427 | |
428 | private static String command = defaultCommand; |
429 | private static SolutionMode solutionMode = defaultSolutionMode; |
430 | private static String extraArgs = defaultExtraArgs; |
431 | + private static Boolean printStdout = defaultPrintStdout; |
432 | + private static Boolean printStderr = defaultPrintStderr; |
433 | private static Boolean debugReach = defaultDebugReach; |
434 | |
435 | public MpsatUtilitySettings() { |
436 | @@ -82,7 +88,27 @@ |
437 | }); |
438 | |
439 | properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>( |
440 | - this, "Print out Reach expressions (debug)", Boolean.class, true, false, false) { |
441 | + this, "Output stdout", Boolean.class, true, false, false) { |
442 | + protected void setter(MpsatUtilitySettings object, Boolean value) { |
443 | + setPrintStdout(value); |
444 | + } |
445 | + protected Boolean getter(MpsatUtilitySettings object) { |
446 | + return getPrintStdout(); |
447 | + } |
448 | + }); |
449 | + |
450 | + properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>( |
451 | + this, "Output stderr", Boolean.class, true, false, false) { |
452 | + protected void setter(MpsatUtilitySettings object, Boolean value) { |
453 | + setPrintStderr(value); |
454 | + } |
455 | + protected Boolean getter(MpsatUtilitySettings object) { |
456 | + return getPrintStderr(); |
457 | + } |
458 | + }); |
459 | + |
460 | + properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>( |
461 | + this, "Output Reach expressions", Boolean.class, true, false, false) { |
462 | protected void setter(MpsatUtilitySettings object, Boolean value) { |
463 | setDebugReach(value); |
464 | } |
465 | @@ -102,6 +128,8 @@ |
466 | setCommand(config.getString(keyCommand, defaultCommand)); |
467 | setSolutionMode(config.getEnum(keySolutionMode, SolutionMode.class, defaultSolutionMode)); |
468 | setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs)); |
469 | + setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout)); |
470 | + setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr)); |
471 | setDebugReach(config.getBoolean(keyDebugReach, defaultDebugReach)); |
472 | } |
473 | |
474 | @@ -110,6 +138,8 @@ |
475 | config.set(keyCommand, getCommand()); |
476 | config.setEnum(keySolutionMode, SolutionMode.class, getSolutionMode()); |
477 | config.set(keyExtraArgs, getExtraArgs()); |
478 | + config.setBoolean(keyPrintStdout, getPrintStdout()); |
479 | + config.setBoolean(keyPrintStderr, getPrintStderr()); |
480 | config.setBoolean(keyDebugReach, getDebugReach()); |
481 | } |
482 | |
483 | @@ -151,6 +181,22 @@ |
484 | return (solutionMode == SolutionMode.ALL) ? 10 : 1; |
485 | } |
486 | |
487 | + public static Boolean getPrintStdout() { |
488 | + return printStdout; |
489 | + } |
490 | + |
491 | + public static void setPrintStdout(Boolean value) { |
492 | + printStdout = value; |
493 | + } |
494 | + |
495 | + public static Boolean getPrintStderr() { |
496 | + return printStderr; |
497 | + } |
498 | + |
499 | + public static void setPrintStderr(Boolean value) { |
500 | + printStderr = value; |
501 | + } |
502 | + |
503 | public static Boolean getDebugReach() { |
504 | return debugReach; |
505 | } |
506 | |
507 | === modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java' |
508 | --- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2016-01-09 22:12:07 +0000 |
509 | +++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2016-01-15 17:12:28 +0000 |
510 | @@ -49,7 +49,7 @@ |
511 | |
512 | // Generate .g for the model |
513 | File netFile = new File(directory, "net" + exporter.getExtenstion()); |
514 | - ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
515 | + ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath()); |
516 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
517 | exportTask, "Exporting .g", subtaskMonitor); |
518 | |
519 | @@ -65,7 +65,7 @@ |
520 | // Generate unfolding |
521 | boolean tryPnml = settings.getMode().canPnml(); |
522 | File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(tryPnml)); |
523 | - PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
524 | + PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath()); |
525 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", subtaskMonitor); |
526 | |
527 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
528 | @@ -79,7 +79,7 @@ |
529 | |
530 | // Run MPSat on the generated unfolding |
531 | MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), |
532 | - unfoldingFile.getCanonicalPath(), directory, tryPnml); |
533 | + unfoldingFile.getAbsolutePath(), directory, tryPnml); |
534 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
535 | mpsatTask, "Running verification [MPSat]", subtaskMonitor); |
536 | |
537 | |
538 | === modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatCombinedChainTask.java' |
539 | --- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatCombinedChainTask.java 2016-01-09 22:12:07 +0000 |
540 | +++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatCombinedChainTask.java 2016-01-15 17:12:28 +0000 |
541 | @@ -51,7 +51,7 @@ |
542 | |
543 | // Generate .g for the model |
544 | File netFile = new File(directory, "net" + exporter.getExtenstion()); |
545 | - ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
546 | + ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath()); |
547 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
548 | exportTask, "Exporting .g", subtaskMonitor); |
549 | |
550 | @@ -70,7 +70,7 @@ |
551 | tryPnml &= settings.getMode().canPnml(); |
552 | } |
553 | File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(tryPnml)); |
554 | - PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
555 | + PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath()); |
556 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", subtaskMonitor); |
557 | |
558 | if (punfResult.getOutcome() != Outcome.FINISHED) { |
559 | @@ -86,7 +86,7 @@ |
560 | ArrayList<Result<? extends ExternalProcessResult>> mpsatResultList = new ArrayList<>(settingsList.size()); |
561 | for (MpsatSettings settings: settingsList) { |
562 | MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), |
563 | - unfoldingFile.getCanonicalPath(), directory, tryPnml); |
564 | + unfoldingFile.getAbsolutePath(), directory, tryPnml); |
565 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
566 | mpsatTask, "Running verification [MPSat]", subtaskMonitor); |
567 | mpsatResultList.add(mpsatResult); |
568 | |
569 | === modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java' |
570 | --- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 2016-01-09 22:12:07 +0000 |
571 | +++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 2016-01-15 17:12:28 +0000 |
572 | @@ -70,7 +70,7 @@ |
573 | |
574 | // Generating .g for the model |
575 | File devStgFile = new File(directory, "dev.g"); |
576 | - ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getCanonicalPath()); |
577 | + ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getAbsolutePath()); |
578 | Result<? extends Object> devExportResult = framework.getTaskManager().execute( |
579 | devExportTask, "Exporting circuit .g", subtaskMonitor); |
580 | |
581 | @@ -92,7 +92,7 @@ |
582 | STG envStg = (STG)framework.loadFile(envFile).getMathModel(); |
583 | Exporter envStgExporter = Export.chooseBestExporter(framework.getPluginManager(), envStg, Format.STG); |
584 | envStgFile = new File(directory, "env.g"); |
585 | - ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getCanonicalPath()); |
586 | + ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getAbsolutePath()); |
587 | Result<? extends Object> envExportResult = framework.getTaskManager().execute( |
588 | envExportTask, "Exporting environment .g", subtaskMonitor); |
589 | |
590 | @@ -127,7 +127,7 @@ |
591 | |
592 | // Generate unfolding |
593 | File unfoldingFile = new File(directory, "system" + PunfUtilitySettings.getUnfoldingExtension(true)); |
594 | - PunfTask punfTask = new PunfTask(stgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
595 | + PunfTask punfTask = new PunfTask(stgFile.getAbsolutePath(), unfoldingFile.getAbsolutePath()); |
596 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
597 | punfTask, "Unfolding .g", subtaskMonitor); |
598 | |
599 | @@ -153,7 +153,7 @@ |
600 | MpsatUtilitySettings.getSolutionCount(), reachConformation, true); |
601 | |
602 | MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(directory), |
603 | - unfoldingFile.getCanonicalPath(), directory, true); |
604 | + unfoldingFile.getAbsolutePath(), directory, true); |
605 | Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute( |
606 | mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor); |
607 | |
608 | |
609 | === modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java' |
610 | --- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2016-01-03 21:57:29 +0000 |
611 | +++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2016-01-15 17:12:28 +0000 |
612 | @@ -59,8 +59,10 @@ |
613 | // Input file |
614 | command.add(inputFileName); |
615 | |
616 | - ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, directory); |
617 | - Result<? extends ExternalProcessResult> res = externalProcessTask.run(monitor); |
618 | + boolean printStdout = MpsatUtilitySettings.getPrintStdout(); |
619 | + boolean printStderr = MpsatUtilitySettings.getPrintStderr(); |
620 | + ExternalProcessTask task = new ExternalProcessTask(command, directory, printStdout, printStderr); |
621 | + Result<? extends ExternalProcessResult> res = task.run(monitor); |
622 | if(res.getOutcome() == Outcome.CANCELLED) { |
623 | return res; |
624 | } |
625 | |
626 | === modified file 'PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java' |
627 | --- PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2016-01-03 21:57:29 +0000 |
628 | +++ PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2016-01-15 17:12:28 +0000 |
629 | @@ -88,7 +88,8 @@ |
630 | command.add(inputFile.getAbsolutePath()); |
631 | } |
632 | |
633 | - Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command).run(monitor); |
634 | + ExternalProcessTask task = new ExternalProcessTask(command, directory, false, true); |
635 | + Result<? extends ExternalProcessResult> res = task.run(monitor); |
636 | if (res.getOutcome() != Outcome.FINISHED) { |
637 | return res; |
638 | } |
639 | |
640 | === modified file 'PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java' |
641 | --- PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java 2016-01-03 21:57:29 +0000 |
642 | +++ PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java 2016-01-15 17:12:28 +0000 |
643 | @@ -49,8 +49,8 @@ |
644 | command.add("-o"); |
645 | command.add(outputPath); |
646 | |
647 | - |
648 | - Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command).run(monitor); |
649 | + ExternalProcessTask task = new ExternalProcessTask(command, null, false, false); |
650 | + Result<? extends ExternalProcessResult> res = task.run(monitor); |
651 | |
652 | if (res.getOutcome() != Outcome.FINISHED) |
653 | return res; |
654 | |
655 | === modified file 'PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java' |
656 | --- PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java 2016-01-03 21:57:29 +0000 |
657 | +++ PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java 2016-01-15 17:12:28 +0000 |
658 | @@ -69,7 +69,8 @@ |
659 | command.add(outputPath); |
660 | } |
661 | |
662 | - Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command).run(monitor); |
663 | + ExternalProcessTask task = new ExternalProcessTask(command, null, false, false); |
664 | + Result<? extends ExternalProcessResult> res = task.run(monitor); |
665 | if (res.getOutcome() != Outcome.FINISHED) { |
666 | return res; |
667 | } |
668 | |
669 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java' |
670 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java 2015-12-30 23:43:20 +0000 |
671 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java 2016-01-15 17:12:28 +0000 |
672 | @@ -36,13 +36,19 @@ |
673 | |
674 | private static final String keyPetrifyCkeyPmmand = prefix + ".petrify.command"; |
675 | private static final String keyPetrifyArgs = prefix + ".petrify.args"; |
676 | + private static final String keyPrintStdout= prefix + ".printStdout"; |
677 | + private static final String keyPrintStderr= prefix + ".printStderr"; |
678 | |
679 | private static final String defaultPetrifyCommand = (DesktopApi.getOs().isWindows() ? "tools\\PetrifyTools\\petrify.exe" : "tools/PetrifyTools/petrify"); |
680 | private static final String defaultPetrifyArgs = ""; |
681 | + private static final Boolean defaultPrintStdout = true; |
682 | + private static final Boolean defaultPrintStderr = true; |
683 | |
684 | private static String petrifyCommand = defaultPetrifyCommand; |
685 | private static String petrifyArgs = defaultPetrifyArgs; |
686 | - |
687 | + private static Boolean printStdout = defaultPrintStdout; |
688 | + private static Boolean printStderr = defaultPrintStderr; |
689 | + |
690 | public PetrifyUtilitySettings() { |
691 | properties.add(new PropertyDeclaration<PetrifyUtilitySettings, String>( |
692 | this, "Petrify command", String.class, true, false, false) { |
693 | @@ -63,6 +69,26 @@ |
694 | return getPetrifyArgs(); |
695 | } |
696 | }); |
697 | + |
698 | + properties.add(new PropertyDeclaration<PetrifyUtilitySettings, Boolean>( |
699 | + this, "Output stdout", Boolean.class, true, false, false) { |
700 | + protected void setter(PetrifyUtilitySettings object, Boolean value) { |
701 | + setPrintStdout(value); |
702 | + } |
703 | + protected Boolean getter(PetrifyUtilitySettings object) { |
704 | + return getPrintStdout(); |
705 | + } |
706 | + }); |
707 | + |
708 | + properties.add(new PropertyDeclaration<PetrifyUtilitySettings, Boolean>( |
709 | + this, "Output stderr", Boolean.class, true, false, false) { |
710 | + protected void setter(PetrifyUtilitySettings object, Boolean value) { |
711 | + setPrintStderr(value); |
712 | + } |
713 | + protected Boolean getter(PetrifyUtilitySettings object) { |
714 | + return getPrintStderr(); |
715 | + } |
716 | + }); |
717 | } |
718 | |
719 | @Override |
720 | @@ -74,12 +100,16 @@ |
721 | public void load(Config config) { |
722 | setPetrifyCommand(config.getString(keyPetrifyCkeyPmmand, defaultPetrifyCommand)); |
723 | setPetrifyArgs(config.getString(keyPetrifyArgs, defaultPetrifyArgs)); |
724 | + setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout)); |
725 | + setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr)); |
726 | } |
727 | |
728 | @Override |
729 | public void save(Config config) { |
730 | config.set(keyPetrifyCkeyPmmand, getPetrifyCommand()); |
731 | config.set(keyPetrifyArgs, getPetrifyArgs()); |
732 | + config.setBoolean(keyPrintStdout, getPrintStdout()); |
733 | + config.setBoolean(keyPrintStderr, getPrintStderr()); |
734 | } |
735 | |
736 | @Override |
737 | @@ -108,4 +138,20 @@ |
738 | petrifyArgs = value; |
739 | } |
740 | |
741 | + public static Boolean getPrintStdout() { |
742 | + return printStdout; |
743 | + } |
744 | + |
745 | + public static void setPrintStdout(Boolean value) { |
746 | + printStdout = value; |
747 | + } |
748 | + |
749 | + public static Boolean getPrintStderr() { |
750 | + return printStderr; |
751 | + } |
752 | + |
753 | + public static void setPrintStderr(Boolean value) { |
754 | + printStderr = value; |
755 | + } |
756 | + |
757 | } |
758 | |
759 | === removed file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/PetrifyTask.java' |
760 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/PetrifyTask.java 2016-01-03 21:57:29 +0000 |
761 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/PetrifyTask.java 1970-01-01 00:00:00 +0000 |
762 | @@ -1,135 +0,0 @@ |
763 | -package org.workcraft.plugins.petrify.tasks; |
764 | - |
765 | -import java.io.IOException; |
766 | -import java.util.ArrayList; |
767 | - |
768 | -import org.workcraft.interop.ExternalProcess; |
769 | -import org.workcraft.interop.ExternalProcessListener; |
770 | -import org.workcraft.plugins.petrify.PetrifyUtilitySettings; |
771 | -import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
772 | -import org.workcraft.tasks.ProgressMonitor; |
773 | -import org.workcraft.tasks.Result; |
774 | -import org.workcraft.tasks.Result.Outcome; |
775 | -import org.workcraft.tasks.Task; |
776 | -import org.workcraft.util.DataAccumulator; |
777 | - |
778 | -public class PetrifyTask implements Task<ExternalProcessResult>, ExternalProcessListener { |
779 | - private String[] args; |
780 | - private String inputFileName; |
781 | - |
782 | - private volatile boolean finished; |
783 | - private volatile int returnCode; |
784 | - private boolean userCancelled = false; |
785 | - private ProgressMonitor<? super ExternalProcessResult> monitor; |
786 | - |
787 | - private DataAccumulator stdoutAccum = new DataAccumulator(); |
788 | - private DataAccumulator stderrAccum = new DataAccumulator(); |
789 | - |
790 | - public PetrifyTask(String[] args, String inputFileName) { |
791 | - this.args = args; |
792 | - this.inputFileName = inputFileName; |
793 | - } |
794 | - |
795 | - @Override |
796 | - public Result<? extends ExternalProcessResult> run(ProgressMonitor<? super ExternalProcessResult> monitor) { |
797 | - this.monitor = monitor; |
798 | - ArrayList<String> command = new ArrayList<String>(); |
799 | - |
800 | - // Name of the executable |
801 | - String toolName = PetrifyUtilitySettings.getPetrifyCommand(); |
802 | - command.add(toolName); |
803 | - |
804 | - // Built-in arguments |
805 | - for (String arg : args) { |
806 | - command.add(arg); |
807 | - } |
808 | - |
809 | - // Extra arguments (should go before the file parameters) |
810 | - for (String arg : PetrifyUtilitySettings.getPetrifyArgs().split(" ")) { |
811 | - if (!arg.isEmpty()) { |
812 | - command.add(arg); |
813 | - } |
814 | - } |
815 | - |
816 | - // Input file |
817 | - command.add(inputFileName); |
818 | - |
819 | - ExternalProcess petrifyProcess = new ExternalProcess(command.toArray(new String[command.size()]), "."); |
820 | - petrifyProcess.addListener(this); |
821 | - |
822 | - try { |
823 | - System.out.println("Running external command: " + getCommandLine(command)); |
824 | - petrifyProcess.start(); |
825 | - } catch (IOException e) { |
826 | - return new Result<ExternalProcessResult>(e); |
827 | - } |
828 | - |
829 | - while (true) { |
830 | - if (monitor.isCancelRequested() && petrifyProcess.isRunning()) { |
831 | - petrifyProcess.cancel(); |
832 | - userCancelled = true; |
833 | - } |
834 | - if (finished) { |
835 | - break; |
836 | - } |
837 | - try { |
838 | - Thread.sleep(20); |
839 | - } catch (InterruptedException e) { |
840 | - petrifyProcess.cancel(); |
841 | - userCancelled = true; |
842 | - break; |
843 | - } |
844 | - } |
845 | - |
846 | - if (userCancelled) { |
847 | - return new Result<ExternalProcessResult>(Outcome.CANCELLED); |
848 | - } |
849 | - |
850 | - ExternalProcessResult result = new ExternalProcessResult(returnCode, stdoutAccum.getData(), stderrAccum.getData()); |
851 | - |
852 | - if (returnCode == 0) { |
853 | - return new Result<ExternalProcessResult>(Outcome.FINISHED, result); |
854 | - } |
855 | - |
856 | - return new Result<ExternalProcessResult>(Outcome.FAILED, result); |
857 | - } |
858 | - |
859 | - private String getCommandLine(ArrayList<String> command) { |
860 | - String commandLine = ""; |
861 | - for (String arg: command) { |
862 | - if (commandLine.isEmpty()) { |
863 | - commandLine = ""; |
864 | - } else { |
865 | - commandLine += " "; |
866 | - } |
867 | - commandLine += arg; |
868 | - } |
869 | - return commandLine; |
870 | - } |
871 | - |
872 | - @Override |
873 | - public void errorData(byte[] data) { |
874 | - try { |
875 | - stderrAccum.write(data); |
876 | - } catch (IOException e) { |
877 | - throw new RuntimeException(e); |
878 | - } |
879 | - monitor.stderr(data); |
880 | - } |
881 | - |
882 | - @Override |
883 | - public void outputData(byte[] data) { |
884 | - try { |
885 | - stdoutAccum.write(data); |
886 | - } catch (IOException e) { |
887 | - throw new RuntimeException(e); |
888 | - } |
889 | - monitor.stdout(data); |
890 | - } |
891 | - |
892 | - @Override |
893 | - public void processFinished(int returnCode) { |
894 | - this.returnCode = returnCode; |
895 | - this.finished = true; |
896 | - } |
897 | - } |
898 | \ No newline at end of file |
899 | |
900 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java' |
901 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java 2016-01-03 21:57:29 +0000 |
902 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java 2016-01-15 17:12:28 +0000 |
903 | @@ -66,32 +66,38 @@ |
904 | // As there may be non-alpha-numerical symbols in the model title, it is better not to include it to the directory name. |
905 | String prefix = FileUtils.getTempPrefix(null/* we.getTitle() */); |
906 | File directory = FileUtils.createTempDirectory(prefix); |
907 | + |
908 | + File outFile = new File(directory, "result.g"); |
909 | + command.add("-o"); |
910 | + command.add(outFile.getAbsolutePath()); |
911 | + |
912 | + File equationsFile = new File(directory, "petrify.eqn"); |
913 | + command.add("-eqn"); |
914 | + command.add(equationsFile.getAbsolutePath()); |
915 | + |
916 | + File verilogFile = new File(directory, "petrify.v"); |
917 | + command.add("-vl"); |
918 | + command.add(verilogFile.getAbsolutePath()); |
919 | + |
920 | + File blifFile = new File(directory, "petrify.blif"); |
921 | + command.add("-blif"); |
922 | + command.add(blifFile.getAbsolutePath()); |
923 | + |
924 | + File logFile = new File(directory, "petrify.log"); |
925 | + command.add("-log"); |
926 | + command.add(logFile.getAbsolutePath()); |
927 | + |
928 | + // Input file |
929 | + STGModel stg = WorkspaceUtils.getAs(we, STGModel.class); |
930 | + File stgFile = getInputFile(stg, directory); |
931 | + command.add(stgFile.getAbsolutePath()); |
932 | + |
933 | + boolean printStdout = PetrifyUtilitySettings.getPrintStdout(); |
934 | + boolean printStderr = PetrifyUtilitySettings.getPrintStderr(); |
935 | + ExternalProcessTask task = new ExternalProcessTask(command, null, printStdout, printStderr); |
936 | + SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
937 | + Result<? extends ExternalProcessResult> res = task.run(mon); |
938 | try { |
939 | - File equationsFile = new File(directory, "petrify.eqn"); |
940 | - command.add("-eqn"); |
941 | - command.add(equationsFile.getCanonicalPath()); |
942 | - |
943 | - File verilogFile = new File(directory, "petrify.v"); |
944 | - command.add("-vl"); |
945 | - command.add(verilogFile.getCanonicalPath()); |
946 | - |
947 | - File blifFile = new File(directory, "petrify.blif"); |
948 | - command.add("-blif"); |
949 | - command.add(blifFile.getCanonicalPath()); |
950 | - |
951 | - File logFile = new File(directory, "petrify.log"); |
952 | - command.add("-log"); |
953 | - command.add(logFile.getCanonicalPath()); |
954 | - |
955 | - // Input file |
956 | - STGModel stg = WorkspaceUtils.getAs(we, STGModel.class); |
957 | - File stgFile = getInputStg(stg, directory); |
958 | - command.add(stgFile.getCanonicalPath()); |
959 | - |
960 | - ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, null); |
961 | - SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
962 | - Result<? extends ExternalProcessResult> res = externalProcessTask.run(mon); |
963 | - |
964 | if (res.getOutcome() == Outcome.CANCELLED) { |
965 | return new Result<SynthesisResult>(Outcome.CANCELLED); |
966 | } else { |
967 | @@ -110,24 +116,24 @@ |
968 | SynthesisResult result = new SynthesisResult(equations, verilog, log, stdout, stderr); |
969 | return new Result<SynthesisResult>(outcome, result); |
970 | } |
971 | - } catch (IOException e1) { |
972 | - throw new RuntimeException(e1); |
973 | + } catch (IOException e) { |
974 | + throw new RuntimeException(e); |
975 | } finally { |
976 | FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles()); |
977 | } |
978 | } |
979 | |
980 | - private File getInputStg(Model model, File directory) throws IOException { |
981 | + private File getInputFile(Model model, File directory) { |
982 | final Framework framework = Framework.getInstance(); |
983 | Exporter stgExporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG); |
984 | if (stgExporter == null) { |
985 | - throw new RuntimeException ("Exporter not available: model class " + model.getClass().getName() + " to format STG."); |
986 | + throw new RuntimeException("Exporter not available: model class " + model.getClass().getName() + " to format STG."); |
987 | } |
988 | |
989 | File stgFile = new File(directory, "petrify" + stgExporter.getExtenstion()); |
990 | - ExportTask exportTask = new ExportTask(stgExporter, model, stgFile.getCanonicalPath()); |
991 | - Result<? extends Object> res = framework.getTaskManager().execute(exportTask, "Exporting .g"); |
992 | - if (res.getOutcome() != Outcome.FINISHED) { |
993 | + ExportTask exportTask = new ExportTask(stgExporter, model, stgFile.getAbsolutePath()); |
994 | + Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, "Exporting .g"); |
995 | + if (exportResult.getOutcome() != Outcome.FINISHED) { |
996 | stgFile = null; |
997 | } |
998 | return stgFile; |
999 | |
1000 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java' |
1001 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java 2015-10-12 14:02:20 +0000 |
1002 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java 2016-01-15 17:12:28 +0000 |
1003 | @@ -2,98 +2,157 @@ |
1004 | |
1005 | import java.io.ByteArrayInputStream; |
1006 | import java.io.File; |
1007 | +import java.util.ArrayList; |
1008 | import java.util.UUID; |
1009 | |
1010 | import org.workcraft.Framework; |
1011 | import org.workcraft.dom.Model; |
1012 | import org.workcraft.exceptions.DeserialisationException; |
1013 | +import org.workcraft.exceptions.SerialisationException; |
1014 | +import org.workcraft.interop.ExternalProcessListener; |
1015 | import org.workcraft.plugins.fsm.Fsm; |
1016 | import org.workcraft.plugins.petri.PetriNetModel; |
1017 | +import org.workcraft.plugins.petrify.PetrifyUtilitySettings; |
1018 | import org.workcraft.plugins.shared.CommonDebugSettings; |
1019 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
1020 | +import org.workcraft.plugins.shared.tasks.ExternalProcessTask; |
1021 | import org.workcraft.plugins.stg.STGModel; |
1022 | import org.workcraft.plugins.stg.interop.DotGImporter; |
1023 | import org.workcraft.serialisation.Format; |
1024 | import org.workcraft.tasks.ProgressMonitor; |
1025 | import org.workcraft.tasks.Result; |
1026 | import org.workcraft.tasks.Result.Outcome; |
1027 | +import org.workcraft.tasks.SubtaskMonitor; |
1028 | import org.workcraft.tasks.Task; |
1029 | import org.workcraft.util.Export; |
1030 | import org.workcraft.util.Export.ExportTask; |
1031 | import org.workcraft.util.FileUtils; |
1032 | +import org.workcraft.util.ToolUtils; |
1033 | import org.workcraft.workspace.WorkspaceEntry; |
1034 | |
1035 | -public class TransformationTask implements Task<TransformationResult>{ |
1036 | - private WorkspaceEntry workspaceEntry; |
1037 | - String description; |
1038 | - String[] parameters; |
1039 | +public class TransformationTask implements Task<TransformationResult>, ExternalProcessListener { |
1040 | + private WorkspaceEntry we; |
1041 | + String[] args; |
1042 | |
1043 | - public TransformationTask(WorkspaceEntry workspaceEntry, String description, String[] parameters) { |
1044 | - this.workspaceEntry = workspaceEntry; |
1045 | - this.description = description; |
1046 | - this.parameters = parameters; |
1047 | + public TransformationTask(WorkspaceEntry we, String description, String[] args) { |
1048 | + this.we = we; |
1049 | + this.args = args; |
1050 | } |
1051 | |
1052 | public WorkspaceEntry getWorkspaceEntry() { |
1053 | - return workspaceEntry; |
1054 | + return we; |
1055 | } |
1056 | |
1057 | @Override |
1058 | public Result<? extends TransformationResult> run(ProgressMonitor<? super TransformationResult> monitor) { |
1059 | - File modelFile = null; |
1060 | + ArrayList<String> command = new ArrayList<String>(); |
1061 | + |
1062 | + // Name of the executable |
1063 | + String toolName = ToolUtils.getAbsoluteCommandPath(PetrifyUtilitySettings.getPetrifyCommand()); |
1064 | + command.add(toolName); |
1065 | + |
1066 | + // Built-in arguments |
1067 | + for (String arg : args) { |
1068 | + command.add(arg); |
1069 | + } |
1070 | + |
1071 | + // Extra arguments (should go before the file parameters) |
1072 | + for (String arg : PetrifyUtilitySettings.getPetrifyArgs().split(" ")) { |
1073 | + if (!arg.isEmpty()) { |
1074 | + command.add(arg); |
1075 | + } |
1076 | + } |
1077 | + |
1078 | + String prefix = FileUtils.getTempPrefix(we.getTitle()); |
1079 | + File directory = FileUtils.createTempDirectory(prefix); |
1080 | try { |
1081 | - final Framework framework = Framework.getInstance(); |
1082 | - modelFile = File.createTempFile("stg_", ".g"); |
1083 | + File logFile = new File(directory, "petrify.log"); |
1084 | + command.add("-log"); |
1085 | + command.add(logFile.getAbsolutePath()); |
1086 | + |
1087 | + File outFile = new File(directory, "result.g"); |
1088 | + command.add("-o"); |
1089 | + command.add(outFile.getAbsolutePath()); |
1090 | + |
1091 | + // Input file |
1092 | + Model model = we.getModelEntry().getMathModel(); |
1093 | + File modelFile = getInputFile(model, directory); |
1094 | + command.add(modelFile.getAbsolutePath()); |
1095 | |
1096 | - Model model = workspaceEntry.getModelEntry().getMathModel(); |
1097 | - UUID format = null; |
1098 | - if (model instanceof PetriNetModel) { |
1099 | - format = Format.STG; |
1100 | - } else if (model instanceof Fsm) { |
1101 | - format = Format.SG; |
1102 | - } |
1103 | - if (format == null) { |
1104 | - return Result.exception(new Throwable("This tool is not applicable to " + model.getDisplayName() + " model.")); |
1105 | - } |
1106 | - |
1107 | - ExportTask exportTask = Export.createExportTask(model, modelFile, format, framework.getPluginManager()); |
1108 | - |
1109 | - final Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, description +": writing .g"); |
1110 | - |
1111 | - if (exportResult.getOutcome() != Outcome.FINISHED) { |
1112 | - if (exportResult.getOutcome() == Outcome.CANCELLED) { |
1113 | - return Result.cancelled(); |
1114 | + boolean printStdout = PetrifyUtilitySettings.getPrintStdout(); |
1115 | + boolean printStderr = PetrifyUtilitySettings.getPrintStderr(); |
1116 | + ExternalProcessTask task = new ExternalProcessTask(command, directory, printStdout, printStderr); |
1117 | + SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
1118 | + Result<? extends ExternalProcessResult> res = task.run(mon); |
1119 | + |
1120 | + if (res.getOutcome() == Outcome.CANCELLED) { |
1121 | + return new Result<TransformationResult>(Outcome.CANCELLED); |
1122 | + } else { |
1123 | + final Outcome outcome; |
1124 | + STGModel outStg = null; |
1125 | + if (res.getReturnValue().getReturnCode() == 0) { |
1126 | + outcome = Outcome.FINISHED; |
1127 | } else { |
1128 | - return Result.exception(exportResult.getCause()); |
1129 | + outcome = Outcome.FAILED; |
1130 | } |
1131 | - } |
1132 | - |
1133 | - PetrifyTask petrifyTask = new PetrifyTask(parameters, modelFile.getAbsolutePath()); |
1134 | - |
1135 | - final Result<? extends ExternalProcessResult> petrifyResult |
1136 | - = framework.getTaskManager().execute(petrifyTask, description + ": executing Petrify"); |
1137 | - |
1138 | - if (petrifyResult.getOutcome() == Outcome.FINISHED) { |
1139 | try { |
1140 | - ByteArrayInputStream in = new ByteArrayInputStream(petrifyResult.getReturnValue().getOutput()); |
1141 | - final STGModel outStg = new DotGImporter().importSTG(in); |
1142 | - return Result.finished(new TransformationResult(null, outStg)); |
1143 | + String out = (outFile.exists() ? FileUtils.readAllText(outFile) : ""); |
1144 | + ByteArrayInputStream outStream = new ByteArrayInputStream(out.getBytes()); |
1145 | + outStg = new DotGImporter().importSTG(outStream); |
1146 | } catch (DeserialisationException e) { |
1147 | return Result.exception(e); |
1148 | } |
1149 | - |
1150 | - } else { |
1151 | - if(petrifyResult.getOutcome() == Outcome.FAILED) { |
1152 | - return Result.failed(new TransformationResult(petrifyResult, null)); |
1153 | - } else { |
1154 | - return Result.cancelled(); |
1155 | - } |
1156 | + TransformationResult result = new TransformationResult(res, outStg); |
1157 | + return new Result<TransformationResult>(outcome, result); |
1158 | } |
1159 | } catch (Throwable e) { |
1160 | - return Result.exception(e); |
1161 | + throw new RuntimeException(e); |
1162 | } finally { |
1163 | - FileUtils.deleteFile(modelFile, CommonDebugSettings.getKeepTemporaryFiles()); |
1164 | - } |
1165 | - } |
1166 | - |
1167 | + FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles()); |
1168 | + } |
1169 | + } |
1170 | + |
1171 | + private File getInputFile(Model model, File directory) { |
1172 | + final Framework framework = Framework.getInstance(); |
1173 | + UUID format = null; |
1174 | + String extension = null; |
1175 | + if (model instanceof PetriNetModel) { |
1176 | + format = Format.STG; |
1177 | + extension = ".g"; |
1178 | + } else if (model instanceof Fsm) { |
1179 | + format = Format.SG; |
1180 | + extension = ".sg"; |
1181 | + } |
1182 | + if (format == null) { |
1183 | + throw new RuntimeException("This tool is not applicable to " + model.getDisplayName() + " model."); |
1184 | + } |
1185 | + |
1186 | + File modelFile = new File(directory, "original" + extension); |
1187 | + try { |
1188 | + ExportTask exportTask = Export.createExportTask(model, modelFile, format, framework.getPluginManager()); |
1189 | + final Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, "Exporting model"); |
1190 | + if (exportResult.getOutcome() != Outcome.FINISHED) { |
1191 | + modelFile = null; |
1192 | + } |
1193 | + } catch (SerialisationException e) { |
1194 | + throw new RuntimeException("Unable to export the model."); |
1195 | + } |
1196 | + return modelFile; |
1197 | + } |
1198 | + |
1199 | + |
1200 | + @Override |
1201 | + public void processFinished(int returnCode) { |
1202 | + } |
1203 | + |
1204 | + @Override |
1205 | + public void errorData(byte[] data) { |
1206 | + System.out.print(data); |
1207 | + } |
1208 | + |
1209 | + @Override |
1210 | + public void outputData(byte[] data) { |
1211 | + System.out.print(data); |
1212 | + } |
1213 | + |
1214 | } |
1215 | |
1216 | === modified file 'PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java' |
1217 | --- PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java 2016-01-09 22:12:07 +0000 |
1218 | +++ PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java 2016-01-15 17:12:28 +0000 |
1219 | @@ -57,7 +57,7 @@ |
1220 | monitor.progressUpdate(0.10); |
1221 | |
1222 | File netFile = new File(directory, "net" + exporter.getExtenstion()); |
1223 | - ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath()); |
1224 | + ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath()); |
1225 | SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); |
1226 | Result<? extends Object> exportResult = framework.getTaskManager().execute( |
1227 | exportTask, "Exporting .g", mon); |
1228 | @@ -72,7 +72,7 @@ |
1229 | monitor.progressUpdate(0.20); |
1230 | |
1231 | File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true)); |
1232 | - PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath()); |
1233 | + PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath()); |
1234 | Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute( |
1235 | punfTask, "Unfolding .g", mon); |
1236 | |
1237 | @@ -86,7 +86,7 @@ |
1238 | monitor.progressUpdate(0.70); |
1239 | |
1240 | MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), |
1241 | - unfoldingFile.getCanonicalPath(), directory, true); |
1242 | + unfoldingFile.getAbsolutePath(), directory, true); |
1243 | Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute( |
1244 | mpsatTask, "Running deadlock checking [MPSat]", mon); |
1245 | |
1246 | |
1247 | === modified file 'PunfPlugin/src/org/workcraft/plugins/punf/PunfUtilitySettings.java' |
1248 | --- PunfPlugin/src/org/workcraft/plugins/punf/PunfUtilitySettings.java 2015-12-30 23:43:20 +0000 |
1249 | +++ PunfPlugin/src/org/workcraft/plugins/punf/PunfUtilitySettings.java 2016-01-15 17:12:28 +0000 |
1250 | @@ -36,14 +36,20 @@ |
1251 | |
1252 | private static final String keyCommand = prefix + ".command"; |
1253 | private static final String keyExtraArgs = prefix + ".args"; |
1254 | + private static final String keyPrintStdout= prefix + ".printStdout"; |
1255 | + private static final String keyPrintStderr= prefix + ".printStderr"; |
1256 | private static final String keyUsePnmlUnfolding = prefix + ".usePnmlUnfolding"; |
1257 | |
1258 | private static final String defaultCommand = (DesktopApi.getOs().isWindows() ? "tools\\UnfoldingTools\\punf.exe" : "tools/UnfoldingTools/punf"); |
1259 | private static final String defaultExtraArgs = "-r"; |
1260 | + private static final Boolean defaultPrintStdout = true; |
1261 | + private static final Boolean defaultPrintStderr = true; |
1262 | private static final Boolean defaultUsePnmlUnfolding = true; |
1263 | |
1264 | private static String command = defaultCommand; |
1265 | private static String extraArgs = defaultExtraArgs; |
1266 | + private static Boolean printStdout = defaultPrintStdout; |
1267 | + private static Boolean printStderr = defaultPrintStderr; |
1268 | private static Boolean usePnmlUnfolding = defaultUsePnmlUnfolding; |
1269 | |
1270 | public PunfUtilitySettings() { |
1271 | @@ -68,6 +74,26 @@ |
1272 | }); |
1273 | |
1274 | properties.add(new PropertyDeclaration<PunfUtilitySettings, Boolean>( |
1275 | + this, "Output stdout", Boolean.class, true, false, false) { |
1276 | + protected void setter(PunfUtilitySettings object, Boolean value) { |
1277 | + setPrintStdout(value); |
1278 | + } |
1279 | + protected Boolean getter(PunfUtilitySettings object) { |
1280 | + return getPrintStdout(); |
1281 | + } |
1282 | + }); |
1283 | + |
1284 | + properties.add(new PropertyDeclaration<PunfUtilitySettings, Boolean>( |
1285 | + this, "Output stderr", Boolean.class, true, false, false) { |
1286 | + protected void setter(PunfUtilitySettings object, Boolean value) { |
1287 | + setPrintStderr(value); |
1288 | + } |
1289 | + protected Boolean getter(PunfUtilitySettings object) { |
1290 | + return getPrintStderr(); |
1291 | + } |
1292 | + }); |
1293 | + |
1294 | + properties.add(new PropertyDeclaration<PunfUtilitySettings, Boolean>( |
1295 | this, "Use PNML-based unfolding (where possible)", Boolean.class, true, false, false) { |
1296 | protected void setter(PunfUtilitySettings object, Boolean value) { |
1297 | setUsePnmlUnfolding(value); |
1298 | @@ -88,12 +114,16 @@ |
1299 | setCommand(config.getString(keyCommand, defaultCommand)); |
1300 | setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs)); |
1301 | setUsePnmlUnfolding(config.getBoolean(keyUsePnmlUnfolding, defaultUsePnmlUnfolding)); |
1302 | + setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout)); |
1303 | + setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr)); |
1304 | } |
1305 | |
1306 | @Override |
1307 | public void save(Config config) { |
1308 | config.set(keyCommand, getCommand()); |
1309 | config.set(keyExtraArgs, getExtraArgs()); |
1310 | + config.setBoolean(keyPrintStdout, getPrintStdout()); |
1311 | + config.setBoolean(keyPrintStderr, getPrintStderr()); |
1312 | config.setBoolean(keyUsePnmlUnfolding, getUsePnmlUnfolding()); |
1313 | } |
1314 | |
1315 | @@ -123,6 +153,22 @@ |
1316 | extraArgs = value; |
1317 | } |
1318 | |
1319 | + public static Boolean getPrintStdout() { |
1320 | + return printStdout; |
1321 | + } |
1322 | + |
1323 | + public static void setPrintStdout(Boolean value) { |
1324 | + printStdout = value; |
1325 | + } |
1326 | + |
1327 | + public static Boolean getPrintStderr() { |
1328 | + return printStderr; |
1329 | + } |
1330 | + |
1331 | + public static void setPrintStderr(Boolean value) { |
1332 | + printStderr = value; |
1333 | + } |
1334 | + |
1335 | public static Boolean getUsePnmlUnfolding() { |
1336 | return usePnmlUnfolding; |
1337 | } |
1338 | @@ -138,5 +184,5 @@ |
1339 | public static String getToolSuffix(boolean tryPnml) { |
1340 | return (tryPnml && getUsePnmlUnfolding() ? "" : "-mci"); |
1341 | } |
1342 | - |
1343 | + |
1344 | } |
1345 | |
1346 | === modified file 'PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java' |
1347 | --- PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java 2016-01-09 22:12:07 +0000 |
1348 | +++ PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java 2016-01-15 17:12:28 +0000 |
1349 | @@ -38,8 +38,11 @@ |
1350 | // Built-in arguments |
1351 | command.add("-m=" + outputPath); |
1352 | command.add(inputPath); |
1353 | - |
1354 | - Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command).run(monitor); |
1355 | + |
1356 | + boolean printStdout = PunfUtilitySettings.getPrintStdout(); |
1357 | + boolean printStderr = PunfUtilitySettings.getPrintStderr(); |
1358 | + ExternalProcessTask task = new ExternalProcessTask(command, null, printStdout, printStderr); |
1359 | + Result<? extends ExternalProcessResult> res = task.run(monitor); |
1360 | |
1361 | if (res.getOutcome() != Outcome.FINISHED) { |
1362 | return res; |
1363 | |
1364 | === modified file 'WorkcraftCore/src/org/workcraft/Config.java' |
1365 | --- WorkcraftCore/src/org/workcraft/Config.java 2014-07-25 16:19:39 +0000 |
1366 | +++ WorkcraftCore/src/org/workcraft/Config.java 2016-01-15 17:12:28 +0000 |
1367 | @@ -190,51 +190,51 @@ |
1368 | group.put(k[1], value); |
1369 | } |
1370 | } |
1371 | - |
1372 | - public void load(String fileName) { |
1373 | - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
1374 | - Document xmldoc; |
1375 | - DocumentBuilder db; |
1376 | - |
1377 | - try { |
1378 | - db = dbf.newDocumentBuilder(); |
1379 | - xmldoc = db.parse(new File(fileName)); |
1380 | - } catch (ParserConfigurationException e) { |
1381 | - e.printStackTrace(); |
1382 | - return; |
1383 | - } catch (IOException e) { |
1384 | - return; |
1385 | - } catch (SAXException e) { |
1386 | - e.printStackTrace(); |
1387 | - return; |
1388 | - } |
1389 | - |
1390 | - Element xmlroot = xmldoc.getDocumentElement(); |
1391 | - NodeList nl = xmlroot.getChildNodes(), nl2; |
1392 | - for (int i=0; i<nl.getLength(); i++) { |
1393 | - if (! (nl.item(i) instanceof Element)) { |
1394 | + |
1395 | + public void load(String fileName) { |
1396 | + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
1397 | + Document xmldoc; |
1398 | + DocumentBuilder db; |
1399 | + |
1400 | + try { |
1401 | + db = dbf.newDocumentBuilder(); |
1402 | + xmldoc = db.parse(new File(fileName)); |
1403 | + } catch (ParserConfigurationException e) { |
1404 | + e.printStackTrace(); |
1405 | + return; |
1406 | + } catch (IOException e) { |
1407 | + return; |
1408 | + } catch (SAXException e) { |
1409 | + e.printStackTrace(); |
1410 | + return; |
1411 | + } |
1412 | + |
1413 | + Element xmlroot = xmldoc.getDocumentElement(); |
1414 | + NodeList nl = xmlroot.getChildNodes(), nl2; |
1415 | + for (int i=0; i<nl.getLength(); i++) { |
1416 | + if (! (nl.item(i) instanceof Element)) { |
1417 | continue; |
1418 | - } |
1419 | - Element e = (Element)nl.item(i); |
1420 | - |
1421 | - if (e.getTagName().equals("var")) { |
1422 | - set(e.getAttribute("name"), e.getAttribute("value")); |
1423 | - } else { |
1424 | - if (e.getTagName().equals("group")) { |
1425 | - String name = e.getAttribute("name"); |
1426 | - nl2 = e.getChildNodes(); |
1427 | - for (int j=0; j<nl2.getLength(); j++) { |
1428 | - if (! (nl2.item(j) instanceof Element)) { |
1429 | - continue; |
1430 | - } |
1431 | - Element e2 = (Element)nl2.item(j); |
1432 | - if (e2.getTagName().equals("var")) |
1433 | - set(name+"."+e2.getAttribute("name"), e2.getAttribute("value")); |
1434 | - } |
1435 | + } |
1436 | + Element e = (Element)nl.item(i); |
1437 | + |
1438 | + if (e.getTagName().equals("var")) { |
1439 | + set(e.getAttribute("name"), e.getAttribute("value")); |
1440 | + } else { |
1441 | + if (e.getTagName().equals("group")) { |
1442 | + String name = e.getAttribute("name"); |
1443 | + nl2 = e.getChildNodes(); |
1444 | + for (int j=0; j<nl2.getLength(); j++) { |
1445 | + if (! (nl2.item(j) instanceof Element)) { |
1446 | + continue; |
1447 | + } |
1448 | + Element e2 = (Element)nl2.item(j); |
1449 | + if (e2.getTagName().equals("var")) |
1450 | + set(name+"."+e2.getAttribute("name"), e2.getAttribute("value")); |
1451 | + } |
1452 | } |
1453 | - } |
1454 | - } |
1455 | - } |
1456 | + } |
1457 | + } |
1458 | + } |
1459 | |
1460 | public void save(String fileName) { |
1461 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
1462 | |
1463 | === modified file 'WorkcraftCore/src/org/workcraft/Framework.java' |
1464 | --- WorkcraftCore/src/org/workcraft/Framework.java 2015-11-27 18:45:40 +0000 |
1465 | +++ WorkcraftCore/src/org/workcraft/Framework.java 2016-01-15 17:12:28 +0000 |
1466 | @@ -228,9 +228,15 @@ |
1467 | return instance; |
1468 | } |
1469 | |
1470 | + public void resetConfig() { |
1471 | + config = new Config(); |
1472 | + for (PluginInfo<? extends Settings> info : pluginManager.getPlugins(Settings.class)) { |
1473 | + info.getSingleton().load(config); |
1474 | + } |
1475 | + } |
1476 | + |
1477 | public void loadConfig(String fileName) { |
1478 | config.load(fileName); |
1479 | - |
1480 | for (PluginInfo<? extends Settings> info : pluginManager.getPlugins(Settings.class)) { |
1481 | info.getSingleton().load(config); |
1482 | } |
1483 | @@ -240,7 +246,6 @@ |
1484 | for (PluginInfo<? extends Settings> info : pluginManager.getPlugins(Settings.class)) { |
1485 | info.getSingleton().save(config); |
1486 | } |
1487 | - |
1488 | config.save(fileName); |
1489 | } |
1490 | |
1491 | |
1492 | === modified file 'WorkcraftCore/src/org/workcraft/gui/AboutDialog.java' |
1493 | --- WorkcraftCore/src/org/workcraft/gui/AboutDialog.java 2014-11-14 23:43:09 +0000 |
1494 | +++ WorkcraftCore/src/org/workcraft/gui/AboutDialog.java 2016-01-15 17:12:28 +0000 |
1495 | @@ -98,7 +98,7 @@ |
1496 | }); |
1497 | |
1498 | okButton = new JButton(); |
1499 | - okButton.setPreferredSize(new Dimension(100, 20)); |
1500 | + okButton.setPreferredSize(new Dimension(100, 25)); |
1501 | okButton.setText("OK"); |
1502 | okButton.addActionListener(new java.awt.event.ActionListener() { |
1503 | public void actionPerformed(java.awt.event.ActionEvent e) { |
1504 | |
1505 | === modified file 'WorkcraftCore/src/org/workcraft/gui/CreateWorkDialog.java' |
1506 | --- WorkcraftCore/src/org/workcraft/gui/CreateWorkDialog.java 2015-10-15 16:52:53 +0000 |
1507 | +++ WorkcraftCore/src/org/workcraft/gui/CreateWorkDialog.java 2016-01-15 17:12:28 +0000 |
1508 | @@ -196,7 +196,7 @@ |
1509 | buttonsPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); |
1510 | |
1511 | okButton = new JButton(); |
1512 | - okButton.setPreferredSize(new Dimension(100, 20)); |
1513 | + okButton.setPreferredSize(new Dimension(100, 25)); |
1514 | okButton.setEnabled(false); |
1515 | okButton.setText("OK"); |
1516 | okButton.addActionListener(new java.awt.event.ActionListener() { |
1517 | @@ -206,7 +206,7 @@ |
1518 | }); |
1519 | |
1520 | cancelButton = new JButton(); |
1521 | - cancelButton.setPreferredSize(new Dimension(100, 20)); |
1522 | + cancelButton.setPreferredSize(new Dimension(100, 25)); |
1523 | cancelButton.setText("Cancel"); |
1524 | cancelButton.addActionListener(new java.awt.event.ActionListener() { |
1525 | public void actionPerformed(java.awt.event.ActionEvent e) { |
1526 | @@ -216,11 +216,11 @@ |
1527 | |
1528 | buttonsPane.add(okButton); |
1529 | buttonsPane.add(cancelButton); |
1530 | - |
1531 | contentPane.add(splitPane, BorderLayout.CENTER); |
1532 | - contentPane.add(buttonsPane, BorderLayout.SOUTH); |
1533 | + contentPane.add(buttonsPane, BorderLayout.SOUTH); |
1534 | + getRootPane().setDefaultButton(okButton); |
1535 | |
1536 | - getRootPane().registerKeyboardAction(new ActionListener() { |
1537 | + getRootPane().registerKeyboardAction(new ActionListener() { |
1538 | @Override |
1539 | public void actionPerformed(ActionEvent e) { |
1540 | ok(); |
1541 | |
1542 | === modified file 'WorkcraftCore/src/org/workcraft/gui/propertyeditor/Settings.java' |
1543 | --- WorkcraftCore/src/org/workcraft/gui/propertyeditor/Settings.java 2014-08-05 22:17:32 +0000 |
1544 | +++ WorkcraftCore/src/org/workcraft/gui/propertyeditor/Settings.java 2016-01-15 17:12:28 +0000 |
1545 | @@ -24,8 +24,8 @@ |
1546 | import org.workcraft.Config; |
1547 | |
1548 | public interface Settings extends Properties { |
1549 | - public void save (Config config); |
1550 | - public void load (Config config); |
1551 | + public void save(Config config); |
1552 | + public void load(Config config); |
1553 | |
1554 | public String getSection(); |
1555 | public String getName(); |
1556 | |
1557 | === modified file 'WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java' |
1558 | --- WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java 2015-10-16 17:25:11 +0000 |
1559 | +++ WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java 2016-01-15 17:12:28 +0000 |
1560 | @@ -26,6 +26,7 @@ |
1561 | import java.awt.FlowLayout; |
1562 | import java.awt.event.ActionEvent; |
1563 | import java.awt.event.ActionListener; |
1564 | +import java.awt.event.KeyEvent; |
1565 | import java.awt.event.WindowAdapter; |
1566 | import java.awt.event.WindowEvent; |
1567 | import java.util.ArrayList; |
1568 | @@ -35,13 +36,16 @@ |
1569 | |
1570 | import javax.swing.BorderFactory; |
1571 | import javax.swing.JButton; |
1572 | +import javax.swing.JComponent; |
1573 | import javax.swing.JDialog; |
1574 | import javax.swing.JFrame; |
1575 | +import javax.swing.JOptionPane; |
1576 | import javax.swing.JPanel; |
1577 | import javax.swing.JScrollPane; |
1578 | import javax.swing.JSplitPane; |
1579 | import javax.swing.JTable; |
1580 | import javax.swing.JTree; |
1581 | +import javax.swing.KeyStroke; |
1582 | import javax.swing.event.TreeSelectionEvent; |
1583 | import javax.swing.event.TreeSelectionListener; |
1584 | import javax.swing.tree.DefaultMutableTreeNode; |
1585 | @@ -49,6 +53,7 @@ |
1586 | import javax.swing.tree.TreePath; |
1587 | import javax.swing.tree.TreeSelectionModel; |
1588 | |
1589 | +import org.workcraft.Config; |
1590 | import org.workcraft.Framework; |
1591 | import org.workcraft.PluginManager; |
1592 | import org.workcraft.gui.MainWindow; |
1593 | @@ -62,10 +67,15 @@ |
1594 | private JSplitPane splitPane; |
1595 | private JPanel buttonsPane; |
1596 | private JButton okButton; |
1597 | + private JButton cancelButton; |
1598 | + private JButton restoreButton; |
1599 | private DefaultMutableTreeNode sectionRoot; |
1600 | private JTree sectionTree; |
1601 | private final PropertyEditorTable propertiesTable; |
1602 | |
1603 | + private Settings currentPage; |
1604 | + private Config currentConfig; |
1605 | + |
1606 | static class SettingsPageNode { |
1607 | private Settings page; |
1608 | |
1609 | @@ -111,7 +121,7 @@ |
1610 | initComponents(); |
1611 | loadSections(); |
1612 | } |
1613 | - |
1614 | + |
1615 | public DefaultMutableTreeNode getSectionNode (DefaultMutableTreeNode node, String section) { |
1616 | int dotPos = section.indexOf('.'); |
1617 | |
1618 | @@ -172,6 +182,7 @@ |
1619 | final TreePath treePath = sectionTree.getPathForRow(i); |
1620 | sectionTree.expandPath(treePath); |
1621 | } |
1622 | + setObject(null); |
1623 | } |
1624 | |
1625 | private ArrayList<Settings> getSortedPluginSettings(Collection<PluginInfo<? extends Settings>> plugins) { |
1626 | @@ -204,12 +215,17 @@ |
1627 | return settings; |
1628 | } |
1629 | |
1630 | - private void setObject(Settings p) { |
1631 | - if (p == null) { |
1632 | - propertiesTable.setObject(null); |
1633 | + private void setObject(Settings page) { |
1634 | + if (page == null) { |
1635 | + currentConfig = null; |
1636 | + restoreButton.setText("Restore defaults (all)"); |
1637 | } else { |
1638 | - propertiesTable.setObject(p); |
1639 | + currentConfig = new Config(); |
1640 | + page.save(currentConfig); |
1641 | + restoreButton.setText("Restore defaults"); |
1642 | } |
1643 | + currentPage = page; |
1644 | + propertiesTable.setObject(currentPage); |
1645 | } |
1646 | |
1647 | private void initComponents() { |
1648 | @@ -227,7 +243,8 @@ |
1649 | public void valueChanged(TreeSelectionEvent e) { |
1650 | Object userObject = ((DefaultMutableTreeNode)e.getPath().getLastPathComponent()).getUserObject(); |
1651 | if (userObject instanceof SettingsPageNode) { |
1652 | - setObject( ((SettingsPageNode) userObject).getPage() ); |
1653 | + Settings page = ((SettingsPageNode) userObject).getPage(); |
1654 | + setObject(page); |
1655 | } else { |
1656 | setObject(null); |
1657 | } |
1658 | @@ -251,24 +268,85 @@ |
1659 | splitPane.setResizeWeight(0.1); |
1660 | |
1661 | okButton = new JButton(); |
1662 | - okButton.setPreferredSize(new Dimension(100, 20)); |
1663 | + okButton.setPreferredSize(new Dimension(100, 25)); |
1664 | okButton.setText("OK"); |
1665 | okButton.addActionListener(new ActionListener() { |
1666 | public void actionPerformed(ActionEvent e) { |
1667 | ok(); |
1668 | } |
1669 | }); |
1670 | + |
1671 | + cancelButton = new JButton(); |
1672 | + cancelButton.setPreferredSize(new Dimension(100, 25)); |
1673 | + cancelButton.setText("Cancel"); |
1674 | + cancelButton.addActionListener(new ActionListener() { |
1675 | + public void actionPerformed(ActionEvent e) { |
1676 | + cancel(); |
1677 | + } |
1678 | + }); |
1679 | + |
1680 | + restoreButton = new JButton(); |
1681 | + restoreButton.setPreferredSize(new Dimension(170, 25)); |
1682 | + restoreButton.setText("Restore defaults"); |
1683 | + restoreButton.addActionListener(new ActionListener() { |
1684 | + public void actionPerformed(ActionEvent e) { |
1685 | + restore(); |
1686 | + } |
1687 | + }); |
1688 | |
1689 | buttonsPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); |
1690 | buttonsPane.add(okButton); |
1691 | + buttonsPane.add(cancelButton); |
1692 | + buttonsPane.add(restoreButton); |
1693 | contentPane.add(splitPane, BorderLayout.CENTER); |
1694 | contentPane.add(buttonsPane, BorderLayout.SOUTH); |
1695 | getRootPane().setDefaultButton(okButton); |
1696 | + |
1697 | + getRootPane().registerKeyboardAction(new ActionListener() { |
1698 | + @Override |
1699 | + public void actionPerformed(ActionEvent e) { |
1700 | + ok(); |
1701 | + } |
1702 | + }, |
1703 | + KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), |
1704 | + JComponent.WHEN_IN_FOCUSED_WINDOW); |
1705 | + |
1706 | + getRootPane().registerKeyboardAction(new ActionListener() { |
1707 | + @Override |
1708 | + public void actionPerformed(ActionEvent e) { |
1709 | + cancel(); |
1710 | + } |
1711 | + }, |
1712 | + KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), |
1713 | + JComponent.WHEN_IN_FOCUSED_WINDOW); |
1714 | } |
1715 | |
1716 | private void ok() { |
1717 | setObject(null); |
1718 | setVisible(false); |
1719 | } |
1720 | + |
1721 | + private void cancel() { |
1722 | + if ((currentPage != null) && (currentConfig != null)) { |
1723 | + currentPage.load(currentConfig); |
1724 | + } |
1725 | + setObject(null); |
1726 | + setVisible(false); |
1727 | + } |
1728 | + |
1729 | + private void restore() { |
1730 | + if (currentPage != null) { |
1731 | + currentPage.load(new Config()); |
1732 | + setObject(currentPage); |
1733 | + } else { |
1734 | + final Framework framework = Framework.getInstance(); |
1735 | + int answer = JOptionPane.showConfirmDialog(framework.getMainWindow(), |
1736 | + "This will reset all the settings to defaults.\nContinue?", |
1737 | + "Please confirm", JOptionPane.YES_NO_OPTION); |
1738 | + if (answer == JOptionPane.YES_OPTION) { |
1739 | + framework.resetConfig(); |
1740 | + } |
1741 | + } |
1742 | + } |
1743 | |
1744 | } |
1745 | |
1746 | === modified file 'WorkcraftCore/src/org/workcraft/interop/ExternalProcess.java' |
1747 | --- WorkcraftCore/src/org/workcraft/interop/ExternalProcess.java 2015-07-31 15:05:52 +0000 |
1748 | +++ WorkcraftCore/src/org/workcraft/interop/ExternalProcess.java 2016-01-15 17:12:28 +0000 |
1749 | @@ -32,34 +32,31 @@ |
1750 | |
1751 | public class ExternalProcess { |
1752 | |
1753 | - abstract static class StreamReaderThread extends Thread |
1754 | - { |
1755 | + abstract static class StreamReaderThread extends Thread { |
1756 | private final ReadableByteChannel channel; |
1757 | private final ByteBuffer buffer = ByteBuffer.allocate(1024); |
1758 | |
1759 | - public StreamReaderThread(ReadableByteChannel channel) |
1760 | - { |
1761 | + public StreamReaderThread(ReadableByteChannel channel) { |
1762 | this.channel = channel; |
1763 | } |
1764 | |
1765 | abstract void handleData(byte [] data); |
1766 | |
1767 | + @Override |
1768 | public void run() { |
1769 | while (true) |
1770 | try { |
1771 | buffer.rewind(); |
1772 | int result = channel.read(buffer); |
1773 | - |
1774 | - if (result == -1) |
1775 | + if (result == -1) { |
1776 | return; |
1777 | - |
1778 | - if (result == 0) |
1779 | + } |
1780 | + if (result == 0) { |
1781 | continue; |
1782 | - |
1783 | + } |
1784 | buffer.rewind(); |
1785 | byte[] data = new byte[result]; |
1786 | buffer.get(data); |
1787 | - |
1788 | handleData(data); |
1789 | } catch (IOException e) { |
1790 | // e.printStackTrace(); -- This exception is mostly caused by the process termination and spams the user with information about exceptions that should |
1791 | @@ -70,29 +67,27 @@ |
1792 | } |
1793 | |
1794 | class InputReaderThread extends StreamReaderThread { |
1795 | - |
1796 | - InputReaderThread() |
1797 | - { |
1798 | + InputReaderThread() { |
1799 | super(inputStream); |
1800 | } |
1801 | - |
1802 | - void handleData(byte[] data) { |
1803 | + @Override |
1804 | + void handleData(byte[] data) { |
1805 | outputData(data); |
1806 | } |
1807 | } |
1808 | |
1809 | class ErrorReaderThread extends StreamReaderThread { |
1810 | - ErrorReaderThread() |
1811 | - { |
1812 | + ErrorReaderThread() { |
1813 | super(errorStream); |
1814 | } |
1815 | - |
1816 | + @Override |
1817 | void handleData(byte[] data) { |
1818 | errorData(data); |
1819 | } |
1820 | } |
1821 | |
1822 | class WaiterThread extends Thread { |
1823 | + @Override |
1824 | public void run() { |
1825 | try { |
1826 | process.waitFor(); |
1827 | @@ -112,7 +107,7 @@ |
1828 | |
1829 | private LinkedList<ExternalProcessListener> listeners = new LinkedList<ExternalProcessListener>(); |
1830 | |
1831 | - public ExternalProcess (String[] command, String workingDirectoryPath) { |
1832 | + public ExternalProcess(String[] command, String workingDirectoryPath) { |
1833 | processBuilder = new ProcessBuilder(command); |
1834 | processBuilder.directory(workingDirectoryPath == null? null : new File(workingDirectoryPath)); |
1835 | } |
1836 | @@ -122,19 +117,21 @@ |
1837 | } |
1838 | |
1839 | private void outputData(byte[] data) { |
1840 | - for (ExternalProcessListener l : listeners) |
1841 | - l.outputData(data); |
1842 | + for (ExternalProcessListener l : listeners) { |
1843 | + l.outputData(data); |
1844 | + } |
1845 | } |
1846 | |
1847 | private void errorData(byte[] data) { |
1848 | - for (ExternalProcessListener l : listeners) |
1849 | - l.errorData(data); |
1850 | + for (ExternalProcessListener l : listeners) { |
1851 | + l.errorData(data); |
1852 | + } |
1853 | } |
1854 | |
1855 | private void processFinished() { |
1856 | for (ExternalProcessListener l : listeners){ |
1857 | l.processFinished(process.exitValue()); |
1858 | - } |
1859 | + } |
1860 | finished = true; |
1861 | } |
1862 | |
1863 | @@ -143,15 +140,13 @@ |
1864 | } |
1865 | |
1866 | public void start() throws IOException { |
1867 | - if (isRunning()) |
1868 | + if (isRunning()) { |
1869 | return; |
1870 | - |
1871 | + } |
1872 | process = processBuilder.start(); |
1873 | - |
1874 | outputStream = Channels.newChannel(process.getOutputStream()); |
1875 | errorStream = Channels.newChannel(process.getErrorStream()); |
1876 | inputStream = Channels.newChannel(process.getInputStream()); |
1877 | - |
1878 | if (outputStream == null) { |
1879 | throw new RuntimeException("No output stream!"); |
1880 | } |
1881 | @@ -161,8 +156,9 @@ |
1882 | } |
1883 | |
1884 | public void cancel() { |
1885 | - if (isRunning()) |
1886 | - process.destroy(); |
1887 | + if (isRunning()) { |
1888 | + process.destroy(); |
1889 | + } |
1890 | } |
1891 | |
1892 | public void writeData(byte[] data) { |
1893 | |
1894 | === modified file 'WorkcraftCore/src/org/workcraft/interop/SynchronousExternalProcess.java' |
1895 | --- WorkcraftCore/src/org/workcraft/interop/SynchronousExternalProcess.java 2009-09-22 21:01:45 +0000 |
1896 | +++ WorkcraftCore/src/org/workcraft/interop/SynchronousExternalProcess.java 2016-01-15 17:12:28 +0000 |
1897 | @@ -25,19 +25,20 @@ |
1898 | import java.util.LinkedList; |
1899 | |
1900 | public class SynchronousExternalProcess { |
1901 | - class SynchronousListener implements ExternalProcessListener { |
1902 | + class SynchronousListener implements ExternalProcessListener { |
1903 | + @Override |
1904 | public void errorData(byte[] data) { |
1905 | synchronized (errorData) { |
1906 | errorData.add(data); |
1907 | } |
1908 | } |
1909 | - |
1910 | + @Override |
1911 | public void outputData(byte[] data) { |
1912 | synchronized (outputData) { |
1913 | outputData.add(data); |
1914 | } |
1915 | } |
1916 | - |
1917 | + @Override |
1918 | public void processFinished(int returnCode) { |
1919 | SynchronousExternalProcess.this.returnCode = returnCode; |
1920 | finished = true; |
1921 | @@ -90,18 +91,18 @@ |
1922 | return returnCode; |
1923 | } |
1924 | |
1925 | - private static byte [] mergeChunksToArray (LinkedList<byte[]> chunks) { |
1926 | + private static byte [] mergeChunksToArray(LinkedList<byte[]> chunks) { |
1927 | int len = 0; |
1928 | - for (byte[] dataChunk : chunks) |
1929 | + for (byte[] dataChunk : chunks) { |
1930 | len += dataChunk.length; |
1931 | - |
1932 | + } |
1933 | byte [] result = new byte[len]; |
1934 | - |
1935 | int cur = 0; |
1936 | - for (byte[] dataChunk : chunks) |
1937 | - for(int i=0;i<dataChunk.length;i++) |
1938 | - result[cur++] = dataChunk[i]; |
1939 | - |
1940 | + for (byte[] dataChunk : chunks) { |
1941 | + for(int i=0;i<dataChunk.length;i++) { |
1942 | + result[cur++] = dataChunk[i]; |
1943 | + } |
1944 | + } |
1945 | return result; |
1946 | } |
1947 | |
1948 | @@ -111,5 +112,6 @@ |
1949 | |
1950 | public byte [] getErrorData() { |
1951 | return mergeChunksToArray(errorData); |
1952 | - } |
1953 | + } |
1954 | + |
1955 | } |
1956 | |
1957 | === modified file 'WorkcraftCore/src/org/workcraft/plugins/layout/DotLayoutTool.java' |
1958 | --- WorkcraftCore/src/org/workcraft/plugins/layout/DotLayoutTool.java 2015-12-26 23:27:09 +0000 |
1959 | +++ WorkcraftCore/src/org/workcraft/plugins/layout/DotLayoutTool.java 2016-01-15 17:12:28 +0000 |
1960 | @@ -204,7 +204,7 @@ |
1961 | args.add(layout.getAbsolutePath()); |
1962 | args.add(original.getAbsolutePath()); |
1963 | |
1964 | - Task<ExternalProcessResult> task = new ExternalProcessTask(args, directory); |
1965 | + Task<ExternalProcessResult> task = new ExternalProcessTask(args, directory, false, false); |
1966 | final Framework framework = Framework.getInstance(); |
1967 | Result<? extends ExternalProcessResult> res = framework.getTaskManager().execute(task, "Laying out the graph..."); |
1968 | |
1969 | |
1970 | === modified file 'WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java' |
1971 | --- WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java 2016-01-05 20:25:07 +0000 |
1972 | +++ WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java 2016-01-15 17:12:28 +0000 |
1973 | @@ -14,6 +14,10 @@ |
1974 | |
1975 | public class ExternalProcessTask implements Task<ExternalProcessResult>, ExternalProcessListener { |
1976 | private List<String> args; |
1977 | + private final File workingDir; |
1978 | + private boolean printStdout; |
1979 | + private boolean printStderr; |
1980 | + private boolean hasNewLine = false; |
1981 | |
1982 | private volatile boolean finished; |
1983 | private volatile int returnCode; |
1984 | @@ -23,15 +27,11 @@ |
1985 | private DataAccumulator stdoutAccum = new DataAccumulator(); |
1986 | private DataAccumulator stderrAccum = new DataAccumulator(); |
1987 | |
1988 | - private final File workingDir; |
1989 | - |
1990 | - public ExternalProcessTask(List<String> args) { |
1991 | - this(args, null); |
1992 | - } |
1993 | - |
1994 | - public ExternalProcessTask(List<String> args, File workingDir) { |
1995 | + public ExternalProcessTask(List<String> args, File workingDir, boolean printStdout, boolean printStderr) { |
1996 | this.args = args; |
1997 | this.workingDir = workingDir; |
1998 | + this.printStdout = printStdout; |
1999 | + this.printStderr = printStderr; |
2000 | } |
2001 | |
2002 | @Override |
2003 | @@ -68,7 +68,9 @@ |
2004 | if (userCancelled) { |
2005 | return Result.cancelled(); |
2006 | } |
2007 | - ExternalProcessResult result = new ExternalProcessResult(returnCode, stdoutAccum.getData(), stderrAccum.getData(), Collections.<String, byte[]>emptyMap()); |
2008 | + ExternalProcessResult result = new ExternalProcessResult( |
2009 | + returnCode, stdoutAccum.getData(), stderrAccum.getData(), |
2010 | + Collections.<String, byte[]>emptyMap()); |
2011 | |
2012 | return Result.finished(result); |
2013 | } |
2014 | @@ -91,6 +93,19 @@ |
2015 | } |
2016 | |
2017 | @Override |
2018 | + public void outputData(byte[] data) { |
2019 | + try { |
2020 | + stdoutAccum.write(data); |
2021 | + } catch (IOException e) { |
2022 | + throw new RuntimeException(e); |
2023 | + } |
2024 | + monitor.stdout(data); |
2025 | + if (printStdout) { |
2026 | + printData(data); |
2027 | + } |
2028 | + } |
2029 | + |
2030 | + @Override |
2031 | public void errorData(byte[] data) { |
2032 | try { |
2033 | stderrAccum.write(data); |
2034 | @@ -98,22 +113,26 @@ |
2035 | throw new RuntimeException(e); |
2036 | } |
2037 | monitor.stderr(data); |
2038 | - } |
2039 | - |
2040 | - @Override |
2041 | - public void outputData(byte[] data) { |
2042 | - try { |
2043 | - stdoutAccum.write(data); |
2044 | - } catch (IOException e) { |
2045 | - throw new RuntimeException(e); |
2046 | + if (printStderr) { |
2047 | + printData(data); |
2048 | } |
2049 | - monitor.stdout(data); |
2050 | + |
2051 | } |
2052 | |
2053 | @Override |
2054 | public void processFinished(int returnCode) { |
2055 | this.returnCode = returnCode; |
2056 | this.finished = true; |
2057 | + if ( !hasNewLine ) { |
2058 | + System.out.println(); |
2059 | + hasNewLine = true; |
2060 | + } |
2061 | + } |
2062 | + |
2063 | + private void printData(byte[] data) { |
2064 | + String s = new String(data); |
2065 | + System.out.print(s); |
2066 | + hasNewLine = (s.endsWith("\n")); |
2067 | } |
2068 | |
2069 | } |
2070 | |
2071 | === modified file 'WorkcraftCore/src/org/workcraft/tasks/DummyProgressMonitor.java' |
2072 | --- WorkcraftCore/src/org/workcraft/tasks/DummyProgressMonitor.java 2010-02-14 17:59:01 +0000 |
2073 | +++ WorkcraftCore/src/org/workcraft/tasks/DummyProgressMonitor.java 2016-01-15 17:12:28 +0000 |
2074 | @@ -1,8 +1,9 @@ |
2075 | package org.workcraft.tasks; |
2076 | |
2077 | public class DummyProgressMonitor<T> implements ProgressMonitor<T> { |
2078 | + |
2079 | @Override |
2080 | - public void finished(Result<? extends T> result, String description) { |
2081 | + public void progressUpdate(double completion) { |
2082 | } |
2083 | |
2084 | @Override |
2085 | @@ -15,10 +16,11 @@ |
2086 | } |
2087 | |
2088 | @Override |
2089 | - public void progressUpdate(double completion) { |
2090 | - } |
2091 | - |
2092 | - @Override |
2093 | public void stderr(byte[] data) { |
2094 | } |
2095 | + |
2096 | + @Override |
2097 | + public void finished(Result<? extends T> result, String description) { |
2098 | + } |
2099 | + |
2100 | } |