Merge lp:~danilovesky/workcraft/trunk-bug-1459158 into lp:workcraft

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
Reviewer Review Type Date Requested Status
Danil Sokolov Approve
Review via email: mp+260281@code.launchpad.net
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
=== modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/Circuit.java'
--- CircuitPlugin/src/org/workcraft/plugins/circuit/Circuit.java 2015-04-23 12:19:54 +0000
+++ CircuitPlugin/src/org/workcraft/plugins/circuit/Circuit.java 2015-05-27 12:15:56 +0000
@@ -21,6 +21,8 @@
2121
22package org.workcraft.plugins.circuit;22package org.workcraft.plugins.circuit;
2323
24import java.util.Collection;
25
24import org.workcraft.dom.Container;26import org.workcraft.dom.Container;
25import org.workcraft.dom.Node;27import org.workcraft.dom.Node;
26import org.workcraft.dom.hierarchy.NamespaceProvider;28import org.workcraft.dom.hierarchy.NamespaceProvider;
@@ -77,6 +79,10 @@
77 return con;79 return con;
78 }80 }
7981
82 public Collection<FunctionContact> getFunctionContacts() {
83 return Hierarchy.getDescendantsOfType(getRoot(), FunctionContact.class);
84 }
85
80 @Override86 @Override
81 public ModelProperties getProperties(Node node) {87 public ModelProperties getProperties(Node node) {
82 ModelProperties properties = super.getProperties(node);88 ModelProperties properties = super.getProperties(node);
8389
=== modified file 'CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java'
--- CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java 2015-05-20 22:01:06 +0000
+++ CircuitPlugin/src/org/workcraft/plugins/circuit/tools/CircuitSimulationTool.java 2015-05-27 12:15:56 +0000
@@ -7,6 +7,7 @@
7import org.workcraft.dom.Node;7import org.workcraft.dom.Node;
8import org.workcraft.dom.hierarchy.NamespaceHelper;8import org.workcraft.dom.hierarchy.NamespaceHelper;
9import org.workcraft.dom.hierarchy.NamespaceProvider;9import org.workcraft.dom.hierarchy.NamespaceProvider;
10import org.workcraft.dom.math.MathModel;
10import org.workcraft.dom.visual.HitMan;11import org.workcraft.dom.visual.HitMan;
11import org.workcraft.dom.visual.VisualGroup;12import org.workcraft.dom.visual.VisualGroup;
12import org.workcraft.dom.visual.VisualModel;13import org.workcraft.dom.visual.VisualModel;
@@ -17,12 +18,13 @@
17import org.workcraft.gui.graph.tools.Decoration;18import org.workcraft.gui.graph.tools.Decoration;
18import org.workcraft.gui.graph.tools.Decorator;19import org.workcraft.gui.graph.tools.Decorator;
19import org.workcraft.gui.graph.tools.GraphEditor;20import org.workcraft.gui.graph.tools.GraphEditor;
21import org.workcraft.plugins.circuit.Circuit;
20import org.workcraft.plugins.circuit.CircuitSettings;22import org.workcraft.plugins.circuit.CircuitSettings;
21import org.workcraft.plugins.circuit.CircuitUtils;23import org.workcraft.plugins.circuit.CircuitUtils;
24import org.workcraft.plugins.circuit.FunctionContact;
22import org.workcraft.plugins.circuit.VisualCircuit;25import org.workcraft.plugins.circuit.VisualCircuit;
23import org.workcraft.plugins.circuit.VisualCircuitConnection;26import org.workcraft.plugins.circuit.VisualCircuitConnection;
24import org.workcraft.plugins.circuit.VisualContact;27import org.workcraft.plugins.circuit.VisualContact;
25import org.workcraft.plugins.circuit.VisualFunctionContact;
26import org.workcraft.plugins.circuit.VisualJoint;28import org.workcraft.plugins.circuit.VisualJoint;
27import org.workcraft.plugins.circuit.stg.CircuitToStgConverter;29import org.workcraft.plugins.circuit.stg.CircuitToStgConverter;
28import org.workcraft.plugins.circuit.stg.SignalStg;30import org.workcraft.plugins.circuit.stg.SignalStg;
@@ -107,14 +109,18 @@
107 if ((savedState == null) || savedState.isEmpty()) {109 if ((savedState == null) || savedState.isEmpty()) {
108 return;110 return;
109 }111 }
110 VisualCircuit circuit = (VisualCircuit)editor.getModel();112 MathModel model = editor.getModel().getMathModel();
111 for (VisualFunctionContact contact : circuit.getVisualFunctionContacts()) {113 if (model instanceof Circuit) {
112 String contactName = CircuitUtils.getContactName(circuit, contact);114 editor.getWorkspaceEntry().saveMemento();
113 String ref = contactName + CircuitToStgConverter.NAME_SUFFIX_1;115 Circuit circuit = (Circuit)model;
114 Node node = net.getNodeByReference(ref);116 for (FunctionContact contact : circuit.getFunctionContacts()) {
115 if ((node instanceof Place) && savedState.containsKey(node)) {117 String contactName = CircuitUtils.getContactName(circuit, contact);
116 boolean initToOne = (savedState.get(node) > 0); 118 String ref = contactName + CircuitToStgConverter.NAME_SUFFIX_1;
117 contact.getReferencedContact().setInitToOne(initToOne);119 Node node = net.getNodeByReference(ref);
120 if ((node instanceof Place) && savedState.containsKey(node)) {
121 boolean initToOne = (savedState.get(node) > 0);
122 contact.setInitToOne(initToOne);
123 }
118 }124 }
119 }125 }
120 }126 }
121127
=== modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tools/CycleAnaliserTool.java'
--- DfsPlugin/src/org/workcraft/plugins/dfs/tools/CycleAnaliserTool.java 2015-03-02 12:18:03 +0000
+++ DfsPlugin/src/org/workcraft/plugins/dfs/tools/CycleAnaliserTool.java 2015-05-27 12:15:56 +0000
@@ -11,7 +11,6 @@
11import java.awt.event.MouseEvent;11import java.awt.event.MouseEvent;
12import java.awt.event.MouseListener;12import java.awt.event.MouseListener;
13import java.text.DecimalFormat;13import java.text.DecimalFormat;
14import java.text.NumberFormat;
15import java.util.ArrayList;14import java.util.ArrayList;
16import java.util.Collection;15import java.util.Collection;
17import java.util.Collections;16import java.util.Collections;
@@ -20,14 +19,14 @@
20import java.util.List;19import java.util.List;
2120
22import javax.swing.Icon;21import javax.swing.Icon;
23import javax.swing.JFormattedTextField;
24import javax.swing.JLabel;22import javax.swing.JLabel;
25import javax.swing.JPanel;23import javax.swing.JPanel;
26import javax.swing.JScrollPane;24import javax.swing.JScrollPane;
27import javax.swing.JTable;25import javax.swing.JTable;
26import javax.swing.JTextField;
28import javax.swing.ListSelectionModel;27import javax.swing.ListSelectionModel;
29import javax.swing.table.AbstractTableModel;28import javax.swing.table.AbstractTableModel;
30import javax.swing.text.NumberFormatter;29import javax.swing.table.TableColumnModel;
3130
32import org.workcraft.dom.Node;31import org.workcraft.dom.Node;
33import org.workcraft.dom.visual.VisualComponent;32import org.workcraft.dom.visual.VisualComponent;
@@ -39,6 +38,7 @@
39import org.workcraft.plugins.dfs.VisualDfs;38import org.workcraft.plugins.dfs.VisualDfs;
40import org.workcraft.util.GUI;39import org.workcraft.util.GUI;
41import org.workcraft.util.Hierarchy;40import org.workcraft.util.Hierarchy;
41import org.workcraft.util.IntDocument;
42import org.workcraft.util.graph.cycle.ElementaryCyclesSearch;42import org.workcraft.util.graph.cycle.ElementaryCyclesSearch;
4343
44public class CycleAnaliserTool extends AbstractTool {44public class CycleAnaliserTool extends AbstractTool {
@@ -61,22 +61,25 @@
61 protected JPanel controlPanel;61 protected JPanel controlPanel;
62 protected JScrollPane infoPanel;62 protected JScrollPane infoPanel;
63 protected JPanel statusPanel;63 protected JPanel statusPanel;
64 protected JTable cycleTable;64 private JTable cycleTable;
65 private JLabel cycleCountLabel;
6566
66 @Override67 @Override
67 public void createInterfacePanel(final GraphEditor editor) {68 public void createInterfacePanel(final GraphEditor editor) {
68 controlPanel = new JPanel();69 controlPanel = new JPanel();
69 cycleTable = new JTable(new CycleTableModel());70 cycleTable = new JTable(new CycleTableModel());
70 cycleTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);71 cycleTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
71 cycleTable.getColumnModel().getColumn(COLUMN_THROUGHPUT).setPreferredWidth(50);72 TableColumnModel columnModel = cycleTable.getColumnModel();
72 cycleTable.getColumnModel().getColumn(COLUMN_TOKEN).setPreferredWidth(30);73 columnModel.getColumn(COLUMN_THROUGHPUT).setPreferredWidth(50);
73 cycleTable.getColumnModel().getColumn(COLUMN_DELAY).setPreferredWidth(30);74 columnModel.getColumn(COLUMN_TOKEN).setPreferredWidth(30);
74 cycleTable.getColumnModel().getColumn(COLUMN_CYCLE).setPreferredWidth(300);75 columnModel.getColumn(COLUMN_DELAY).setPreferredWidth(30);
76 columnModel.getColumn(COLUMN_CYCLE).setPreferredWidth(300);
75 cycleTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);77 cycleTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
78 cycleTable.setAutoCreateColumnsFromModel(false);
76 cycleTable.addMouseListener(new MouseListener() {79 cycleTable.addMouseListener(new MouseListener() {
77 public void mouseClicked(MouseEvent e) {80 public void mouseClicked(MouseEvent e) {
78 int selectedRow = cycleTable.getSelectedRow();81 int selectedRow = cycleTable.getSelectedRow();
79 if (cycles != null && selectedRow >= 0 && selectedRow < cycles.size()) {82 if ((cycles != null) && (selectedRow >= 0) && (selectedRow < cycles.size())) {
80 Cycle curCycle = cycles.get(selectedRow);83 Cycle curCycle = cycles.get(selectedRow);
81 if (selectedCycle != curCycle) {84 if (selectedCycle != curCycle) {
82 selectedCycle = curCycle;85 selectedCycle = curCycle;
@@ -109,21 +112,24 @@
109 interfacePanel.add(controlPanel, BorderLayout.PAGE_START);112 interfacePanel.add(controlPanel, BorderLayout.PAGE_START);
110 interfacePanel.add(infoPanel, BorderLayout.CENTER);113 interfacePanel.add(infoPanel, BorderLayout.CENTER);
111 interfacePanel.add(statusPanel, BorderLayout.PAGE_END);114 interfacePanel.add(statusPanel, BorderLayout.PAGE_END);
115 interfacePanel.setPreferredSize(new Dimension(0, 0));
112116
113 NumberFormat format = NumberFormat.getIntegerInstance();117 final JTextField cycleCountText = new JTextField();
114 NumberFormatter formatter = new NumberFormatter(format);118 Dimension dimension = cycleCountText.getPreferredSize();
115 formatter.setAllowsInvalid(false);119 dimension.width = 40;
116 formatter.setMinimum(1);120 cycleCountText.setPreferredSize(dimension);
117 formatter.setMaximum(1000);121 cycleCountText.setDocument(new IntDocument(3));
118 final JFormattedTextField cycleCountText = new JFormattedTextField(formatter);
119 cycleCountText.setPreferredSize(new Dimension(100, 24));
120 cycleCountText.setText(new Integer(cycleCount).toString());122 cycleCountText.setText(new Integer(cycleCount).toString());
121 cycleCountText.addKeyListener(new KeyListener() {123 cycleCountText.addKeyListener(new KeyListener() {
122 @Override124 @Override
123 public void keyPressed(KeyEvent arg0) {125 public void keyPressed(KeyEvent arg0) {
124 if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {126 if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
125 cycleCount = Integer.parseInt(cycleCountText.getText());127 try {
126 resetSelectedCycle(editor); 128 cycleCount = Integer.parseInt(cycleCountText.getText());
129 resetSelectedCycle(editor);
130 } catch (NumberFormatException e) {
131 cycleCountText.setText(new Integer(cycleCount).toString());
132 }
127 }133 }
128 else if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE) {134 else if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE) {
129 cycleCountText.setText(new Integer(cycleCount).toString());135 cycleCountText.setText(new Integer(cycleCount).toString());
@@ -150,7 +156,7 @@
150 }156 }
151 });157 });
152 158
153 JLabel cycleCountLabel = new JLabel();159 cycleCountLabel = new JLabel();
154 cycleCountLabel.setText("Cycle count:");160 cycleCountLabel.setText("Cycle count:");
155 cycleCountLabel.setLabelFor(cycleCountText);161 cycleCountLabel.setLabelFor(cycleCountText);
156162
@@ -170,6 +176,9 @@
170 cycleTable.clearSelection();176 cycleTable.clearSelection();
171 selectedCycle = null;177 selectedCycle = null;
172 cycles = findCycles();178 cycles = findCycles();
179 if ((cycles != null) && (cycleCountLabel != null)) {
180 cycleCountLabel.setText("Cycle count (out of " + cycles.size() + "):");
181 }
173 super.activated(editor);182 super.activated(editor);
174 editor.getWorkspaceEntry().setCanModify(false);183 editor.getWorkspaceEntry().setCanModify(false);
175 }184 }
@@ -247,7 +256,7 @@
247 256
248 public ArrayList<Cycle> findCycles() {257 public ArrayList<Cycle> findCycles() {
249 ArrayList<Cycle> result = new ArrayList<Cycle>();258 ArrayList<Cycle> result = new ArrayList<Cycle>();
250 // update global min and max delay values259 // Update global min and max delay values
251 Collection<VisualDelayComponent> allComponents = Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualDelayComponent.class);260 Collection<VisualDelayComponent> allComponents = Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualDelayComponent.class);
252 boolean first = true;261 boolean first = true;
253 for (VisualDelayComponent c: allComponents) {262 for (VisualDelayComponent c: allComponents) {
@@ -260,7 +269,7 @@
260 }269 }
261 first = false;270 first = false;
262 }271 }
263 // prepare temporary node array and adjacency matrix272 // Prepare temporary node array and adjacency matrix
264 int size = allComponents.size();273 int size = allComponents.size();
265 VisualComponent tmpComponents[] = allComponents.toArray(new VisualComponent[size]);274 VisualComponent tmpComponents[] = allComponents.toArray(new VisualComponent[size]);
266 boolean adjMatrix[][] = new boolean[size][size];275 boolean adjMatrix[][] = new boolean[size][size];
@@ -272,7 +281,7 @@
272 adjMatrix[j][i] = preset.contains(tmpComponents[j]);281 adjMatrix[j][i] = preset.contains(tmpComponents[j]);
273 }282 }
274 }283 }
275 // calculate simple cycles and process the results284 // Calculate simple cycles and process the results
276 ElementaryCyclesSearch ecs = new ElementaryCyclesSearch(adjMatrix, tmpComponents);285 ElementaryCyclesSearch ecs = new ElementaryCyclesSearch(adjMatrix, tmpComponents);
277 List tmpCycles = ecs.getElementaryCycles();286 List tmpCycles = ecs.getElementaryCycles();
278 for (int i = 0; i < tmpCycles.size(); i++) {287 for (int i = 0; i < tmpCycles.size(); i++) {
279288
=== modified file 'DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java'
--- DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java 2015-05-06 20:28:22 +0000
+++ DfsPlugin/src/org/workcraft/plugins/dfs/tools/DfsSimulationTool.java 2015-05-27 12:15:56 +0000
@@ -16,6 +16,7 @@
16import org.workcraft.gui.graph.tools.Decorator;16import org.workcraft.gui.graph.tools.Decorator;
17import org.workcraft.gui.graph.tools.GraphEditor;17import org.workcraft.gui.graph.tools.GraphEditor;
18import org.workcraft.plugins.dfs.BinaryRegister.Marking;18import org.workcraft.plugins.dfs.BinaryRegister.Marking;
19import org.workcraft.plugins.dfs.VisualAbstractRegister;
19import org.workcraft.plugins.dfs.VisualBinaryRegister;20import org.workcraft.plugins.dfs.VisualBinaryRegister;
20import org.workcraft.plugins.dfs.VisualControlRegister;21import org.workcraft.plugins.dfs.VisualControlRegister;
21import org.workcraft.plugins.dfs.VisualCounterflowLogic;22import org.workcraft.plugins.dfs.VisualCounterflowLogic;
@@ -38,6 +39,7 @@
38import org.workcraft.plugins.dfs.stg.StgGenerator;39import org.workcraft.plugins.dfs.stg.StgGenerator;
39import org.workcraft.plugins.petri.Place;40import org.workcraft.plugins.petri.Place;
40import org.workcraft.plugins.petri.Transition;41import org.workcraft.plugins.petri.Transition;
42import org.workcraft.plugins.petri.VisualPlace;
41import org.workcraft.plugins.shared.CommonSimulationSettings;43import org.workcraft.plugins.shared.CommonSimulationSettings;
42import org.workcraft.plugins.stg.VisualSignalTransition;44import org.workcraft.plugins.stg.VisualSignalTransition;
43import org.workcraft.plugins.stg.tools.StgSimulationTool;45import org.workcraft.plugins.stg.tools.StgSimulationTool;
@@ -64,12 +66,31 @@
64 generator = new StgGenerator((VisualDfs)model);66 generator = new StgGenerator((VisualDfs)model);
65 return generator.getStg();67 return generator.getStg();
66 }68 }
69
70 private VisualPlace getVisualPlace(Place place) {
71 VisualPlace result = null;
72 for (VisualPlace vp: Hierarchy.getDescendantsOfType(visualNet.getRoot(), VisualPlace.class)) {
73 if (vp.getReferencedPlace() == place) {
74 result = vp;
75 break;
76 }
77 }
78 return result;
79 }
80
81 private void copyTokenColor(VisualAbstractRegister r, Node nodeM) {
82 VisualPlace vp = getVisualPlace((Place)nodeM);
83 if (vp != null) {
84 r.setTokenColor(vp.getTokenColor());
85 }
86 }
6787
68 @Override88 @Override
69 public void applyInitState(final GraphEditor editor) {89 public void applyInitState(final GraphEditor editor) {
70 if ((savedState == null) || savedState.isEmpty()) {90 if ((savedState == null) || savedState.isEmpty()) {
71 return;91 return;
72 }92 }
93 editor.getWorkspaceEntry().saveMemento();
73 VisualDfs dfs = (VisualDfs)editor.getModel();94 VisualDfs dfs = (VisualDfs)editor.getModel();
74 for(VisualLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualLogic.class)) {95 for(VisualLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualLogic.class)) {
75 String refC = StgGenerator.nameC + dfs.getNodeMathReference(l) + StgGenerator.name1;96 String refC = StgGenerator.nameC + dfs.getNodeMathReference(l) + StgGenerator.name1;
@@ -85,6 +106,7 @@
85 if ((nodeM instanceof Place) && savedState.containsKey(nodeM)) {106 if ((nodeM instanceof Place) && savedState.containsKey(nodeM)) {
86 boolean marked = (savedState.get(nodeM) > 0);107 boolean marked = (savedState.get(nodeM) > 0);
87 r.getReferencedRegister().setMarked(marked);108 r.getReferencedRegister().setMarked(marked);
109 copyTokenColor(r, nodeM);
88 }110 }
89 }111 }
90 for(VisualCounterflowLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualCounterflowLogic.class)) {112 for(VisualCounterflowLogic l : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualCounterflowLogic.class)) {
@@ -107,12 +129,14 @@
107 if ((nodeOrM instanceof Place) && savedState.containsKey(nodeOrM)) {129 if ((nodeOrM instanceof Place) && savedState.containsKey(nodeOrM)) {
108 boolean orMarked = (savedState.get(nodeOrM) > 0);130 boolean orMarked = (savedState.get(nodeOrM) > 0);
109 r.getReferencedCounterflowRegister().setOrMarked(orMarked);131 r.getReferencedCounterflowRegister().setOrMarked(orMarked);
132 copyTokenColor(r, nodeOrM);
110 }133 }
111 String refAndM = StgGenerator.nameAndM + dfs.getNodeMathReference(r) + StgGenerator.name1;134 String refAndM = StgGenerator.nameAndM + dfs.getNodeMathReference(r) + StgGenerator.name1;
112 Node nodeAndM = net.getNodeByReference(refAndM);135 Node nodeAndM = net.getNodeByReference(refAndM);
113 if ((nodeAndM instanceof Place) && savedState.containsKey(nodeAndM)) {136 if ((nodeAndM instanceof Place) && savedState.containsKey(nodeAndM)) {
114 boolean andMarked = (savedState.get(nodeAndM) > 0);137 boolean andMarked = (savedState.get(nodeAndM) > 0);
115 r.getReferencedCounterflowRegister().setAndMarked(andMarked);138 r.getReferencedCounterflowRegister().setAndMarked(andMarked);
139 copyTokenColor(r, nodeAndM);
116 }140 }
117 }141 }
118 for(VisualBinaryRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualBinaryRegister.class)) {142 for(VisualBinaryRegister r : Hierarchy.getDescendantsOfType(dfs.getRoot(), VisualBinaryRegister.class)) {
@@ -123,6 +147,7 @@
123 if (savedState.get(nodeTrueM) > 0) {147 if (savedState.get(nodeTrueM) > 0) {
124 r.getReferencedBinaryRegister().setMarking(Marking.TRUE_TOKEN);148 r.getReferencedBinaryRegister().setMarking(Marking.TRUE_TOKEN);
125 }149 }
150 copyTokenColor(r, nodeTrueM);
126 }151 }
127 String refFalseM = StgGenerator.nameFalseM + dfs.getNodeMathReference(r) + StgGenerator.name1;152 String refFalseM = StgGenerator.nameFalseM + dfs.getNodeMathReference(r) + StgGenerator.name1;
128 Node nodeFalseM = net.getNodeByReference(refFalseM);153 Node nodeFalseM = net.getNodeByReference(refFalseM);
@@ -130,6 +155,7 @@
130 if (savedState.get(nodeFalseM) > 0) {155 if (savedState.get(nodeFalseM) > 0) {
131 r.getReferencedBinaryRegister().setMarking(Marking.FALSE_TOKEN);156 r.getReferencedBinaryRegister().setMarking(Marking.FALSE_TOKEN);
132 }157 }
158 copyTokenColor(r, nodeFalseM);
133 }159 }
134 }160 }
135 }161 }
136162
=== modified file 'FsmPlugin/src/org/workcraft/plugins/fsm/Fsm.java'
--- FsmPlugin/src/org/workcraft/plugins/fsm/Fsm.java 2015-04-23 12:19:54 +0000
+++ FsmPlugin/src/org/workcraft/plugins/fsm/Fsm.java 2015-05-27 12:15:56 +0000
@@ -43,7 +43,6 @@
43 new SymbolConsistencySupervisor(this).attach(getRoot());43 new SymbolConsistencySupervisor(this).attach(getRoot());
44 }44 }
4545
46
47 public State createState(String name) {46 public State createState(String name) {
48 return createNode(name, null, State.class);47 return createNode(name, null, State.class);
49 }48 }
5049
=== modified file 'FsmPlugin/src/org/workcraft/plugins/fsm/tools/FsmSimulationTool.java'
--- FsmPlugin/src/org/workcraft/plugins/fsm/tools/FsmSimulationTool.java 2015-05-06 20:28:22 +0000
+++ FsmPlugin/src/org/workcraft/plugins/fsm/tools/FsmSimulationTool.java 2015-05-27 12:15:56 +0000
@@ -5,6 +5,7 @@
55
6import org.workcraft.dom.Container;6import org.workcraft.dom.Container;
7import org.workcraft.dom.Node;7import org.workcraft.dom.Node;
8import org.workcraft.dom.math.MathModel;
8import org.workcraft.dom.visual.HitMan;9import org.workcraft.dom.visual.HitMan;
9import org.workcraft.dom.visual.VisualGroup;10import org.workcraft.dom.visual.VisualGroup;
10import org.workcraft.dom.visual.VisualModel;11import org.workcraft.dom.visual.VisualModel;
@@ -15,6 +16,8 @@
15import org.workcraft.gui.graph.tools.Decoration;16import org.workcraft.gui.graph.tools.Decoration;
16import org.workcraft.gui.graph.tools.Decorator;17import org.workcraft.gui.graph.tools.Decorator;
17import org.workcraft.gui.graph.tools.GraphEditor;18import org.workcraft.gui.graph.tools.GraphEditor;
19import org.workcraft.plugins.fsm.Fsm;
20import org.workcraft.plugins.fsm.State;
18import org.workcraft.plugins.fsm.VisualEvent;21import org.workcraft.plugins.fsm.VisualEvent;
19import org.workcraft.plugins.fsm.VisualFsm;22import org.workcraft.plugins.fsm.VisualFsm;
20import org.workcraft.plugins.fsm.VisualState;23import org.workcraft.plugins.fsm.VisualState;
@@ -66,13 +69,17 @@
66 if ((savedState == null) || savedState.isEmpty()) {69 if ((savedState == null) || savedState.isEmpty()) {
67 return;70 return;
68 }71 }
69 VisualFsm fsm = (VisualFsm)editor.getModel();72 MathModel model = editor.getModel().getMathModel();
70 for (VisualState state: fsm.getVisualStates()) {73 if (model instanceof Fsm) {
71 String ref = fsm.getNodeMathReference(state);74 editor.getWorkspaceEntry().saveMemento();
72 Node node = net.getNodeByReference(ref);75 Fsm fsm = (Fsm)model;
73 if (node instanceof Place) {76 for (State state: fsm.getStates()) {
74 boolean isInitial = ((Place)node).getTokens() > 0;77 String ref = fsm.getNodeReference(state);
75 state.getReferencedState().setInitial(isInitial);78 Node node = net.getNodeByReference(ref);
79 if (node instanceof Place) {
80 boolean isInitial = ((Place)node).getTokens() > 0;
81 state.setInitial(isInitial);
82 }
76 }83 }
77 }84 }
78 }85 }
7986
=== modified file 'FstPlugin/src/org/workcraft/plugins/fst/tools/FstSimulationTool.java'
--- FstPlugin/src/org/workcraft/plugins/fst/tools/FstSimulationTool.java 2015-05-06 20:28:22 +0000
+++ FstPlugin/src/org/workcraft/plugins/fst/tools/FstSimulationTool.java 2015-05-27 12:15:56 +0000
@@ -5,6 +5,7 @@
55
6import org.workcraft.dom.Container;6import org.workcraft.dom.Container;
7import org.workcraft.dom.Node;7import org.workcraft.dom.Node;
8import org.workcraft.dom.math.MathModel;
8import org.workcraft.dom.visual.HitMan;9import org.workcraft.dom.visual.HitMan;
9import org.workcraft.dom.visual.VisualGroup;10import org.workcraft.dom.visual.VisualGroup;
10import org.workcraft.dom.visual.VisualModel;11import org.workcraft.dom.visual.VisualModel;
@@ -15,8 +16,10 @@
15import org.workcraft.gui.graph.tools.Decoration;16import org.workcraft.gui.graph.tools.Decoration;
16import org.workcraft.gui.graph.tools.Decorator;17import org.workcraft.gui.graph.tools.Decorator;
17import org.workcraft.gui.graph.tools.GraphEditor;18import org.workcraft.gui.graph.tools.GraphEditor;
19import org.workcraft.plugins.fsm.State;
18import org.workcraft.plugins.fsm.VisualEvent;20import org.workcraft.plugins.fsm.VisualEvent;
19import org.workcraft.plugins.fsm.VisualState;21import org.workcraft.plugins.fsm.VisualState;
22import org.workcraft.plugins.fst.Fst;
20import org.workcraft.plugins.fst.VisualFst;23import org.workcraft.plugins.fst.VisualFst;
21import org.workcraft.plugins.petri.Place;24import org.workcraft.plugins.petri.Place;
22import org.workcraft.plugins.petri.Transition;25import org.workcraft.plugins.petri.Transition;
@@ -63,13 +66,17 @@
63 if ((savedState == null) || savedState.isEmpty()) {66 if ((savedState == null) || savedState.isEmpty()) {
64 return;67 return;
65 }68 }
66 VisualFst fst = (VisualFst)editor.getModel();69 MathModel model = editor.getModel().getMathModel();
67 for (VisualState state: fst.getVisualStates()) {70 if (model instanceof Fst) {
68 String ref = fst.getNodeMathReference(state);71 editor.getWorkspaceEntry().saveMemento();
69 Node node = net.getNodeByReference(ref);72 Fst fst = (Fst)model;
70 if (node instanceof Place) {73 for (State state: fst.getStates()) {
71 boolean isInitial = ((Place)node).getTokens() > 0;74 String ref = fst.getNodeReference(state);
72 state.getReferencedState().setInitial(isInitial);75 Node node = net.getNodeByReference(ref);
76 if (node instanceof Place) {
77 boolean isInitial = ((Place)node).getTokens() > 0;
78 state.setInitial(isInitial);
79 }
73 }80 }
74 }81 }
75 }82 }
7683
=== modified file 'MpsatPlugin/src/org/workcraft/plugins/mpsat/gui/MpsatConfigurationDialog.java'
--- MpsatPlugin/src/org/workcraft/plugins/mpsat/gui/MpsatConfigurationDialog.java 2015-05-22 17:42:39 +0000
+++ MpsatPlugin/src/org/workcraft/plugins/mpsat/gui/MpsatConfigurationDialog.java 2015-05-27 12:15:56 +0000
@@ -26,9 +26,6 @@
26import javax.swing.JTextArea;26import javax.swing.JTextArea;
27import javax.swing.JTextField;27import javax.swing.JTextField;
28import javax.swing.KeyStroke;28import javax.swing.KeyStroke;
29import javax.swing.text.AttributeSet;
30import javax.swing.text.BadLocationException;
31import javax.swing.text.PlainDocument;
3229
33import org.workcraft.dom.hierarchy.NamespaceHelper;30import org.workcraft.dom.hierarchy.NamespaceHelper;
34import org.workcraft.gui.DesktopApi;31import org.workcraft.gui.DesktopApi;
@@ -42,6 +39,7 @@
42import org.workcraft.plugins.shared.presets.PresetManager;39import org.workcraft.plugins.shared.presets.PresetManager;
43import org.workcraft.plugins.shared.presets.SettingsToControlsMapper;40import org.workcraft.plugins.shared.presets.SettingsToControlsMapper;
44import org.workcraft.util.GUI;41import org.workcraft.util.GUI;
42import org.workcraft.util.IntDocument;
4543
46@SuppressWarnings("serial")44@SuppressWarnings("serial")
47public class MpsatConfigurationDialog extends JDialog {45public class MpsatConfigurationDialog extends JDialog {
@@ -72,25 +70,6 @@
72 return description;70 return description;
73 }71 }
74 }72 }
75
76 class IntDocument extends PlainDocument {
77 private int limit;
78
79 public IntDocument(int limit) {
80 super();
81 this.limit = limit;
82 }
83
84 @Override
85 public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException {
86 if (str != null) {
87 String s = str.replaceAll("\\D++", "");
88 if (getLength() + s.length() <= limit) {
89 super.insertString(offset, s, attr);
90 }
91 }
92 }
93 }
9473
95 public MpsatConfigurationDialog(Window owner, PresetManager<MpsatSettings> presetManager) {74 public MpsatConfigurationDialog(Window owner, PresetManager<MpsatSettings> presetManager) {
96 super(owner, "Custom property definition", ModalityType.APPLICATION_MODAL);75 super(owner, "Custom property definition", ModalityType.APPLICATION_MODAL);
@@ -226,14 +205,12 @@
226 solutionModePanel.add(allSolutionsRadioButton);205 solutionModePanel.add(allSolutionsRadioButton);
227206
228 solutionLimitText = new JTextField();207 solutionLimitText = new JTextField();
229 solutionLimitText.setText("WWW");208 Dimension dimension = solutionLimitText.getPreferredSize();
230 209 dimension.width = 38;
210 solutionLimitText.setPreferredSize(dimension);
231 solutionLimitText.setToolTipText("Maximum number of solutions. Leave blank for no limit.");211 solutionLimitText.setToolTipText("Maximum number of solutions. Leave blank for no limit.");
232 Dimension soludioLimitDimention = solutionLimitText.getPreferredSize();212 solutionLimitText.setDocument(new IntDocument(3));
233 solutionLimitText.setText("");
234 solutionLimitText.setPreferredSize(soludioLimitDimention);
235 solutionLimitText.setEnabled(false);213 solutionLimitText.setEnabled(false);
236 solutionLimitText.setDocument(new IntDocument(3));
237 solutionModePanel.add(solutionLimitText);214 solutionModePanel.add(solutionLimitText);
238 optionsPanel.add(solutionModePanel);215 optionsPanel.add(solutionModePanel);
239 optionsPanel.add(new SimpleFlowLayout.LineBreak());216 optionsPanel.add(new SimpleFlowLayout.LineBreak());
240217
=== modified file 'PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java'
--- PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java 2015-05-22 17:42:39 +0000
+++ PetriNetPlugin/src/org/workcraft/plugins/petri/tools/PetriNetSimulationTool.java 2015-05-27 12:15:56 +0000
@@ -667,6 +667,7 @@
667 }667 }
668 MathModel model = editor.getModel().getMathModel();668 MathModel model = editor.getModel().getMathModel();
669 if (model instanceof PetriNetModel) {669 if (model instanceof PetriNetModel) {
670 editor.getWorkspaceEntry().saveMemento();
670 PetriNetModel pn = (PetriNetModel)model;671 PetriNetModel pn = (PetriNetModel)model;
671 for (Place place: savedState.keySet()) {672 for (Place place: savedState.keySet()) {
672 String ref = net.getNodeReference(place);673 String ref = net.getNodeReference(place);
673674
=== modified file 'PolicyNetPlugin/src/org/workcraft/plugins/policy/PolicyNetToolProvider.java'
--- PolicyNetPlugin/src/org/workcraft/plugins/policy/PolicyNetToolProvider.java 2014-09-09 20:42:17 +0000
+++ PolicyNetPlugin/src/org/workcraft/plugins/policy/PolicyNetToolProvider.java 2015-05-27 12:15:56 +0000
@@ -10,7 +10,7 @@
10import org.workcraft.gui.graph.tools.NodeGeneratorTool;10import org.workcraft.gui.graph.tools.NodeGeneratorTool;
11import org.workcraft.plugins.petri.Place;11import org.workcraft.plugins.petri.Place;
12import org.workcraft.plugins.policy.tools.SelectionTool;12import org.workcraft.plugins.policy.tools.SelectionTool;
13import org.workcraft.plugins.policy.tools.SimulationTool;13import org.workcraft.plugins.policy.tools.PolicySimulationTool;
1414
15public class PolicyNetToolProvider implements CustomToolsProvider {15public class PolicyNetToolProvider implements CustomToolsProvider {
1616
@@ -24,7 +24,7 @@
24 24
25 result.add(new NodeGeneratorTool(new DefaultNodeGenerator(Place.class)));25 result.add(new NodeGeneratorTool(new DefaultNodeGenerator(Place.class)));
26 result.add(new NodeGeneratorTool(new DefaultNodeGenerator(BundledTransition.class)));26 result.add(new NodeGeneratorTool(new DefaultNodeGenerator(BundledTransition.class)));
27 result.add(new SimulationTool());27 result.add(new PolicySimulationTool());
28 28
29 return result;29 return result;
30 }30 }
3131
=== renamed file 'PolicyNetPlugin/src/org/workcraft/plugins/policy/tools/SimulationTool.java' => 'PolicyNetPlugin/src/org/workcraft/plugins/policy/tools/PolicySimulationTool.java'
--- PolicyNetPlugin/src/org/workcraft/plugins/policy/tools/SimulationTool.java 2015-05-15 11:47:39 +0000
+++ PolicyNetPlugin/src/org/workcraft/plugins/policy/tools/PolicySimulationTool.java 2015-05-27 12:15:56 +0000
@@ -6,6 +6,7 @@
66
7import org.workcraft.dom.Container;7import org.workcraft.dom.Container;
8import org.workcraft.dom.Node;8import org.workcraft.dom.Node;
9import org.workcraft.dom.math.MathModel;
9import org.workcraft.dom.visual.HitMan;10import org.workcraft.dom.visual.HitMan;
10import org.workcraft.dom.visual.VisualGroup;11import org.workcraft.dom.visual.VisualGroup;
11import org.workcraft.dom.visual.VisualModel;12import org.workcraft.dom.visual.VisualModel;
@@ -22,12 +23,13 @@
22import org.workcraft.plugins.petri.VisualTransition;23import org.workcraft.plugins.petri.VisualTransition;
23import org.workcraft.plugins.petri.tools.PetriNetSimulationTool;24import org.workcraft.plugins.petri.tools.PetriNetSimulationTool;
24import org.workcraft.plugins.petri.tools.PlaceDecoration;25import org.workcraft.plugins.petri.tools.PlaceDecoration;
26import org.workcraft.plugins.policy.PolicyNet;
25import org.workcraft.plugins.policy.VisualBundledTransition;27import org.workcraft.plugins.policy.VisualBundledTransition;
26import org.workcraft.plugins.policy.VisualPolicyNet;28import org.workcraft.plugins.policy.VisualPolicyNet;
27import org.workcraft.plugins.shared.CommonSimulationSettings;29import org.workcraft.plugins.shared.CommonSimulationSettings;
28import org.workcraft.util.Func;30import org.workcraft.util.Func;
2931
30public class SimulationTool extends PetriNetSimulationTool {32public class PolicySimulationTool extends PetriNetSimulationTool {
31 private PetriNetGenerator generator;33 private PetriNetGenerator generator;
3234
33 @Override35 @Override
@@ -47,13 +49,17 @@
47 if ((savedState == null) || savedState.isEmpty()) {49 if ((savedState == null) || savedState.isEmpty()) {
48 return;50 return;
49 }51 }
50 VisualPolicyNet policy = (VisualPolicyNet)editor.getModel();52 MathModel model = editor.getModel().getMathModel();
51 for (VisualPlace place: policy.getVisualPlaces()) {53 if (model instanceof PolicyNet) {
52 String ref = policy.getNodeMathReference(place);54 editor.getWorkspaceEntry().saveMemento();
53 Node node = net.getNodeByReference(ref);55 PolicyNet policy = (PolicyNet)model;
54 if (node instanceof Place) {56 for (Place place: policy.getPlaces()) {
55 int tokens = ((Place)node).getTokens();57 String ref = policy.getNodeReference(place);
56 place.getReferencedPlace().setTokens(tokens);58 Node node = net.getNodeByReference(ref);
59 if (node instanceof Place) {
60 int tokens = ((Place)node).getTokens();
61 place.setTokens(tokens);
62 }
57 }63 }
58 }64 }
59 }65 }
6066
=== modified file 'STGPlugin/src/org/workcraft/plugins/stg/tools/StgSimulationTool.java'
--- STGPlugin/src/org/workcraft/plugins/stg/tools/StgSimulationTool.java 2015-05-15 11:47:39 +0000
+++ STGPlugin/src/org/workcraft/plugins/stg/tools/StgSimulationTool.java 2015-05-27 12:15:56 +0000
@@ -31,7 +31,6 @@
31import org.workcraft.plugins.stg.VisualImplicitPlaceArc;31import org.workcraft.plugins.stg.VisualImplicitPlaceArc;
32import org.workcraft.plugins.stg.VisualSTG;32import org.workcraft.plugins.stg.VisualSTG;
33import org.workcraft.util.ColorGenerator;33import org.workcraft.util.ColorGenerator;
34import org.workcraft.util.Pair;
3534
36public class StgSimulationTool extends PetriNetSimulationTool {35public class StgSimulationTool extends PetriNetSimulationTool {
37 private static Color inputsColor = Color.RED.darker();36 private static Color inputsColor = Color.RED.darker();
3837
=== modified file 'WorkcraftCore/src/org/workcraft/dom/visual/VisualModel.java'
--- WorkcraftCore/src/org/workcraft/dom/visual/VisualModel.java 2015-05-19 18:01:37 +0000
+++ WorkcraftCore/src/org/workcraft/dom/visual/VisualModel.java 2015-05-27 12:15:56 +0000
@@ -74,4 +74,4 @@
74 public void setTemplateNode(VisualNode node);74 public void setTemplateNode(VisualNode node);
75 public VisualNode getTemplateNode();75 public VisualNode getTemplateNode();
76 76
77}
78\ No newline at end of file77\ No newline at end of file
78}
7979
=== modified file 'WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java'
--- WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java 2015-05-22 17:42:39 +0000
+++ WorkcraftCore/src/org/workcraft/gui/propertyeditor/SettingsEditorDialog.java 2015-05-27 12:15:56 +0000
@@ -33,6 +33,7 @@
33import javax.swing.JFrame;33import javax.swing.JFrame;
34import javax.swing.JPanel;34import javax.swing.JPanel;
35import javax.swing.JScrollPane;35import javax.swing.JScrollPane;
36import javax.swing.JTable;
36import javax.swing.JTree;37import javax.swing.JTree;
37import javax.swing.event.TreeSelectionEvent;38import javax.swing.event.TreeSelectionEvent;
38import javax.swing.event.TreeSelectionListener;39import javax.swing.event.TreeSelectionListener;
@@ -81,6 +82,7 @@
81 super(owner);82 super(owner);
8283
83 propertiesTable = new PropertyEditorTable();84 propertiesTable = new PropertyEditorTable();
85 propertiesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
8486
85 setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);87 setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
86 setModal(true);88 setModal(true);
@@ -92,12 +94,15 @@
92 }94 }
93 });95 });
94 96
97 Dimension minSize = new Dimension(640, 480);
98 setMinimumSize(minSize);
99 Dimension mySize = new Dimension(900, 600);
100 setSize(mySize);
101
95 Dimension parentSize = owner.getSize();102 Dimension parentSize = owner.getSize();
96 this.setSize(parentSize.width / 2, parentSize.height / 2);
97 Dimension mySize = getSize();
98 owner.getLocationOnScreen();103 owner.getLocationOnScreen();
104 setLocation(((parentSize.width - mySize.width)/2) + 0, ((parentSize.height - mySize.height)/2) + 0);
99105
100 this.setLocation(((parentSize.width - mySize.width)/2) + 0, ((parentSize.height - mySize.height)/2) + 0);
101 initComponents();106 initComponents();
102 loadSections();107 loadSections();
103 }108 }
@@ -195,7 +200,7 @@
195 200
196 sectionScroll.setViewportView(sectionTree);201 sectionScroll.setViewportView(sectionTree);
197 sectionScroll.setMinimumSize(new Dimension (200,0));202 sectionScroll.setMinimumSize(new Dimension (200,0));
198 sectionScroll.setPreferredSize(new Dimension (200,0));203 sectionScroll.setPreferredSize(new Dimension (250,0));
199 sectionScroll.setBorder(BorderFactory.createTitledBorder("Section"));204 sectionScroll.setBorder(BorderFactory.createTitledBorder("Section"));
200205
201 propertiesPane = new JPanel();206 propertiesPane = new JPanel();
202207
=== added file 'WorkcraftCore/src/org/workcraft/util/IntDocument.java'
--- WorkcraftCore/src/org/workcraft/util/IntDocument.java 1970-01-01 00:00:00 +0000
+++ WorkcraftCore/src/org/workcraft/util/IntDocument.java 2015-05-27 12:15:56 +0000
@@ -0,0 +1,26 @@
1package org.workcraft.util;
2
3import javax.swing.text.AttributeSet;
4import javax.swing.text.BadLocationException;
5import javax.swing.text.PlainDocument;
6
7@SuppressWarnings("serial")
8public class IntDocument extends PlainDocument {
9 private int limit;
10
11 public IntDocument(int limit) {
12 super();
13 this.limit = limit;
14 }
15
16 @Override
17 public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException {
18 if (str != null) {
19 String s = str.replaceAll("\\D++", "");
20 if (getLength() + s.length() <= limit) {
21 super.insertString(offset, s, attr);
22 }
23 }
24 }
25
26}

Subscribers

People subscribed via source and target branches