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