Merge lp:~danilovesky/workcraft/trunk-ui-tools-output into lp:workcraft

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
Reviewer Review Type Date Requested Status
Workcraft core developers Pending
Review via email: mp+282784@code.launchpad.net
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
=== modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java'
--- CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java 2016-01-02 22:46:33 +0000
+++ CircuitPlugin/src/org/workcraft/plugins/circuit/stg/CircuitStgUtils.java 2016-01-15 17:12:28 +0000
@@ -114,7 +114,7 @@
114 }114 }
115115
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,
117 ProgressMonitor<? super MpsatChainResult> monitor) throws IOException {117 ProgressMonitor<? super MpsatChainResult> monitor) {
118 118
119 Framework framework = Framework.getInstance();119 Framework framework = Framework.getInstance();
120 PluginManager pluginManager = framework.getPluginManager();120 PluginManager pluginManager = framework.getPluginManager();
@@ -123,7 +123,7 @@
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.");
124 }124 }
125 125
126 ExportTask exportTask = new ExportTask(stgExporter, stg, stgFile.getCanonicalPath());126 ExportTask exportTask = new ExportTask(stgExporter, stg, stgFile.getAbsolutePath());
127 String description = "Exporting " + stgFile.getAbsolutePath();127 String description = "Exporting " + stgFile.getAbsolutePath();
128 SubtaskMonitor<Object> subtaskMonitor = null;128 SubtaskMonitor<Object> subtaskMonitor = null;
129 if (monitor != null) {129 if (monitor != null) {
130130
=== modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java'
--- CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2016-01-09 22:12:07 +0000
+++ CircuitPlugin/src/org/workcraft/plugins/circuit/tasks/CheckCircuitTask.java 2016-01-15 17:12:28 +0000
@@ -176,7 +176,7 @@
176 Result<? extends ExternalProcessResult> punfResult = null;176 Result<? extends ExternalProcessResult> punfResult = null;
177 if (checkDeadlock || checkHazard) {177 if (checkDeadlock || checkHazard) {
178 unfoldingFile = new File(directory, StgUtils.SYSTEM_FILE_NAME + PunfUtilitySettings.getUnfoldingExtension(true));178 unfoldingFile = new File(directory, StgUtils.SYSTEM_FILE_NAME + PunfUtilitySettings.getUnfoldingExtension(true));
179 punfTask = new PunfTask(sysStgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());179 punfTask = new PunfTask(sysStgFile.getAbsolutePath(), unfoldingFile.getAbsolutePath());
180 SubtaskMonitor<Object> punfMonitor = new SubtaskMonitor<Object>(monitor);180 SubtaskMonitor<Object> punfMonitor = new SubtaskMonitor<Object>(monitor);
181 punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", punfMonitor);181 punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", punfMonitor);
182 182
@@ -195,7 +195,7 @@
195 if (hasEnvironment && checkConformation) {195 if (hasEnvironment && checkConformation) {
196 if ((sysStgFile != sysModStgFile) || (unfoldingModFile == null)) {196 if ((sysStgFile != sysModStgFile) || (unfoldingModFile == null)) {
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));
198 punfModTask = new PunfTask(sysModStgFile.getCanonicalPath(), unfoldingModFile.getCanonicalPath());198 punfModTask = new PunfTask(sysModStgFile.getAbsolutePath(), unfoldingModFile.getAbsolutePath());
199 SubtaskMonitor<Object> punfModMonitor = new SubtaskMonitor<Object>(monitor);199 SubtaskMonitor<Object> punfModMonitor = new SubtaskMonitor<Object>(monitor);
200 punfModResult = framework.getTaskManager().execute(punfModTask, "Unfolding .g", punfModMonitor);200 punfModResult = framework.getTaskManager().execute(punfModTask, "Unfolding .g", punfModMonitor);
201 201
@@ -214,7 +214,7 @@
214 // Check for deadlock (if requested)214 // Check for deadlock (if requested)
215 if (checkDeadlock) {215 if (checkDeadlock) {
216 MpsatTask mpsatDeadlockTask = new MpsatTask(deadlockSettings.getMpsatArguments(directory),216 MpsatTask mpsatDeadlockTask = new MpsatTask(deadlockSettings.getMpsatArguments(directory),
217 unfoldingFile.getCanonicalPath(), directory, true);217 unfoldingFile.getAbsolutePath(), directory, true);
218 SubtaskMonitor<Object> mpsatMonitor = new SubtaskMonitor<Object>(monitor);218 SubtaskMonitor<Object> mpsatMonitor = new SubtaskMonitor<Object>(monitor);
219 Result<? extends ExternalProcessResult> mpsatDeadlockResult = framework.getTaskManager().execute(219 Result<? extends ExternalProcessResult> mpsatDeadlockResult = framework.getTaskManager().execute(
220 mpsatDeadlockTask, "Running deadlock check [MPSat]", mpsatMonitor);220 mpsatDeadlockTask, "Running deadlock check [MPSat]", mpsatMonitor);
@@ -240,7 +240,7 @@
240 // Check for hazards (if requested)240 // Check for hazards (if requested)
241 if (checkHazard) {241 if (checkHazard) {
242 MpsatTask mpsatHazardTask = new MpsatTask(hazardSettings.getMpsatArguments(directory),242 MpsatTask mpsatHazardTask = new MpsatTask(hazardSettings.getMpsatArguments(directory),
243 unfoldingFile.getCanonicalPath(), directory, true);243 unfoldingFile.getAbsolutePath(), directory, true);
244 if (MpsatUtilitySettings.getDebugReach()) {244 if (MpsatUtilitySettings.getDebugReach()) {
245 System.out.println("\nReach expression for the hazard property:");245 System.out.println("\nReach expression for the hazard property:");
246 System.out.println(hazardSettings.getReach());246 System.out.println(hazardSettings.getReach());
@@ -281,7 +281,7 @@
281 MpsatUtilitySettings.getSolutionCount(), reachConformation, true);281 MpsatUtilitySettings.getSolutionCount(), reachConformation, true);
282 282
283 MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(directory),283 MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(directory),
284 unfoldingModFile.getCanonicalPath(), directory, true);284 unfoldingModFile.getAbsolutePath(), directory, true);
285 SubtaskMonitor<Object> mpsatMonitor = new SubtaskMonitor<Object>(monitor);285 SubtaskMonitor<Object> mpsatMonitor = new SubtaskMonitor<Object>(monitor);
286 Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute(286 Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute(
287 mpsatConformationTask, "Running conformation check [MPSat]", mpsatMonitor);287 mpsatConformationTask, "Running conformation check [MPSat]", mpsatMonitor);
288288
=== modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/optimisation/ProcessIO.java'
--- CpogsPlugin/src/org/workcraft/plugins/cpog/optimisation/ProcessIO.java 2010-11-29 15:02:36 +0000
+++ CpogsPlugin/src/org/workcraft/plugins/cpog/optimisation/ProcessIO.java 2016-01-15 17:12:28 +0000
@@ -65,7 +65,7 @@
65 65
66 writeFile(input, inputFile);66 writeFile(input, inputFile);
67 67
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()});
69 minisat.getOutputStream().close();69 minisat.getOutputStream().close();
70 while(true) {70 while(true) {
71 int r = minisat.getInputStream().read();71 int r = minisat.getInputStream().read();
@@ -80,7 +80,6 @@
80 }80 }
81 81
82 result = readFile(outputFile);82 result = readFile(outputFile);
83
84 } catch (IOException e) {83 } catch (IOException e) {
85 throw new RuntimeException(e);84 throw new RuntimeException(e);
86 }85 }
8786
=== modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/PGMinerTask.java'
--- CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/PGMinerTask.java 2015-12-26 23:27:09 +0000
+++ CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/PGMinerTask.java 2016-01-15 17:12:28 +0000
@@ -42,7 +42,7 @@
42 command.add(inputFile.getAbsolutePath());42 command.add(inputFile.getAbsolutePath());
43 43
44 //Call PGMiner44 //Call PGMiner
45 ExternalProcessTask task = new ExternalProcessTask(command, new File("."));45 ExternalProcessTask task = new ExternalProcessTask(command, new File("."), false, false);
46 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);46 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
47 47
48 Result<? extends ExternalProcessResult> result = task.run(mon);48 Result<? extends ExternalProcessResult> result = task.run(mon);
4949
=== modified file 'CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExternalToolTask.java'
--- CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExternalToolTask.java 2015-11-02 13:37:58 +0000
+++ CpogsPlugin/src/org/workcraft/plugins/cpog/tasks/ScencoExternalToolTask.java 2016-01-15 17:12:28 +0000
@@ -2,8 +2,6 @@
22
3import java.util.ArrayList;3import java.util.ArrayList;
44
5import javax.swing.JOptionPane;
6
7import org.workcraft.interop.ExternalProcessListener;5import org.workcraft.interop.ExternalProcessListener;
8import org.workcraft.plugins.shared.tasks.ExternalProcessResult;6import org.workcraft.plugins.shared.tasks.ExternalProcessResult;
9import org.workcraft.plugins.shared.tasks.ExternalProcessTask;7import org.workcraft.plugins.shared.tasks.ExternalProcessTask;
@@ -37,9 +35,9 @@
37 }35 }
38 36
39 // Running the tool through external process interface37 // Running the tool through external process interface
40 ExternalProcessTask externalProcessTask = new ExternalProcessTask(args);38 ExternalProcessTask task = new ExternalProcessTask(args, null, false, false);
41 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor); 39 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
42 Result<? extends ExternalProcessResult> result = externalProcessTask.run(mon);40 Result<? extends ExternalProcessResult> result = task.run(mon);
43 41
44 // Handling the result42 // Handling the result
45 if (result.getOutcome() == Outcome.CANCELLED) {43 if (result.getOutcome() == Outcome.CANCELLED) {
4644
=== modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java'
--- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java 2016-01-09 22:12:07 +0000
+++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowDeadlockTask.java 2016-01-15 17:12:28 +0000
@@ -58,7 +58,7 @@
58 monitor.progressUpdate(0.10);58 monitor.progressUpdate(0.10);
59 59
60 File netFile = new File(directory, "net" + exporter.getExtenstion());60 File netFile = new File(directory, "net" + exporter.getExtenstion());
61 ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath());61 ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath());
62 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);62 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
63 Result<? extends Object> exportResult = framework.getTaskManager().execute(63 Result<? extends Object> exportResult = framework.getTaskManager().execute(
64 exportTask, "Exporting .g", mon);64 exportTask, "Exporting .g", mon);
@@ -73,7 +73,7 @@
73 monitor.progressUpdate(0.20);73 monitor.progressUpdate(0.20);
74 74
75 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true));75 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true));
76 PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());76 PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath());
77 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(77 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(
78 punfTask, "Unfolding .g", mon);78 punfTask, "Unfolding .g", mon);
79 79
@@ -87,7 +87,7 @@
87 monitor.progressUpdate(0.70);87 monitor.progressUpdate(0.70);
8888
89 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory),89 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory),
90 unfoldingFile.getCanonicalPath(), directory, true);90 unfoldingFile.getAbsolutePath(), directory, true);
91 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(91 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(
92 mpsatTask, "Running deadlock checking [MPSat]", mon);92 mpsatTask, "Running deadlock checking [MPSat]", mon);
93 93
9494
=== modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java'
--- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java 2016-01-09 22:12:07 +0000
+++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowHazardTask.java 2016-01-15 17:12:28 +0000
@@ -58,7 +58,7 @@
58 monitor.progressUpdate(0.10);58 monitor.progressUpdate(0.10);
59 59
60 File netFile = new File(directory, "net" + exporter.getExtenstion());60 File netFile = new File(directory, "net" + exporter.getExtenstion());
61 ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath());61 ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath());
62 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);62 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
63 Result<? extends Object> exportResult = framework.getTaskManager().execute(63 Result<? extends Object> exportResult = framework.getTaskManager().execute(
64 exportTask, "Exporting .g", mon);64 exportTask, "Exporting .g", mon);
@@ -73,7 +73,7 @@
73 monitor.progressUpdate(0.20);73 monitor.progressUpdate(0.20);
74 74
75 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true));75 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true));
76 PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());76 PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath());
77 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(77 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(
78 punfTask, "Unfolding .g", mon);78 punfTask, "Unfolding .g", mon);
79 79
@@ -87,7 +87,7 @@
87 monitor.progressUpdate(0.40);87 monitor.progressUpdate(0.40);
8888
89 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory),89 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory),
90 unfoldingFile.getCanonicalPath(), directory, true);90 unfoldingFile.getAbsolutePath(), directory, true);
91 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(91 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(
92 mpsatTask, "Running semimodularity checking [MPSat]", mon);92 mpsatTask, "Running semimodularity checking [MPSat]", mon);
93 93
9494
=== modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java'
--- DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java 2016-01-09 22:12:07 +0000
+++ DfsPlugin/src/org/workcraft/plugins/dfs/tasks/CheckDataflowTask.java 2016-01-15 17:12:28 +0000
@@ -63,7 +63,7 @@
63 monitor.progressUpdate(0.10);63 monitor.progressUpdate(0.10);
64 64
65 File netFile = new File(directory, "net" + exporter.getExtenstion());65 File netFile = new File(directory, "net" + exporter.getExtenstion());
66 ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath());66 ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath());
67 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);67 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
68 Result<? extends Object> exportResult = framework.getTaskManager().execute(68 Result<? extends Object> exportResult = framework.getTaskManager().execute(
69 exportTask, "Exporting .g", mon);69 exportTask, "Exporting .g", mon);
@@ -78,7 +78,7 @@
78 monitor.progressUpdate(0.20);78 monitor.progressUpdate(0.20);
79 79
80 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true));80 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true));
81 PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());81 PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath());
82 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(82 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(
83 punfTask, "Unfolding .g", mon);83 punfTask, "Unfolding .g", mon);
84 84
@@ -92,7 +92,7 @@
92 monitor.progressUpdate(0.40);92 monitor.progressUpdate(0.40);
9393
94 MpsatTask mpsatTask = new MpsatTask(deadlockSettings.getMpsatArguments(directory),94 MpsatTask mpsatTask = new MpsatTask(deadlockSettings.getMpsatArguments(directory),
95 unfoldingFile.getCanonicalPath(), directory, true);95 unfoldingFile.getAbsolutePath(), directory, true);
96 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(96 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(
97 mpsatTask, "Running deadlock checking [MPSat]", mon);97 mpsatTask, "Running deadlock checking [MPSat]", mon);
98 98
@@ -113,7 +113,7 @@
113 monitor.progressUpdate(0.70);113 monitor.progressUpdate(0.70);
114114
115 mpsatTask = new MpsatTask(hazardSettings.getMpsatArguments(directory), 115 mpsatTask = new MpsatTask(hazardSettings.getMpsatArguments(directory),
116 unfoldingFile.getCanonicalPath(), directory, true);116 unfoldingFile.getAbsolutePath(), directory, true);
117 mpsatResult = framework.getTaskManager().execute(mpsatTask, "Running semimodularity checking [MPSat]", mon);117 mpsatResult = framework.getTaskManager().execute(mpsatTask, "Running semimodularity checking [MPSat]", mon);
118 if (mpsatResult.getOutcome() != Outcome.FINISHED) {118 if (mpsatResult.getOutcome() != Outcome.FINISHED) {
119 if (mpsatResult.getOutcome() == Outcome.CANCELLED) {119 if (mpsatResult.getOutcome() == Outcome.CANCELLED) {
120120
=== modified file 'FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java'
--- FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java 2015-10-13 17:22:00 +0000
+++ FstPlugin/src/org/workcraft/plugins/fst/task/WriteSgConversionTask.java 2016-01-15 17:12:28 +0000
@@ -88,7 +88,7 @@
8888
89 // Generating .g file for Petri Net89 // Generating .g file for Petri Net
90 pnFile = File.createTempFile("stg_", ".g");90 pnFile = File.createTempFile("stg_", ".g");
91 ExportTask pnExportTask = new ExportTask(pnExporter, pn, pnFile.getCanonicalPath());91 ExportTask pnExportTask = new ExportTask(pnExporter, pn, pnFile.getAbsolutePath());
92 Result<? extends Object> pnExportResult = framework.getTaskManager().execute(92 Result<? extends Object> pnExportResult = framework.getTaskManager().execute(
93 pnExportTask, "Exporting .g", subtaskMonitor);93 pnExportTask, "Exporting .g", subtaskMonitor);
94 94
@@ -107,7 +107,7 @@
107 }107 }
108108
109 while (true) {109 while (true) {
110 WriteSgTask writeSgTask = new WriteSgTask(pnFile.getCanonicalPath(), null, writeSgOptions);110 WriteSgTask writeSgTask = new WriteSgTask(pnFile.getAbsolutePath(), null, writeSgOptions);
111 Result<? extends ExternalProcessResult> writeSgResult = framework.getTaskManager().execute(111 Result<? extends ExternalProcessResult> writeSgResult = framework.getTaskManager().execute(
112 writeSgTask, "Building state graph", subtaskMonitor);112 writeSgTask, "Building state graph", subtaskMonitor);
113 113
114114
=== modified file 'MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java'
--- MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java 2015-12-30 23:43:20 +0000
+++ MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java 2016-01-15 17:12:28 +0000
@@ -35,12 +35,18 @@
35 35
36 private static final String keyCommand = prefix + ".command";36 private static final String keyCommand = prefix + ".command";
37 private static final String keyExtraArgs = prefix + ".args";37 private static final String keyExtraArgs = prefix + ".args";
38 private static final String keyPrintStdout= prefix + ".printStdout";
39 private static final String keyPrintStderr= prefix + ".printStderr";
38 40
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");
40 private static final String defaultExtraArgs = "";42 private static final String defaultExtraArgs = "";
43 private static final Boolean defaultPrintStdout = true;
44 private static final Boolean defaultPrintStderr = true;
4145
42 private static String command = defaultCommand;46 private static String command = defaultCommand;
43 private static String extraArgs = defaultExtraArgs;47 private static String extraArgs = defaultExtraArgs;
48 private static Boolean printStdout = defaultPrintStdout;
49 private static Boolean printStderr = defaultPrintStderr;
4450
45 public MpsatSynthesisUtilitySettings() {51 public MpsatSynthesisUtilitySettings() {
46 properties.add(new PropertyDeclaration<MpsatSynthesisUtilitySettings, String>(52 properties.add(new PropertyDeclaration<MpsatSynthesisUtilitySettings, String>(
@@ -57,11 +63,32 @@
57 this, "Additional parameters", String.class, true, false, false) {63 this, "Additional parameters", String.class, true, false, false) {
58 protected void setter(MpsatSynthesisUtilitySettings object, String value) {64 protected void setter(MpsatSynthesisUtilitySettings object, String value) {
59 setExtraArgs(value);65 setExtraArgs(value);
66
60 }67 }
61 protected String getter(MpsatSynthesisUtilitySettings object) {68 protected String getter(MpsatSynthesisUtilitySettings object) {
62 return getExtraArgs();69 return getExtraArgs();
63 }70 }
64 });71 });
72
73 properties.add(new PropertyDeclaration<MpsatSynthesisUtilitySettings, Boolean>(
74 this, "Output stdout", Boolean.class, true, false, false) {
75 protected void setter(MpsatSynthesisUtilitySettings object, Boolean value) {
76 setPrintStdout(value);
77 }
78 protected Boolean getter(MpsatSynthesisUtilitySettings object) {
79 return getPrintStdout();
80 }
81 });
82
83 properties.add(new PropertyDeclaration<MpsatSynthesisUtilitySettings, Boolean>(
84 this, "Output stderr", Boolean.class, true, false, false) {
85 protected void setter(MpsatSynthesisUtilitySettings object, Boolean value) {
86 setPrintStderr(value);
87 }
88 protected Boolean getter(MpsatSynthesisUtilitySettings object) {
89 return getPrintStderr();
90 }
91 });
65 }92 }
66 93
67 @Override94 @Override
@@ -73,12 +100,16 @@
73 public void load(Config config) {100 public void load(Config config) {
74 setCommand(config.getString(keyCommand, defaultCommand));101 setCommand(config.getString(keyCommand, defaultCommand));
75 setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs));102 setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs));
103 setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout));
104 setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr));
76 }105 }
77106
78 @Override107 @Override
79 public void save(Config config) {108 public void save(Config config) {
80 config.set(keyCommand, getCommand());109 config.set(keyCommand, getCommand());
81 config.set(keyExtraArgs, getExtraArgs());110 config.set(keyExtraArgs, getExtraArgs());
111 config.setBoolean(keyPrintStdout, getPrintStdout());
112 config.setBoolean(keyPrintStderr, getPrintStderr());
82 }113 }
83 114
84 @Override115 @Override
@@ -107,4 +138,20 @@
107 extraArgs = value;138 extraArgs = value;
108 }139 }
109140
141 public static Boolean getPrintStdout() {
142 return printStdout;
143 }
144
145 public static void setPrintStdout(Boolean value) {
146 printStdout = value;
147 }
148
149 public static Boolean getPrintStderr() {
150 return printStderr;
151 }
152
153 public static void setPrintStderr(Boolean value) {
154 printStderr = value;
155 }
156
110}157}
111158
=== modified file 'MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisChainTask.java'
--- MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisChainTask.java 2016-01-09 22:12:07 +0000
+++ MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisChainTask.java 2016-01-15 17:12:28 +0000
@@ -49,7 +49,7 @@
4949
50 // Generate .g for the model50 // Generate .g for the model
51 File netFile = new File(directory, "net" + exporter.getExtenstion());51 File netFile = new File(directory, "net" + exporter.getExtenstion());
52 ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath());52 ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath());
53 Result<? extends Object> exportResult = framework.getTaskManager().execute(53 Result<? extends Object> exportResult = framework.getTaskManager().execute(
54 exportTask, "Exporting .g", subtaskMonitor);54 exportTask, "Exporting .g", subtaskMonitor);
5555
@@ -65,7 +65,7 @@
65 // Generate unfolding65 // Generate unfolding
66 boolean tryPnml = settings.getMode().canPnml();66 boolean tryPnml = settings.getMode().canPnml();
67 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(tryPnml));67 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(tryPnml));
68 PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());68 PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath());
69 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", subtaskMonitor);69 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", subtaskMonitor);
70 70
71 if (punfResult.getOutcome() != Outcome.FINISHED) {71 if (punfResult.getOutcome() != Outcome.FINISHED) {
@@ -80,7 +80,7 @@
80 // Run MPSat on the generated unfolding80 // Run MPSat on the generated unfolding
81 boolean needLib = settings.getMode().needLib();81 boolean needLib = settings.getMode().needLib();
82 MpsatSynthesisTask mpsatTask = new MpsatSynthesisTask(settings.getMpsatArguments(directory), 82 MpsatSynthesisTask mpsatTask = new MpsatSynthesisTask(settings.getMpsatArguments(directory),
83 unfoldingFile.getCanonicalPath(), directory, tryPnml, needLib);83 unfoldingFile.getAbsolutePath(), directory, tryPnml, needLib);
84 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(84 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(
85 mpsatTask, "Running synthesis [MPSat]", subtaskMonitor);85 mpsatTask, "Running synthesis [MPSat]", subtaskMonitor);
86 86
8787
=== modified file 'MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java'
--- MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java 2016-01-03 21:57:29 +0000
+++ MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java 2016-01-15 17:12:28 +0000
@@ -87,8 +87,10 @@
87 File outputFile = new File(directory, outputFileName);87 File outputFile = new File(directory, outputFileName);
88 command.add(outputFile.getAbsolutePath());88 command.add(outputFile.getAbsolutePath());
89 89
90 ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, directory);90 boolean printStdout = MpsatSynthesisUtilitySettings.getPrintStdout();
91 Result<? extends ExternalProcessResult> res = externalProcessTask.run(monitor);91 boolean printStderr = MpsatSynthesisUtilitySettings.getPrintStderr();
92 ExternalProcessTask task = new ExternalProcessTask(command, directory, printStdout, printStderr);
93 Result<? extends ExternalProcessResult> res = task.run(monitor);
92 if(res.getOutcome() == Outcome.CANCELLED) {94 if(res.getOutcome() == Outcome.CANCELLED) {
93 return res;95 return res;
94 }96 }
9597
=== modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java'
--- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2016-01-06 16:36:03 +0000
+++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatSettings.java 2016-01-15 17:12:28 +0000
@@ -199,7 +199,7 @@
199 }199 }
200 FileUtils.dumpString(reachFile, getReach());200 FileUtils.dumpString(reachFile, getReach());
201 args.add("-d");201 args.add("-d");
202 args.add("@" + reachFile.getCanonicalPath());202 args.add("@" + reachFile.getAbsolutePath());
203 } catch (IOException e) {203 } catch (IOException e) {
204 throw new RuntimeException(e);204 throw new RuntimeException(e);
205 }205 }
206206
=== modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java'
--- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2015-12-30 23:43:20 +0000
+++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2016-01-15 17:12:28 +0000
@@ -38,16 +38,22 @@
38 private static final String keyCommand = prefix + ".command";38 private static final String keyCommand = prefix + ".command";
39 private static final String keySolutionMode = prefix + ".solutionMode";39 private static final String keySolutionMode = prefix + ".solutionMode";
40 private static final String keyExtraArgs = prefix + ".args";40 private static final String keyExtraArgs = prefix + ".args";
41 private static final String keyPrintStdout= prefix + ".printStdout";
42 private static final String keyPrintStderr= prefix + ".printStderr";
41 private static final String keyDebugReach = prefix + ".debugReach";43 private static final String keyDebugReach = prefix + ".debugReach";
42 44
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");
44 private static final SolutionMode defaultSolutionMode = SolutionMode.MINIMUM_COST;46 private static final SolutionMode defaultSolutionMode = SolutionMode.MINIMUM_COST;
45 private static final String defaultExtraArgs = "";47 private static final String defaultExtraArgs = "";
48 private static final Boolean defaultPrintStdout = true;
49 private static final Boolean defaultPrintStderr = true;
46 private static final Boolean defaultDebugReach = false;50 private static final Boolean defaultDebugReach = false;
4751
48 private static String command = defaultCommand;52 private static String command = defaultCommand;
49 private static SolutionMode solutionMode = defaultSolutionMode;53 private static SolutionMode solutionMode = defaultSolutionMode;
50 private static String extraArgs = defaultExtraArgs;54 private static String extraArgs = defaultExtraArgs;
55 private static Boolean printStdout = defaultPrintStdout;
56 private static Boolean printStderr = defaultPrintStderr;
51 private static Boolean debugReach = defaultDebugReach;57 private static Boolean debugReach = defaultDebugReach;
5258
53 public MpsatUtilitySettings() {59 public MpsatUtilitySettings() {
@@ -82,7 +88,27 @@
82 });88 });
8389
84 properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>(90 properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>(
85 this, "Print out Reach expressions (debug)", Boolean.class, true, false, false) {91 this, "Output stdout", Boolean.class, true, false, false) {
92 protected void setter(MpsatUtilitySettings object, Boolean value) {
93 setPrintStdout(value);
94 }
95 protected Boolean getter(MpsatUtilitySettings object) {
96 return getPrintStdout();
97 }
98 });
99
100 properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>(
101 this, "Output stderr", Boolean.class, true, false, false) {
102 protected void setter(MpsatUtilitySettings object, Boolean value) {
103 setPrintStderr(value);
104 }
105 protected Boolean getter(MpsatUtilitySettings object) {
106 return getPrintStderr();
107 }
108 });
109
110 properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>(
111 this, "Output Reach expressions", Boolean.class, true, false, false) {
86 protected void setter(MpsatUtilitySettings object, Boolean value) {112 protected void setter(MpsatUtilitySettings object, Boolean value) {
87 setDebugReach(value);113 setDebugReach(value);
88 }114 }
@@ -102,6 +128,8 @@
102 setCommand(config.getString(keyCommand, defaultCommand));128 setCommand(config.getString(keyCommand, defaultCommand));
103 setSolutionMode(config.getEnum(keySolutionMode, SolutionMode.class, defaultSolutionMode));129 setSolutionMode(config.getEnum(keySolutionMode, SolutionMode.class, defaultSolutionMode));
104 setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs));130 setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs));
131 setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout));
132 setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr));
105 setDebugReach(config.getBoolean(keyDebugReach, defaultDebugReach));133 setDebugReach(config.getBoolean(keyDebugReach, defaultDebugReach));
106 }134 }
107135
@@ -110,6 +138,8 @@
110 config.set(keyCommand, getCommand());138 config.set(keyCommand, getCommand());
111 config.setEnum(keySolutionMode, SolutionMode.class, getSolutionMode());139 config.setEnum(keySolutionMode, SolutionMode.class, getSolutionMode());
112 config.set(keyExtraArgs, getExtraArgs());140 config.set(keyExtraArgs, getExtraArgs());
141 config.setBoolean(keyPrintStdout, getPrintStdout());
142 config.setBoolean(keyPrintStderr, getPrintStderr());
113 config.setBoolean(keyDebugReach, getDebugReach());143 config.setBoolean(keyDebugReach, getDebugReach());
114 }144 }
115 145
@@ -151,6 +181,22 @@
151 return (solutionMode == SolutionMode.ALL) ? 10 : 1;181 return (solutionMode == SolutionMode.ALL) ? 10 : 1;
152 }182 }
153183
184 public static Boolean getPrintStdout() {
185 return printStdout;
186 }
187
188 public static void setPrintStdout(Boolean value) {
189 printStdout = value;
190 }
191
192 public static Boolean getPrintStderr() {
193 return printStderr;
194 }
195
196 public static void setPrintStderr(Boolean value) {
197 printStderr = value;
198 }
199
154 public static Boolean getDebugReach() {200 public static Boolean getDebugReach() {
155 return debugReach;201 return debugReach;
156 }202 }
157203
=== modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java'
--- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2016-01-09 22:12:07 +0000
+++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatChainTask.java 2016-01-15 17:12:28 +0000
@@ -49,7 +49,7 @@
4949
50 // Generate .g for the model50 // Generate .g for the model
51 File netFile = new File(directory, "net" + exporter.getExtenstion());51 File netFile = new File(directory, "net" + exporter.getExtenstion());
52 ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath());52 ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath());
53 Result<? extends Object> exportResult = framework.getTaskManager().execute(53 Result<? extends Object> exportResult = framework.getTaskManager().execute(
54 exportTask, "Exporting .g", subtaskMonitor);54 exportTask, "Exporting .g", subtaskMonitor);
5555
@@ -65,7 +65,7 @@
65 // Generate unfolding65 // Generate unfolding
66 boolean tryPnml = settings.getMode().canPnml();66 boolean tryPnml = settings.getMode().canPnml();
67 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(tryPnml));67 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(tryPnml));
68 PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());68 PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath());
69 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", subtaskMonitor);69 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", subtaskMonitor);
70 70
71 if (punfResult.getOutcome() != Outcome.FINISHED) {71 if (punfResult.getOutcome() != Outcome.FINISHED) {
@@ -79,7 +79,7 @@
7979
80 // Run MPSat on the generated unfolding80 // Run MPSat on the generated unfolding
81 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), 81 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory),
82 unfoldingFile.getCanonicalPath(), directory, tryPnml);82 unfoldingFile.getAbsolutePath(), directory, tryPnml);
83 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(83 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(
84 mpsatTask, "Running verification [MPSat]", subtaskMonitor);84 mpsatTask, "Running verification [MPSat]", subtaskMonitor);
85 85
8686
=== modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatCombinedChainTask.java'
--- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatCombinedChainTask.java 2016-01-09 22:12:07 +0000
+++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatCombinedChainTask.java 2016-01-15 17:12:28 +0000
@@ -51,7 +51,7 @@
5151
52 // Generate .g for the model52 // Generate .g for the model
53 File netFile = new File(directory, "net" + exporter.getExtenstion());53 File netFile = new File(directory, "net" + exporter.getExtenstion());
54 ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath());54 ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath());
55 Result<? extends Object> exportResult = framework.getTaskManager().execute(55 Result<? extends Object> exportResult = framework.getTaskManager().execute(
56 exportTask, "Exporting .g", subtaskMonitor);56 exportTask, "Exporting .g", subtaskMonitor);
5757
@@ -70,7 +70,7 @@
70 tryPnml &= settings.getMode().canPnml();70 tryPnml &= settings.getMode().canPnml();
71 }71 }
72 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(tryPnml));72 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(tryPnml));
73 PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());73 PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath());
74 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", subtaskMonitor);74 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(punfTask, "Unfolding .g", subtaskMonitor);
75 75
76 if (punfResult.getOutcome() != Outcome.FINISHED) {76 if (punfResult.getOutcome() != Outcome.FINISHED) {
@@ -86,7 +86,7 @@
86 ArrayList<Result<? extends ExternalProcessResult>> mpsatResultList = new ArrayList<>(settingsList.size());86 ArrayList<Result<? extends ExternalProcessResult>> mpsatResultList = new ArrayList<>(settingsList.size());
87 for (MpsatSettings settings: settingsList) {87 for (MpsatSettings settings: settingsList) {
88 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), 88 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory),
89 unfoldingFile.getCanonicalPath(), directory, tryPnml);89 unfoldingFile.getAbsolutePath(), directory, tryPnml);
90 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(90 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(
91 mpsatTask, "Running verification [MPSat]", subtaskMonitor);91 mpsatTask, "Running verification [MPSat]", subtaskMonitor);
92 mpsatResultList.add(mpsatResult);92 mpsatResultList.add(mpsatResult);
9393
=== modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java'
--- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 2016-01-09 22:12:07 +0000
+++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatConformationTask.java 2016-01-15 17:12:28 +0000
@@ -70,7 +70,7 @@
7070
71 // Generating .g for the model71 // Generating .g for the model
72 File devStgFile = new File(directory, "dev.g");72 File devStgFile = new File(directory, "dev.g");
73 ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getCanonicalPath());73 ExportTask devExportTask = new ExportTask(devStgExporter, devStg, devStgFile.getAbsolutePath());
74 Result<? extends Object> devExportResult = framework.getTaskManager().execute(74 Result<? extends Object> devExportResult = framework.getTaskManager().execute(
75 devExportTask, "Exporting circuit .g", subtaskMonitor);75 devExportTask, "Exporting circuit .g", subtaskMonitor);
76 76
@@ -92,7 +92,7 @@
92 STG envStg = (STG)framework.loadFile(envFile).getMathModel();92 STG envStg = (STG)framework.loadFile(envFile).getMathModel();
93 Exporter envStgExporter = Export.chooseBestExporter(framework.getPluginManager(), envStg, Format.STG);93 Exporter envStgExporter = Export.chooseBestExporter(framework.getPluginManager(), envStg, Format.STG);
94 envStgFile = new File(directory, "env.g");94 envStgFile = new File(directory, "env.g");
95 ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getCanonicalPath());95 ExportTask envExportTask = new ExportTask(envStgExporter, envStg, envStgFile.getAbsolutePath());
96 Result<? extends Object> envExportResult = framework.getTaskManager().execute(96 Result<? extends Object> envExportResult = framework.getTaskManager().execute(
97 envExportTask, "Exporting environment .g", subtaskMonitor);97 envExportTask, "Exporting environment .g", subtaskMonitor);
98 98
@@ -127,7 +127,7 @@
127 127
128 // Generate unfolding128 // Generate unfolding
129 File unfoldingFile = new File(directory, "system" + PunfUtilitySettings.getUnfoldingExtension(true));129 File unfoldingFile = new File(directory, "system" + PunfUtilitySettings.getUnfoldingExtension(true));
130 PunfTask punfTask = new PunfTask(stgFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());130 PunfTask punfTask = new PunfTask(stgFile.getAbsolutePath(), unfoldingFile.getAbsolutePath());
131 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(131 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(
132 punfTask, "Unfolding .g", subtaskMonitor);132 punfTask, "Unfolding .g", subtaskMonitor);
133 133
@@ -153,7 +153,7 @@
153 MpsatUtilitySettings.getSolutionCount(), reachConformation, true);153 MpsatUtilitySettings.getSolutionCount(), reachConformation, true);
154 154
155 MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(directory), 155 MpsatTask mpsatConformationTask = new MpsatTask(conformationSettings.getMpsatArguments(directory),
156 unfoldingFile.getCanonicalPath(), directory, true);156 unfoldingFile.getAbsolutePath(), directory, true);
157 Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute(157 Result<? extends ExternalProcessResult> mpsatConformationResult = framework.getTaskManager().execute(
158 mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor);158 mpsatConformationTask, "Running conformation check [MPSat]", subtaskMonitor);
159159
160160
=== modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java'
--- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2016-01-03 21:57:29 +0000
+++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2016-01-15 17:12:28 +0000
@@ -59,8 +59,10 @@
59 // Input file59 // Input file
60 command.add(inputFileName);60 command.add(inputFileName);
6161
62 ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, directory);62 boolean printStdout = MpsatUtilitySettings.getPrintStdout();
63 Result<? extends ExternalProcessResult> res = externalProcessTask.run(monitor);63 boolean printStderr = MpsatUtilitySettings.getPrintStderr();
64 ExternalProcessTask task = new ExternalProcessTask(command, directory, printStdout, printStderr);
65 Result<? extends ExternalProcessResult> res = task.run(monitor);
64 if(res.getOutcome() == Outcome.CANCELLED) {66 if(res.getOutcome() == Outcome.CANCELLED) {
65 return res;67 return res;
66 }68 }
6769
=== modified file 'PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java'
--- PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2016-01-03 21:57:29 +0000
+++ PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2016-01-15 17:12:28 +0000
@@ -88,7 +88,8 @@
88 command.add(inputFile.getAbsolutePath());88 command.add(inputFile.getAbsolutePath());
89 }89 }
90 90
91 Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command).run(monitor);91 ExternalProcessTask task = new ExternalProcessTask(command, directory, false, true);
92 Result<? extends ExternalProcessResult> res = task.run(monitor);
92 if (res.getOutcome() != Outcome.FINISHED) {93 if (res.getOutcome() != Outcome.FINISHED) {
93 return res;94 return res;
94 }95 }
9596
=== modified file 'PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java'
--- PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java 2016-01-03 21:57:29 +0000
+++ PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java 2016-01-15 17:12:28 +0000
@@ -49,8 +49,8 @@
49 command.add("-o");49 command.add("-o");
50 command.add(outputPath);50 command.add(outputPath);
51 51
5252 ExternalProcessTask task = new ExternalProcessTask(command, null, false, false);
53 Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command).run(monitor);53 Result<? extends ExternalProcessResult> res = task.run(monitor);
54 54
55 if (res.getOutcome() != Outcome.FINISHED)55 if (res.getOutcome() != Outcome.FINISHED)
56 return res;56 return res;
5757
=== modified file 'PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java'
--- PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java 2016-01-03 21:57:29 +0000
+++ PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java 2016-01-15 17:12:28 +0000
@@ -69,7 +69,8 @@
69 command.add(outputPath);69 command.add(outputPath);
70 }70 }
71 71
72 Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command).run(monitor);72 ExternalProcessTask task = new ExternalProcessTask(command, null, false, false);
73 Result<? extends ExternalProcessResult> res = task.run(monitor);
73 if (res.getOutcome() != Outcome.FINISHED) {74 if (res.getOutcome() != Outcome.FINISHED) {
74 return res;75 return res;
75 }76 }
7677
=== modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java'
--- PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java 2015-12-30 23:43:20 +0000
+++ PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java 2016-01-15 17:12:28 +0000
@@ -36,13 +36,19 @@
36 36
37 private static final String keyPetrifyCkeyPmmand = prefix + ".petrify.command";37 private static final String keyPetrifyCkeyPmmand = prefix + ".petrify.command";
38 private static final String keyPetrifyArgs = prefix + ".petrify.args";38 private static final String keyPetrifyArgs = prefix + ".petrify.args";
39 private static final String keyPrintStdout= prefix + ".printStdout";
40 private static final String keyPrintStderr= prefix + ".printStderr";
39 41
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");
41 private static final String defaultPetrifyArgs = "";43 private static final String defaultPetrifyArgs = "";
44 private static final Boolean defaultPrintStdout = true;
45 private static final Boolean defaultPrintStderr = true;
4246
43 private static String petrifyCommand = defaultPetrifyCommand;47 private static String petrifyCommand = defaultPetrifyCommand;
44 private static String petrifyArgs = defaultPetrifyArgs;48 private static String petrifyArgs = defaultPetrifyArgs;
45 49 private static Boolean printStdout = defaultPrintStdout;
50 private static Boolean printStderr = defaultPrintStderr;
51
46 public PetrifyUtilitySettings() {52 public PetrifyUtilitySettings() {
47 properties.add(new PropertyDeclaration<PetrifyUtilitySettings, String>(53 properties.add(new PropertyDeclaration<PetrifyUtilitySettings, String>(
48 this, "Petrify command", String.class, true, false, false) {54 this, "Petrify command", String.class, true, false, false) {
@@ -63,6 +69,26 @@
63 return getPetrifyArgs();69 return getPetrifyArgs();
64 }70 }
65 });71 });
72
73 properties.add(new PropertyDeclaration<PetrifyUtilitySettings, Boolean>(
74 this, "Output stdout", Boolean.class, true, false, false) {
75 protected void setter(PetrifyUtilitySettings object, Boolean value) {
76 setPrintStdout(value);
77 }
78 protected Boolean getter(PetrifyUtilitySettings object) {
79 return getPrintStdout();
80 }
81 });
82
83 properties.add(new PropertyDeclaration<PetrifyUtilitySettings, Boolean>(
84 this, "Output stderr", Boolean.class, true, false, false) {
85 protected void setter(PetrifyUtilitySettings object, Boolean value) {
86 setPrintStderr(value);
87 }
88 protected Boolean getter(PetrifyUtilitySettings object) {
89 return getPrintStderr();
90 }
91 });
66 }92 }
67 93
68 @Override94 @Override
@@ -74,12 +100,16 @@
74 public void load(Config config) {100 public void load(Config config) {
75 setPetrifyCommand(config.getString(keyPetrifyCkeyPmmand, defaultPetrifyCommand));101 setPetrifyCommand(config.getString(keyPetrifyCkeyPmmand, defaultPetrifyCommand));
76 setPetrifyArgs(config.getString(keyPetrifyArgs, defaultPetrifyArgs));102 setPetrifyArgs(config.getString(keyPetrifyArgs, defaultPetrifyArgs));
103 setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout));
104 setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr));
77 }105 }
78106
79 @Override107 @Override
80 public void save(Config config) {108 public void save(Config config) {
81 config.set(keyPetrifyCkeyPmmand, getPetrifyCommand());109 config.set(keyPetrifyCkeyPmmand, getPetrifyCommand());
82 config.set(keyPetrifyArgs, getPetrifyArgs());110 config.set(keyPetrifyArgs, getPetrifyArgs());
111 config.setBoolean(keyPrintStdout, getPrintStdout());
112 config.setBoolean(keyPrintStderr, getPrintStderr());
83 }113 }
84114
85 @Override115 @Override
@@ -108,4 +138,20 @@
108 petrifyArgs = value;138 petrifyArgs = value;
109 }139 }
110140
141 public static Boolean getPrintStdout() {
142 return printStdout;
143 }
144
145 public static void setPrintStdout(Boolean value) {
146 printStdout = value;
147 }
148
149 public static Boolean getPrintStderr() {
150 return printStderr;
151 }
152
153 public static void setPrintStderr(Boolean value) {
154 printStderr = value;
155 }
156
111}157}
112158
=== removed file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/PetrifyTask.java'
--- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/PetrifyTask.java 2016-01-03 21:57:29 +0000
+++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/PetrifyTask.java 1970-01-01 00:00:00 +0000
@@ -1,135 +0,0 @@
1package org.workcraft.plugins.petrify.tasks;
2
3import java.io.IOException;
4import java.util.ArrayList;
5
6import org.workcraft.interop.ExternalProcess;
7import org.workcraft.interop.ExternalProcessListener;
8import org.workcraft.plugins.petrify.PetrifyUtilitySettings;
9import org.workcraft.plugins.shared.tasks.ExternalProcessResult;
10import org.workcraft.tasks.ProgressMonitor;
11import org.workcraft.tasks.Result;
12import org.workcraft.tasks.Result.Outcome;
13import org.workcraft.tasks.Task;
14import org.workcraft.util.DataAccumulator;
15
16public class PetrifyTask implements Task<ExternalProcessResult>, ExternalProcessListener {
17 private String[] args;
18 private String inputFileName;
19
20 private volatile boolean finished;
21 private volatile int returnCode;
22 private boolean userCancelled = false;
23 private ProgressMonitor<? super ExternalProcessResult> monitor;
24
25 private DataAccumulator stdoutAccum = new DataAccumulator();
26 private DataAccumulator stderrAccum = new DataAccumulator();
27
28 public PetrifyTask(String[] args, String inputFileName) {
29 this.args = args;
30 this.inputFileName = inputFileName;
31 }
32
33 @Override
34 public Result<? extends ExternalProcessResult> run(ProgressMonitor<? super ExternalProcessResult> monitor) {
35 this.monitor = monitor;
36 ArrayList<String> command = new ArrayList<String>();
37
38 // Name of the executable
39 String toolName = PetrifyUtilitySettings.getPetrifyCommand();
40 command.add(toolName);
41
42 // Built-in arguments
43 for (String arg : args) {
44 command.add(arg);
45 }
46
47 // Extra arguments (should go before the file parameters)
48 for (String arg : PetrifyUtilitySettings.getPetrifyArgs().split(" ")) {
49 if (!arg.isEmpty()) {
50 command.add(arg);
51 }
52 }
53
54 // Input file
55 command.add(inputFileName);
56
57 ExternalProcess petrifyProcess = new ExternalProcess(command.toArray(new String[command.size()]), ".");
58 petrifyProcess.addListener(this);
59
60 try {
61 System.out.println("Running external command: " + getCommandLine(command));
62 petrifyProcess.start();
63 } catch (IOException e) {
64 return new Result<ExternalProcessResult>(e);
65 }
66
67 while (true) {
68 if (monitor.isCancelRequested() && petrifyProcess.isRunning()) {
69 petrifyProcess.cancel();
70 userCancelled = true;
71 }
72 if (finished) {
73 break;
74 }
75 try {
76 Thread.sleep(20);
77 } catch (InterruptedException e) {
78 petrifyProcess.cancel();
79 userCancelled = true;
80 break;
81 }
82 }
83
84 if (userCancelled) {
85 return new Result<ExternalProcessResult>(Outcome.CANCELLED);
86 }
87
88 ExternalProcessResult result = new ExternalProcessResult(returnCode, stdoutAccum.getData(), stderrAccum.getData());
89
90 if (returnCode == 0) {
91 return new Result<ExternalProcessResult>(Outcome.FINISHED, result);
92 }
93
94 return new Result<ExternalProcessResult>(Outcome.FAILED, result);
95 }
96
97 private String getCommandLine(ArrayList<String> command) {
98 String commandLine = "";
99 for (String arg: command) {
100 if (commandLine.isEmpty()) {
101 commandLine = "";
102 } else {
103 commandLine += " ";
104 }
105 commandLine += arg;
106 }
107 return commandLine;
108 }
109
110 @Override
111 public void errorData(byte[] data) {
112 try {
113 stderrAccum.write(data);
114 } catch (IOException e) {
115 throw new RuntimeException(e);
116 }
117 monitor.stderr(data);
118 }
119
120 @Override
121 public void outputData(byte[] data) {
122 try {
123 stdoutAccum.write(data);
124 } catch (IOException e) {
125 throw new RuntimeException(e);
126 }
127 monitor.stdout(data);
128 }
129
130 @Override
131 public void processFinished(int returnCode) {
132 this.returnCode = returnCode;
133 this.finished = true;
134 }
135 }
136\ No newline at end of file0\ No newline at end of file
1371
=== modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java'
--- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java 2016-01-03 21:57:29 +0000
+++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java 2016-01-15 17:12:28 +0000
@@ -66,32 +66,38 @@
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.
67 String prefix = FileUtils.getTempPrefix(null/* we.getTitle() */);67 String prefix = FileUtils.getTempPrefix(null/* we.getTitle() */);
68 File directory = FileUtils.createTempDirectory(prefix);68 File directory = FileUtils.createTempDirectory(prefix);
69
70 File outFile = new File(directory, "result.g");
71 command.add("-o");
72 command.add(outFile.getAbsolutePath());
73
74 File equationsFile = new File(directory, "petrify.eqn");
75 command.add("-eqn");
76 command.add(equationsFile.getAbsolutePath());
77
78 File verilogFile = new File(directory, "petrify.v");
79 command.add("-vl");
80 command.add(verilogFile.getAbsolutePath());
81
82 File blifFile = new File(directory, "petrify.blif");
83 command.add("-blif");
84 command.add(blifFile.getAbsolutePath());
85
86 File logFile = new File(directory, "petrify.log");
87 command.add("-log");
88 command.add(logFile.getAbsolutePath());
89
90 // Input file
91 STGModel stg = WorkspaceUtils.getAs(we, STGModel.class);
92 File stgFile = getInputFile(stg, directory);
93 command.add(stgFile.getAbsolutePath());
94
95 boolean printStdout = PetrifyUtilitySettings.getPrintStdout();
96 boolean printStderr = PetrifyUtilitySettings.getPrintStderr();
97 ExternalProcessTask task = new ExternalProcessTask(command, null, printStdout, printStderr);
98 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
99 Result<? extends ExternalProcessResult> res = task.run(mon);
69 try {100 try {
70 File equationsFile = new File(directory, "petrify.eqn");
71 command.add("-eqn");
72 command.add(equationsFile.getCanonicalPath());
73
74 File verilogFile = new File(directory, "petrify.v");
75 command.add("-vl");
76 command.add(verilogFile.getCanonicalPath());
77
78 File blifFile = new File(directory, "petrify.blif");
79 command.add("-blif");
80 command.add(blifFile.getCanonicalPath());
81
82 File logFile = new File(directory, "petrify.log");
83 command.add("-log");
84 command.add(logFile.getCanonicalPath());
85
86 // Input file
87 STGModel stg = WorkspaceUtils.getAs(we, STGModel.class);
88 File stgFile = getInputStg(stg, directory);
89 command.add(stgFile.getCanonicalPath());
90
91 ExternalProcessTask externalProcessTask = new ExternalProcessTask(command, null);
92 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
93 Result<? extends ExternalProcessResult> res = externalProcessTask.run(mon);
94
95 if (res.getOutcome() == Outcome.CANCELLED) {101 if (res.getOutcome() == Outcome.CANCELLED) {
96 return new Result<SynthesisResult>(Outcome.CANCELLED);102 return new Result<SynthesisResult>(Outcome.CANCELLED);
97 } else {103 } else {
@@ -110,24 +116,24 @@
110 SynthesisResult result = new SynthesisResult(equations, verilog, log, stdout, stderr);116 SynthesisResult result = new SynthesisResult(equations, verilog, log, stdout, stderr);
111 return new Result<SynthesisResult>(outcome, result);117 return new Result<SynthesisResult>(outcome, result);
112 }118 }
113 } catch (IOException e1) {119 } catch (IOException e) {
114 throw new RuntimeException(e1);120 throw new RuntimeException(e);
115 } finally {121 } finally {
116 FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles());122 FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles());
117 }123 }
118 }124 }
119125
120 private File getInputStg(Model model, File directory) throws IOException {126 private File getInputFile(Model model, File directory) {
121 final Framework framework = Framework.getInstance();127 final Framework framework = Framework.getInstance();
122 Exporter stgExporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG);128 Exporter stgExporter = Export.chooseBestExporter(framework.getPluginManager(), model, Format.STG);
123 if (stgExporter == null) {129 if (stgExporter == null) {
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.");
125 }131 }
126 132
127 File stgFile = new File(directory, "petrify" + stgExporter.getExtenstion());133 File stgFile = new File(directory, "petrify" + stgExporter.getExtenstion());
128 ExportTask exportTask = new ExportTask(stgExporter, model, stgFile.getCanonicalPath());134 ExportTask exportTask = new ExportTask(stgExporter, model, stgFile.getAbsolutePath());
129 Result<? extends Object> res = framework.getTaskManager().execute(exportTask, "Exporting .g");135 Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, "Exporting .g");
130 if (res.getOutcome() != Outcome.FINISHED) {136 if (exportResult.getOutcome() != Outcome.FINISHED) {
131 stgFile = null;137 stgFile = null;
132 }138 }
133 return stgFile;139 return stgFile;
134140
=== modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java'
--- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java 2015-10-12 14:02:20 +0000
+++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java 2016-01-15 17:12:28 +0000
@@ -2,98 +2,157 @@
22
3import java.io.ByteArrayInputStream;3import java.io.ByteArrayInputStream;
4import java.io.File;4import java.io.File;
5import java.util.ArrayList;
5import java.util.UUID;6import java.util.UUID;
67
7import org.workcraft.Framework;8import org.workcraft.Framework;
8import org.workcraft.dom.Model;9import org.workcraft.dom.Model;
9import org.workcraft.exceptions.DeserialisationException;10import org.workcraft.exceptions.DeserialisationException;
11import org.workcraft.exceptions.SerialisationException;
12import org.workcraft.interop.ExternalProcessListener;
10import org.workcraft.plugins.fsm.Fsm;13import org.workcraft.plugins.fsm.Fsm;
11import org.workcraft.plugins.petri.PetriNetModel;14import org.workcraft.plugins.petri.PetriNetModel;
15import org.workcraft.plugins.petrify.PetrifyUtilitySettings;
12import org.workcraft.plugins.shared.CommonDebugSettings;16import org.workcraft.plugins.shared.CommonDebugSettings;
13import org.workcraft.plugins.shared.tasks.ExternalProcessResult;17import org.workcraft.plugins.shared.tasks.ExternalProcessResult;
18import org.workcraft.plugins.shared.tasks.ExternalProcessTask;
14import org.workcraft.plugins.stg.STGModel;19import org.workcraft.plugins.stg.STGModel;
15import org.workcraft.plugins.stg.interop.DotGImporter;20import org.workcraft.plugins.stg.interop.DotGImporter;
16import org.workcraft.serialisation.Format;21import org.workcraft.serialisation.Format;
17import org.workcraft.tasks.ProgressMonitor;22import org.workcraft.tasks.ProgressMonitor;
18import org.workcraft.tasks.Result;23import org.workcraft.tasks.Result;
19import org.workcraft.tasks.Result.Outcome;24import org.workcraft.tasks.Result.Outcome;
25import org.workcraft.tasks.SubtaskMonitor;
20import org.workcraft.tasks.Task;26import org.workcraft.tasks.Task;
21import org.workcraft.util.Export;27import org.workcraft.util.Export;
22import org.workcraft.util.Export.ExportTask;28import org.workcraft.util.Export.ExportTask;
23import org.workcraft.util.FileUtils;29import org.workcraft.util.FileUtils;
30import org.workcraft.util.ToolUtils;
24import org.workcraft.workspace.WorkspaceEntry;31import org.workcraft.workspace.WorkspaceEntry;
2532
26public class TransformationTask implements Task<TransformationResult>{33public class TransformationTask implements Task<TransformationResult>, ExternalProcessListener {
27 private WorkspaceEntry workspaceEntry;34 private WorkspaceEntry we;
28 String description;35 String[] args;
29 String[] parameters;
3036
31 public TransformationTask(WorkspaceEntry workspaceEntry, String description, String[] parameters) {37 public TransformationTask(WorkspaceEntry we, String description, String[] args) {
32 this.workspaceEntry = workspaceEntry;38 this.we = we;
33 this.description = description;39 this.args = args;
34 this.parameters = parameters;
35 }40 }
3641
37 public WorkspaceEntry getWorkspaceEntry() {42 public WorkspaceEntry getWorkspaceEntry() {
38 return workspaceEntry;43 return we;
39 }44 }
4045
41 @Override46 @Override
42 public Result<? extends TransformationResult> run(ProgressMonitor<? super TransformationResult> monitor) {47 public Result<? extends TransformationResult> run(ProgressMonitor<? super TransformationResult> monitor) {
43 File modelFile = null;48 ArrayList<String> command = new ArrayList<String>();
49
50 // Name of the executable
51 String toolName = ToolUtils.getAbsoluteCommandPath(PetrifyUtilitySettings.getPetrifyCommand());
52 command.add(toolName);
53
54 // Built-in arguments
55 for (String arg : args) {
56 command.add(arg);
57 }
58
59 // Extra arguments (should go before the file parameters)
60 for (String arg : PetrifyUtilitySettings.getPetrifyArgs().split(" ")) {
61 if (!arg.isEmpty()) {
62 command.add(arg);
63 }
64 }
65
66 String prefix = FileUtils.getTempPrefix(we.getTitle());
67 File directory = FileUtils.createTempDirectory(prefix);
44 try {68 try {
45 final Framework framework = Framework.getInstance();69 File logFile = new File(directory, "petrify.log");
46 modelFile = File.createTempFile("stg_", ".g");70 command.add("-log");
71 command.add(logFile.getAbsolutePath());
72
73 File outFile = new File(directory, "result.g");
74 command.add("-o");
75 command.add(outFile.getAbsolutePath());
76
77 // Input file
78 Model model = we.getModelEntry().getMathModel();
79 File modelFile = getInputFile(model, directory);
80 command.add(modelFile.getAbsolutePath());
47 81
48 Model model = workspaceEntry.getModelEntry().getMathModel();82 boolean printStdout = PetrifyUtilitySettings.getPrintStdout();
49 UUID format = null;83 boolean printStderr = PetrifyUtilitySettings.getPrintStderr();
50 if (model instanceof PetriNetModel) {84 ExternalProcessTask task = new ExternalProcessTask(command, directory, printStdout, printStderr);
51 format = Format.STG;85 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
52 } else if (model instanceof Fsm) {86 Result<? extends ExternalProcessResult> res = task.run(mon);
53 format = Format.SG;87
54 }88 if (res.getOutcome() == Outcome.CANCELLED) {
55 if (format == null) {89 return new Result<TransformationResult>(Outcome.CANCELLED);
56 return Result.exception(new Throwable("This tool is not applicable to " + model.getDisplayName() + " model."));90 } else {
57 }91 final Outcome outcome;
5892 STGModel outStg = null;
59 ExportTask exportTask = Export.createExportTask(model, modelFile, format, framework.getPluginManager());93 if (res.getReturnValue().getReturnCode() == 0) {
6094 outcome = Outcome.FINISHED;
61 final Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, description +": writing .g");
62
63 if (exportResult.getOutcome() != Outcome.FINISHED) {
64 if (exportResult.getOutcome() == Outcome.CANCELLED) {
65 return Result.cancelled();
66 } else {95 } else {
67 return Result.exception(exportResult.getCause());96 outcome = Outcome.FAILED;
68 }97 }
69 }
70
71 PetrifyTask petrifyTask = new PetrifyTask(parameters, modelFile.getAbsolutePath());
72
73 final Result<? extends ExternalProcessResult> petrifyResult
74 = framework.getTaskManager().execute(petrifyTask, description + ": executing Petrify");
75
76 if (petrifyResult.getOutcome() == Outcome.FINISHED) {
77 try {98 try {
78 ByteArrayInputStream in = new ByteArrayInputStream(petrifyResult.getReturnValue().getOutput());99 String out = (outFile.exists() ? FileUtils.readAllText(outFile) : "");
79 final STGModel outStg = new DotGImporter().importSTG(in);100 ByteArrayInputStream outStream = new ByteArrayInputStream(out.getBytes());
80 return Result.finished(new TransformationResult(null, outStg));101 outStg = new DotGImporter().importSTG(outStream);
81 } catch (DeserialisationException e) {102 } catch (DeserialisationException e) {
82 return Result.exception(e);103 return Result.exception(e);
83 }104 }
84105 TransformationResult result = new TransformationResult(res, outStg);
85 } else {106 return new Result<TransformationResult>(outcome, result);
86 if(petrifyResult.getOutcome() == Outcome.FAILED) {
87 return Result.failed(new TransformationResult(petrifyResult, null));
88 } else {
89 return Result.cancelled();
90 }
91 }107 }
92 } catch (Throwable e) {108 } catch (Throwable e) {
93 return Result.exception(e);109 throw new RuntimeException(e);
94 } finally {110 } finally {
95 FileUtils.deleteFile(modelFile, CommonDebugSettings.getKeepTemporaryFiles());111 FileUtils.deleteFile(directory, CommonDebugSettings.getKeepTemporaryFiles());
96 }112 }
97 }113 }
98 114
115 private File getInputFile(Model model, File directory) {
116 final Framework framework = Framework.getInstance();
117 UUID format = null;
118 String extension = null;
119 if (model instanceof PetriNetModel) {
120 format = Format.STG;
121 extension = ".g";
122 } else if (model instanceof Fsm) {
123 format = Format.SG;
124 extension = ".sg";
125 }
126 if (format == null) {
127 throw new RuntimeException("This tool is not applicable to " + model.getDisplayName() + " model.");
128 }
129
130 File modelFile = new File(directory, "original" + extension);
131 try {
132 ExportTask exportTask = Export.createExportTask(model, modelFile, format, framework.getPluginManager());
133 final Result<? extends Object> exportResult = framework.getTaskManager().execute(exportTask, "Exporting model");
134 if (exportResult.getOutcome() != Outcome.FINISHED) {
135 modelFile = null;
136 }
137 } catch (SerialisationException e) {
138 throw new RuntimeException("Unable to export the model.");
139 }
140 return modelFile;
141 }
142
143
144 @Override
145 public void processFinished(int returnCode) {
146 }
147
148 @Override
149 public void errorData(byte[] data) {
150 System.out.print(data);
151 }
152
153 @Override
154 public void outputData(byte[] data) {
155 System.out.print(data);
156 }
157
99}158}
100159
=== modified file 'PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java'
--- PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java 2016-01-09 22:12:07 +0000
+++ PolicyNetPlugin/src/org/workcraft/plugins/policy/tasks/CheckDeadlockTask.java 2016-01-15 17:12:28 +0000
@@ -57,7 +57,7 @@
57 monitor.progressUpdate(0.10);57 monitor.progressUpdate(0.10);
58 58
59 File netFile = new File(directory, "net" + exporter.getExtenstion());59 File netFile = new File(directory, "net" + exporter.getExtenstion());
60 ExportTask exportTask = new ExportTask(exporter, model, netFile.getCanonicalPath());60 ExportTask exportTask = new ExportTask(exporter, model, netFile.getAbsolutePath());
61 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);61 SubtaskMonitor<Object> mon = new SubtaskMonitor<Object>(monitor);
62 Result<? extends Object> exportResult = framework.getTaskManager().execute(62 Result<? extends Object> exportResult = framework.getTaskManager().execute(
63 exportTask, "Exporting .g", mon);63 exportTask, "Exporting .g", mon);
@@ -72,7 +72,7 @@
72 monitor.progressUpdate(0.20);72 monitor.progressUpdate(0.20);
73 73
74 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true));74 File unfoldingFile = new File(directory, "unfolding" + PunfUtilitySettings.getUnfoldingExtension(true));
75 PunfTask punfTask = new PunfTask(netFile.getCanonicalPath(), unfoldingFile.getCanonicalPath());75 PunfTask punfTask = new PunfTask(netFile.getAbsolutePath(), unfoldingFile.getAbsolutePath());
76 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(76 Result<? extends ExternalProcessResult> punfResult = framework.getTaskManager().execute(
77 punfTask, "Unfolding .g", mon);77 punfTask, "Unfolding .g", mon);
78 78
@@ -86,7 +86,7 @@
86 monitor.progressUpdate(0.70);86 monitor.progressUpdate(0.70);
8787
88 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory), 88 MpsatTask mpsatTask = new MpsatTask(settings.getMpsatArguments(directory),
89 unfoldingFile.getCanonicalPath(), directory, true);89 unfoldingFile.getAbsolutePath(), directory, true);
90 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(90 Result<? extends ExternalProcessResult> mpsatResult = framework.getTaskManager().execute(
91 mpsatTask, "Running deadlock checking [MPSat]", mon);91 mpsatTask, "Running deadlock checking [MPSat]", mon);
92 92
9393
=== modified file 'PunfPlugin/src/org/workcraft/plugins/punf/PunfUtilitySettings.java'
--- PunfPlugin/src/org/workcraft/plugins/punf/PunfUtilitySettings.java 2015-12-30 23:43:20 +0000
+++ PunfPlugin/src/org/workcraft/plugins/punf/PunfUtilitySettings.java 2016-01-15 17:12:28 +0000
@@ -36,14 +36,20 @@
36 36
37 private static final String keyCommand = prefix + ".command";37 private static final String keyCommand = prefix + ".command";
38 private static final String keyExtraArgs = prefix + ".args";38 private static final String keyExtraArgs = prefix + ".args";
39 private static final String keyPrintStdout= prefix + ".printStdout";
40 private static final String keyPrintStderr= prefix + ".printStderr";
39 private static final String keyUsePnmlUnfolding = prefix + ".usePnmlUnfolding";41 private static final String keyUsePnmlUnfolding = prefix + ".usePnmlUnfolding";
40 42
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");
42 private static final String defaultExtraArgs = "-r";44 private static final String defaultExtraArgs = "-r";
45 private static final Boolean defaultPrintStdout = true;
46 private static final Boolean defaultPrintStderr = true;
43 private static final Boolean defaultUsePnmlUnfolding = true;47 private static final Boolean defaultUsePnmlUnfolding = true;
4448
45 private static String command = defaultCommand;49 private static String command = defaultCommand;
46 private static String extraArgs = defaultExtraArgs;50 private static String extraArgs = defaultExtraArgs;
51 private static Boolean printStdout = defaultPrintStdout;
52 private static Boolean printStderr = defaultPrintStderr;
47 private static Boolean usePnmlUnfolding = defaultUsePnmlUnfolding;53 private static Boolean usePnmlUnfolding = defaultUsePnmlUnfolding;
4854
49 public PunfUtilitySettings() {55 public PunfUtilitySettings() {
@@ -68,6 +74,26 @@
68 });74 });
6975
70 properties.add(new PropertyDeclaration<PunfUtilitySettings, Boolean>(76 properties.add(new PropertyDeclaration<PunfUtilitySettings, Boolean>(
77 this, "Output stdout", Boolean.class, true, false, false) {
78 protected void setter(PunfUtilitySettings object, Boolean value) {
79 setPrintStdout(value);
80 }
81 protected Boolean getter(PunfUtilitySettings object) {
82 return getPrintStdout();
83 }
84 });
85
86 properties.add(new PropertyDeclaration<PunfUtilitySettings, Boolean>(
87 this, "Output stderr", Boolean.class, true, false, false) {
88 protected void setter(PunfUtilitySettings object, Boolean value) {
89 setPrintStderr(value);
90 }
91 protected Boolean getter(PunfUtilitySettings object) {
92 return getPrintStderr();
93 }
94 });
95
96 properties.add(new PropertyDeclaration<PunfUtilitySettings, Boolean>(
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) {
72 protected void setter(PunfUtilitySettings object, Boolean value) {98 protected void setter(PunfUtilitySettings object, Boolean value) {
73 setUsePnmlUnfolding(value);99 setUsePnmlUnfolding(value);
@@ -88,12 +114,16 @@
88 setCommand(config.getString(keyCommand, defaultCommand));114 setCommand(config.getString(keyCommand, defaultCommand));
89 setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs));115 setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs));
90 setUsePnmlUnfolding(config.getBoolean(keyUsePnmlUnfolding, defaultUsePnmlUnfolding));116 setUsePnmlUnfolding(config.getBoolean(keyUsePnmlUnfolding, defaultUsePnmlUnfolding));
117 setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout));
118 setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr));
91 }119 }
92120
93 @Override121 @Override
94 public void save(Config config) {122 public void save(Config config) {
95 config.set(keyCommand, getCommand());123 config.set(keyCommand, getCommand());
96 config.set(keyExtraArgs, getExtraArgs());124 config.set(keyExtraArgs, getExtraArgs());
125 config.setBoolean(keyPrintStdout, getPrintStdout());
126 config.setBoolean(keyPrintStderr, getPrintStderr());
97 config.setBoolean(keyUsePnmlUnfolding, getUsePnmlUnfolding());127 config.setBoolean(keyUsePnmlUnfolding, getUsePnmlUnfolding());
98 }128 }
99 129
@@ -123,6 +153,22 @@
123 extraArgs = value;153 extraArgs = value;
124 }154 }
125155
156 public static Boolean getPrintStdout() {
157 return printStdout;
158 }
159
160 public static void setPrintStdout(Boolean value) {
161 printStdout = value;
162 }
163
164 public static Boolean getPrintStderr() {
165 return printStderr;
166 }
167
168 public static void setPrintStderr(Boolean value) {
169 printStderr = value;
170 }
171
126 public static Boolean getUsePnmlUnfolding() {172 public static Boolean getUsePnmlUnfolding() {
127 return usePnmlUnfolding;173 return usePnmlUnfolding;
128 }174 }
@@ -138,5 +184,5 @@
138 public static String getToolSuffix(boolean tryPnml) {184 public static String getToolSuffix(boolean tryPnml) {
139 return (tryPnml && getUsePnmlUnfolding() ? "" : "-mci");185 return (tryPnml && getUsePnmlUnfolding() ? "" : "-mci");
140 }186 }
141 187
142}188}
143189
=== modified file 'PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java'
--- PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java 2016-01-09 22:12:07 +0000
+++ PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java 2016-01-15 17:12:28 +0000
@@ -38,8 +38,11 @@
38 // Built-in arguments38 // Built-in arguments
39 command.add("-m=" + outputPath);39 command.add("-m=" + outputPath);
40 command.add(inputPath);40 command.add(inputPath);
4141
42 Result<? extends ExternalProcessResult> res = new ExternalProcessTask(command).run(monitor);42 boolean printStdout = PunfUtilitySettings.getPrintStdout();
43 boolean printStderr = PunfUtilitySettings.getPrintStderr();
44 ExternalProcessTask task = new ExternalProcessTask(command, null, printStdout, printStderr);
45 Result<? extends ExternalProcessResult> res = task.run(monitor);
43 46
44 if (res.getOutcome() != Outcome.FINISHED) {47 if (res.getOutcome() != Outcome.FINISHED) {
45 return res;48 return res;
4649
=== modified file 'WorkcraftCore/src/org/workcraft/Config.java'
--- WorkcraftCore/src/org/workcraft/Config.java 2014-07-25 16:19:39 +0000
+++ WorkcraftCore/src/org/workcraft/Config.java 2016-01-15 17:12:28 +0000
@@ -190,51 +190,51 @@
190 group.put(k[1], value);190 group.put(k[1], value);
191 }191 }
192 }192 }
193193
194 public void load(String fileName) {194 public void load(String fileName) {
195 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();195 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
196 Document xmldoc;196 Document xmldoc;
197 DocumentBuilder db;197 DocumentBuilder db;
198198
199 try {199 try {
200 db = dbf.newDocumentBuilder();200 db = dbf.newDocumentBuilder();
201 xmldoc = db.parse(new File(fileName));201 xmldoc = db.parse(new File(fileName));
202 } catch (ParserConfigurationException e) {202 } catch (ParserConfigurationException e) {
203 e.printStackTrace();203 e.printStackTrace();
204 return;204 return;
205 } catch (IOException e) {205 } catch (IOException e) {
206 return;206 return;
207 } catch (SAXException e) {207 } catch (SAXException e) {
208 e.printStackTrace();208 e.printStackTrace();
209 return;209 return;
210 }210 }
211211
212 Element xmlroot = xmldoc.getDocumentElement();212 Element xmlroot = xmldoc.getDocumentElement();
213 NodeList nl = xmlroot.getChildNodes(), nl2;213 NodeList nl = xmlroot.getChildNodes(), nl2;
214 for (int i=0; i<nl.getLength(); i++) {214 for (int i=0; i<nl.getLength(); i++) {
215 if (! (nl.item(i) instanceof Element)) {215 if (! (nl.item(i) instanceof Element)) {
216 continue;216 continue;
217 }217 }
218 Element e = (Element)nl.item(i);218 Element e = (Element)nl.item(i);
219219
220 if (e.getTagName().equals("var")) {220 if (e.getTagName().equals("var")) {
221 set(e.getAttribute("name"), e.getAttribute("value"));221 set(e.getAttribute("name"), e.getAttribute("value"));
222 } else {222 } else {
223 if (e.getTagName().equals("group")) {223 if (e.getTagName().equals("group")) {
224 String name = e.getAttribute("name");224 String name = e.getAttribute("name");
225 nl2 = e.getChildNodes();225 nl2 = e.getChildNodes();
226 for (int j=0; j<nl2.getLength(); j++) {226 for (int j=0; j<nl2.getLength(); j++) {
227 if (! (nl2.item(j) instanceof Element)) {227 if (! (nl2.item(j) instanceof Element)) {
228 continue;228 continue;
229 }229 }
230 Element e2 = (Element)nl2.item(j);230 Element e2 = (Element)nl2.item(j);
231 if (e2.getTagName().equals("var"))231 if (e2.getTagName().equals("var"))
232 set(name+"."+e2.getAttribute("name"), e2.getAttribute("value"));232 set(name+"."+e2.getAttribute("name"), e2.getAttribute("value"));
233 }233 }
234 }234 }
235 }235 }
236 }236 }
237 }237 }
238238
239 public void save(String fileName) {239 public void save(String fileName) {
240 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();240 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
241241
=== modified file 'WorkcraftCore/src/org/workcraft/Framework.java'
--- WorkcraftCore/src/org/workcraft/Framework.java 2015-11-27 18:45:40 +0000
+++ WorkcraftCore/src/org/workcraft/Framework.java 2016-01-15 17:12:28 +0000
@@ -228,9 +228,15 @@
228 return instance;228 return instance;
229 }229 }
230230
231 public void resetConfig() {
232 config = new Config();
233 for (PluginInfo<? extends Settings> info : pluginManager.getPlugins(Settings.class)) {
234 info.getSingleton().load(config);
235 }
236 }
237
231 public void loadConfig(String fileName) {238 public void loadConfig(String fileName) {
232 config.load(fileName);239 config.load(fileName);
233
234 for (PluginInfo<? extends Settings> info : pluginManager.getPlugins(Settings.class)) {240 for (PluginInfo<? extends Settings> info : pluginManager.getPlugins(Settings.class)) {
235 info.getSingleton().load(config);241 info.getSingleton().load(config);
236 }242 }
@@ -240,7 +246,6 @@
240 for (PluginInfo<? extends Settings> info : pluginManager.getPlugins(Settings.class)) {246 for (PluginInfo<? extends Settings> info : pluginManager.getPlugins(Settings.class)) {
241 info.getSingleton().save(config);247 info.getSingleton().save(config);
242 }248 }
243
244 config.save(fileName);249 config.save(fileName);
245 }250 }
246251
247252
=== modified file 'WorkcraftCore/src/org/workcraft/gui/AboutDialog.java'
--- WorkcraftCore/src/org/workcraft/gui/AboutDialog.java 2014-11-14 23:43:09 +0000
+++ WorkcraftCore/src/org/workcraft/gui/AboutDialog.java 2016-01-15 17:12:28 +0000
@@ -98,7 +98,7 @@
98 });98 });
99 99
100 okButton = new JButton();100 okButton = new JButton();
101 okButton.setPreferredSize(new Dimension(100, 20));101 okButton.setPreferredSize(new Dimension(100, 25));
102 okButton.setText("OK");102 okButton.setText("OK");
103 okButton.addActionListener(new java.awt.event.ActionListener() {103 okButton.addActionListener(new java.awt.event.ActionListener() {
104 public void actionPerformed(java.awt.event.ActionEvent e) {104 public void actionPerformed(java.awt.event.ActionEvent e) {
105105
=== modified file 'WorkcraftCore/src/org/workcraft/gui/CreateWorkDialog.java'
--- WorkcraftCore/src/org/workcraft/gui/CreateWorkDialog.java 2015-10-15 16:52:53 +0000
+++ WorkcraftCore/src/org/workcraft/gui/CreateWorkDialog.java 2016-01-15 17:12:28 +0000
@@ -196,7 +196,7 @@
196 buttonsPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));196 buttonsPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
197197
198 okButton = new JButton();198 okButton = new JButton();
199 okButton.setPreferredSize(new Dimension(100, 20));199 okButton.setPreferredSize(new Dimension(100, 25));
200 okButton.setEnabled(false);200 okButton.setEnabled(false);
201 okButton.setText("OK");201 okButton.setText("OK");
202 okButton.addActionListener(new java.awt.event.ActionListener() {202 okButton.addActionListener(new java.awt.event.ActionListener() {
@@ -206,7 +206,7 @@
206 });206 });
207207
208 cancelButton = new JButton();208 cancelButton = new JButton();
209 cancelButton.setPreferredSize(new Dimension(100, 20));209 cancelButton.setPreferredSize(new Dimension(100, 25));
210 cancelButton.setText("Cancel");210 cancelButton.setText("Cancel");
211 cancelButton.addActionListener(new java.awt.event.ActionListener() {211 cancelButton.addActionListener(new java.awt.event.ActionListener() {
212 public void actionPerformed(java.awt.event.ActionEvent e) {212 public void actionPerformed(java.awt.event.ActionEvent e) {
@@ -216,11 +216,11 @@
216216
217 buttonsPane.add(okButton);217 buttonsPane.add(okButton);
218 buttonsPane.add(cancelButton);218 buttonsPane.add(cancelButton);
219
220 contentPane.add(splitPane, BorderLayout.CENTER);219 contentPane.add(splitPane, BorderLayout.CENTER);
221 contentPane.add(buttonsPane, BorderLayout.SOUTH);220 contentPane.add(buttonsPane, BorderLayout.SOUTH);
221 getRootPane().setDefaultButton(okButton);
222222
223 getRootPane().registerKeyboardAction(new ActionListener() {223 getRootPane().registerKeyboardAction(new ActionListener() {
224 @Override224 @Override
225 public void actionPerformed(ActionEvent e) {225 public void actionPerformed(ActionEvent e) {
226 ok(); 226 ok();
227227
=== modified file 'WorkcraftCore/src/org/workcraft/gui/propertyeditor/Settings.java'
--- WorkcraftCore/src/org/workcraft/gui/propertyeditor/Settings.java 2014-08-05 22:17:32 +0000
+++ WorkcraftCore/src/org/workcraft/gui/propertyeditor/Settings.java 2016-01-15 17:12:28 +0000
@@ -24,8 +24,8 @@
24import org.workcraft.Config;24import org.workcraft.Config;
2525
26public interface Settings extends Properties {26public interface Settings extends Properties {
27 public void save (Config config);27 public void save(Config config);
28 public void load (Config config);28 public void load(Config config);
29 29
30 public String getSection();30 public String getSection();
31 public String getName();31 public String getName();
3232
=== modified file 'WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java'
--- WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java 2015-10-16 17:25:11 +0000
+++ WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java 2016-01-15 17:12:28 +0000
@@ -26,6 +26,7 @@
26import java.awt.FlowLayout;26import java.awt.FlowLayout;
27import java.awt.event.ActionEvent;27import java.awt.event.ActionEvent;
28import java.awt.event.ActionListener;28import java.awt.event.ActionListener;
29import java.awt.event.KeyEvent;
29import java.awt.event.WindowAdapter;30import java.awt.event.WindowAdapter;
30import java.awt.event.WindowEvent;31import java.awt.event.WindowEvent;
31import java.util.ArrayList;32import java.util.ArrayList;
@@ -35,13 +36,16 @@
3536
36import javax.swing.BorderFactory;37import javax.swing.BorderFactory;
37import javax.swing.JButton;38import javax.swing.JButton;
39import javax.swing.JComponent;
38import javax.swing.JDialog;40import javax.swing.JDialog;
39import javax.swing.JFrame;41import javax.swing.JFrame;
42import javax.swing.JOptionPane;
40import javax.swing.JPanel;43import javax.swing.JPanel;
41import javax.swing.JScrollPane;44import javax.swing.JScrollPane;
42import javax.swing.JSplitPane;45import javax.swing.JSplitPane;
43import javax.swing.JTable;46import javax.swing.JTable;
44import javax.swing.JTree;47import javax.swing.JTree;
48import javax.swing.KeyStroke;
45import javax.swing.event.TreeSelectionEvent;49import javax.swing.event.TreeSelectionEvent;
46import javax.swing.event.TreeSelectionListener;50import javax.swing.event.TreeSelectionListener;
47import javax.swing.tree.DefaultMutableTreeNode;51import javax.swing.tree.DefaultMutableTreeNode;
@@ -49,6 +53,7 @@
49import javax.swing.tree.TreePath;53import javax.swing.tree.TreePath;
50import javax.swing.tree.TreeSelectionModel;54import javax.swing.tree.TreeSelectionModel;
5155
56import org.workcraft.Config;
52import org.workcraft.Framework;57import org.workcraft.Framework;
53import org.workcraft.PluginManager;58import org.workcraft.PluginManager;
54import org.workcraft.gui.MainWindow;59import org.workcraft.gui.MainWindow;
@@ -62,10 +67,15 @@
62 private JSplitPane splitPane;67 private JSplitPane splitPane;
63 private JPanel buttonsPane;68 private JPanel buttonsPane;
64 private JButton okButton;69 private JButton okButton;
70 private JButton cancelButton;
71 private JButton restoreButton;
65 private DefaultMutableTreeNode sectionRoot;72 private DefaultMutableTreeNode sectionRoot;
66 private JTree sectionTree;73 private JTree sectionTree;
67 private final PropertyEditorTable propertiesTable;74 private final PropertyEditorTable propertiesTable;
68 75
76 private Settings currentPage;
77 private Config currentConfig;
78
69 static class SettingsPageNode {79 static class SettingsPageNode {
70 private Settings page;80 private Settings page;
71 81
@@ -111,7 +121,7 @@
111 initComponents();121 initComponents();
112 loadSections();122 loadSections();
113 }123 }
114 124
115 public DefaultMutableTreeNode getSectionNode (DefaultMutableTreeNode node, String section) {125 public DefaultMutableTreeNode getSectionNode (DefaultMutableTreeNode node, String section) {
116 int dotPos = section.indexOf('.');126 int dotPos = section.indexOf('.');
117 127
@@ -172,6 +182,7 @@
172 final TreePath treePath = sectionTree.getPathForRow(i); 182 final TreePath treePath = sectionTree.getPathForRow(i);
173 sectionTree.expandPath(treePath);183 sectionTree.expandPath(treePath);
174 }184 }
185 setObject(null);
175 }186 }
176187
177 private ArrayList<Settings> getSortedPluginSettings(Collection<PluginInfo<? extends Settings>> plugins) {188 private ArrayList<Settings> getSortedPluginSettings(Collection<PluginInfo<? extends Settings>> plugins) {
@@ -204,12 +215,17 @@
204 return settings;215 return settings;
205 }216 }
206 217
207 private void setObject(Settings p) {218 private void setObject(Settings page) {
208 if (p == null) {219 if (page == null) {
209 propertiesTable.setObject(null);220 currentConfig = null;
221 restoreButton.setText("Restore defaults (all)");
210 } else {222 } else {
211 propertiesTable.setObject(p);223 currentConfig = new Config();
224 page.save(currentConfig);
225 restoreButton.setText("Restore defaults");
212 }226 }
227 currentPage = page;
228 propertiesTable.setObject(currentPage);
213 }229 }
214230
215 private void initComponents() {231 private void initComponents() {
@@ -227,7 +243,8 @@
227 public void valueChanged(TreeSelectionEvent e) {243 public void valueChanged(TreeSelectionEvent e) {
228 Object userObject = ((DefaultMutableTreeNode)e.getPath().getLastPathComponent()).getUserObject();244 Object userObject = ((DefaultMutableTreeNode)e.getPath().getLastPathComponent()).getUserObject();
229 if (userObject instanceof SettingsPageNode) {245 if (userObject instanceof SettingsPageNode) {
230 setObject( ((SettingsPageNode) userObject).getPage() ); 246 Settings page = ((SettingsPageNode) userObject).getPage();
247 setObject(page);
231 } else {248 } else {
232 setObject(null);249 setObject(null);
233 }250 }
@@ -251,24 +268,85 @@
251 splitPane.setResizeWeight(0.1);268 splitPane.setResizeWeight(0.1);
252269
253 okButton = new JButton();270 okButton = new JButton();
254 okButton.setPreferredSize(new Dimension(100, 20));271 okButton.setPreferredSize(new Dimension(100, 25));
255 okButton.setText("OK");272 okButton.setText("OK");
256 okButton.addActionListener(new ActionListener() {273 okButton.addActionListener(new ActionListener() {
257 public void actionPerformed(ActionEvent e) {274 public void actionPerformed(ActionEvent e) {
258 ok();275 ok();
259 }276 }
260 });277 });
278
279 cancelButton = new JButton();
280 cancelButton.setPreferredSize(new Dimension(100, 25));
281 cancelButton.setText("Cancel");
282 cancelButton.addActionListener(new ActionListener() {
283 public void actionPerformed(ActionEvent e) {
284 cancel();
285 }
286 });
287
288 restoreButton = new JButton();
289 restoreButton.setPreferredSize(new Dimension(170, 25));
290 restoreButton.setText("Restore defaults");
291 restoreButton.addActionListener(new ActionListener() {
292 public void actionPerformed(ActionEvent e) {
293 restore();
294 }
295 });
261 296
262 buttonsPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));297 buttonsPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
263 buttonsPane.add(okButton);298 buttonsPane.add(okButton);
299 buttonsPane.add(cancelButton);
300 buttonsPane.add(restoreButton);
264 contentPane.add(splitPane, BorderLayout.CENTER);301 contentPane.add(splitPane, BorderLayout.CENTER);
265 contentPane.add(buttonsPane, BorderLayout.SOUTH);302 contentPane.add(buttonsPane, BorderLayout.SOUTH);
266 getRootPane().setDefaultButton(okButton);303 getRootPane().setDefaultButton(okButton);
304
305 getRootPane().registerKeyboardAction(new ActionListener() {
306 @Override
307 public void actionPerformed(ActionEvent e) {
308 ok();
309 }
310 },
311 KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
312 JComponent.WHEN_IN_FOCUSED_WINDOW);
313
314 getRootPane().registerKeyboardAction(new ActionListener() {
315 @Override
316 public void actionPerformed(ActionEvent e) {
317 cancel();
318 }
319 },
320 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
321 JComponent.WHEN_IN_FOCUSED_WINDOW);
267 }322 }
268323
269 private void ok() {324 private void ok() {
270 setObject(null); 325 setObject(null);
271 setVisible(false);326 setVisible(false);
272 }327 }
328
329 private void cancel() {
330 if ((currentPage != null) && (currentConfig != null)) {
331 currentPage.load(currentConfig);
332 }
333 setObject(null);
334 setVisible(false);
335 }
336
337 private void restore() {
338 if (currentPage != null) {
339 currentPage.load(new Config());
340 setObject(currentPage);
341 } else {
342 final Framework framework = Framework.getInstance();
343 int answer = JOptionPane.showConfirmDialog(framework.getMainWindow(),
344 "This will reset all the settings to defaults.\nContinue?",
345 "Please confirm", JOptionPane.YES_NO_OPTION);
346 if (answer == JOptionPane.YES_OPTION) {
347 framework.resetConfig();
348 }
349 }
350 }
273 351
274}352}
275353
=== modified file 'WorkcraftCore/src/org/workcraft/interop/ExternalProcess.java'
--- WorkcraftCore/src/org/workcraft/interop/ExternalProcess.java 2015-07-31 15:05:52 +0000
+++ WorkcraftCore/src/org/workcraft/interop/ExternalProcess.java 2016-01-15 17:12:28 +0000
@@ -32,34 +32,31 @@
3232
33public class ExternalProcess {33public class ExternalProcess {
34 34
35 abstract static class StreamReaderThread extends Thread35 abstract static class StreamReaderThread extends Thread {
36 {
37 private final ReadableByteChannel channel;36 private final ReadableByteChannel channel;
38 private final ByteBuffer buffer = ByteBuffer.allocate(1024);37 private final ByteBuffer buffer = ByteBuffer.allocate(1024);
39 38
40 public StreamReaderThread(ReadableByteChannel channel)39 public StreamReaderThread(ReadableByteChannel channel) {
41 {
42 this.channel = channel;40 this.channel = channel;
43 }41 }
44 42
45 abstract void handleData(byte [] data);43 abstract void handleData(byte [] data);
4644
45 @Override
47 public void run() {46 public void run() {
48 while (true)47 while (true)
49 try {48 try {
50 buffer.rewind();49 buffer.rewind();
51 int result = channel.read(buffer);50 int result = channel.read(buffer);
5251 if (result == -1) {
53 if (result == -1)
54 return;52 return;
55 53 }
56 if (result == 0)54 if (result == 0) {
57 continue;55 continue;
5856 }
59 buffer.rewind();57 buffer.rewind();
60 byte[] data = new byte[result];58 byte[] data = new byte[result];
61 buffer.get(data);59 buffer.get(data);
62
63 handleData(data);60 handleData(data);
64 } catch (IOException e) {61 } catch (IOException e) {
65// e.printStackTrace(); -- This exception is mostly caused by the process termination and spams the user with information about exceptions that should62// e.printStackTrace(); -- This exception is mostly caused by the process termination and spams the user with information about exceptions that should
@@ -70,29 +67,27 @@
70 }67 }
71 68
72 class InputReaderThread extends StreamReaderThread {69 class InputReaderThread extends StreamReaderThread {
73 70 InputReaderThread() {
74 InputReaderThread()
75 {
76 super(inputStream);71 super(inputStream);
77 }72 }
78 73 @Override
79 void handleData(byte[] data) {74 void handleData(byte[] data) {
80 outputData(data);75 outputData(data);
81 }76 }
82 }77 }
83 78
84 class ErrorReaderThread extends StreamReaderThread {79 class ErrorReaderThread extends StreamReaderThread {
85 ErrorReaderThread()80 ErrorReaderThread() {
86 {
87 super(errorStream);81 super(errorStream);
88 }82 }
8983 @Override
90 void handleData(byte[] data) {84 void handleData(byte[] data) {
91 errorData(data);85 errorData(data);
92 }86 }
93 }87 }
9488
95 class WaiterThread extends Thread {89 class WaiterThread extends Thread {
90 @Override
96 public void run() {91 public void run() {
97 try {92 try {
98 process.waitFor();93 process.waitFor();
@@ -112,7 +107,7 @@
112107
113 private LinkedList<ExternalProcessListener> listeners = new LinkedList<ExternalProcessListener>();108 private LinkedList<ExternalProcessListener> listeners = new LinkedList<ExternalProcessListener>();
114109
115 public ExternalProcess (String[] command, String workingDirectoryPath) {110 public ExternalProcess(String[] command, String workingDirectoryPath) {
116 processBuilder = new ProcessBuilder(command);111 processBuilder = new ProcessBuilder(command);
117 processBuilder.directory(workingDirectoryPath == null? null : new File(workingDirectoryPath));112 processBuilder.directory(workingDirectoryPath == null? null : new File(workingDirectoryPath));
118 }113 }
@@ -122,19 +117,21 @@
122 }117 }
123118
124 private void outputData(byte[] data) {119 private void outputData(byte[] data) {
125 for (ExternalProcessListener l : listeners)120 for (ExternalProcessListener l : listeners) {
126 l.outputData(data);121 l.outputData(data);
122 }
127 }123 }
128124
129 private void errorData(byte[] data) {125 private void errorData(byte[] data) {
130 for (ExternalProcessListener l : listeners)126 for (ExternalProcessListener l : listeners) {
131 l.errorData(data);127 l.errorData(data);
128 }
132 }129 }
133130
134 private void processFinished() {131 private void processFinished() {
135 for (ExternalProcessListener l : listeners){132 for (ExternalProcessListener l : listeners){
136 l.processFinished(process.exitValue());133 l.processFinished(process.exitValue());
137 }134 }
138 finished = true;135 finished = true;
139 }136 }
140137
@@ -143,15 +140,13 @@
143 }140 }
144141
145 public void start() throws IOException {142 public void start() throws IOException {
146 if (isRunning())143 if (isRunning()) {
147 return;144 return;
148145 }
149 process = processBuilder.start();146 process = processBuilder.start();
150
151 outputStream = Channels.newChannel(process.getOutputStream());147 outputStream = Channels.newChannel(process.getOutputStream());
152 errorStream = Channels.newChannel(process.getErrorStream());148 errorStream = Channels.newChannel(process.getErrorStream());
153 inputStream = Channels.newChannel(process.getInputStream());149 inputStream = Channels.newChannel(process.getInputStream());
154
155 if (outputStream == null) {150 if (outputStream == null) {
156 throw new RuntimeException("No output stream!");151 throw new RuntimeException("No output stream!");
157 }152 }
@@ -161,8 +156,9 @@
161 }156 }
162157
163 public void cancel() {158 public void cancel() {
164 if (isRunning())159 if (isRunning()) {
165 process.destroy();160 process.destroy();
161 }
166 }162 }
167163
168 public void writeData(byte[] data) {164 public void writeData(byte[] data) {
169165
=== modified file 'WorkcraftCore/src/org/workcraft/interop/SynchronousExternalProcess.java'
--- WorkcraftCore/src/org/workcraft/interop/SynchronousExternalProcess.java 2009-09-22 21:01:45 +0000
+++ WorkcraftCore/src/org/workcraft/interop/SynchronousExternalProcess.java 2016-01-15 17:12:28 +0000
@@ -25,19 +25,20 @@
25import java.util.LinkedList;25import java.util.LinkedList;
2626
27public class SynchronousExternalProcess {27public class SynchronousExternalProcess {
28 class SynchronousListener implements ExternalProcessListener {28 class SynchronousListener implements ExternalProcessListener {
29 @Override
29 public void errorData(byte[] data) {30 public void errorData(byte[] data) {
30 synchronized (errorData) {31 synchronized (errorData) {
31 errorData.add(data);32 errorData.add(data);
32 }33 }
33 }34 }
3435 @Override
35 public void outputData(byte[] data) {36 public void outputData(byte[] data) {
36 synchronized (outputData) {37 synchronized (outputData) {
37 outputData.add(data);38 outputData.add(data);
38 }39 }
39 }40 }
4041 @Override
41 public void processFinished(int returnCode) {42 public void processFinished(int returnCode) {
42 SynchronousExternalProcess.this.returnCode = returnCode;43 SynchronousExternalProcess.this.returnCode = returnCode;
43 finished = true;44 finished = true;
@@ -90,18 +91,18 @@
90 return returnCode;91 return returnCode;
91 }92 }
92 93
93 private static byte [] mergeChunksToArray (LinkedList<byte[]> chunks) {94 private static byte [] mergeChunksToArray(LinkedList<byte[]> chunks) {
94 int len = 0;95 int len = 0;
95 for (byte[] dataChunk : chunks)96 for (byte[] dataChunk : chunks) {
96 len += dataChunk.length;97 len += dataChunk.length;
97 98 }
98 byte [] result = new byte[len];99 byte [] result = new byte[len];
99
100 int cur = 0;100 int cur = 0;
101 for (byte[] dataChunk : chunks)101 for (byte[] dataChunk : chunks) {
102 for(int i=0;i<dataChunk.length;i++)102 for(int i=0;i<dataChunk.length;i++) {
103 result[cur++] = dataChunk[i];103 result[cur++] = dataChunk[i];
104 104 }
105 }
105 return result;106 return result;
106 }107 }
107 108
@@ -111,5 +112,6 @@
111 112
112 public byte [] getErrorData() {113 public byte [] getErrorData() {
113 return mergeChunksToArray(errorData);114 return mergeChunksToArray(errorData);
114 }115 }
116
115}117}
116118
=== modified file 'WorkcraftCore/src/org/workcraft/plugins/layout/DotLayoutTool.java'
--- WorkcraftCore/src/org/workcraft/plugins/layout/DotLayoutTool.java 2015-12-26 23:27:09 +0000
+++ WorkcraftCore/src/org/workcraft/plugins/layout/DotLayoutTool.java 2016-01-15 17:12:28 +0000
@@ -204,7 +204,7 @@
204 args.add(layout.getAbsolutePath());204 args.add(layout.getAbsolutePath());
205 args.add(original.getAbsolutePath());205 args.add(original.getAbsolutePath());
206 206
207 Task<ExternalProcessResult> task = new ExternalProcessTask(args, directory);207 Task<ExternalProcessResult> task = new ExternalProcessTask(args, directory, false, false);
208 final Framework framework = Framework.getInstance();208 final Framework framework = Framework.getInstance();
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...");
210 210
211211
=== modified file 'WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java'
--- WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java 2016-01-05 20:25:07 +0000
+++ WorkcraftCore/src/org/workcraft/plugins/shared/tasks/ExternalProcessTask.java 2016-01-15 17:12:28 +0000
@@ -14,6 +14,10 @@
1414
15public class ExternalProcessTask implements Task<ExternalProcessResult>, ExternalProcessListener {15public class ExternalProcessTask implements Task<ExternalProcessResult>, ExternalProcessListener {
16 private List<String> args;16 private List<String> args;
17 private final File workingDir;
18 private boolean printStdout;
19 private boolean printStderr;
20 private boolean hasNewLine = false;
17 21
18 private volatile boolean finished;22 private volatile boolean finished;
19 private volatile int returnCode;23 private volatile int returnCode;
@@ -23,15 +27,11 @@
23 private DataAccumulator stdoutAccum = new DataAccumulator();27 private DataAccumulator stdoutAccum = new DataAccumulator();
24 private DataAccumulator stderrAccum = new DataAccumulator();28 private DataAccumulator stderrAccum = new DataAccumulator();
2529
26 private final File workingDir;30 public ExternalProcessTask(List<String> args, File workingDir, boolean printStdout, boolean printStderr) {
27
28 public ExternalProcessTask(List<String> args) {
29 this(args, null);
30 }
31
32 public ExternalProcessTask(List<String> args, File workingDir) {
33 this.args = args;31 this.args = args;
34 this.workingDir = workingDir;32 this.workingDir = workingDir;
33 this.printStdout = printStdout;
34 this.printStderr = printStderr;
35 }35 }
36 36
37 @Override37 @Override
@@ -68,7 +68,9 @@
68 if (userCancelled) {68 if (userCancelled) {
69 return Result.cancelled();69 return Result.cancelled();
70 }70 }
71 ExternalProcessResult result = new ExternalProcessResult(returnCode, stdoutAccum.getData(), stderrAccum.getData(), Collections.<String, byte[]>emptyMap());71 ExternalProcessResult result = new ExternalProcessResult(
72 returnCode, stdoutAccum.getData(), stderrAccum.getData(),
73 Collections.<String, byte[]>emptyMap());
72 74
73 return Result.finished(result);75 return Result.finished(result);
74 }76 }
@@ -91,6 +93,19 @@
91 }93 }
9294
93 @Override95 @Override
96 public void outputData(byte[] data) {
97 try {
98 stdoutAccum.write(data);
99 } catch (IOException e) {
100 throw new RuntimeException(e);
101 }
102 monitor.stdout(data);
103 if (printStdout) {
104 printData(data);
105 }
106 }
107
108 @Override
94 public void errorData(byte[] data) {109 public void errorData(byte[] data) {
95 try {110 try {
96 stderrAccum.write(data);111 stderrAccum.write(data);
@@ -98,22 +113,26 @@
98 throw new RuntimeException(e);113 throw new RuntimeException(e);
99 }114 }
100 monitor.stderr(data);115 monitor.stderr(data);
101 }116 if (printStderr) {
102117 printData(data);
103 @Override
104 public void outputData(byte[] data) {
105 try {
106 stdoutAccum.write(data);
107 } catch (IOException e) {
108 throw new RuntimeException(e);
109 }118 }
110 monitor.stdout(data);119
111 }120 }
112121
113 @Override122 @Override
114 public void processFinished(int returnCode) {123 public void processFinished(int returnCode) {
115 this.returnCode = returnCode;124 this.returnCode = returnCode;
116 this.finished = true;125 this.finished = true;
126 if ( !hasNewLine ) {
127 System.out.println();
128 hasNewLine = true;
129 }
130 }
131
132 private void printData(byte[] data) {
133 String s = new String(data);
134 System.out.print(s);
135 hasNewLine = (s.endsWith("\n"));
117 }136 }
118 137
119}138}
120139
=== modified file 'WorkcraftCore/src/org/workcraft/tasks/DummyProgressMonitor.java'
--- WorkcraftCore/src/org/workcraft/tasks/DummyProgressMonitor.java 2010-02-14 17:59:01 +0000
+++ WorkcraftCore/src/org/workcraft/tasks/DummyProgressMonitor.java 2016-01-15 17:12:28 +0000
@@ -1,8 +1,9 @@
1package org.workcraft.tasks;1package org.workcraft.tasks;
22
3public class DummyProgressMonitor<T> implements ProgressMonitor<T> {3public class DummyProgressMonitor<T> implements ProgressMonitor<T> {
4
4 @Override5 @Override
5 public void finished(Result<? extends T> result, String description) {6 public void progressUpdate(double completion) {
6 }7 }
78
8 @Override9 @Override
@@ -15,10 +16,11 @@
15 }16 }
1617
17 @Override18 @Override
18 public void progressUpdate(double completion) {
19 }
20
21 @Override
22 public void stderr(byte[] data) {19 public void stderr(byte[] data) {
23 }20 }
21
22 @Override
23 public void finished(Result<? extends T> result, String description) {
24 }
25
24}26}

Subscribers

People subscribed via source and target branches