Merge lp:~tapaal-contributor/tapaal/cpn-variable-color-tool-window into lp:~tapaal-contributor/tapaal/cpn-gui-dev

Proposed by Kristian Morsing Pedersen
Status: Superseded
Proposed branch: lp:~tapaal-contributor/tapaal/cpn-variable-color-tool-window
Merge into: lp:~tapaal-contributor/tapaal/cpn-gui-dev
Diff against target: 271 lines (+138/-8)
5 files modified
src/net/tapaal/gui/GuiFrameController.java (+1/-0)
src/net/tapaal/gui/TabActions.java (+2/-0)
src/net/tapaal/gui/petrinet/editor/ConstantsPane.java (+1/-1)
src/pipe/gui/GuiFrame.java (+16/-5)
src/pipe/gui/petrinet/PetriNetTab.java (+118/-2)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/cpn-variable-color-tool-window
Reviewer Review Type Date Requested Status
Jiri Srba Needs Fixing
Review via email: mp+416247@code.launchpad.net

This proposal supersedes a proposal from 2022-02-23.

This proposal has been superseded by a proposal from 2022-03-06.

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) wrote : Posted in a previous version of this proposal

open CPN token-ring net and show the color type information and it does not do it correctly for the product type Couple is (after which it does not print anything).

Could this be a problem also in tikz export?

review: Needs Fixing
Revision history for this message
Jiri Srba (srba) wrote :

The ctrl-0 abbreviation clashes with "show token age" in case of timed CPNs. Perhaps change it to ctrl-F (but double check if it is free).

review: Needs Fixing
1620. By Kristian Morsing Pedersen <email address hidden>

Changed shortcut key

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/net/tapaal/gui/GuiFrameController.java'
2--- src/net/tapaal/gui/GuiFrameController.java 2022-02-21 18:32:54 +0000
3+++ src/net/tapaal/gui/GuiFrameController.java 2022-03-06 11:11:17 +0000
4@@ -735,6 +735,7 @@
5 public void showSimpleWorkspace() {
6 showAdvancedWorkspace(false);
7 }
8+
9 private void showAdvancedWorkspace(boolean advanced){
10 QueryDialog.setAdvancedView(advanced);
11 setComponents(advanced);
12
13=== modified file 'src/net/tapaal/gui/TabActions.java'
14--- src/net/tapaal/gui/TabActions.java 2022-02-21 07:29:48 +0000
15+++ src/net/tapaal/gui/TabActions.java 2022-03-06 11:11:17 +0000
16@@ -108,6 +108,8 @@
17
18 void showChangeNameVisibility();
19
20+ void showColorTypesVariables();
21+
22 void alignToGrid();
23
24 void copy();
25
26=== modified file 'src/net/tapaal/gui/petrinet/editor/ConstantsPane.java'
27--- src/net/tapaal/gui/petrinet/editor/ConstantsPane.java 2022-02-20 20:18:49 +0000
28+++ src/net/tapaal/gui/petrinet/editor/ConstantsPane.java 2022-03-06 11:11:17 +0000
29@@ -59,7 +59,7 @@
30
31 private static final String titleBorder = "Global constants, Color types and Variables";
32 private static final String titleBorderNoColor = "Global constants";
33- private static final String titleBorderToolTip = "Declaration of global constants that can be used in intervals and age invariants, declaration of Colors types and declaration of Variables";
34+ private static final String titleBorderToolTip = "<html>Declaration of colors types, color variables and global integer constants.<br>To see a summary list press SHIFT + F</html>";
35 private static final String titleBorderToolTipNoColor = "Declaration of global constants that can be used in intervals and age invariants";
36
37 private static final String CONSTANTS = "Constants";
38
39=== modified file 'src/pipe/gui/GuiFrame.java'
40--- src/pipe/gui/GuiFrame.java 2022-02-21 14:38:38 +0000
41+++ src/pipe/gui/GuiFrame.java 2022-03-06 11:11:17 +0000
42@@ -17,10 +17,7 @@
43 import javax.swing.*;
44
45 import com.sun.jna.Platform;
46-import net.tapaal.gui.GuiFrameActions;
47-import net.tapaal.gui.GuiFrameControllerActions;
48-import net.tapaal.gui.SafeGuiFrameActions;
49-import net.tapaal.gui.TabActions;
50+import net.tapaal.gui.*;
51 import net.tapaal.gui.debug.DEBUG;
52 import dk.aau.cs.util.JavaUtil;
53 import dk.aau.cs.verification.VerifyTAPN.VerifyPN;
54@@ -225,7 +222,11 @@
55 guiFrameController.ifPresent(GuiFrameControllerActions::clearPreferences);
56 }
57 };
58-
59+ private final GuiAction showColorTypesVariables = new GuiAction("Show color types/variables/constants", "Opens a floating window showing the global color types/variables/constants for the net.", KeyStroke.getKeyStroke(("shift F"))) {
60+ public void actionPerformed(ActionEvent arg0) {
61+ currentTab.ifPresent(TabActions::showColorTypesVariables);
62+ }
63+ };
64 private final GuiAction verifyAction = new GuiAction("Verify query", "Verifies the currently selected query", KeyStroke.getKeyStroke(KeyEvent.VK_M, shortcutkey)) {
65 public void actionPerformed(ActionEvent arg0) {
66 currentTab.ifPresent(TabActions::verifySelectedQuery);
67@@ -796,6 +797,8 @@
68 mergeComponentsDialog.setMnemonic('c');
69 toolsMenu.add(mergeComponentsDialog);
70
71+ toolsMenu.add(showColorTypesVariables);
72+
73 toolsMenu.addSeparator();
74
75 JMenuItem batchProcessing = new JMenuItem(batchProcessingAction);
76@@ -964,6 +967,8 @@
77
78 verifyAction.setEnabled(getCurrentTab().isQueryPossible());
79
80+ showColorTypesVariables.setEnabled(getCurrentTab().lens.isColored());
81+
82 smartDrawAction.setEnabled(true);
83 mergeComponentsDialogAction.setEnabled(true);
84 if (gameFeatureOptions.getSelectedIndex() == 1 || colorFeatureOptions.getSelectedIndex() == 1) {
85@@ -1005,6 +1010,8 @@
86 redoAction.setEnabled(false);
87 verifyAction.setEnabled(false);
88
89+ showColorTypesVariables.setEnabled(getCurrentTab().lens.isColored());
90+
91 smartDrawAction.setEnabled(false);
92 mergeComponentsDialogAction.setEnabled(false);
93 workflowDialogAction.setEnabled(false);
94@@ -1022,6 +1029,8 @@
95 importTraceAction.setEnabled(false);
96 verifyAction.setEnabled(false);
97
98+ showColorTypesVariables.setEnabled(false);
99+
100 annotationAction.setEnabled(false);
101 selectAllAction.setEnabled(false);
102
103@@ -1245,6 +1254,8 @@
104 mergeComponentsDialog.setMnemonic('c');
105 toolsMenu.add(mergeComponentsDialog);
106
107+ toolsMenu.add(showColorTypesVariables);
108+
109 for(GuiAction action : toolsActions){
110 toolsMenu.add(action);
111 }
112
113=== modified file 'src/pipe/gui/petrinet/PetriNetTab.java'
114--- src/pipe/gui/petrinet/PetriNetTab.java 2022-02-22 13:27:24 +0000
115+++ src/pipe/gui/petrinet/PetriNetTab.java 2022-03-06 11:11:17 +0000
116@@ -3,6 +3,21 @@
117 import dk.aau.cs.TCTL.Parsing.ParseException;
118 import dk.aau.cs.TCTL.*;
119 import dk.aau.cs.debug.Logger;
120+import dk.aau.cs.model.CPN.ColorType;
121+import dk.aau.cs.model.CPN.Variable;
122+import net.tapaal.gui.GuiFrameActions;
123+import net.tapaal.gui.GuiFrameControllerActions;
124+import net.tapaal.gui.SafeGuiFrameActions;
125+import net.tapaal.gui.TabActions;
126+import net.tapaal.gui.petrinet.*;
127+import net.tapaal.gui.petrinet.model.ModelViolation;
128+import net.tapaal.gui.petrinet.model.Result;
129+import net.tapaal.gui.petrinet.editor.TemplateExplorer;
130+import net.tapaal.gui.petrinet.model.GuiModelManager;
131+import net.tapaal.gui.swingcomponents.BugHandledJXMultisplitPane;
132+import net.tapaal.gui.petrinet.dialog.NameVisibilityPanel;
133+import net.tapaal.gui.petrinet.dialog.StatisticsPanel;
134+import net.tapaal.gui.petrinet.animation.TransitionFiringComponent;
135 import dk.aau.cs.io.*;
136 import dk.aau.cs.io.queries.SUMOQueryLoader;
137 import dk.aau.cs.io.queries.XMLQueryLoader;
138@@ -43,10 +58,13 @@
139 import net.tapaal.gui.petrinet.widgets.QueryPane;
140 import net.tapaal.gui.swingcomponents.BugHandledJXMultisplitPane;
141 import net.tapaal.helpers.Reference.MutableReference;
142+import net.tapaal.resourcemanager.ResourceManager;
143 import net.tapaal.swinghelpers.JSplitPaneFix;
144 import org.jdesktop.swingx.MultiSplitLayout.Divider;
145 import org.jdesktop.swingx.MultiSplitLayout.Leaf;
146 import org.jdesktop.swingx.MultiSplitLayout.Split;
147+import pipe.gui.petrinet.dataLayer.DataLayer;
148+import pipe.gui.petrinet.action.GuiAction;
149 import pipe.gui.Constants;
150 import pipe.gui.GuiFrame;
151 import pipe.gui.MessengerImpl;
152@@ -54,12 +72,10 @@
153 import pipe.gui.canvas.DrawingSurfaceImpl;
154 import pipe.gui.canvas.Grid;
155 import pipe.gui.canvas.Zoomer;
156-import pipe.gui.petrinet.action.GuiAction;
157 import pipe.gui.petrinet.animation.AnimationControlSidePanel;
158 import pipe.gui.petrinet.animation.AnimationHistoryList;
159 import pipe.gui.petrinet.animation.AnimationHistorySidePanel;
160 import pipe.gui.petrinet.animation.Animator;
161-import pipe.gui.petrinet.dataLayer.DataLayer;
162 import pipe.gui.petrinet.graphicElements.*;
163 import pipe.gui.petrinet.graphicElements.tapn.*;
164 import pipe.gui.petrinet.undo.UndoManager;
165@@ -1425,6 +1441,106 @@
166 }
167
168 @Override
169+ public void showColorTypesVariables() {
170+ StringBuilder buffer = new StringBuilder();
171+ Context context = new Context(TAPAALGUI.getCurrentTab());
172+
173+ List<ColorType> listColorTypes = context.network().colorTypes();
174+ List<Variable> variableList = context.network().variables();
175+ List<Constant> constantsList = new ArrayList<>(context.network().constants());
176+
177+ getColorTypesFormattedString(listColorTypes, buffer);
178+
179+ if(!variableList.isEmpty()) {
180+ buffer.append("<br>");
181+ }
182+
183+ getVariablesFormattedString(variableList, buffer);
184+
185+ if(!constantsList.isEmpty()) {
186+ buffer.append("<br><br>");
187+ }
188+
189+ getConstantsFormattedString(constantsList, buffer);
190+
191+ JLabel label = new JLabel("<html>" + buffer + "</html>");
192+ label.setFont(new Font(label.getFont().getName(), Font.PLAIN, label.getFont().getSize()));
193+
194+ JOptionPane.showMessageDialog(null, label, "Global color types/variables", JOptionPane.INFORMATION_MESSAGE);
195+ }
196+
197+ private String getColorTypesFormattedString(List<ColorType> listColorTypes, StringBuilder buffer) {
198+ String stringColorList = "";
199+ for(int i = 0; i < listColorTypes.size(); i++) {
200+ if(i == 0) {
201+ buffer.append("Color Types:<br>");
202+ }
203+ buffer.append(listColorTypes.get(i).getName() + " <b>is</b> ");
204+
205+ if(listColorTypes.get(i).isProductColorType()) {
206+ buffer.append("&lt;");
207+ for(int x = 0; x < listColorTypes.get(i).getProductColorTypes().size(); x++) {
208+ stringColorList += listColorTypes.get(i).getProductColorTypes().get(x).getName();
209+
210+ if(x != listColorTypes.get(i).getProductColorTypes().size() - 1){
211+ stringColorList += ", ";
212+ }
213+ }
214+ buffer.append(stringColorList + "&gt;<br>");
215+ stringColorList = "";
216+
217+ } else if(listColorTypes.get(i).isIntegerRange()) {
218+ if(listColorTypes.get(i).size() > 1) {
219+ int listSize = listColorTypes.get(i).size();
220+ buffer.append("[" + listColorTypes.get(i).getColors().get(0).getColorName() + ".." + listColorTypes.get(i).getColors().get(listSize - 1).getColorName() + "]");
221+ } else {
222+ buffer.append("[" + listColorTypes.get(i).getFirstColor().getColorName() + "]");
223+ }
224+ buffer.append("<br>");
225+
226+ } else {
227+ buffer.append("[");
228+ for(int x = 0; x < listColorTypes.get(i).getColors().size(); x++) {
229+ stringColorList += listColorTypes.get(i).getColors().get(x).getName();
230+
231+ if(x != listColorTypes.get(i).getColors().size() - 1){
232+ stringColorList += ", ";
233+ }
234+ }
235+ buffer.append(stringColorList + "]<br>");
236+ stringColorList = "";
237+ }
238+ }
239+
240+ return buffer.toString();
241+ }
242+
243+ private String getVariablesFormattedString(List<Variable> variableList, StringBuilder buffer) {
244+ for(int i = 0; i < variableList.size(); i++) {
245+ if (i == 0) {
246+ buffer.append("Variables:<br>");
247+ }
248+ buffer.append(variableList.get(i).getName() + " <b>in</b> " + variableList.get(i).getColorType().getName());
249+ if(i != variableList.size() - 1) {
250+ buffer.append("<br>");
251+ }
252+ }
253+ return buffer.toString();
254+ }
255+
256+ private String getConstantsFormattedString(List<Constant> constantsList, StringBuilder buffer) {
257+ for (int i = 0; i < constantsList.size(); i++) {
258+ if (i == 0) {
259+ buffer.append("Constants:<br>");
260+ }
261+ buffer.append(constantsList.get(i).toString());
262+ if (i != constantsList.size() - 1) {
263+ buffer.append("<br>");
264+ }
265+ }
266+ return buffer.toString();
267+ }
268+
269 public void alignToGrid() {
270 ArrayList<PetriNetObject> petriNetObjects = drawingSurface.getGuiModel().getPlaceTransitionObjects();
271 undoManager.newEdit();

Subscribers

People subscribed via source and target branches

to all changes: