Merge lp:~danilovesky/workcraft/trunk-bug-1538674 into lp:workcraft
- trunk-bug-1538674
- Merge into trunk
Proposed by
Danil Sokolov
Status: | Merged |
---|---|
Merged at revision: | 727 |
Proposed branch: | lp:~danilovesky/workcraft/trunk-bug-1538674 |
Merge into: | lp:workcraft |
Diff against target: |
1291 lines (+389/-202) 30 files modified
MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java (+36/-13) MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java (+14/-2) MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatCombinedChainResultHandler.java (+0/-1) MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java (+35/-12) MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java (+14/-2) PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java (+1/-1) PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetConnectionTool.java (+1/-1) PetriNetPlugin/src/org/workcraft/plugins/petri/tools/ReadArcConnectionTool.java (+1/-1) PetriNetPlugin/src/org/workcraft/plugins/petri/tools/TransitionContractorTool.java (+5/-5) PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/PetrifyExtraModule.java (+2/-1) PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java (+1/-1) PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java (+1/-1) PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyModule.java (+4/-1) PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java (+53/-30) PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java (+16/-5) PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java (+15/-4) PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/PetrifyNetSynthesisHide.java (+68/-0) PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java (+1/-1) STGPlugin/src/org/workcraft/plugins/stg/StgUtils.java (+1/-0) STGPlugin/src/org/workcraft/plugins/stg/VisualDummyTransition.java (+0/-10) STGPlugin/src/org/workcraft/plugins/stg/VisualSTG.java (+3/-1) WorkcraftCore/src/org/workcraft/Console.java (+17/-4) WorkcraftCore/src/org/workcraft/Framework.java (+6/-3) WorkcraftCore/src/org/workcraft/gui/DesktopApi.java (+1/-1) WorkcraftCore/src/org/workcraft/gui/LookAndFeelHelper.java (+7/-5) WorkcraftCore/src/org/workcraft/gui/MainMenu.java (+9/-9) WorkcraftCore/src/org/workcraft/gui/MainWindow.java (+77/-82) WorkcraftCore/src/org/workcraft/plugins/BuiltinExporters.java (+0/-2) WorkcraftCore/src/scripts/shutdown.js (+0/-1) WorkcraftCore/src/scripts/startup.js (+0/-2) |
To merge this branch: | bzr merge lp:~danilovesky/workcraft/trunk-bug-1538674 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danil Sokolov | Approve | ||
Review via email: mp+284234@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Danil Sokolov (danilovesky) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java' |
2 | --- MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java 2016-01-15 17:00:47 +0000 |
3 | +++ MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/MpsatSynthesisUtilitySettings.java 2016-01-28 09:55:28 +0000 |
4 | @@ -34,17 +34,20 @@ |
5 | private static final String prefix = "Tools.mpsatSynthesis"; |
6 | |
7 | private static final String keyCommand = prefix + ".command"; |
8 | - private static final String keyExtraArgs = prefix + ".args"; |
9 | + private static final String keyArgs = prefix + ".args"; |
10 | + private static final String keyAdvancedMode= prefix + ".advancedMode"; |
11 | private static final String keyPrintStdout= prefix + ".printStdout"; |
12 | private static final String keyPrintStderr= prefix + ".printStderr"; |
13 | |
14 | private static final String defaultCommand = (DesktopApi.getOs().isWindows() ? "tools\\UnfoldingTools\\mpsat.exe" : "tools/UnfoldingTools/mpsat"); |
15 | - private static final String defaultExtraArgs = ""; |
16 | + private static final String defaultArgs = ""; |
17 | + private static final Boolean defaultAdvancedMode = false; |
18 | private static final Boolean defaultPrintStdout = true; |
19 | private static final Boolean defaultPrintStderr = true; |
20 | |
21 | private static String command = defaultCommand; |
22 | - private static String extraArgs = defaultExtraArgs; |
23 | + private static String args = defaultArgs; |
24 | + private static Boolean advancedMode = defaultAdvancedMode; |
25 | private static Boolean printStdout = defaultPrintStdout; |
26 | private static Boolean printStderr = defaultPrintStderr; |
27 | |
28 | @@ -62,11 +65,21 @@ |
29 | properties.add(new PropertyDeclaration<MpsatSynthesisUtilitySettings, String>( |
30 | this, "Additional parameters", String.class, true, false, false) { |
31 | protected void setter(MpsatSynthesisUtilitySettings object, String value) { |
32 | - setExtraArgs(value); |
33 | + setArgs(value); |
34 | |
35 | } |
36 | protected String getter(MpsatSynthesisUtilitySettings object) { |
37 | - return getExtraArgs(); |
38 | + return getArgs(); |
39 | + } |
40 | + }); |
41 | + |
42 | + properties.add(new PropertyDeclaration<MpsatSynthesisUtilitySettings, Boolean>( |
43 | + this, "Edit additional parameters before every call", Boolean.class, true, false, false) { |
44 | + protected void setter(MpsatSynthesisUtilitySettings object, Boolean value) { |
45 | + setAdvancedMode(value); |
46 | + } |
47 | + protected Boolean getter(MpsatSynthesisUtilitySettings object) { |
48 | + return getAdvancedMode(); |
49 | } |
50 | }); |
51 | |
52 | @@ -99,7 +112,8 @@ |
53 | @Override |
54 | public void load(Config config) { |
55 | setCommand(config.getString(keyCommand, defaultCommand)); |
56 | - setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs)); |
57 | + setArgs(config.getString(keyArgs, defaultArgs)); |
58 | + setAdvancedMode(config.getBoolean(keyAdvancedMode, defaultAdvancedMode)); |
59 | setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout)); |
60 | setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr)); |
61 | } |
62 | @@ -107,7 +121,8 @@ |
63 | @Override |
64 | public void save(Config config) { |
65 | config.set(keyCommand, getCommand()); |
66 | - config.set(keyExtraArgs, getExtraArgs()); |
67 | + config.set(keyArgs, getArgs()); |
68 | + config.setBoolean(keyAdvancedMode, getAdvancedMode()); |
69 | config.setBoolean(keyPrintStdout, getPrintStdout()); |
70 | config.setBoolean(keyPrintStderr, getPrintStderr()); |
71 | } |
72 | @@ -130,12 +145,20 @@ |
73 | command = value; |
74 | } |
75 | |
76 | - public static String getExtraArgs() { |
77 | - return extraArgs; |
78 | - } |
79 | - |
80 | - public static void setExtraArgs(String value) { |
81 | - extraArgs = value; |
82 | + public static String getArgs() { |
83 | + return args; |
84 | + } |
85 | + |
86 | + public static void setArgs(String value) { |
87 | + args = value; |
88 | + } |
89 | + |
90 | + public static Boolean getAdvancedMode() { |
91 | + return advancedMode; |
92 | + } |
93 | + |
94 | + public static void setAdvancedMode(Boolean value) { |
95 | + advancedMode = value; |
96 | } |
97 | |
98 | public static Boolean getPrintStdout() { |
99 | |
100 | === modified file 'MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java' |
101 | --- MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java 2016-01-17 22:35:32 +0000 |
102 | +++ MpsatSynthesisPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatSynthesisTask.java 2016-01-28 09:55:28 +0000 |
103 | @@ -6,6 +6,10 @@ |
104 | import java.util.HashMap; |
105 | import java.util.Map; |
106 | |
107 | +import javax.swing.JOptionPane; |
108 | + |
109 | +import org.workcraft.Framework; |
110 | +import org.workcraft.gui.MainWindow; |
111 | import org.workcraft.plugins.circuit.CircuitSettings; |
112 | import org.workcraft.plugins.mpsat.MpsatSynthesisUtilitySettings; |
113 | import org.workcraft.plugins.punf.PunfUtilitySettings; |
114 | @@ -74,8 +78,16 @@ |
115 | } |
116 | |
117 | // Extra arguments (should go before the file parameters) |
118 | - for (String arg : MpsatSynthesisUtilitySettings.getExtraArgs().split("\\s")) { |
119 | - if (!arg.isEmpty()) { |
120 | + String extraArgs = MpsatSynthesisUtilitySettings.getArgs(); |
121 | + if (MpsatSynthesisUtilitySettings.getAdvancedMode()) { |
122 | + MainWindow mainWindow = Framework.getInstance().getMainWindow(); |
123 | + String tmp = JOptionPane.showInputDialog(mainWindow, "Additional parameters for MPSat:", extraArgs); |
124 | + if (tmp != null) { |
125 | + extraArgs = tmp; |
126 | + } |
127 | + } |
128 | + for (String arg : extraArgs.split("\\s")) { |
129 | + if ( !arg.isEmpty() ) { |
130 | command.add(arg); |
131 | } |
132 | } |
133 | |
134 | === modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatCombinedChainResultHandler.java' |
135 | --- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatCombinedChainResultHandler.java 2016-01-22 23:52:54 +0000 |
136 | +++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatCombinedChainResultHandler.java 2016-01-28 09:55:28 +0000 |
137 | @@ -15,7 +15,6 @@ |
138 | import org.workcraft.tasks.DummyProgressMonitor; |
139 | import org.workcraft.tasks.Result; |
140 | import org.workcraft.tasks.Result.Outcome; |
141 | -import org.workcraft.util.LogUtils; |
142 | import org.workcraft.workspace.WorkspaceEntry; |
143 | |
144 | public class MpsatCombinedChainResultHandler extends DummyProgressMonitor<MpsatCombinedChainResult> { |
145 | |
146 | === modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java' |
147 | --- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2016-01-15 17:00:47 +0000 |
148 | +++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/MpsatUtilitySettings.java 2016-01-28 09:55:28 +0000 |
149 | @@ -33,25 +33,28 @@ |
150 | public class MpsatUtilitySettings implements Settings { |
151 | |
152 | private static final LinkedList<PropertyDescriptor> properties = new LinkedList<PropertyDescriptor>(); |
153 | - private static final String prefix = "Tools.mpsat"; |
154 | + private static final String prefix = "Tools.mpsatVerification"; |
155 | |
156 | private static final String keyCommand = prefix + ".command"; |
157 | private static final String keySolutionMode = prefix + ".solutionMode"; |
158 | - private static final String keyExtraArgs = prefix + ".args"; |
159 | + private static final String keyArgs = prefix + ".args"; |
160 | + private static final String keyAdvancedMode= prefix + ".advancedMode"; |
161 | private static final String keyPrintStdout= prefix + ".printStdout"; |
162 | private static final String keyPrintStderr= prefix + ".printStderr"; |
163 | private static final String keyDebugReach = prefix + ".debugReach"; |
164 | |
165 | private static final String defaultCommand = (DesktopApi.getOs().isWindows() ? "tools\\UnfoldingTools\\mpsat.exe" : "tools/UnfoldingTools/mpsat"); |
166 | private static final SolutionMode defaultSolutionMode = SolutionMode.MINIMUM_COST; |
167 | - private static final String defaultExtraArgs = ""; |
168 | + private static final String defaultArgs = ""; |
169 | + private static final Boolean defaultAdvancedMode = false; |
170 | private static final Boolean defaultPrintStdout = true; |
171 | private static final Boolean defaultPrintStderr = true; |
172 | private static final Boolean defaultDebugReach = false; |
173 | |
174 | private static String command = defaultCommand; |
175 | private static SolutionMode solutionMode = defaultSolutionMode; |
176 | - private static String extraArgs = defaultExtraArgs; |
177 | + private static String args = defaultArgs; |
178 | + private static Boolean advancedMode = defaultAdvancedMode; |
179 | private static Boolean printStdout = defaultPrintStdout; |
180 | private static Boolean printStderr = defaultPrintStderr; |
181 | private static Boolean debugReach = defaultDebugReach; |
182 | @@ -80,10 +83,20 @@ |
183 | properties.add(new PropertyDeclaration<MpsatUtilitySettings, String>( |
184 | this, "Additional parameters", String.class, true, false, false) { |
185 | protected void setter(MpsatUtilitySettings object, String value) { |
186 | - setExtraArgs(value); |
187 | + setArgs(value); |
188 | } |
189 | protected String getter(MpsatUtilitySettings object) { |
190 | - return getExtraArgs(); |
191 | + return getArgs(); |
192 | + } |
193 | + }); |
194 | + |
195 | + properties.add(new PropertyDeclaration<MpsatUtilitySettings, Boolean>( |
196 | + this, "Edit additional parameters before every call", Boolean.class, true, false, false) { |
197 | + protected void setter(MpsatUtilitySettings object, Boolean value) { |
198 | + setAdvancedMode(value); |
199 | + } |
200 | + protected Boolean getter(MpsatUtilitySettings object) { |
201 | + return getAdvancedMode(); |
202 | } |
203 | }); |
204 | |
205 | @@ -127,7 +140,8 @@ |
206 | public void load(Config config) { |
207 | setCommand(config.getString(keyCommand, defaultCommand)); |
208 | setSolutionMode(config.getEnum(keySolutionMode, SolutionMode.class, defaultSolutionMode)); |
209 | - setExtraArgs(config.getString(keyExtraArgs, defaultExtraArgs)); |
210 | + setArgs(config.getString(keyArgs, defaultArgs)); |
211 | + setAdvancedMode(config.getBoolean(keyAdvancedMode, defaultAdvancedMode)); |
212 | setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout)); |
213 | setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr)); |
214 | setDebugReach(config.getBoolean(keyDebugReach, defaultDebugReach)); |
215 | @@ -137,7 +151,8 @@ |
216 | public void save(Config config) { |
217 | config.set(keyCommand, getCommand()); |
218 | config.setEnum(keySolutionMode, SolutionMode.class, getSolutionMode()); |
219 | - config.set(keyExtraArgs, getExtraArgs()); |
220 | + config.set(keyArgs, getArgs()); |
221 | + config.setBoolean(keyAdvancedMode, getAdvancedMode()); |
222 | config.setBoolean(keyPrintStdout, getPrintStdout()); |
223 | config.setBoolean(keyPrintStderr, getPrintStderr()); |
224 | config.setBoolean(keyDebugReach, getDebugReach()); |
225 | @@ -161,12 +176,12 @@ |
226 | command = value; |
227 | } |
228 | |
229 | - public static String getExtraArgs() { |
230 | - return extraArgs; |
231 | + public static String getArgs() { |
232 | + return args; |
233 | } |
234 | |
235 | - public static void setExtraArgs(String value) { |
236 | - extraArgs = value; |
237 | + public static void setArgs(String value) { |
238 | + args = value; |
239 | } |
240 | |
241 | public static void setSolutionMode(SolutionMode value) { |
242 | @@ -181,6 +196,14 @@ |
243 | return (solutionMode == SolutionMode.ALL) ? 10 : 1; |
244 | } |
245 | |
246 | + public static Boolean getAdvancedMode() { |
247 | + return advancedMode; |
248 | + } |
249 | + |
250 | + public static void setAdvancedMode(Boolean value) { |
251 | + advancedMode = value; |
252 | + } |
253 | + |
254 | public static Boolean getPrintStdout() { |
255 | return printStdout; |
256 | } |
257 | |
258 | === modified file 'MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java' |
259 | --- MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2016-01-15 17:00:47 +0000 |
260 | +++ MpsatVerificationPlugin/src/org/workcraft/plugins/mpsat/tasks/MpsatTask.java 2016-01-28 09:55:28 +0000 |
261 | @@ -6,6 +6,10 @@ |
262 | import java.util.HashMap; |
263 | import java.util.Map; |
264 | |
265 | +import javax.swing.JOptionPane; |
266 | + |
267 | +import org.workcraft.Framework; |
268 | +import org.workcraft.gui.MainWindow; |
269 | import org.workcraft.plugins.mpsat.MpsatUtilitySettings; |
270 | import org.workcraft.plugins.punf.PunfUtilitySettings; |
271 | import org.workcraft.plugins.shared.tasks.ExternalProcessResult; |
272 | @@ -50,8 +54,16 @@ |
273 | } |
274 | |
275 | // Extra arguments (should go before the file parameters) |
276 | - for (String arg : MpsatUtilitySettings.getExtraArgs().split("\\s")) { |
277 | - if (!arg.isEmpty()) { |
278 | + String extraArgs = MpsatUtilitySettings.getArgs(); |
279 | + if (MpsatUtilitySettings.getAdvancedMode()) { |
280 | + MainWindow mainWindow = Framework.getInstance().getMainWindow(); |
281 | + String tmp = JOptionPane.showInputDialog(mainWindow, "Additional parameters for MPSat:", extraArgs); |
282 | + if (tmp != null) { |
283 | + extraArgs = tmp; |
284 | + } |
285 | + } |
286 | + for (String arg : extraArgs.split("\\s")) { |
287 | + if ( !arg.isEmpty() ) { |
288 | command.add(arg); |
289 | } |
290 | } |
291 | |
292 | === modified file 'PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java' |
293 | --- PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2016-01-15 17:00:47 +0000 |
294 | +++ PcompPlugin/src/org/workcraft/plugins/pcomp/tasks/PcompTask.java 2016-01-28 09:55:28 +0000 |
295 | @@ -63,7 +63,7 @@ |
296 | } |
297 | |
298 | // Extra arguments (should go before the file parameters) |
299 | - for (String arg : PcompUtilitySettings.getExtraArgs().split(" ")) { |
300 | + for (String arg : PcompUtilitySettings.getExtraArgs().split("\\s")) { |
301 | if (!arg.isEmpty()) { |
302 | command.add(arg); |
303 | } |
304 | |
305 | === modified file 'PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetConnectionTool.java' |
306 | --- PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetConnectionTool.java 2016-01-25 14:44:27 +0000 |
307 | +++ PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetConnectionTool.java 2016-01-28 09:55:28 +0000 |
308 | @@ -27,7 +27,7 @@ |
309 | |
310 | @Override |
311 | public String getSecondHintMessage() { |
312 | - return (super.getSecondHintMessage() + " Hold Shift to create a place shadow."); |
313 | + return (super.getSecondHintMessage() + " Hold Shift to create a place proxy."); |
314 | } |
315 | |
316 | @Override |
317 | |
318 | === modified file 'PetriNetPlugin/src/org/workcraft/plugins/petri/tools/ReadArcConnectionTool.java' |
319 | --- PetriNetPlugin/src/org/workcraft/plugins/petri/tools/ReadArcConnectionTool.java 2016-01-25 14:44:27 +0000 |
320 | +++ PetriNetPlugin/src/org/workcraft/plugins/petri/tools/ReadArcConnectionTool.java 2016-01-28 09:55:28 +0000 |
321 | @@ -52,7 +52,7 @@ |
322 | |
323 | @Override |
324 | public String getSecondHintMessage() { |
325 | - return (super.getSecondHintMessage() + " Hold Shift to create a place shadow."); |
326 | + return (super.getSecondHintMessage() + " Hold Shift to create a place proxy."); |
327 | } |
328 | |
329 | @Override |
330 | |
331 | === modified file 'PetriNetPlugin/src/org/workcraft/plugins/petri/tools/TransitionContractorTool.java' |
332 | --- PetriNetPlugin/src/org/workcraft/plugins/petri/tools/TransitionContractorTool.java 2016-01-14 18:28:55 +0000 |
333 | +++ PetriNetPlugin/src/org/workcraft/plugins/petri/tools/TransitionContractorTool.java 2016-01-28 09:55:28 +0000 |
334 | @@ -87,14 +87,14 @@ |
335 | PetriNetModel mathModel = (PetriNetModel)visualModel.getMathModel(); |
336 | VisualTransition visualTransition = (VisualTransition)node; |
337 | Transition mathTransition = visualTransition.getReferencedTransition(); |
338 | - if (needsWaitedArcs(mathModel, mathTransition)) { |
339 | + if (hasSelfLoop(mathModel, mathTransition)) { |
340 | + JOptionPane.showMessageDialog(null, |
341 | + "Error: a transition with a self-loop/read-arc cannot be contracted.", |
342 | + MESSAGE_TITLE, JOptionPane.ERROR_MESSAGE); |
343 | + } else if (needsWaitedArcs(mathModel, mathTransition)) { |
344 | JOptionPane.showMessageDialog(null, |
345 | "Error: this transformation requires weighted arcs that are currently not supported.", |
346 | MESSAGE_TITLE, JOptionPane.ERROR_MESSAGE); |
347 | - } else if (hasSelfLoop(mathModel, mathTransition)) { |
348 | - JOptionPane.showMessageDialog(null, |
349 | - "Error: a transition with a self-loop/read-arc cannot be contracted.", |
350 | - MESSAGE_TITLE, JOptionPane.ERROR_MESSAGE); |
351 | } else if (isLanguageChanging(mathModel, mathTransition)) { |
352 | contractTransition(visualModel, visualTransition); |
353 | JOptionPane.showMessageDialog(null, |
354 | |
355 | === modified file 'PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/PetrifyExtraModule.java' |
356 | --- PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/PetrifyExtraModule.java 2015-12-26 00:22:59 +0000 |
357 | +++ PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/PetrifyExtraModule.java 2016-01-28 09:55:28 +0000 |
358 | @@ -35,6 +35,7 @@ |
359 | |
360 | @Override |
361 | public String getDescription() { |
362 | - return "Petrify tool support"; |
363 | + return "Petrify state graph support"; |
364 | } |
365 | + |
366 | } |
367 | |
368 | === modified file 'PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java' |
369 | --- PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java 2016-01-22 23:52:54 +0000 |
370 | +++ PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/DrawAstgTask.java 2016-01-28 09:55:28 +0000 |
371 | @@ -36,7 +36,7 @@ |
372 | } |
373 | |
374 | // Extra arguments (should go before the file parameters) |
375 | - for (String arg : PetrifyExtraUtilitySettings.getDrawAstgArgs().split(" ")) { |
376 | + for (String arg : PetrifyExtraUtilitySettings.getDrawAstgArgs().split("\\s")) { |
377 | if (!arg.isEmpty()) { |
378 | command.add(arg); |
379 | } |
380 | |
381 | === modified file 'PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java' |
382 | --- PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java 2016-01-22 23:52:54 +0000 |
383 | +++ PetrifyExtraPlugin/src/org/workcraft/plugins/petrify/tasks/WriteSgTask.java 2016-01-28 09:55:28 +0000 |
384 | @@ -52,7 +52,7 @@ |
385 | } |
386 | |
387 | // Extra arguments (should go before the file parameters) |
388 | - for (String arg : PetrifyExtraUtilitySettings.getWriteSgArgs().split(" ")) { |
389 | + for (String arg : PetrifyExtraUtilitySettings.getWriteSgArgs().split("\\s")) { |
390 | if (!arg.isEmpty()) { |
391 | command.add(arg); |
392 | } |
393 | |
394 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyModule.java' |
395 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyModule.java 2015-12-26 00:13:28 +0000 |
396 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyModule.java 2016-01-28 09:55:28 +0000 |
397 | @@ -8,6 +8,7 @@ |
398 | import org.workcraft.plugins.petrify.tools.PetrifyCscConflictResolution; |
399 | import org.workcraft.plugins.petrify.tools.PetrifyDummyContraction; |
400 | import org.workcraft.plugins.petrify.tools.PetrifyNetSynthesis; |
401 | +import org.workcraft.plugins.petrify.tools.PetrifyNetSynthesisHide; |
402 | import org.workcraft.plugins.petrify.tools.PetrifyNetSynthesisWithEr; |
403 | import org.workcraft.plugins.petrify.tools.PetrifySynthesisComplexGate; |
404 | import org.workcraft.plugins.petrify.tools.PetrifySynthesisGeneralisedCelement; |
405 | @@ -31,10 +32,12 @@ |
406 | pm.registerClass(Tool.class, PetrifyDummyContraction.class); |
407 | pm.registerClass(Tool.class, PetrifyNetSynthesis.class); |
408 | pm.registerClass(Tool.class, PetrifyNetSynthesisWithEr.class); |
409 | + pm.registerClass(Tool.class, PetrifyNetSynthesisHide.class); |
410 | } |
411 | |
412 | @Override |
413 | public String getDescription() { |
414 | - return "Petrify tool support"; |
415 | + return "Petrify synthesis support"; |
416 | } |
417 | + |
418 | } |
419 | |
420 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java' |
421 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java 2016-01-15 17:00:47 +0000 |
422 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/PetrifyUtilitySettings.java 2016-01-28 09:55:28 +0000 |
423 | @@ -32,20 +32,23 @@ |
424 | public class PetrifyUtilitySettings implements Settings { |
425 | |
426 | private static final LinkedList<PropertyDescriptor> properties = new LinkedList<PropertyDescriptor>(); |
427 | - private static final String prefix = "Tools"; |
428 | + private static final String prefix = "Tools.petrify"; |
429 | |
430 | - private static final String keyPetrifyCkeyPmmand = prefix + ".petrify.command"; |
431 | - private static final String keyPetrifyArgs = prefix + ".petrify.args"; |
432 | + private static final String keyPetrifyCkeyPmmand = prefix + ".command"; |
433 | + private static final String keyPetrifyArgs = prefix + ".args"; |
434 | + private static final String keyAdvancedMode= prefix + ".advancedMode"; |
435 | private static final String keyPrintStdout= prefix + ".printStdout"; |
436 | private static final String keyPrintStderr= prefix + ".printStderr"; |
437 | |
438 | - private static final String defaultPetrifyCommand = (DesktopApi.getOs().isWindows() ? "tools\\PetrifyTools\\petrify.exe" : "tools/PetrifyTools/petrify"); |
439 | - private static final String defaultPetrifyArgs = ""; |
440 | + private static final String defaultCommand = (DesktopApi.getOs().isWindows() ? "tools\\PetrifyTools\\petrify.exe" : "tools/PetrifyTools/petrify"); |
441 | + private static final String defaultArgs = ""; |
442 | + private static final Boolean defaultAdvancedMode = false; |
443 | private static final Boolean defaultPrintStdout = true; |
444 | private static final Boolean defaultPrintStderr = true; |
445 | |
446 | - private static String petrifyCommand = defaultPetrifyCommand; |
447 | - private static String petrifyArgs = defaultPetrifyArgs; |
448 | + private static String command = defaultCommand; |
449 | + private static String args = defaultArgs; |
450 | + private static Boolean advancedMode = defaultAdvancedMode; |
451 | private static Boolean printStdout = defaultPrintStdout; |
452 | private static Boolean printStderr = defaultPrintStderr; |
453 | |
454 | @@ -53,20 +56,30 @@ |
455 | properties.add(new PropertyDeclaration<PetrifyUtilitySettings, String>( |
456 | this, "Petrify command", String.class, true, false, false) { |
457 | protected void setter(PetrifyUtilitySettings object, String value) { |
458 | - setPetrifyCommand(value); |
459 | + setCommand(value); |
460 | } |
461 | protected String getter(PetrifyUtilitySettings object) { |
462 | - return getPetrifyCommand(); |
463 | + return getCommand(); |
464 | } |
465 | }); |
466 | |
467 | properties.add(new PropertyDeclaration<PetrifyUtilitySettings, String>( |
468 | - this, "Additional parameters for Petrify", String.class, true, false, false) { |
469 | + this, "Additional parameters", String.class, true, false, false) { |
470 | protected void setter(PetrifyUtilitySettings object, String value) { |
471 | - setPetrifyArgs(value); |
472 | + setArgs(value); |
473 | } |
474 | protected String getter(PetrifyUtilitySettings object) { |
475 | - return getPetrifyArgs(); |
476 | + return getArgs(); |
477 | + } |
478 | + }); |
479 | + |
480 | + properties.add(new PropertyDeclaration<PetrifyUtilitySettings, Boolean>( |
481 | + this, "Edit additional parameters before every call", Boolean.class, true, false, false) { |
482 | + protected void setter(PetrifyUtilitySettings object, Boolean value) { |
483 | + setAdvancedMode(value); |
484 | + } |
485 | + protected Boolean getter(PetrifyUtilitySettings object) { |
486 | + return getAdvancedMode(); |
487 | } |
488 | }); |
489 | |
490 | @@ -98,16 +111,18 @@ |
491 | |
492 | @Override |
493 | public void load(Config config) { |
494 | - setPetrifyCommand(config.getString(keyPetrifyCkeyPmmand, defaultPetrifyCommand)); |
495 | - setPetrifyArgs(config.getString(keyPetrifyArgs, defaultPetrifyArgs)); |
496 | + setCommand(config.getString(keyPetrifyCkeyPmmand, defaultCommand)); |
497 | + setArgs(config.getString(keyPetrifyArgs, defaultArgs)); |
498 | + setAdvancedMode(config.getBoolean(keyAdvancedMode, defaultAdvancedMode)); |
499 | setPrintStdout(config.getBoolean(keyPrintStdout, defaultPrintStdout)); |
500 | setPrintStderr(config.getBoolean(keyPrintStderr, defaultPrintStderr)); |
501 | } |
502 | |
503 | @Override |
504 | public void save(Config config) { |
505 | - config.set(keyPetrifyCkeyPmmand, getPetrifyCommand()); |
506 | - config.set(keyPetrifyArgs, getPetrifyArgs()); |
507 | + config.set(keyPetrifyCkeyPmmand, getCommand()); |
508 | + config.set(keyPetrifyArgs, getArgs()); |
509 | + config.setBoolean(keyAdvancedMode, getAdvancedMode()); |
510 | config.setBoolean(keyPrintStdout, getPrintStdout()); |
511 | config.setBoolean(keyPrintStderr, getPrintStderr()); |
512 | } |
513 | @@ -122,20 +137,28 @@ |
514 | return "Petrify"; |
515 | } |
516 | |
517 | - public static String getPetrifyCommand() { |
518 | - return petrifyCommand; |
519 | - } |
520 | - |
521 | - public static void setPetrifyCommand(String value) { |
522 | - petrifyCommand = value; |
523 | - } |
524 | - |
525 | - public static String getPetrifyArgs() { |
526 | - return petrifyArgs; |
527 | - } |
528 | - |
529 | - public static void setPetrifyArgs(String value) { |
530 | - petrifyArgs = value; |
531 | + public static String getCommand() { |
532 | + return command; |
533 | + } |
534 | + |
535 | + public static void setCommand(String value) { |
536 | + command = value; |
537 | + } |
538 | + |
539 | + public static String getArgs() { |
540 | + return args; |
541 | + } |
542 | + |
543 | + public static void setArgs(String value) { |
544 | + args = value; |
545 | + } |
546 | + |
547 | + public static Boolean getAdvancedMode() { |
548 | + return advancedMode; |
549 | + } |
550 | + |
551 | + public static void setAdvancedMode(Boolean value) { |
552 | + advancedMode = value; |
553 | } |
554 | |
555 | public static Boolean getPrintStdout() { |
556 | |
557 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java' |
558 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java 2016-01-15 17:00:47 +0000 |
559 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/SynthesisTask.java 2016-01-28 09:55:28 +0000 |
560 | @@ -4,8 +4,11 @@ |
561 | import java.io.IOException; |
562 | import java.util.ArrayList; |
563 | |
564 | +import javax.swing.JOptionPane; |
565 | + |
566 | import org.workcraft.Framework; |
567 | import org.workcraft.dom.Model; |
568 | +import org.workcraft.gui.MainWindow; |
569 | import org.workcraft.interop.Exporter; |
570 | import org.workcraft.interop.ExternalProcessListener; |
571 | import org.workcraft.plugins.petrify.PetrifyUtilitySettings; |
572 | @@ -44,10 +47,10 @@ |
573 | |
574 | @Override |
575 | public Result<? extends SynthesisResult> run(ProgressMonitor<? super SynthesisResult> monitor) { |
576 | - ArrayList<String> command = new ArrayList<String>(); |
577 | + ArrayList<String> command = new ArrayList<>(); |
578 | |
579 | // Name of the executable |
580 | - String toolName = ToolUtils.getAbsoluteCommandPath(PetrifyUtilitySettings.getPetrifyCommand()); |
581 | + String toolName = ToolUtils.getAbsoluteCommandPath(PetrifyUtilitySettings.getCommand()); |
582 | command.add(toolName); |
583 | |
584 | // Built-in arguments |
585 | @@ -56,12 +59,20 @@ |
586 | } |
587 | |
588 | // Extra arguments (should go before the file parameters) |
589 | - for (String arg : PetrifyUtilitySettings.getPetrifyArgs().split(" ")) { |
590 | - if (!arg.isEmpty()) { |
591 | + String extraArgs = PetrifyUtilitySettings.getArgs(); |
592 | + if (PetrifyUtilitySettings.getAdvancedMode()) { |
593 | + MainWindow mainWindow = Framework.getInstance().getMainWindow(); |
594 | + String tmp = JOptionPane.showInputDialog(mainWindow, "Additional parameters for Petrify:", extraArgs); |
595 | + if (tmp != null) { |
596 | + extraArgs = tmp; |
597 | + } |
598 | + } |
599 | + for (String arg : extraArgs.split("\\s")) { |
600 | + if ( !arg.isEmpty() ) { |
601 | command.add(arg); |
602 | } |
603 | } |
604 | - |
605 | + |
606 | // Petrify uses the full name of the file as the name of the Verilog module (with _net suffix). |
607 | // As there may be non-alpha-numerical symbols in the model title, it is better not to include it to the directory name. |
608 | String prefix = FileUtils.getTempPrefix(null/* we.getTitle() */); |
609 | |
610 | === modified file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java' |
611 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java 2016-01-15 17:00:47 +0000 |
612 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tasks/TransformationTask.java 2016-01-28 09:55:28 +0000 |
613 | @@ -5,10 +5,13 @@ |
614 | import java.util.ArrayList; |
615 | import java.util.UUID; |
616 | |
617 | +import javax.swing.JOptionPane; |
618 | + |
619 | import org.workcraft.Framework; |
620 | import org.workcraft.dom.Model; |
621 | import org.workcraft.exceptions.DeserialisationException; |
622 | import org.workcraft.exceptions.SerialisationException; |
623 | +import org.workcraft.gui.MainWindow; |
624 | import org.workcraft.interop.ExternalProcessListener; |
625 | import org.workcraft.plugins.fsm.Fsm; |
626 | import org.workcraft.plugins.petri.PetriNetModel; |
627 | @@ -48,17 +51,25 @@ |
628 | ArrayList<String> command = new ArrayList<String>(); |
629 | |
630 | // Name of the executable |
631 | - String toolName = ToolUtils.getAbsoluteCommandPath(PetrifyUtilitySettings.getPetrifyCommand()); |
632 | + String toolName = ToolUtils.getAbsoluteCommandPath(PetrifyUtilitySettings.getCommand()); |
633 | command.add(toolName); |
634 | |
635 | // Built-in arguments |
636 | for (String arg : args) { |
637 | command.add(arg); |
638 | } |
639 | - |
640 | + |
641 | // Extra arguments (should go before the file parameters) |
642 | - for (String arg : PetrifyUtilitySettings.getPetrifyArgs().split(" ")) { |
643 | - if (!arg.isEmpty()) { |
644 | + String extraArgs = PetrifyUtilitySettings.getArgs(); |
645 | + if (PetrifyUtilitySettings.getAdvancedMode()) { |
646 | + MainWindow mainWindow = Framework.getInstance().getMainWindow(); |
647 | + String tmp = JOptionPane.showInputDialog(mainWindow, "Additional parameters for Petrify:", extraArgs); |
648 | + if (tmp != null) { |
649 | + extraArgs = tmp; |
650 | + } |
651 | + } |
652 | + for (String arg : extraArgs.split("\\s")) { |
653 | + if ( !arg.isEmpty() ) { |
654 | command.add(arg); |
655 | } |
656 | } |
657 | |
658 | === added file 'PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/PetrifyNetSynthesisHide.java' |
659 | --- PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/PetrifyNetSynthesisHide.java 1970-01-01 00:00:00 +0000 |
660 | +++ PetrifyPlugin/src/org/workcraft/plugins/petrify/tools/PetrifyNetSynthesisHide.java 2016-01-28 09:55:28 +0000 |
661 | @@ -0,0 +1,68 @@ |
662 | +package org.workcraft.plugins.petrify.tools; |
663 | + |
664 | +import java.util.HashSet; |
665 | + |
666 | +import org.workcraft.ConversionTool; |
667 | +import org.workcraft.Framework; |
668 | +import org.workcraft.dom.visual.VisualModel; |
669 | +import org.workcraft.plugins.petri.PetriNetModel; |
670 | +import org.workcraft.plugins.petri.PetriNetUtils; |
671 | +import org.workcraft.plugins.petri.VisualTransition; |
672 | +import org.workcraft.plugins.petrify.tasks.TransformationResultHandler; |
673 | +import org.workcraft.plugins.petrify.tasks.TransformationTask; |
674 | +import org.workcraft.plugins.stg.STGModel; |
675 | +import org.workcraft.plugins.stg.VisualDummyTransition; |
676 | +import org.workcraft.plugins.stg.VisualSignalTransition; |
677 | +import org.workcraft.util.WorkspaceUtils; |
678 | +import org.workcraft.workspace.WorkspaceEntry; |
679 | + |
680 | +public class PetrifyNetSynthesisHide extends ConversionTool { |
681 | + |
682 | + @Override |
683 | + public String getDisplayName() { |
684 | + return "Net synthesis hiding selected signals and dummies [Petrify]"; |
685 | + } |
686 | + |
687 | + @Override |
688 | + public boolean isApplicableTo(WorkspaceEntry we) { |
689 | + return WorkspaceUtils.canHas(we, PetriNetModel.class); |
690 | + } |
691 | + |
692 | + @Override |
693 | + public void run(WorkspaceEntry we) { |
694 | + VisualModel visualModel = we.getModelEntry().getVisualModel(); |
695 | + HashSet<VisualTransition> transitions = PetriNetUtils.getVisualTransitions(visualModel); |
696 | + transitions.retainAll(visualModel.getSelection()); |
697 | + |
698 | + HashSet<String> nameSet = new HashSet<>(); |
699 | + for (VisualTransition transition: transitions) { |
700 | + String name = null; |
701 | + if (transition instanceof VisualSignalTransition) { |
702 | + name = ((VisualSignalTransition)transition).getSignalName(); |
703 | + } else if (transition instanceof VisualDummyTransition) { |
704 | + name = ((VisualDummyTransition)transition).getReferencedTransition().getName(); |
705 | + } else { |
706 | + name = visualModel.getMathName(transition); |
707 | + } |
708 | + if ((name != null) && !name.isEmpty()) { |
709 | + nameSet.add(name); |
710 | + } |
711 | + } |
712 | + if ( !nameSet.isEmpty() ) { |
713 | + String names = ""; |
714 | + for (String name: nameSet) { |
715 | + if ( !names.isEmpty() ) { |
716 | + names += ","; |
717 | + } |
718 | + names += name; |
719 | + } |
720 | + final TransformationTask task = new TransformationTask(we, "Net synthesis", new String[] {"-hide", names}); |
721 | + |
722 | + final Framework framework = Framework.getInstance(); |
723 | + boolean hasSignals = WorkspaceUtils.canHas(we, STGModel.class); |
724 | + TransformationResultHandler monitor = new TransformationResultHandler(we, hasSignals); |
725 | + framework.getTaskManager().queue(task, "Petrify net synthesis", monitor); |
726 | + } |
727 | + } |
728 | + |
729 | +} |
730 | |
731 | === modified file 'PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java' |
732 | --- PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java 2016-01-15 17:00:47 +0000 |
733 | +++ PunfPlugin/src/org/workcraft/plugins/punf/tasks/PunfTask.java 2016-01-28 09:55:28 +0000 |
734 | @@ -29,7 +29,7 @@ |
735 | command.add(toolName); |
736 | |
737 | // Extra arguments (should go before the file parameters) |
738 | - for (String arg : PunfUtilitySettings.getExtraArgs().split(" ")) { |
739 | + for (String arg : PunfUtilitySettings.getExtraArgs().split("\\s")) { |
740 | if (!arg.isEmpty()) { |
741 | command.add(arg); |
742 | } |
743 | |
744 | === modified file 'STGPlugin/src/org/workcraft/plugins/stg/StgUtils.java' |
745 | --- STGPlugin/src/org/workcraft/plugins/stg/StgUtils.java 2016-01-02 22:46:33 +0000 |
746 | +++ STGPlugin/src/org/workcraft/plugins/stg/StgUtils.java 2016-01-28 09:55:28 +0000 |
747 | @@ -50,6 +50,7 @@ |
748 | VisualConnection oldPredConnection = (VisualConnection)stg.getConnection(pred, oldTransition); |
749 | VisualConnection newPredConnection = stg.connect(pred, newTransition); |
750 | newPredConnection.copyStyle(oldPredConnection); |
751 | + newPredConnection.copyShape(oldPredConnection); |
752 | } catch (InvalidConnectionException e) { |
753 | e.printStackTrace(); |
754 | } |
755 | |
756 | === modified file 'STGPlugin/src/org/workcraft/plugins/stg/VisualDummyTransition.java' |
757 | --- STGPlugin/src/org/workcraft/plugins/stg/VisualDummyTransition.java 2015-01-14 18:10:46 +0000 |
758 | +++ STGPlugin/src/org/workcraft/plugins/stg/VisualDummyTransition.java 2016-01-28 09:55:28 +0000 |
759 | @@ -43,16 +43,6 @@ |
760 | public DummyTransition getReferencedTransition() { |
761 | return (DummyTransition)getReferencedComponent(); |
762 | } |
763 | - |
764 | - @NoAutoSerialisation |
765 | - public String getText() { |
766 | - return getReferencedTransition().getName(); |
767 | - } |
768 | - |
769 | - @NoAutoSerialisation |
770 | - public void setText(String name) { |
771 | - getReferencedTransition().setName(name); |
772 | - } |
773 | |
774 | @Override |
775 | public Color getColor() { |
776 | |
777 | === modified file 'STGPlugin/src/org/workcraft/plugins/stg/VisualSTG.java' |
778 | --- STGPlugin/src/org/workcraft/plugins/stg/VisualSTG.java 2016-01-15 19:01:38 +0000 |
779 | +++ STGPlugin/src/org/workcraft/plugins/stg/VisualSTG.java 2016-01-28 09:55:28 +0000 |
780 | @@ -37,6 +37,7 @@ |
781 | import org.workcraft.dom.math.MathNode; |
782 | import org.workcraft.dom.visual.AbstractVisualModel; |
783 | import org.workcraft.dom.visual.ConnectionHelper; |
784 | +import org.workcraft.dom.visual.Replica; |
785 | import org.workcraft.dom.visual.VisualComponent; |
786 | import org.workcraft.dom.visual.VisualGroup; |
787 | import org.workcraft.dom.visual.VisualNode; |
788 | @@ -280,7 +281,8 @@ |
789 | public void maybeMakeImplicit(VisualPlace place, boolean preserveConnectionShape) { |
790 | Collection<Node> preset = getPreset(place); |
791 | Collection<Node> postset = getPostset(place); |
792 | - if ((preset.size() == 1) && (postset.size() == 1)) { |
793 | + Collection<Replica> replicas = place.getReplicas(); |
794 | + if ((preset.size() == 1) && (postset.size() == 1) && replicas.isEmpty()) { |
795 | final STGPlace stgPlace = (STGPlace)place.getReferencedPlace(); |
796 | stgPlace.setImplicit(true); |
797 | VisualComponent first = (VisualComponent)preset.iterator().next(); |
798 | |
799 | === modified file 'WorkcraftCore/src/org/workcraft/Console.java' |
800 | --- WorkcraftCore/src/org/workcraft/Console.java 2016-01-21 18:39:24 +0000 |
801 | +++ WorkcraftCore/src/org/workcraft/Console.java 2016-01-28 09:55:28 +0000 |
802 | @@ -32,6 +32,7 @@ |
803 | import org.mozilla.javascript.WrappedException; |
804 | import org.workcraft.exceptions.OperationCancelledException; |
805 | import org.workcraft.gui.FileFilters; |
806 | +import org.workcraft.gui.MainWindow; |
807 | import org.workcraft.util.FileUtils; |
808 | import org.workcraft.util.LogUtils; |
809 | |
810 | @@ -77,15 +78,25 @@ |
811 | if (startGUI) { |
812 | framework.startGUI(); |
813 | } |
814 | + |
815 | + framework.loadConfig(); |
816 | + |
817 | + // Setting recent files and the window geometry is postponed until the configuration is loaded. |
818 | + if (framework.isInGUIMode()) { |
819 | + MainWindow mainWindow = framework.getMainWindow(); |
820 | + mainWindow.loadRecentFilesFromConfig(); |
821 | + mainWindow.loadWindowGeometryFromConfig(); |
822 | + mainWindow.loadDockingLayout(); |
823 | + } |
824 | |
825 | framework.initPlugins(); |
826 | - |
827 | + |
828 | LogUtils.logMessageLine("Running startup scripts..."); |
829 | try { |
830 | framework.execJavaScript(FileUtils.readAllTextFromSystemResource("scripts/functions.js")); |
831 | framework.execJavaScript(FileUtils.readAllTextFromSystemResource("scripts/startup.js")); |
832 | - } catch (FileNotFoundException e2) { |
833 | - LogUtils.logWarningLine("System script file not found: " + e2.getMessage()); |
834 | + } catch (FileNotFoundException e) { |
835 | + LogUtils.logWarningLine("System script file not found: " + e.getMessage()); |
836 | } catch (IOException e) { |
837 | LogUtils.logErrorLine("Error reading system script file: " + e.getMessage()); |
838 | } catch (WrappedException e) { |
839 | @@ -117,7 +128,8 @@ |
840 | for (String arg: arglist) { |
841 | if (arg.endsWith(FileFilters.DOCUMENT_EXTENSION)) { |
842 | File file = new File(dir, arg); |
843 | - framework.getMainWindow().openWork(file); |
844 | + MainWindow mainWindow = framework.getMainWindow(); |
845 | + mainWindow.openWork(file); |
846 | } |
847 | } |
848 | } |
849 | @@ -126,6 +138,7 @@ |
850 | if (framework.shutdownRequested()) { |
851 | try { |
852 | framework.shutdownGUI(); |
853 | + framework.saveConfig(); |
854 | } catch (OperationCancelledException e) { |
855 | framework.abortShutdown(); |
856 | } |
857 | |
858 | === modified file 'WorkcraftCore/src/org/workcraft/Framework.java' |
859 | --- WorkcraftCore/src/org/workcraft/Framework.java 2016-01-21 18:39:24 +0000 |
860 | +++ WorkcraftCore/src/org/workcraft/Framework.java 2016-01-28 09:55:28 +0000 |
861 | @@ -431,11 +431,11 @@ |
862 | |
863 | public void startGUI() { |
864 | if (inGUIMode) { |
865 | - System.out.println ("Already in GUI mode"); |
866 | + System.out.println("Already in GUI mode"); |
867 | return; |
868 | } |
869 | GUIRestartRequested = false; |
870 | - System.out.println ("Switching to GUI mode..."); |
871 | + System.out.println("Switching to GUI mode..."); |
872 | |
873 | if (SwingUtilities.isEventDispatchThread()) { |
874 | mainWindow = new MainWindow(); |
875 | @@ -443,6 +443,7 @@ |
876 | } else { |
877 | try { |
878 | SwingUtilities.invokeAndWait(new Runnable() { |
879 | + @Override |
880 | public void run() { |
881 | mainWindow = new MainWindow(); |
882 | mainWindow.startup(); |
883 | @@ -456,14 +457,15 @@ |
884 | } |
885 | |
886 | contextFactory.call(new ContextAction() { |
887 | + @Override |
888 | public Object run(Context cx) { |
889 | Object guiScriptable = Context.javaToJS(mainWindow, systemScope); |
890 | ScriptableObject.putProperty(systemScope, "mainWindow", guiScriptable); |
891 | systemScope.setAttributes("mainWindow", ScriptableObject.READONLY); |
892 | return null; |
893 | - |
894 | } |
895 | }); |
896 | + |
897 | inGUIMode = true; |
898 | } |
899 | |
900 | @@ -475,6 +477,7 @@ |
901 | inGUIMode = false; |
902 | |
903 | contextFactory.call(new ContextAction() { |
904 | + @Override |
905 | public Object run(Context cx) { |
906 | ScriptableObject.deleteProperty(systemScope, "mainWindow"); |
907 | return null; |
908 | |
909 | === modified file 'WorkcraftCore/src/org/workcraft/gui/DesktopApi.java' |
910 | --- WorkcraftCore/src/org/workcraft/gui/DesktopApi.java 2015-11-09 10:55:18 +0000 |
911 | +++ WorkcraftCore/src/org/workcraft/gui/DesktopApi.java 2016-01-28 09:55:28 +0000 |
912 | @@ -115,7 +115,7 @@ |
913 | List<String> parts = new ArrayList<String>(); |
914 | parts.add(command); |
915 | if (args != null) { |
916 | - for (String s : args.split(" ")) { |
917 | + for (String s : args.split("\\s")) { |
918 | s = String.format(s, file); |
919 | parts.add(s.trim()); |
920 | } |
921 | |
922 | === modified file 'WorkcraftCore/src/org/workcraft/gui/LookAndFeelHelper.java' |
923 | --- WorkcraftCore/src/org/workcraft/gui/LookAndFeelHelper.java 2015-06-26 22:40:59 +0000 |
924 | +++ WorkcraftCore/src/org/workcraft/gui/LookAndFeelHelper.java 2016-01-28 09:55:28 +0000 |
925 | @@ -48,12 +48,14 @@ |
926 | } |
927 | return Collections.unmodifiableMap(lafMap); |
928 | } |
929 | - |
930 | + |
931 | + public static void setDefaultLookAndFeel() { |
932 | + String laf = UIManager.getCrossPlatformLookAndFeelClassName(); |
933 | + //String laf = UIManager.getSystemLookAndFeelClassName(); |
934 | + setLookAndFeel(laf); |
935 | + } |
936 | + |
937 | public static void setLookAndFeel(String laf) { |
938 | - if (laf == null) { |
939 | - laf = UIManager.getCrossPlatformLookAndFeelClassName(); |
940 | - //laf = UIManager.getSystemLookAndFeelClassName(); |
941 | - } |
942 | try { |
943 | UIManager.setLookAndFeel(laf); |
944 | } catch (ClassNotFoundException e) { |
945 | |
946 | === modified file 'WorkcraftCore/src/org/workcraft/gui/MainMenu.java' |
947 | --- WorkcraftCore/src/org/workcraft/gui/MainMenu.java 2016-01-14 18:28:55 +0000 |
948 | +++ WorkcraftCore/src/org/workcraft/gui/MainMenu.java 2016-01-28 09:55:28 +0000 |
949 | @@ -378,27 +378,27 @@ |
950 | PluginManager pluginManager = framework.getPluginManager(); |
951 | Collection<PluginInfo<? extends Exporter>> plugins = pluginManager.getPlugins(Exporter.class); |
952 | |
953 | - boolean haveVisual = false; |
954 | + boolean hasVisualModelExporter = false; |
955 | for (PluginInfo<? extends Exporter> info : plugins) { |
956 | Exporter exporter = info.getSingleton(); |
957 | if (exporter.getCompatibility(model) > Exporter.NOT_COMPATIBLE) { |
958 | - if (!haveVisual) { |
959 | - addExportSeparator("Visual"); |
960 | + if (!hasVisualModelExporter) { |
961 | + addExportSeparator("Visual model"); |
962 | } |
963 | addExporter(exporter); |
964 | - haveVisual = true; |
965 | + hasVisualModelExporter = true; |
966 | } |
967 | } |
968 | |
969 | - boolean haveNonVisual = false; |
970 | + boolean hasMathModelExporter = false; |
971 | for (PluginInfo<? extends Exporter> info : plugins) { |
972 | Exporter exporter = info.getSingleton(); |
973 | if (exporter.getCompatibility(model.getMathModel()) > Exporter.NOT_COMPATIBLE) { |
974 | - if (!haveNonVisual) { |
975 | - addExportSeparator("Non-visual"); |
976 | + if (!hasMathModelExporter) { |
977 | + addExportSeparator("Math model"); |
978 | } |
979 | addExporter(exporter); |
980 | - haveNonVisual = true; |
981 | + hasMathModelExporter = true; |
982 | } |
983 | } |
984 | revalidate(); |
985 | @@ -446,7 +446,7 @@ |
986 | miClear.addActionListener(new ActionListener() { |
987 | @Override |
988 | public void actionPerformed(ActionEvent e) { |
989 | - mainWindow.clearRecentFiles(); |
990 | + mainWindow.clearRecentFilesMenu(); |
991 | } |
992 | }); |
993 | mnRecent.add(miClear); |
994 | |
995 | === modified file 'WorkcraftCore/src/org/workcraft/gui/MainWindow.java' |
996 | --- WorkcraftCore/src/org/workcraft/gui/MainWindow.java 2016-01-21 18:39:24 +0000 |
997 | +++ WorkcraftCore/src/org/workcraft/gui/MainWindow.java 2016-01-28 09:55:28 +0000 |
998 | @@ -185,19 +185,6 @@ |
999 | }); |
1000 | } |
1001 | |
1002 | - public void setLookAndFeel(String laf) throws OperationCancelledException { |
1003 | - int dialogResult = JOptionPane.showConfirmDialog(this, |
1004 | - "Changing Look and Feel requires GUI restart.\n\n" |
1005 | - + "This will cause the visual editor windows to be closed.\n\nProceed?", |
1006 | - "Confirm", JOptionPane.YES_NO_OPTION); |
1007 | - |
1008 | - if (dialogResult == JOptionPane.YES_OPTION) { |
1009 | - final Framework framework = Framework.getInstance(); |
1010 | - framework.setConfigVar("gui.lookandfeel", laf); |
1011 | - framework.restartGUI(); |
1012 | - } |
1013 | - } |
1014 | - |
1015 | private int getNextDockableID() { |
1016 | return dockableIDCounter++; |
1017 | } |
1018 | @@ -361,10 +348,8 @@ |
1019 | mainMenu = new MainMenu(this); |
1020 | setJMenuBar(mainMenu); |
1021 | |
1022 | - final Framework framework = Framework.getInstance(); |
1023 | - String laf = framework.getConfigVar("gui.lookandfeel"); |
1024 | SilverOceanTheme.enable(); |
1025 | - LookAndFeelHelper.setLookAndFeel(laf); |
1026 | + LookAndFeelHelper.setDefaultLookAndFeel(); |
1027 | SwingUtilities.updateComponentTreeUI(this); |
1028 | |
1029 | content = new JPanel(new BorderLayout(0, 0)); |
1030 | @@ -377,38 +362,13 @@ |
1031 | rootDockingPort = new DefaultDockingPort("defaultDockingPort"); |
1032 | content.add(rootDockingPort, BorderLayout.CENTER); |
1033 | |
1034 | - lastSavePath = framework.getConfigVar("gui.main.lastSavePath"); |
1035 | - lastOpenPath = framework.getConfigVar("gui.main.lastOpenPath"); |
1036 | - for (int i = 0; i < CommonEditorSettings.getRecentCount(); i++) { |
1037 | - String entry = framework.getConfigVar("gui.main.recentFile" + i); |
1038 | - pushRecentFile(entry, false); |
1039 | - } |
1040 | - mainMenu.setRecentMenu(new ArrayList<String>(recentFiles)); |
1041 | - |
1042 | - String maximisedStr = framework.getConfigVar("gui.main.maximised"); |
1043 | - String widthStr = framework.getConfigVar("gui.main.width"); |
1044 | - String heightStr = framework.getConfigVar("gui.main.height"); |
1045 | - |
1046 | - boolean maximised = (maximisedStr == null) ? true : Boolean.parseBoolean(maximisedStr); |
1047 | - this.setExtendedState(maximised ? JFrame.MAXIMIZED_BOTH : JFrame.NORMAL); |
1048 | - |
1049 | - DisplayMode mode = this.getGraphicsConfiguration().getDevice().getDisplayMode(); |
1050 | - Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(this.getGraphicsConfiguration()); |
1051 | - int width = mode.getWidth() - insets.right - insets.left; |
1052 | - int height = mode.getHeight() - insets.top - insets.bottom; |
1053 | - if ((widthStr != null) && (heightStr != null)) { |
1054 | - width = Integer.parseInt(widthStr); |
1055 | - height = Integer.parseInt(heightStr); |
1056 | - } |
1057 | - this.setSize(width, height); |
1058 | - |
1059 | createWindows(); |
1060 | |
1061 | outputWindow.captureStream(); |
1062 | errorWindow.captureStream(); |
1063 | |
1064 | - rootDockingPort.setBorderManager(new StandardBorderManager( |
1065 | - new ShadowBorder())); |
1066 | + StandardBorderManager borderManager = new StandardBorderManager(new ShadowBorder()); |
1067 | + rootDockingPort.setBorderManager(borderManager); |
1068 | |
1069 | float xSplit = 0.88f; |
1070 | float ySplit = 0.82f; |
1071 | @@ -475,13 +435,11 @@ |
1072 | new Thread(new Runnable() { |
1073 | @Override |
1074 | public void run() { |
1075 | - // hack to fix the annoying delay occurring when |
1076 | - // createGlyphVector is called for the first time |
1077 | + // Hack to fix the annoying delay occurring when createGlyphVector is called for the first time. |
1078 | Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 1); |
1079 | - font.createGlyphVector(new FontRenderContext( |
1080 | - new AffineTransform(), true, true), TITLE_PLACEHOLDER); |
1081 | - |
1082 | - // force svg rendering classes to load |
1083 | + FontRenderContext frc = new FontRenderContext(new AffineTransform(), true, true); |
1084 | + font.createGlyphVector(frc, TITLE_PLACEHOLDER); |
1085 | + // Force SVG rendering classes to load. |
1086 | GUI.createIconFromSVG("images/icons/svg/place.svg"); |
1087 | } |
1088 | }).start(); |
1089 | @@ -649,13 +607,11 @@ |
1090 | } |
1091 | } |
1092 | |
1093 | - private void saveDockingLayout() { |
1094 | - PerspectiveManager pm = (PerspectiveManager) DockingManager |
1095 | - .getLayoutManager(); |
1096 | + public void saveDockingLayout() { |
1097 | + PerspectiveManager pm = (PerspectiveManager)DockingManager.getLayoutManager(); |
1098 | pm.getCurrentPerspective().cacheLayoutState(rootDockingPort); |
1099 | pm.forceDockableUpdate(); |
1100 | - PerspectiveModel pmodel = new PerspectiveModel(pm |
1101 | - .getDefaultPerspective().getPersistentId(), |
1102 | + PerspectiveModel pmodel = new PerspectiveModel(pm.getDefaultPerspective().getPersistentId(), |
1103 | pm.getCurrentPerspectiveName(), pm.getPerspectives()); |
1104 | XMLPersister pers = new XMLPersister(); |
1105 | try { |
1106 | @@ -677,29 +633,24 @@ |
1107 | } |
1108 | } |
1109 | |
1110 | - private void loadDockingLayout() { |
1111 | - PerspectiveManager pm = (PerspectiveManager) DockingManager |
1112 | - .getLayoutManager(); |
1113 | + public void loadDockingLayout() { |
1114 | + PerspectiveManager pm = (PerspectiveManager)DockingManager.getLayoutManager(); |
1115 | XMLPersister pers = new XMLPersister(); |
1116 | try { |
1117 | File file = new File(Framework.UILAYOUT_FILE_PATH); |
1118 | - if (!file.exists()) { |
1119 | - return; |
1120 | + if (file.exists()) { |
1121 | + LogUtils.logMessageLine("Loading UI layout from " + file.getAbsolutePath()); |
1122 | + FileInputStream is = new FileInputStream(file); |
1123 | + PerspectiveModel pmodel = pers.load(is); |
1124 | + pm.remove("defaultWorkspace"); |
1125 | + pm.setCurrentPerspective("defaultWorkspace"); |
1126 | + for (Perspective p : pmodel.getPerspectives()) { |
1127 | + pm.add(p, false); |
1128 | + } |
1129 | + pm.reload(rootDockingPort); |
1130 | + is.close(); |
1131 | + DockingManager.display(outputDockable); |
1132 | } |
1133 | - LogUtils.logMessageLine("Loading UI layout from " + file.getAbsolutePath()); |
1134 | - FileInputStream is = new FileInputStream(file); |
1135 | - |
1136 | - PerspectiveModel pmodel = pers.load(is); |
1137 | - |
1138 | - pm.remove("defaultWorkspace"); |
1139 | - pm.setCurrentPerspective("defaultWorkspace"); |
1140 | - |
1141 | - for (Perspective p : pmodel.getPerspectives()) |
1142 | - pm.add(p, false); |
1143 | - |
1144 | - pm.reload(rootDockingPort); |
1145 | - |
1146 | - is.close(); |
1147 | } catch (FileNotFoundException e) { |
1148 | e.printStackTrace(); |
1149 | } catch (IOException e) { |
1150 | @@ -729,16 +680,58 @@ |
1151 | throw new OperationCancelledException("Operation cancelled by user."); |
1152 | } |
1153 | } |
1154 | - |
1155 | saveDockingLayout(); |
1156 | + saveWindowGeometryToConfig(); |
1157 | + saveRecentFilesToConfig(); |
1158 | |
1159 | content.remove(rootDockingPort); |
1160 | - |
1161 | + |
1162 | + outputWindow.releaseStream(); |
1163 | + errorWindow.releaseStream(); |
1164 | + setVisible(false); |
1165 | + } |
1166 | + |
1167 | + public void loadWindowGeometryFromConfig() { |
1168 | + final Framework framework = Framework.getInstance(); |
1169 | + String maximisedStr = framework.getConfigVar("gui.main.maximised"); |
1170 | + String widthStr = framework.getConfigVar("gui.main.width"); |
1171 | + String heightStr = framework.getConfigVar("gui.main.height"); |
1172 | + |
1173 | + boolean maximised = (maximisedStr == null) ? true : Boolean.parseBoolean(maximisedStr); |
1174 | + this.setExtendedState(maximised ? JFrame.MAXIMIZED_BOTH : JFrame.NORMAL); |
1175 | + |
1176 | + DisplayMode mode = this.getGraphicsConfiguration().getDevice().getDisplayMode(); |
1177 | + Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(this.getGraphicsConfiguration()); |
1178 | + int width = mode.getWidth() - insets.right - insets.left; |
1179 | + int height = mode.getHeight() - insets.top - insets.bottom; |
1180 | + if ((widthStr != null) && (heightStr != null)) { |
1181 | + width = Integer.parseInt(widthStr); |
1182 | + height = Integer.parseInt(heightStr); |
1183 | + } |
1184 | + this.setSize(width, height); |
1185 | + } |
1186 | + |
1187 | + public void saveWindowGeometryToConfig() { |
1188 | + final Framework framework = Framework.getInstance(); |
1189 | boolean maximised = ((getExtendedState() & JFrame.MAXIMIZED_BOTH) != 0); |
1190 | framework.setConfigVar("gui.main.maximised", Boolean.toString(maximised)); |
1191 | framework.setConfigVar("gui.main.width", Integer.toString(getWidth())); |
1192 | framework.setConfigVar("gui.main.height", Integer.toString(getHeight())); |
1193 | - |
1194 | + } |
1195 | + |
1196 | + public void loadRecentFilesFromConfig() { |
1197 | + final Framework framework = Framework.getInstance(); |
1198 | + lastSavePath = framework.getConfigVar("gui.main.lastSavePath"); |
1199 | + lastOpenPath = framework.getConfigVar("gui.main.lastOpenPath"); |
1200 | + for (int i = 0; i < CommonEditorSettings.getRecentCount(); i++) { |
1201 | + String entry = framework.getConfigVar("gui.main.recentFile" + i); |
1202 | + pushRecentFile(entry, false); |
1203 | + } |
1204 | + updateRecentFilesMenu(); |
1205 | + } |
1206 | + |
1207 | + public void saveRecentFilesToConfig() { |
1208 | + final Framework framework = Framework.getInstance(); |
1209 | if (lastSavePath != null) { |
1210 | framework.setConfigVar("gui.main.lastSavePath", lastSavePath); |
1211 | } |
1212 | @@ -750,10 +743,6 @@ |
1213 | for (int i = 0; i < recentCount; i++) { |
1214 | framework.setConfigVar("gui.main.recentFile" + i, tmp[i]); |
1215 | } |
1216 | - |
1217 | - outputWindow.releaseStream(); |
1218 | - errorWindow.releaseStream(); |
1219 | - setVisible(false); |
1220 | } |
1221 | |
1222 | public void pushRecentFile(String fileName, boolean updateMenu) { |
1223 | @@ -774,15 +763,19 @@ |
1224 | } |
1225 | } |
1226 | if (updateMenu) { |
1227 | - mainMenu.setRecentMenu(new ArrayList<String>(recentFiles)); |
1228 | + updateRecentFilesMenu(); |
1229 | } |
1230 | } |
1231 | |
1232 | - public void clearRecentFiles() { |
1233 | + public void clearRecentFilesMenu() { |
1234 | recentFiles.clear(); |
1235 | mainMenu.setRecentMenu(new ArrayList<String>(recentFiles)); |
1236 | } |
1237 | |
1238 | + public void updateRecentFilesMenu() { |
1239 | + mainMenu.setRecentMenu(new ArrayList<String>(recentFiles)); |
1240 | + } |
1241 | + |
1242 | public void createWork() throws OperationCancelledException { |
1243 | createWork(Path.<String> empty()); |
1244 | } |
1245 | @@ -1359,6 +1352,8 @@ |
1246 | framework.shutdownGUI(); |
1247 | new File(Framework.UILAYOUT_FILE_PATH).delete(); |
1248 | framework.startGUI(); |
1249 | + loadWindowGeometryFromConfig(); |
1250 | + loadDockingLayout(); |
1251 | } catch (OperationCancelledException e) { |
1252 | } |
1253 | } |
1254 | |
1255 | === modified file 'WorkcraftCore/src/org/workcraft/plugins/BuiltinExporters.java' |
1256 | --- WorkcraftCore/src/org/workcraft/plugins/BuiltinExporters.java 2016-01-25 12:22:01 +0000 |
1257 | +++ WorkcraftCore/src/org/workcraft/plugins/BuiltinExporters.java 2016-01-28 09:55:28 +0000 |
1258 | @@ -8,7 +8,6 @@ |
1259 | import org.workcraft.plugins.interop.EPSExporter; |
1260 | import org.workcraft.plugins.interop.PDFExporter; |
1261 | import org.workcraft.plugins.interop.PNGExporter; |
1262 | -import org.workcraft.plugins.interop.PSExporter; |
1263 | import org.workcraft.plugins.interop.SVGExporter; |
1264 | |
1265 | public class BuiltinExporters implements Module { |
1266 | @@ -20,7 +19,6 @@ |
1267 | pm.registerClass(Exporter.class, DotExporter.class); |
1268 | pm.registerClass(Exporter.class, SVGExporter.class); |
1269 | pm.registerClass(Exporter.class, PDFExporter.class); |
1270 | - pm.registerClass(Exporter.class, PSExporter.class); |
1271 | pm.registerClass(Exporter.class, EPSExporter.class); |
1272 | pm.registerClass(Exporter.class, PNGExporter.class); |
1273 | } |
1274 | |
1275 | === modified file 'WorkcraftCore/src/scripts/shutdown.js' |
1276 | --- WorkcraftCore/src/scripts/shutdown.js 2010-07-18 00:21:00 +0000 |
1277 | +++ WorkcraftCore/src/scripts/shutdown.js 2016-01-28 09:55:28 +0000 |
1278 | @@ -1,3 +1,2 @@ |
1279 | // shutdown actions |
1280 | |
1281 | -saveConfig(); |
1282 | |
1283 | === modified file 'WorkcraftCore/src/scripts/startup.js' |
1284 | --- WorkcraftCore/src/scripts/startup.js 2010-07-18 00:21:00 +0000 |
1285 | +++ WorkcraftCore/src/scripts/startup.js 2016-01-28 09:55:28 +0000 |
1286 | @@ -1,5 +1,3 @@ |
1287 | // startup actions |
1288 | |
1289 | -loadConfig(); |
1290 | - |
1291 | execResource("scripts/editor.js"); |