Merge lp:~danilovesky/workcraft/trunk-bug-1459158 into lp:workcraft
- trunk-bug-1459158
- Merge into trunk
Proposed by
Danil Sokolov
Status: | Merged |
---|---|
Merged at revision: | 617 |
Proposed branch: | lp:~danilovesky/workcraft/trunk-bug-1459158 |
Merge into: | lp:workcraft |
Diff against target: |
678 lines (+164/-90) 15 files modified
CircuitPlugin/src/org/workcraft/plugins/circuit/Circuit.java (+6/-0) CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java (+15/-9) DfsPlugin/src/org/workcraft/plugins/dfs/tools/CycleAnaliserTool.java (+31/-22) DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java (+26/-0) FsmPlugin/src/org/workcraft/plugins/fsm/Fsm.java (+0/-1) FsmPlugin/src/org/workcraft/plugins/fsm/tools/FsmSimulationTool.java (+14/-7) FstPlugin/src/org/workcraft/plugins/fst/tools/FstSimulationTool.java (+14/-7) MpsatPlugin/src/org/workcraft/plugins/mpsat/gui/MpsatConfigurationDialog.java (+5/-28) PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java (+1/-0) PolicyNetPlugin/src/org/workcraft/plugins/policy/PolicyNetToolProvider.java (+2/-2) PolicyNetPlugin/src/org/workcraft/plugins/policy/tools/PolicySimulationTool.java (+14/-8) STGPlugin/src/org/workcraft/plugins/stg/tools/StgSimulationTool.java (+0/-1) WorkcraftCore/src/org/workcraft/dom/visual/VisualModel.java (+1/-1) WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java (+9/-4) WorkcraftCore/src/org/workcraft/util/IntDocument.java (+26/-0) |
To merge this branch: | bzr merge lp:~danilovesky/workcraft/trunk-bug-1459158 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danil Sokolov | Approve | ||
Review via email: mp+260281@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 'CircuitPlugin/src/org/workcraft/plugins/circuit/Circuit.java' |
2 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/Circuit.java 2015-04-23 12:19:54 +0000 |
3 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/Circuit.java 2015-05-27 12:15:56 +0000 |
4 | @@ -21,6 +21,8 @@ |
5 | |
6 | package org.workcraft.plugins.circuit; |
7 | |
8 | +import java.util.Collection; |
9 | + |
10 | import org.workcraft.dom.Container; |
11 | import org.workcraft.dom.Node; |
12 | import org.workcraft.dom.hierarchy.NamespaceProvider; |
13 | @@ -77,6 +79,10 @@ |
14 | return con; |
15 | } |
16 | |
17 | + public Collection<FunctionContact> getFunctionContacts() { |
18 | + return Hierarchy.getDescendantsOfType(getRoot(), FunctionContact.class); |
19 | + } |
20 | + |
21 | @Override |
22 | public ModelProperties getProperties(Node node) { |
23 | ModelProperties properties = super.getProperties(node); |
24 | |
25 | === modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java' |
26 | --- CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java 2015-05-20 22:01:06 +0000 |
27 | +++ CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java 2015-05-27 12:15:56 +0000 |
28 | @@ -7,6 +7,7 @@ |
29 | import org.workcraft.dom.Node; |
30 | import org.workcraft.dom.hierarchy.NamespaceHelper; |
31 | import org.workcraft.dom.hierarchy.NamespaceProvider; |
32 | +import org.workcraft.dom.math.MathModel; |
33 | import org.workcraft.dom.visual.HitMan; |
34 | import org.workcraft.dom.visual.VisualGroup; |
35 | import org.workcraft.dom.visual.VisualModel; |
36 | @@ -17,12 +18,13 @@ |
37 | import org.workcraft.gui.graph.tools.Decoration; |
38 | import org.workcraft.gui.graph.tools.Decorator; |
39 | import org.workcraft.gui.graph.tools.GraphEditor; |
40 | +import org.workcraft.plugins.circuit.Circuit; |
41 | import org.workcraft.plugins.circuit.CircuitSettings; |
42 | import org.workcraft.plugins.circuit.CircuitUtils; |
43 | +import org.workcraft.plugins.circuit.FunctionContact; |
44 | import org.workcraft.plugins.circuit.VisualCircuit; |
45 | import org.workcraft.plugins.circuit.VisualCircuitConnection; |
46 | import org.workcraft.plugins.circuit.VisualContact; |
47 | -import org.workcraft.plugins.circuit.VisualFunctionContact; |
48 | import org.workcraft.plugins.circuit.VisualJoint; |
49 | import org.workcraft.plugins.circuit.stg.CircuitToStgConverter; |
50 | import org.workcraft.plugins.circuit.stg.SignalStg; |
51 | @@ -107,14 +109,18 @@ |
52 | if ((savedState == null) || savedState.isEmpty()) { |
53 | return; |
54 | } |
55 | - VisualCircuit circuit = (VisualCircuit)editor.getModel(); |
56 | - for (VisualFunctionContact contact : circuit.getVisualFunctionContacts()) { |
57 | - String contactName = CircuitUtils.getContactName(circuit, contact); |
58 | - String ref = contactName + CircuitToStgConverter.NAME_SUFFIX_1; |
59 | - Node node = net.getNodeByReference(ref); |
60 | - if ((node instanceof Place) && savedState.containsKey(node)) { |
61 | - boolean initToOne = (savedState.get(node) > 0); |
62 | - contact.getReferencedContact().setInitToOne(initToOne); |
63 | + MathModel model = editor.getModel().getMathModel(); |
64 | + if (model instanceof Circuit) { |
65 | + editor.getWorkspaceEntry().saveMemento(); |
66 | + Circuit circuit = (Circuit)model; |
67 | + for (FunctionContact contact : circuit.getFunctionContacts()) { |
68 | + String contactName = CircuitUtils.getContactName(circuit, contact); |
69 | + String ref = contactName + CircuitToStgConverter.NAME_SUFFIX_1; |
70 | + Node node = net.getNodeByReference(ref); |
71 | + if ((node instanceof Place) && savedState.containsKey(node)) { |
72 | + boolean initToOne = (savedState.get(node) > 0); |
73 | + contact.setInitToOne(initToOne); |
74 | + } |
75 | } |
76 | } |
77 | } |
78 | |
79 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tools/CycleAnaliserTool.java' |
80 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tools/CycleAnaliserTool.java 2015-03-02 12:18:03 +0000 |
81 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tools/CycleAnaliserTool.java 2015-05-27 12:15:56 +0000 |
82 | @@ -11,7 +11,6 @@ |
83 | import java.awt.event.MouseEvent; |
84 | import java.awt.event.MouseListener; |
85 | import java.text.DecimalFormat; |
86 | -import java.text.NumberFormat; |
87 | import java.util.ArrayList; |
88 | import java.util.Collection; |
89 | import java.util.Collections; |
90 | @@ -20,14 +19,14 @@ |
91 | import java.util.List; |
92 | |
93 | import javax.swing.Icon; |
94 | -import javax.swing.JFormattedTextField; |
95 | import javax.swing.JLabel; |
96 | import javax.swing.JPanel; |
97 | import javax.swing.JScrollPane; |
98 | import javax.swing.JTable; |
99 | +import javax.swing.JTextField; |
100 | import javax.swing.ListSelectionModel; |
101 | import javax.swing.table.AbstractTableModel; |
102 | -import javax.swing.text.NumberFormatter; |
103 | +import javax.swing.table.TableColumnModel; |
104 | |
105 | import org.workcraft.dom.Node; |
106 | import org.workcraft.dom.visual.VisualComponent; |
107 | @@ -39,6 +38,7 @@ |
108 | import org.workcraft.plugins.dfs.VisualDfs; |
109 | import org.workcraft.util.GUI; |
110 | import org.workcraft.util.Hierarchy; |
111 | +import org.workcraft.util.IntDocument; |
112 | import org.workcraft.util.graph.cycle.ElementaryCyclesSearch; |
113 | |
114 | public class CycleAnaliserTool extends AbstractTool { |
115 | @@ -61,22 +61,25 @@ |
116 | protected JPanel controlPanel; |
117 | protected JScrollPane infoPanel; |
118 | protected JPanel statusPanel; |
119 | - protected JTable cycleTable; |
120 | + private JTable cycleTable; |
121 | + private JLabel cycleCountLabel; |
122 | |
123 | @Override |
124 | public void createInterfacePanel(final GraphEditor editor) { |
125 | controlPanel = new JPanel(); |
126 | cycleTable = new JTable(new CycleTableModel()); |
127 | cycleTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
128 | - cycleTable.getColumnModel().getColumn(COLUMN_THROUGHPUT).setPreferredWidth(50); |
129 | - cycleTable.getColumnModel().getColumn(COLUMN_TOKEN).setPreferredWidth(30); |
130 | - cycleTable.getColumnModel().getColumn(COLUMN_DELAY).setPreferredWidth(30); |
131 | - cycleTable.getColumnModel().getColumn(COLUMN_CYCLE).setPreferredWidth(300); |
132 | + TableColumnModel columnModel = cycleTable.getColumnModel(); |
133 | + columnModel.getColumn(COLUMN_THROUGHPUT).setPreferredWidth(50); |
134 | + columnModel.getColumn(COLUMN_TOKEN).setPreferredWidth(30); |
135 | + columnModel.getColumn(COLUMN_DELAY).setPreferredWidth(30); |
136 | + columnModel.getColumn(COLUMN_CYCLE).setPreferredWidth(300); |
137 | cycleTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); |
138 | + cycleTable.setAutoCreateColumnsFromModel(false); |
139 | cycleTable.addMouseListener(new MouseListener() { |
140 | public void mouseClicked(MouseEvent e) { |
141 | int selectedRow = cycleTable.getSelectedRow(); |
142 | - if (cycles != null && selectedRow >= 0 && selectedRow < cycles.size()) { |
143 | + if ((cycles != null) && (selectedRow >= 0) && (selectedRow < cycles.size())) { |
144 | Cycle curCycle = cycles.get(selectedRow); |
145 | if (selectedCycle != curCycle) { |
146 | selectedCycle = curCycle; |
147 | @@ -109,21 +112,24 @@ |
148 | interfacePanel.add(controlPanel, BorderLayout.PAGE_START); |
149 | interfacePanel.add(infoPanel, BorderLayout.CENTER); |
150 | interfacePanel.add(statusPanel, BorderLayout.PAGE_END); |
151 | + interfacePanel.setPreferredSize(new Dimension(0, 0)); |
152 | |
153 | - NumberFormat format = NumberFormat.getIntegerInstance(); |
154 | - NumberFormatter formatter = new NumberFormatter(format); |
155 | - formatter.setAllowsInvalid(false); |
156 | - formatter.setMinimum(1); |
157 | - formatter.setMaximum(1000); |
158 | - final JFormattedTextField cycleCountText = new JFormattedTextField(formatter); |
159 | - cycleCountText.setPreferredSize(new Dimension(100, 24)); |
160 | + final JTextField cycleCountText = new JTextField(); |
161 | + Dimension dimension = cycleCountText.getPreferredSize(); |
162 | + dimension.width = 40; |
163 | + cycleCountText.setPreferredSize(dimension); |
164 | + cycleCountText.setDocument(new IntDocument(3)); |
165 | cycleCountText.setText(new Integer(cycleCount).toString()); |
166 | cycleCountText.addKeyListener(new KeyListener() { |
167 | @Override |
168 | public void keyPressed(KeyEvent arg0) { |
169 | if (arg0.getKeyCode() == KeyEvent.VK_ENTER) { |
170 | - cycleCount = Integer.parseInt(cycleCountText.getText()); |
171 | - resetSelectedCycle(editor); |
172 | + try { |
173 | + cycleCount = Integer.parseInt(cycleCountText.getText()); |
174 | + resetSelectedCycle(editor); |
175 | + } catch (NumberFormatException e) { |
176 | + cycleCountText.setText(new Integer(cycleCount).toString()); |
177 | + } |
178 | } |
179 | else if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE) { |
180 | cycleCountText.setText(new Integer(cycleCount).toString()); |
181 | @@ -150,7 +156,7 @@ |
182 | } |
183 | }); |
184 | |
185 | - JLabel cycleCountLabel = new JLabel(); |
186 | + cycleCountLabel = new JLabel(); |
187 | cycleCountLabel.setText("Cycle count:"); |
188 | cycleCountLabel.setLabelFor(cycleCountText); |
189 | |
190 | @@ -170,6 +176,9 @@ |
191 | cycleTable.clearSelection(); |
192 | selectedCycle = null; |
193 | cycles = findCycles(); |
194 | + if ((cycles != null) && (cycleCountLabel != null)) { |
195 | + cycleCountLabel.setText("Cycle count (out of " + cycles.size() + "):"); |
196 | + } |
197 | super.activated(editor); |
198 | editor.getWorkspaceEntry().setCanModify(false); |
199 | } |
200 | @@ -247,7 +256,7 @@ |
201 | |
202 | public ArrayList<Cycle> findCycles() { |
203 | ArrayList<Cycle> result = new ArrayList<Cycle>(); |
204 | - // update global min and max delay values |
205 | + // Update global min and max delay values |
206 | Collection<VisualDelayComponent> allComponents = Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualDelayComponent.class); |
207 | boolean first = true; |
208 | for (VisualDelayComponent c: allComponents) { |
209 | @@ -260,7 +269,7 @@ |
210 | } |
211 | first = false; |
212 | } |
213 | - // prepare temporary node array and adjacency matrix |
214 | + // Prepare temporary node array and adjacency matrix |
215 | int size = allComponents.size(); |
216 | VisualComponent tmpComponents[] = allComponents.toArray(new VisualComponent[size]); |
217 | boolean adjMatrix[][] = new boolean[size][size]; |
218 | @@ -272,7 +281,7 @@ |
219 | adjMatrix[j][i] = preset.contains(tmpComponents[j]); |
220 | } |
221 | } |
222 | - // calculate simple cycles and process the results |
223 | + // Calculate simple cycles and process the results |
224 | ElementaryCyclesSearch ecs = new ElementaryCyclesSearch(adjMatrix, tmpComponents); |
225 | List tmpCycles = ecs.getElementaryCycles(); |
226 | for (int i = 0; i < tmpCycles.size(); i++) { |
227 | |
228 | === modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java' |
229 | --- DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java 2015-05-06 20:28:22 +0000 |
230 | +++ DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java 2015-05-27 12:15:56 +0000 |
231 | @@ -16,6 +16,7 @@ |
232 | import org.workcraft.gui.graph.tools.Decorator; |
233 | import org.workcraft.gui.graph.tools.GraphEditor; |
234 | import org.workcraft.plugins.dfs.BinaryRegister.Marking; |
235 | +import org.workcraft.plugins.dfs.VisualAbstractRegister; |
236 | import org.workcraft.plugins.dfs.VisualBinaryRegister; |
237 | import org.workcraft.plugins.dfs.VisualControlRegister; |
238 | import org.workcraft.plugins.dfs.VisualCounterflowLogic; |
239 | @@ -38,6 +39,7 @@ |
240 | import org.workcraft.plugins.dfs.stg.StgGenerator; |
241 | import org.workcraft.plugins.petri.Place; |
242 | import org.workcraft.plugins.petri.Transition; |
243 | +import org.workcraft.plugins.petri.VisualPlace; |
244 | import org.workcraft.plugins.shared.CommonSimulationSettings; |
245 | import org.workcraft.plugins.stg.VisualSignalTransition; |
246 | import org.workcraft.plugins.stg.tools.StgSimulationTool; |
247 | @@ -64,12 +66,31 @@ |
248 | generator = new StgGenerator((VisualDfs)model); |
249 | return generator.getStg(); |
250 | } |
251 | + |
252 | + private VisualPlace getVisualPlace(Place place) { |
253 | + VisualPlace result = null; |
254 | + for (VisualPlace vp: Hierarchy.getDescendantsOfType(visualNet.getRoot(), VisualPlace.class)) { |
255 | + if (vp.getReferencedPlace() == place) { |
256 | + result = vp; |
257 | + break; |
258 | + } |
259 | + } |
260 | + return result; |
261 | + } |
262 | + |
263 | + private void copyTokenColor(VisualAbstractRegister r, Node nodeM) { |
264 | + VisualPlace vp = getVisualPlace((Place)nodeM); |
265 | + if (vp != null) { |
266 | + r.setTokenColor(vp.getTokenColor()); |
267 | + } |
268 | + } |
269 | |
270 | @Override |
271 | public void applyInitState(final GraphEditor editor) { |
272 | if ((savedState == null) || savedState.isEmpty()) { |
273 | return; |
274 | } |
275 | + editor.getWorkspaceEntry().saveMemento(); |
276 | VisualDfs dfs = (VisualDfs)editor.getModel(); |
277 | for(VisualLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualLogic.class)) { |
278 | String refC = StgGenerator.nameC + dfs.getNodeMathReference(l) + StgGenerator.name1; |
279 | @@ -85,6 +106,7 @@ |
280 | if ((nodeM instanceof Place) && savedState.containsKey(nodeM)) { |
281 | boolean marked = (savedState.get(nodeM) > 0); |
282 | r.getReferencedRegister().setMarked(marked); |
283 | + copyTokenColor(r, nodeM); |
284 | } |
285 | } |
286 | for(VisualCounterflowLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualCounterflowLogic.class)) { |
287 | @@ -107,12 +129,14 @@ |
288 | if ((nodeOrM instanceof Place) && savedState.containsKey(nodeOrM)) { |
289 | boolean orMarked = (savedState.get(nodeOrM) > 0); |
290 | r.getReferencedCounterflowRegister().setOrMarked(orMarked); |
291 | + copyTokenColor(r, nodeOrM); |
292 | } |
293 | String refAndM = StgGenerator.nameAndM + dfs.getNodeMathReference(r) + StgGenerator.name1; |
294 | Node nodeAndM = net.getNodeByReference(refAndM); |
295 | if ((nodeAndM instanceof Place) && savedState.containsKey(nodeAndM)) { |
296 | boolean andMarked = (savedState.get(nodeAndM) > 0); |
297 | r.getReferencedCounterflowRegister().setAndMarked(andMarked); |
298 | + copyTokenColor(r, nodeAndM); |
299 | } |
300 | } |
301 | for(VisualBinaryRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualBinaryRegister.class)) { |
302 | @@ -123,6 +147,7 @@ |
303 | if (savedState.get(nodeTrueM) > 0) { |
304 | r.getReferencedBinaryRegister().setMarking(Marking.TRUE_TOKEN); |
305 | } |
306 | + copyTokenColor(r, nodeTrueM); |
307 | } |
308 | String refFalseM = StgGenerator.nameFalseM + dfs.getNodeMathReference(r) + StgGenerator.name1; |
309 | Node nodeFalseM = net.getNodeByReference(refFalseM); |
310 | @@ -130,6 +155,7 @@ |
311 | if (savedState.get(nodeFalseM) > 0) { |
312 | r.getReferencedBinaryRegister().setMarking(Marking.FALSE_TOKEN); |
313 | } |
314 | + copyTokenColor(r, nodeFalseM); |
315 | } |
316 | } |
317 | } |
318 | |
319 | === modified file 'FsmPlugin/src/org/workcraft/plugins/fsm/Fsm.java' |
320 | --- FsmPlugin/src/org/workcraft/plugins/fsm/Fsm.java 2015-04-23 12:19:54 +0000 |
321 | +++ FsmPlugin/src/org/workcraft/plugins/fsm/Fsm.java 2015-05-27 12:15:56 +0000 |
322 | @@ -43,7 +43,6 @@ |
323 | new SymbolConsistencySupervisor(this).attach(getRoot()); |
324 | } |
325 | |
326 | - |
327 | public State createState(String name) { |
328 | return createNode(name, null, State.class); |
329 | } |
330 | |
331 | === modified file 'FsmPlugin/src/org/workcraft/plugins/fsm/tools/FsmSimulationTool.java' |
332 | --- FsmPlugin/src/org/workcraft/plugins/fsm/tools/FsmSimulationTool.java 2015-05-06 20:28:22 +0000 |
333 | +++ FsmPlugin/src/org/workcraft/plugins/fsm/tools/FsmSimulationTool.java 2015-05-27 12:15:56 +0000 |
334 | @@ -5,6 +5,7 @@ |
335 | |
336 | import org.workcraft.dom.Container; |
337 | import org.workcraft.dom.Node; |
338 | +import org.workcraft.dom.math.MathModel; |
339 | import org.workcraft.dom.visual.HitMan; |
340 | import org.workcraft.dom.visual.VisualGroup; |
341 | import org.workcraft.dom.visual.VisualModel; |
342 | @@ -15,6 +16,8 @@ |
343 | import org.workcraft.gui.graph.tools.Decoration; |
344 | import org.workcraft.gui.graph.tools.Decorator; |
345 | import org.workcraft.gui.graph.tools.GraphEditor; |
346 | +import org.workcraft.plugins.fsm.Fsm; |
347 | +import org.workcraft.plugins.fsm.State; |
348 | import org.workcraft.plugins.fsm.VisualEvent; |
349 | import org.workcraft.plugins.fsm.VisualFsm; |
350 | import org.workcraft.plugins.fsm.VisualState; |
351 | @@ -66,13 +69,17 @@ |
352 | if ((savedState == null) || savedState.isEmpty()) { |
353 | return; |
354 | } |
355 | - VisualFsm fsm = (VisualFsm)editor.getModel(); |
356 | - for (VisualState state: fsm.getVisualStates()) { |
357 | - String ref = fsm.getNodeMathReference(state); |
358 | - Node node = net.getNodeByReference(ref); |
359 | - if (node instanceof Place) { |
360 | - boolean isInitial = ((Place)node).getTokens() > 0; |
361 | - state.getReferencedState().setInitial(isInitial); |
362 | + MathModel model = editor.getModel().getMathModel(); |
363 | + if (model instanceof Fsm) { |
364 | + editor.getWorkspaceEntry().saveMemento(); |
365 | + Fsm fsm = (Fsm)model; |
366 | + for (State state: fsm.getStates()) { |
367 | + String ref = fsm.getNodeReference(state); |
368 | + Node node = net.getNodeByReference(ref); |
369 | + if (node instanceof Place) { |
370 | + boolean isInitial = ((Place)node).getTokens() > 0; |
371 | + state.setInitial(isInitial); |
372 | + } |
373 | } |
374 | } |
375 | } |
376 | |
377 | === modified file 'FstPlugin/src/org/workcraft/plugins/fst/tools/FstSimulationTool.java' |
378 | --- FstPlugin/src/org/workcraft/plugins/fst/tools/FstSimulationTool.java 2015-05-06 20:28:22 +0000 |
379 | +++ FstPlugin/src/org/workcraft/plugins/fst/tools/FstSimulationTool.java 2015-05-27 12:15:56 +0000 |
380 | @@ -5,6 +5,7 @@ |
381 | |
382 | import org.workcraft.dom.Container; |
383 | import org.workcraft.dom.Node; |
384 | +import org.workcraft.dom.math.MathModel; |
385 | import org.workcraft.dom.visual.HitMan; |
386 | import org.workcraft.dom.visual.VisualGroup; |
387 | import org.workcraft.dom.visual.VisualModel; |
388 | @@ -15,8 +16,10 @@ |
389 | import org.workcraft.gui.graph.tools.Decoration; |
390 | import org.workcraft.gui.graph.tools.Decorator; |
391 | import org.workcraft.gui.graph.tools.GraphEditor; |
392 | +import org.workcraft.plugins.fsm.State; |
393 | import org.workcraft.plugins.fsm.VisualEvent; |
394 | import org.workcraft.plugins.fsm.VisualState; |
395 | +import org.workcraft.plugins.fst.Fst; |
396 | import org.workcraft.plugins.fst.VisualFst; |
397 | import org.workcraft.plugins.petri.Place; |
398 | import org.workcraft.plugins.petri.Transition; |
399 | @@ -63,13 +66,17 @@ |
400 | if ((savedState == null) || savedState.isEmpty()) { |
401 | return; |
402 | } |
403 | - VisualFst fst = (VisualFst)editor.getModel(); |
404 | - for (VisualState state: fst.getVisualStates()) { |
405 | - String ref = fst.getNodeMathReference(state); |
406 | - Node node = net.getNodeByReference(ref); |
407 | - if (node instanceof Place) { |
408 | - boolean isInitial = ((Place)node).getTokens() > 0; |
409 | - state.getReferencedState().setInitial(isInitial); |
410 | + MathModel model = editor.getModel().getMathModel(); |
411 | + if (model instanceof Fst) { |
412 | + editor.getWorkspaceEntry().saveMemento(); |
413 | + Fst fst = (Fst)model; |
414 | + for (State state: fst.getStates()) { |
415 | + String ref = fst.getNodeReference(state); |
416 | + Node node = net.getNodeByReference(ref); |
417 | + if (node instanceof Place) { |
418 | + boolean isInitial = ((Place)node).getTokens() > 0; |
419 | + state.setInitial(isInitial); |
420 | + } |
421 | } |
422 | } |
423 | } |
424 | |
425 | === modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/gui/MpsatConfigurationDialog.java' |
426 | --- MpsatPlugin/src/org/workcraft/plugins/mpsat/gui/MpsatConfigurationDialog.java 2015-05-22 17:42:39 +0000 |
427 | +++ MpsatPlugin/src/org/workcraft/plugins/mpsat/gui/MpsatConfigurationDialog.java 2015-05-27 12:15:56 +0000 |
428 | @@ -26,9 +26,6 @@ |
429 | import javax.swing.JTextArea; |
430 | import javax.swing.JTextField; |
431 | import javax.swing.KeyStroke; |
432 | -import javax.swing.text.AttributeSet; |
433 | -import javax.swing.text.BadLocationException; |
434 | -import javax.swing.text.PlainDocument; |
435 | |
436 | import org.workcraft.dom.hierarchy.NamespaceHelper; |
437 | import org.workcraft.gui.DesktopApi; |
438 | @@ -42,6 +39,7 @@ |
439 | import org.workcraft.plugins.shared.presets.PresetManager; |
440 | import org.workcraft.plugins.shared.presets.SettingsToControlsMapper; |
441 | import org.workcraft.util.GUI; |
442 | +import org.workcraft.util.IntDocument; |
443 | |
444 | @SuppressWarnings("serial") |
445 | public class MpsatConfigurationDialog extends JDialog { |
446 | @@ -72,25 +70,6 @@ |
447 | return description; |
448 | } |
449 | } |
450 | - |
451 | - class IntDocument extends PlainDocument { |
452 | - private int limit; |
453 | - |
454 | - public IntDocument(int limit) { |
455 | - super(); |
456 | - this.limit = limit; |
457 | - } |
458 | - |
459 | - @Override |
460 | - public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException { |
461 | - if (str != null) { |
462 | - String s = str.replaceAll("\\D++", ""); |
463 | - if (getLength() + s.length() <= limit) { |
464 | - super.insertString(offset, s, attr); |
465 | - } |
466 | - } |
467 | - } |
468 | - } |
469 | |
470 | public MpsatConfigurationDialog(Window owner, PresetManager<MpsatSettings> presetManager) { |
471 | super(owner, "Custom property definition", ModalityType.APPLICATION_MODAL); |
472 | @@ -226,14 +205,12 @@ |
473 | solutionModePanel.add(allSolutionsRadioButton); |
474 | |
475 | solutionLimitText = new JTextField(); |
476 | - solutionLimitText.setText("WWW"); |
477 | - |
478 | + Dimension dimension = solutionLimitText.getPreferredSize(); |
479 | + dimension.width = 38; |
480 | + solutionLimitText.setPreferredSize(dimension); |
481 | solutionLimitText.setToolTipText("Maximum number of solutions. Leave blank for no limit."); |
482 | - Dimension soludioLimitDimention = solutionLimitText.getPreferredSize(); |
483 | - solutionLimitText.setText(""); |
484 | - solutionLimitText.setPreferredSize(soludioLimitDimention); |
485 | + solutionLimitText.setDocument(new IntDocument(3)); |
486 | solutionLimitText.setEnabled(false); |
487 | - solutionLimitText.setDocument(new IntDocument(3)); |
488 | solutionModePanel.add(solutionLimitText); |
489 | optionsPanel.add(solutionModePanel); |
490 | optionsPanel.add(new SimpleFlowLayout.LineBreak()); |
491 | |
492 | === modified file 'PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java' |
493 | --- PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java 2015-05-22 17:42:39 +0000 |
494 | +++ PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java 2015-05-27 12:15:56 +0000 |
495 | @@ -667,6 +667,7 @@ |
496 | } |
497 | MathModel model = editor.getModel().getMathModel(); |
498 | if (model instanceof PetriNetModel) { |
499 | + editor.getWorkspaceEntry().saveMemento(); |
500 | PetriNetModel pn = (PetriNetModel)model; |
501 | for (Place place: savedState.keySet()) { |
502 | String ref = net.getNodeReference(place); |
503 | |
504 | === modified file 'PolicyNetPlugin/src/org/workcraft/plugins/policy/PolicyNetToolProvider.java' |
505 | --- PolicyNetPlugin/src/org/workcraft/plugins/policy/PolicyNetToolProvider.java 2014-09-09 20:42:17 +0000 |
506 | +++ PolicyNetPlugin/src/org/workcraft/plugins/policy/PolicyNetToolProvider.java 2015-05-27 12:15:56 +0000 |
507 | @@ -10,7 +10,7 @@ |
508 | import org.workcraft.gui.graph.tools.NodeGeneratorTool; |
509 | import org.workcraft.plugins.petri.Place; |
510 | import org.workcraft.plugins.policy.tools.SelectionTool; |
511 | -import org.workcraft.plugins.policy.tools.SimulationTool; |
512 | +import org.workcraft.plugins.policy.tools.PolicySimulationTool; |
513 | |
514 | public class PolicyNetToolProvider implements CustomToolsProvider { |
515 | |
516 | @@ -24,7 +24,7 @@ |
517 | |
518 | result.add(new NodeGeneratorTool(new DefaultNodeGenerator(Place.class))); |
519 | result.add(new NodeGeneratorTool(new DefaultNodeGenerator(BundledTransition.class))); |
520 | - result.add(new SimulationTool()); |
521 | + result.add(new PolicySimulationTool()); |
522 | |
523 | return result; |
524 | } |
525 | |
526 | === renamed file 'PolicyNetPlugin/src/org/workcraft/plugins/policy/tools/SimulationTool.java' => 'PolicyNetPlugin/src/org/workcraft/plugins/policy/tools/PolicySimulationTool.java' |
527 | --- PolicyNetPlugin/src/org/workcraft/plugins/policy/tools/SimulationTool.java 2015-05-15 11:47:39 +0000 |
528 | +++ PolicyNetPlugin/src/org/workcraft/plugins/policy/tools/PolicySimulationTool.java 2015-05-27 12:15:56 +0000 |
529 | @@ -6,6 +6,7 @@ |
530 | |
531 | import org.workcraft.dom.Container; |
532 | import org.workcraft.dom.Node; |
533 | +import org.workcraft.dom.math.MathModel; |
534 | import org.workcraft.dom.visual.HitMan; |
535 | import org.workcraft.dom.visual.VisualGroup; |
536 | import org.workcraft.dom.visual.VisualModel; |
537 | @@ -22,12 +23,13 @@ |
538 | import org.workcraft.plugins.petri.VisualTransition; |
539 | import org.workcraft.plugins.petri.tools.PetriNetSimulationTool; |
540 | import org.workcraft.plugins.petri.tools.PlaceDecoration; |
541 | +import org.workcraft.plugins.policy.PolicyNet; |
542 | import org.workcraft.plugins.policy.VisualBundledTransition; |
543 | import org.workcraft.plugins.policy.VisualPolicyNet; |
544 | import org.workcraft.plugins.shared.CommonSimulationSettings; |
545 | import org.workcraft.util.Func; |
546 | |
547 | -public class SimulationTool extends PetriNetSimulationTool { |
548 | +public class PolicySimulationTool extends PetriNetSimulationTool { |
549 | private PetriNetGenerator generator; |
550 | |
551 | @Override |
552 | @@ -47,13 +49,17 @@ |
553 | if ((savedState == null) || savedState.isEmpty()) { |
554 | return; |
555 | } |
556 | - VisualPolicyNet policy = (VisualPolicyNet)editor.getModel(); |
557 | - for (VisualPlace place: policy.getVisualPlaces()) { |
558 | - String ref = policy.getNodeMathReference(place); |
559 | - Node node = net.getNodeByReference(ref); |
560 | - if (node instanceof Place) { |
561 | - int tokens = ((Place)node).getTokens(); |
562 | - place.getReferencedPlace().setTokens(tokens); |
563 | + MathModel model = editor.getModel().getMathModel(); |
564 | + if (model instanceof PolicyNet) { |
565 | + editor.getWorkspaceEntry().saveMemento(); |
566 | + PolicyNet policy = (PolicyNet)model; |
567 | + for (Place place: policy.getPlaces()) { |
568 | + String ref = policy.getNodeReference(place); |
569 | + Node node = net.getNodeByReference(ref); |
570 | + if (node instanceof Place) { |
571 | + int tokens = ((Place)node).getTokens(); |
572 | + place.setTokens(tokens); |
573 | + } |
574 | } |
575 | } |
576 | } |
577 | |
578 | === modified file 'STGPlugin/src/org/workcraft/plugins/stg/tools/StgSimulationTool.java' |
579 | --- STGPlugin/src/org/workcraft/plugins/stg/tools/StgSimulationTool.java 2015-05-15 11:47:39 +0000 |
580 | +++ STGPlugin/src/org/workcraft/plugins/stg/tools/StgSimulationTool.java 2015-05-27 12:15:56 +0000 |
581 | @@ -31,7 +31,6 @@ |
582 | import org.workcraft.plugins.stg.VisualImplicitPlaceArc; |
583 | import org.workcraft.plugins.stg.VisualSTG; |
584 | import org.workcraft.util.ColorGenerator; |
585 | -import org.workcraft.util.Pair; |
586 | |
587 | public class StgSimulationTool extends PetriNetSimulationTool { |
588 | private static Color inputsColor = Color.RED.darker(); |
589 | |
590 | === modified file 'WorkcraftCore/src/org/workcraft/dom/visual/VisualModel.java' |
591 | --- WorkcraftCore/src/org/workcraft/dom/visual/VisualModel.java 2015-05-19 18:01:37 +0000 |
592 | +++ WorkcraftCore/src/org/workcraft/dom/visual/VisualModel.java 2015-05-27 12:15:56 +0000 |
593 | @@ -74,4 +74,4 @@ |
594 | public void setTemplateNode(VisualNode node); |
595 | public VisualNode getTemplateNode(); |
596 | |
597 | -} |
598 | \ No newline at end of file |
599 | +} |
600 | |
601 | === modified file 'WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java' |
602 | --- WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java 2015-05-22 17:42:39 +0000 |
603 | +++ WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java 2015-05-27 12:15:56 +0000 |
604 | @@ -33,6 +33,7 @@ |
605 | import javax.swing.JFrame; |
606 | import javax.swing.JPanel; |
607 | import javax.swing.JScrollPane; |
608 | +import javax.swing.JTable; |
609 | import javax.swing.JTree; |
610 | import javax.swing.event.TreeSelectionEvent; |
611 | import javax.swing.event.TreeSelectionListener; |
612 | @@ -81,6 +82,7 @@ |
613 | super(owner); |
614 | |
615 | propertiesTable = new PropertyEditorTable(); |
616 | + propertiesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); |
617 | |
618 | setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); |
619 | setModal(true); |
620 | @@ -92,12 +94,15 @@ |
621 | } |
622 | }); |
623 | |
624 | + Dimension minSize = new Dimension(640, 480); |
625 | + setMinimumSize(minSize); |
626 | + Dimension mySize = new Dimension(900, 600); |
627 | + setSize(mySize); |
628 | + |
629 | Dimension parentSize = owner.getSize(); |
630 | - this.setSize(parentSize.width / 2, parentSize.height / 2); |
631 | - Dimension mySize = getSize(); |
632 | owner.getLocationOnScreen(); |
633 | + setLocation(((parentSize.width - mySize.width)/2) + 0, ((parentSize.height - mySize.height)/2) + 0); |
634 | |
635 | - this.setLocation(((parentSize.width - mySize.width)/2) + 0, ((parentSize.height - mySize.height)/2) + 0); |
636 | initComponents(); |
637 | loadSections(); |
638 | } |
639 | @@ -195,7 +200,7 @@ |
640 | |
641 | sectionScroll.setViewportView(sectionTree); |
642 | sectionScroll.setMinimumSize(new Dimension (200,0)); |
643 | - sectionScroll.setPreferredSize(new Dimension (200,0)); |
644 | + sectionScroll.setPreferredSize(new Dimension (250,0)); |
645 | sectionScroll.setBorder(BorderFactory.createTitledBorder("Section")); |
646 | |
647 | propertiesPane = new JPanel(); |
648 | |
649 | === added file 'WorkcraftCore/src/org/workcraft/util/IntDocument.java' |
650 | --- WorkcraftCore/src/org/workcraft/util/IntDocument.java 1970-01-01 00:00:00 +0000 |
651 | +++ WorkcraftCore/src/org/workcraft/util/IntDocument.java 2015-05-27 12:15:56 +0000 |
652 | @@ -0,0 +1,26 @@ |
653 | +package org.workcraft.util; |
654 | + |
655 | +import javax.swing.text.AttributeSet; |
656 | +import javax.swing.text.BadLocationException; |
657 | +import javax.swing.text.PlainDocument; |
658 | + |
659 | +@SuppressWarnings("serial") |
660 | +public class IntDocument extends PlainDocument { |
661 | + private int limit; |
662 | + |
663 | + public IntDocument(int limit) { |
664 | + super(); |
665 | + this.limit = limit; |
666 | + } |
667 | + |
668 | + @Override |
669 | + public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException { |
670 | + if (str != null) { |
671 | + String s = str.replaceAll("\\D++", ""); |
672 | + if (getLength() + s.length() <= limit) { |
673 | + super.insertString(offset, s, attr); |
674 | + } |
675 | + } |
676 | + } |
677 | + |
678 | +} |