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