Merge lp:~tapaal-contributor/tapaal/hide-show-names-1921393 into lp:tapaal

Proposed by Lena Ernstsen
Status: Merged
Approved by: Jiri Srba
Approved revision: 1146
Merged at revision: 1130
Proposed branch: lp:~tapaal-contributor/tapaal/hide-show-names-1921393
Merge into: lp:tapaal
Diff against target: 769 lines (+439/-43)
15 files modified
src/dk/aau/cs/gui/TabContent.java (+59/-2)
src/dk/aau/cs/gui/TabContentActions.java (+7/-0)
src/dk/aau/cs/gui/components/NameVisibilityPanel.java (+247/-0)
src/dk/aau/cs/gui/undo/ChangeAllNamesVisibilityCommand.java (+70/-0)
src/dk/aau/cs/gui/undo/RenameTimedPlaceCommand.java (+2/-2)
src/pipe/gui/GuiFrame.java (+11/-5)
src/pipe/gui/GuiFrameActions.java (+1/-1)
src/pipe/gui/GuiFrameController.java (+0/-1)
src/pipe/gui/canvas/DrawingSurfaceImpl.java (+6/-4)
src/pipe/gui/graphicElements/PlaceTransitionObject.java (+2/-2)
src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java (+0/-1)
src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java (+0/-1)
src/pipe/gui/widgets/PlaceEditorPanel.java (+22/-23)
src/pipe/gui/widgets/QueryDialog.java (+1/-1)
src/pipe/gui/widgets/TAPNTransitionEditor.java (+11/-0)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/hide-show-names-1921393
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+406578@code.launchpad.net

This proposal supersedes a proposal from 2021-07-27.

Commit message

Visibility of all place/transition names can be changed through the view menu

Description of the change

Place/transition names stay hidden when opening new nets and when switching tabs and templates.

Go to the view menu and then press "Change visibility of transition/place names". This will open a dialog, where you choose which options you want. When pressing "ok", the changes will be executed.
When entering the dialog again, the dialog will remember the options selected last time it was closed.

It is also possible to undo/redo the change of visibility.

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 Intro example, select "hide place names" and the names disappear. Then click on the editing surface and the names appear again.

Also, select e.g. Place P2 and unclick in the dialog "Show place name". The disable showing place names and enable it again in the view menu. Showing the name for P2 should be still disabled. This should have a priority over "show place names" in the view menu (i.e. if explicitly disabled, it should not show the place names at all). The same for transitions.

To make the semantics more clear, perhaps rename the View items to "Hide place names" and "Hide transition names" and leave them initially unselected (i.g. a normal behaviour). When you select the "hide" menu option, all transition or place names should be hidden, once you deselect it again, it should return to normal behaviour (i.e. depending on the choice made in the place/transition editing dialog).

Also, when you open a new net, the View options for these two items should be set to default (showing the names).

review: Needs Fixing
Revision history for this message
Jiri Srba (srba) wrote (last edit ): Posted in a previous version of this proposal

The logics is broken. Run TAPAAL (notice that hide place/transitions names is set even though
it should not be), open a new net and go to view menu and click on "hide place names" which is now selected. Try to draw a new place and transition. The place has a name (even though it should not) and the transition does not have a name (even though it should).

review: Needs Fixing
Revision history for this message
Jiri Srba (srba) wrote : Posted in a previous version of this proposal

Undo is broken: to reproduce open intro example, use the dialog to hide both place/transition names and then manually show the name of one selected place. Then try to undo and nothing happens (the selected place should be now without name).

review: Needs Fixing
1145. By Lena Ernstsen

Changed tooltip for 'Merge Composed Net'

1146. By Lena Ernstsen

Changed tooltip for 'Merge Composed Net'

Revision history for this message
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/dk/aau/cs/gui/TabContent.java'
--- src/dk/aau/cs/gui/TabContent.java 2020-10-30 21:14:42 +0000
+++ src/dk/aau/cs/gui/TabContent.java 2021-08-03 09:29:22 +0000
@@ -16,6 +16,7 @@
16import dk.aau.cs.TCTL.*;16import dk.aau.cs.TCTL.*;
17import dk.aau.cs.debug.Logger;17import dk.aau.cs.debug.Logger;
18import dk.aau.cs.gui.components.BugHandledJXMultisplitPane;18import dk.aau.cs.gui.components.BugHandledJXMultisplitPane;
19import dk.aau.cs.gui.components.NameVisibilityPanel;
19import dk.aau.cs.gui.components.StatisticsPanel;20import dk.aau.cs.gui.components.StatisticsPanel;
20import dk.aau.cs.gui.components.TransitionFireingComponent;21import dk.aau.cs.gui.components.TransitionFireingComponent;
21import dk.aau.cs.gui.undo.*;22import dk.aau.cs.gui.undo.*;
@@ -843,8 +844,14 @@
843 844
844 private WorkflowDialog workflowDialog = null;845 private WorkflowDialog workflowDialog = null;
845846
846847 private NameVisibilityPanel nameVisibilityPanel = null;
847 private TabContent(boolean isTimed, boolean isGame) {848
849 private Boolean showNamesOption = null;
850 private Boolean isSelectedComponentOption = null;
851 private Boolean isPlaceOption = null;
852 private Boolean isTransitionOption = null;
853
854 private TabContent(boolean isTimed, boolean isGame) {
848 this(new TimedArcPetriNetNetwork(), new ArrayList<>(), new TAPNLens(isTimed,isGame));855 this(new TimedArcPetriNetNetwork(), new ArrayList<>(), new TAPNLens(isTimed,isGame));
849 }856 }
850857
@@ -903,6 +910,8 @@
903 this.setDividerSize(8);910 this.setDividerSize(8);
904 //XXX must be after the animationcontroller is created911 //XXX must be after the animationcontroller is created
905 animationModeController = new CanvasAnimationController(getAnimator());912 animationModeController = new CanvasAnimationController(getAnimator());
913
914 nameVisibilityPanel = new NameVisibilityPanel(this);
906 }915 }
907916
908 public TabContent(TimedArcPetriNetNetwork network, Collection<Template> templates, Iterable<TAPNQuery> tapnqueries, TAPNLens lens) {917 public TabContent(TimedArcPetriNetNetwork network, Collection<Template> templates, Iterable<TAPNQuery> tapnqueries, TAPNLens lens) {
@@ -1621,6 +1630,39 @@
1621 }1630 }
1622 }1631 }
16231632
1633 @Override
1634 public Map<PetriNetObject, Boolean> showNames(boolean showNames, boolean placeNames, boolean selectedComponent) {
1635 Map<PetriNetObject, Boolean> map = new HashMap<>();
1636 List<PetriNetObject> components = new ArrayList<>();
1637
1638 if (selectedComponent) {
1639 Template template = currentTemplate();
1640 template.guiModel().getPetriNetObjects().forEach(components::add);
1641 } else {
1642 Iterable<Template> templates = allTemplates();
1643 for (Template template : templates) {
1644 template.guiModel().getPetriNetObjects().forEach(components::add);
1645 }
1646 }
1647
1648 for (Component component : components) {
1649 if (placeNames && component instanceof TimedPlaceComponent) {
1650 TimedPlaceComponent place = (TimedPlaceComponent) component;
1651 map.put(place, place.getAttributesVisible());
1652 place.setAttributesVisible(showNames);
1653 place.update(true);
1654 repaint();
1655 } else if (!placeNames && component instanceof TimedTransitionComponent) {
1656 TimedTransitionComponent transition = (TimedTransitionComponent) component;
1657 map.put(transition, transition.getAttributesVisible());
1658 transition.setAttributesVisible(showNames);
1659 transition.update(true);
1660 repaint();
1661 }
1662 }
1663 return map;
1664 }
1665
1624 public static Split getEditorModelRoot(){1666 public static Split getEditorModelRoot(){
1625 return editorModelroot;1667 return editorModelroot;
1626 }1668 }
@@ -1839,6 +1881,21 @@
1839 StatisticsPanel.showStatisticsPanel(drawingSurface().getModel().getStatistics());1881 StatisticsPanel.showStatisticsPanel(drawingSurface().getModel().getStatistics());
1840 }1882 }
18411883
1884 @Override
1885 public void showChangeNameVisibility() {
1886 NameVisibilityPanel panel = new NameVisibilityPanel(this);
1887 if (showNamesOption != null && isSelectedComponentOption != null && isPlaceOption != null && isTransitionOption != null) {
1888 panel.showNameVisibilityPanel(showNamesOption, isPlaceOption, isTransitionOption, isSelectedComponentOption);
1889 } else {
1890 panel.showNameVisibilityPanel();
1891 }
1892
1893 showNamesOption = panel.isShowNamesOption();
1894 isPlaceOption = panel.isPlaceOption();
1895 isTransitionOption = panel.isTransitionOption();
1896 isSelectedComponentOption = panel.isSelectedComponentOption();
1897 }
1898
1842 @Override1899 @Override
1843 public void importSUMOQueries() {1900 public void importSUMOQueries() {
1844 File[] files = FileBrowser.constructor("Import SUMO", "txt", FileBrowser.userPath).openFiles();1901 File[] files = FileBrowser.constructor("Import SUMO", "txt", FileBrowser.userPath).openFiles();
18451902
=== modified file 'src/dk/aau/cs/gui/TabContentActions.java'
--- src/dk/aau/cs/gui/TabContentActions.java 2020-08-11 11:51:55 +0000
+++ src/dk/aau/cs/gui/TabContentActions.java 2021-08-03 09:29:22 +0000
@@ -4,8 +4,10 @@
4import pipe.gui.GuiFrameActions;4import pipe.gui.GuiFrameActions;
5import pipe.gui.Pipe;5import pipe.gui.Pipe;
6import pipe.gui.SafeGuiFrameActions;6import pipe.gui.SafeGuiFrameActions;
7import pipe.gui.graphicElements.PetriNetObject;
78
8import java.io.File;9import java.io.File;
10import java.util.Map;
911
10public interface TabContentActions {12public interface TabContentActions {
1113
@@ -96,4 +98,9 @@
9698
97 void changeGameFeature(boolean isGame);99 void changeGameFeature(boolean isGame);
98100
101 Map<PetriNetObject, Boolean> showNames(boolean isVisible, boolean placeNames, boolean selectedComponent);
102
103 void showChangeNameVisibility();
104
105
99}106}
100107
=== added file 'src/dk/aau/cs/gui/components/NameVisibilityPanel.java'
--- src/dk/aau/cs/gui/components/NameVisibilityPanel.java 1970-01-01 00:00:00 +0000
+++ src/dk/aau/cs/gui/components/NameVisibilityPanel.java 2021-08-03 09:29:22 +0000
@@ -0,0 +1,247 @@
1package dk.aau.cs.gui.components;
2
3import dk.aau.cs.gui.TabContent;
4import dk.aau.cs.gui.undo.ChangeAllNamesVisibilityCommand;
5import dk.aau.cs.gui.undo.Command;
6import pipe.gui.graphicElements.PetriNetObject;
7
8import javax.swing.*;
9import java.awt.*;
10import java.util.HashMap;
11import java.util.Map;
12
13public class NameVisibilityPanel extends JPanel {
14 private static final String DIALOG_TITLE = "Change Name Visibility";
15
16 private static JDialog dialog;
17 private JRadioButton showNames;
18 private JRadioButton hideNames;
19 private JRadioButton placeOption;
20 private JRadioButton transitionOption;
21 private JRadioButton bothOption;
22 private JRadioButton selectedComponent;
23 private JRadioButton allComponents;
24
25 ButtonGroup visibilityRadioButtonGroup;
26 ButtonGroup objectRadioButtonGroup;
27 ButtonGroup componentRadioButtonGroup;
28
29 JPanel visibilityPanel;
30 JPanel placeTransitionPanel;
31 JPanel componentPanel;
32
33 private final TabContent tab;
34
35 public NameVisibilityPanel(TabContent tab) {
36 super(new GridBagLayout());
37
38 this.tab = tab;
39
40 init();
41 }
42
43 public void showNameVisibilityPanel() {
44 JOptionPane optionPane = new JOptionPane(this, JOptionPane.INFORMATION_MESSAGE);
45
46 dialog = optionPane.createDialog(DIALOG_TITLE);
47 dialog.pack();
48 dialog.setVisible(true);
49
50 Object selectedValue = optionPane.getValue();
51
52 if (selectedValue != null) ChangeNameVisibilityBasedOnSelection();
53 }
54
55 public void showNameVisibilityPanel(boolean isVisible, boolean isPlace, boolean isTransition, boolean isSelectedComponent) {
56 JOptionPane optionPane = new JOptionPane(this, JOptionPane.INFORMATION_MESSAGE);
57
58 showNames.setSelected(isVisible);
59 hideNames.setSelected(!isVisible);
60 placeOption.setSelected(isPlace && !isTransition);
61 transitionOption.setSelected(isTransition && !isPlace);
62 bothOption.setSelected(isPlace && isTransition);
63 selectedComponent.setSelected(isSelectedComponent);
64 allComponents.setSelected(!isSelectedComponent);
65
66 dialog = optionPane.createDialog(DIALOG_TITLE);
67 dialog.pack();
68 dialog.setVisible(true);
69
70 Object selectedValue = optionPane.getValue();
71
72 if (selectedValue != null) ChangeNameVisibilityBasedOnSelection();
73 }
74
75 private void init() {
76 visibilityPanel = initVisibilityOptions();
77 placeTransitionPanel = initPlaceTransitionOptions();
78 componentPanel = initComponentOptions();
79
80 GridBagConstraints gbc = new GridBagConstraints();
81 gbc.gridx = 0;
82 gbc.gridy = 0;
83 gbc.anchor = GridBagConstraints.WEST;
84 gbc.gridwidth = 3;
85 gbc.insets = new Insets(5, 5, 5, 5);
86
87 this.add(visibilityPanel, gbc);
88 gbc.gridy = 1;
89 this.add(placeTransitionPanel, gbc);
90 gbc.gridy = 2;
91 this.add(componentPanel, gbc);
92
93 this.setVisible(true);
94 }
95
96 private JPanel initVisibilityOptions() {
97 JPanel panel = new JPanel(new GridBagLayout());
98 visibilityRadioButtonGroup = new ButtonGroup();
99
100 JLabel text = new JLabel("Choose visibility: ");
101 GridBagConstraints gbc = new GridBagConstraints();
102 gbc.gridx = 0;
103 gbc.gridy = 0;
104 gbc.weightx = 0;
105 gbc.anchor = GridBagConstraints.WEST;
106 gbc.insets = new Insets(3, 3, 3, 3);
107 panel.add(text, gbc);
108
109 showNames = new JRadioButton("Show");
110 showNames.setSelected(true);
111 gbc = new GridBagConstraints();
112 gbc.gridx = 1;
113 gbc.gridy = 0;
114 gbc.weightx = 0;
115 gbc.anchor = GridBagConstraints.WEST;
116 gbc.insets = new Insets(3, 3, 3, 3);
117 panel.add(showNames, gbc);
118 visibilityRadioButtonGroup.add(showNames);
119
120 hideNames = new JRadioButton("Hide");
121 gbc = new GridBagConstraints();
122 gbc.gridx = 2;
123 gbc.gridy = 0;
124 gbc.weightx = 0;
125 gbc.anchor = GridBagConstraints.WEST;
126 gbc.insets = new Insets(3, 3, 3, 3);
127 panel.add(hideNames, gbc);
128 visibilityRadioButtonGroup.add(hideNames);
129
130 return panel;
131 }
132
133 private JPanel initPlaceTransitionOptions() {
134 JPanel panel = new JPanel(new GridBagLayout());
135 objectRadioButtonGroup = new ButtonGroup();
136
137 JLabel text = new JLabel("Choose group: ");
138 GridBagConstraints gbc = new GridBagConstraints();
139 gbc.gridx = 0;
140 gbc.gridy = 0;
141 gbc.weightx = 0;
142 gbc.anchor = GridBagConstraints.WEST;
143 gbc.insets = new Insets(3, 3, 3, 3);
144 panel.add(text, gbc);
145
146 placeOption = new JRadioButton("Places");
147 placeOption.setSelected(true);
148 gbc = new GridBagConstraints();
149 gbc.gridx = 1;
150 gbc.gridy = 0;
151 gbc.weightx = 0;
152 gbc.anchor = GridBagConstraints.WEST;
153 gbc.insets = new Insets(3, 3, 3, 3);
154 panel.add(placeOption, gbc);
155 objectRadioButtonGroup.add(placeOption);
156
157 transitionOption = new JRadioButton("Transitions");
158 gbc = new GridBagConstraints();
159 gbc.gridx = 2;
160 gbc.gridy = 0;
161 gbc.weightx = 0;
162 gbc.anchor = GridBagConstraints.WEST;
163 gbc.insets = new Insets(3, 3, 3, 3);
164 panel.add(transitionOption, gbc);
165 objectRadioButtonGroup.add(transitionOption);
166
167 bothOption = new JRadioButton("Both");
168 gbc = new GridBagConstraints();
169 gbc.gridx = 3;
170 gbc.gridy = 0;
171 gbc.weightx = 0;
172 gbc.anchor = GridBagConstraints.WEST;
173 gbc.insets = new Insets(3, 3, 3, 3);
174 panel.add(bothOption, gbc);
175 objectRadioButtonGroup.add(bothOption);
176
177 return panel;
178 }
179
180 private JPanel initComponentOptions() {
181 JPanel panel = new JPanel(new GridBagLayout());
182 componentRadioButtonGroup = new ButtonGroup();
183
184 JLabel text = new JLabel("Choose components: ");
185 GridBagConstraints gbc = new GridBagConstraints();
186 gbc.gridx = 0;
187 gbc.gridy = 0;
188 gbc.weightx = 0;
189 gbc.anchor = GridBagConstraints.WEST;
190 gbc.insets = new Insets(3, 3, 3, 3);
191 panel.add(text, gbc);
192
193 selectedComponent = new JRadioButton("Selected component");
194 selectedComponent.setSelected(true);
195 gbc = new GridBagConstraints();
196 gbc.gridx = 1;
197 gbc.gridy = 0;
198 gbc.weightx = 0;
199 gbc.anchor = GridBagConstraints.WEST;
200 gbc.insets = new Insets(3, 3, 3, 3);
201 panel.add(selectedComponent, gbc);
202 componentRadioButtonGroup.add(selectedComponent);
203
204 allComponents = new JRadioButton("All components");
205 gbc = new GridBagConstraints();
206 gbc.gridx = 2;
207 gbc.gridy = 0;
208 gbc.weightx = 0;
209 gbc.anchor = GridBagConstraints.WEST;
210 gbc.insets = new Insets(3, 3, 3, 3);
211 panel.add(allComponents, gbc);
212 componentRadioButtonGroup.add(allComponents);
213
214 return panel;
215 }
216
217 protected void ChangeNameVisibilityBasedOnSelection() {
218 Map<PetriNetObject, Boolean> places = new HashMap<>();
219 Map<PetriNetObject, Boolean> transitions = new HashMap<>();
220
221 if (placeOption.isSelected() || bothOption.isSelected()) {
222 places = tab.showNames(showNames.isSelected(), true, selectedComponent.isSelected());
223 }
224 if (transitionOption.isSelected() || bothOption.isSelected()) {
225 transitions = tab.showNames(showNames.isSelected(), false, selectedComponent.isSelected());
226 }
227
228 Command changeVisibilityCommand = new ChangeAllNamesVisibilityCommand(tab, places, transitions, showNames.isSelected());
229 tab.getUndoManager().addNewEdit(changeVisibilityCommand);
230 }
231
232 public boolean isShowNamesOption() {
233 return showNames.isSelected();
234 }
235
236 public boolean isSelectedComponentOption() {
237 return selectedComponent.isSelected();
238 }
239
240 public boolean isPlaceOption() {
241 return placeOption.isSelected() || bothOption.isSelected();
242 }
243
244 public boolean isTransitionOption() {
245 return transitionOption.isSelected() || bothOption.isSelected();
246 }
247}
0248
=== added file 'src/dk/aau/cs/gui/undo/ChangeAllNamesVisibilityCommand.java'
--- src/dk/aau/cs/gui/undo/ChangeAllNamesVisibilityCommand.java 1970-01-01 00:00:00 +0000
+++ src/dk/aau/cs/gui/undo/ChangeAllNamesVisibilityCommand.java 2021-08-03 09:29:22 +0000
@@ -0,0 +1,70 @@
1package dk.aau.cs.gui.undo;
2
3import dk.aau.cs.gui.TabContent;
4import pipe.gui.graphicElements.PetriNetObject;
5import pipe.gui.graphicElements.tapn.TimedPlaceComponent;
6import pipe.gui.graphicElements.tapn.TimedTransitionComponent;
7
8import java.util.Map;
9
10public class ChangeAllNamesVisibilityCommand extends Command {
11 private final Map<PetriNetObject, Boolean> places;
12 private final Map<PetriNetObject, Boolean> transitions;
13 private final boolean isVisible;
14 private final TabContent tabContent;
15
16 public ChangeAllNamesVisibilityCommand(TabContent tabContent, Map<PetriNetObject, Boolean> places, Map<PetriNetObject, Boolean> transitions, boolean isVisible) {
17 this.tabContent = tabContent;
18 this.places = places;
19 this.transitions= transitions;
20 this.isVisible = isVisible;
21 }
22
23 @Override
24 public void redo() {
25 if (places != null) {
26 for (PetriNetObject place : places.keySet()) {
27 if (place instanceof TimedPlaceComponent) {
28 TimedPlaceComponent component = (TimedPlaceComponent) place;
29 component.setAttributesVisible(isVisible);
30 component.update(true);
31 tabContent.repaint();
32 }
33 }
34 }
35 if (transitions != null) {
36 for (PetriNetObject transition : transitions.keySet()) {
37 if (transition instanceof TimedTransitionComponent) {
38 TimedTransitionComponent component = (TimedTransitionComponent) transition;
39 component.setAttributesVisible(isVisible);
40 component.update(true);
41 tabContent.repaint();
42 }
43 }
44 }
45 }
46
47 @Override
48 public void undo() {
49 if (places != null) {
50 for (PetriNetObject place : places.keySet()) {
51 if (place instanceof TimedPlaceComponent) {
52 TimedPlaceComponent component = (TimedPlaceComponent) place;
53 component.setAttributesVisible(places.get(component));
54 component.update(true);
55 tabContent.repaint();
56 }
57 }
58 }
59 if (transitions != null) {
60 for (PetriNetObject transition : transitions.keySet()) {
61 if (transition instanceof TimedTransitionComponent) {
62 TimedTransitionComponent component = (TimedTransitionComponent) transition;
63 component.setAttributesVisible(transitions.get(component));
64 component.update(true);
65 tabContent.repaint();
66 }
67 }
68 }
69 }
70}
071
=== modified file 'src/dk/aau/cs/gui/undo/RenameTimedPlaceCommand.java'
--- src/dk/aau/cs/gui/undo/RenameTimedPlaceCommand.java 2011-03-12 12:12:12 +0000
+++ src/dk/aau/cs/gui/undo/RenameTimedPlaceCommand.java 2021-08-03 09:29:22 +0000
@@ -22,13 +22,13 @@
22 public void redo() {22 public void redo() {
23 place.setName(newName);23 place.setName(newName);
24 updateQueries(oldName, newName);24 updateQueries(oldName, newName);
25 }25 }
2626
27 @Override27 @Override
28 public void undo() {28 public void undo() {
29 place.setName(oldName);29 place.setName(oldName);
30 updateQueries(newName,oldName);30 updateQueries(newName,oldName);
31 }31 }
32 32
33 private void updateQueries(String nameToFind, String nameToInsert){33 private void updateQueries(String nameToFind, String nameToInsert){
34 RenamePlaceTCTLVisitor renameVisitor = new RenamePlaceTCTLVisitor(nameToFind, nameToInsert);34 RenamePlaceTCTLVisitor renameVisitor = new RenamePlaceTCTLVisitor(nameToFind, nameToInsert);
3535
=== modified file 'src/pipe/gui/GuiFrame.java'
--- src/pipe/gui/GuiFrame.java 2021-04-08 08:39:05 +0000
+++ src/pipe/gui/GuiFrame.java 2021-08-03 09:29:22 +0000
@@ -18,10 +18,8 @@
1818
19import com.sun.jna.Platform;19import com.sun.jna.Platform;
20import dk.aau.cs.gui.*;20import dk.aau.cs.gui.*;
21import dk.aau.cs.model.tapn.TimedArcPetriNet;
22import dk.aau.cs.util.JavaUtil;21import dk.aau.cs.util.JavaUtil;
23import dk.aau.cs.verification.VerifyTAPN.VerifyPN;22import dk.aau.cs.verification.VerifyTAPN.VerifyPN;
24import dk.aau.cs.verification.VerifyTAPN.VerifyTAPNExporter;
25import net.tapaal.Preferences;23import net.tapaal.Preferences;
26import net.tapaal.TAPAAL;24import net.tapaal.TAPAAL;
27import net.tapaal.helpers.Reference.MutableReference;25import net.tapaal.helpers.Reference.MutableReference;
@@ -30,10 +28,8 @@
30import net.tapaal.swinghelpers.SwingHelper;28import net.tapaal.swinghelpers.SwingHelper;
31import net.tapaal.swinghelpers.ToggleButtonWithoutText;29import net.tapaal.swinghelpers.ToggleButtonWithoutText;
32import org.jetbrains.annotations.NotNull;30import org.jetbrains.annotations.NotNull;
33import pipe.dataLayer.TAPNQuery;
34import pipe.gui.Pipe.ElementType;31import pipe.gui.Pipe.ElementType;
35import pipe.gui.action.GuiAction;32import pipe.gui.action.GuiAction;
36import pipe.gui.widgets.WorkflowDialog;
37import dk.aau.cs.debug.Logger;33import dk.aau.cs.debug.Logger;
38import dk.aau.cs.gui.smartDraw.SmartDrawDialog;34import dk.aau.cs.gui.smartDraw.SmartDrawDialog;
39import net.tapaal.resourcemanager.ResourceManager;35import net.tapaal.resourcemanager.ResourceManager;
@@ -241,7 +237,7 @@
241 SmartDrawDialog.showSmartDrawDialog();237 SmartDrawDialog.showSmartDrawDialog();
242 }238 }
243 };239 };
244 private final GuiAction mergeComponentsDialogAction = new GuiAction("Merge net components", "Export an xml file of composed net and approximated net if enabled", KeyStroke.getKeyStroke(KeyEvent.VK_C, (shortcutkey + InputEvent.SHIFT_MASK))) {240 private final GuiAction mergeComponentsDialogAction = new GuiAction("Merge net components", "Open a composed net in a new tab and use approximated net if enabled", KeyStroke.getKeyStroke(KeyEvent.VK_C, (shortcutkey + InputEvent.SHIFT_MASK))) {
245 public void actionPerformed(ActionEvent e) {241 public void actionPerformed(ActionEvent e) {
246 currentTab.ifPresent(TabContentActions::mergeNetComponents);242 currentTab.ifPresent(TabContentActions::mergeNetComponents);
247 }243 }
@@ -334,6 +330,11 @@
334 guiFrameController.ifPresent(GuiFrameControllerActions::toggleDisplayToolTips);330 guiFrameController.ifPresent(GuiFrameControllerActions::toggleDisplayToolTips);
335 }331 }
336 };332 };
333 private final GuiAction changeNameVisibility = new GuiAction("Change visibility of transition/place names", "Executing this action will open a dialog where you can hide or show place and transition names", true) {
334 public void actionPerformed(ActionEvent e) {
335 currentTab.ifPresent(TabContentActions::showChangeNameVisibility);
336 }
337 };
337 private final GuiAction showAdvancedWorkspaceAction = new GuiAction("Show advanced workspace", "Show all panels", false) {338 private final GuiAction showAdvancedWorkspaceAction = new GuiAction("Show advanced workspace", "Show all panels", false) {
338 public void actionPerformed(ActionEvent e) {339 public void actionPerformed(ActionEvent e) {
339 guiFrameController.ifPresent(GuiFrameControllerActions::showAdvancedWorkspace);340 guiFrameController.ifPresent(GuiFrameControllerActions::showAdvancedWorkspace);
@@ -677,6 +678,10 @@
677678
678 viewMenu.addSeparator();679 viewMenu.addSeparator();
679680
681 viewMenu.add(changeNameVisibility);
682
683 viewMenu.addSeparator();
684
680 viewMenu.add(showSimpleWorkspaceAction);685 viewMenu.add(showSimpleWorkspaceAction);
681 viewMenu.add(showAdvancedWorkspaceAction);686 viewMenu.add(showAdvancedWorkspaceAction);
682 viewMenu.add(saveWorkSpaceAction);687 viewMenu.add(saveWorkSpaceAction);
@@ -1066,6 +1071,7 @@
1066 showDelayEnabledTransitionsAction.setEnabled(enable);1071 showDelayEnabledTransitionsAction.setEnabled(enable);
1067 showToolTipsAction.setEnabled(enable);1072 showToolTipsAction.setEnabled(enable);
1068 showTokenAgeAction.setEnabled(enable);1073 showTokenAgeAction.setEnabled(enable);
1074 changeNameVisibility.setEnabled(enable);
1069 showAdvancedWorkspaceAction.setEnabled(enable);1075 showAdvancedWorkspaceAction.setEnabled(enable);
1070 showSimpleWorkspaceAction.setEnabled(enable);1076 showSimpleWorkspaceAction.setEnabled(enable);
1071 saveWorkSpaceAction.setEnabled(enable);1077 saveWorkSpaceAction.setEnabled(enable);
10721078
=== modified file 'src/pipe/gui/GuiFrameActions.java'
--- src/pipe/gui/GuiFrameActions.java 2020-08-11 11:51:55 +0000
+++ src/pipe/gui/GuiFrameActions.java 2021-08-03 09:29:22 +0000
@@ -47,7 +47,7 @@
47 void setShowQueriesSelected(boolean b);47 void setShowQueriesSelected(boolean b);
48 void setShowEnabledTransitionsSelected(boolean b);48 void setShowEnabledTransitionsSelected(boolean b);
49 void setShowDelayEnabledTransitionsSelected(boolean b);49 void setShowDelayEnabledTransitionsSelected(boolean b);
50 void setShowToolTipsSelected(boolean b);50 void setShowToolTipsSelected(boolean b);;
51 void setShowZeroToInfinityIntervalsSelected(boolean b);51 void setShowZeroToInfinityIntervalsSelected(boolean b);
52 void setShowTokenAgeSelected(boolean b);52 void setShowTokenAgeSelected(boolean b);
5353
5454
=== modified file 'src/pipe/gui/GuiFrameController.java'
--- src/pipe/gui/GuiFrameController.java 2021-04-05 10:10:17 +0000
+++ src/pipe/gui/GuiFrameController.java 2021-08-03 09:29:22 +0000
@@ -113,7 +113,6 @@
113 guiFrame.changeToTab(tab);113 guiFrame.changeToTab(tab);
114 //XXX fixes an issue where on first open of a net the time intervals are not shown114 //XXX fixes an issue where on first open of a net the time intervals are not shown
115 tab.drawingSurface().repaintAll();115 tab.drawingSurface().repaintAll();
116
117 }116 }
118117
119 //If needed, add boolean forceClose, where net is not checkedForSave and just closed118 //If needed, add boolean forceClose, where net is not checkedForSave and just closed
120119
=== modified file 'src/pipe/gui/canvas/DrawingSurfaceImpl.java'
--- src/pipe/gui/canvas/DrawingSurfaceImpl.java 2020-08-11 06:00:12 +0000
+++ src/pipe/gui/canvas/DrawingSurfaceImpl.java 2021-08-03 09:29:22 +0000
@@ -495,9 +495,11 @@
495495
496496
497 public void translateSelection(ArrayList<PetriNetObject> objects, int transX, int transY) {497 public void translateSelection(ArrayList<PetriNetObject> objects, int transX, int transY) {
498 tabContent.getUndoManager().newEdit(); // new "transaction""498 if (transX != 0 || transY != 0) {
499 for (PetriNetObject pnobject : objects) {499 tabContent.getUndoManager().newEdit(); // new "transaction""
500 tabContent.getUndoManager().addEdit(new TranslatePetriNetObjectEdit(pnobject, transX, transY, this));500 for (PetriNetObject pnobject : objects) {
501 }501 tabContent.getUndoManager().addEdit(new TranslatePetriNetObjectEdit(pnobject, transX, transY, this));
502 }
503 }
502 }504 }
503}505}
504506
=== modified file 'src/pipe/gui/graphicElements/PlaceTransitionObject.java'
--- src/pipe/gui/graphicElements/PlaceTransitionObject.java 2020-08-20 20:45:38 +0000
+++ src/pipe/gui/graphicElements/PlaceTransitionObject.java 2021-08-03 09:29:22 +0000
@@ -19,9 +19,9 @@
19 private final LinkedList<Arc> connectTo = new LinkedList<Arc>();19 private final LinkedList<Arc> connectTo = new LinkedList<Arc>();
20 private final LinkedList<Arc> connectFrom = new LinkedList<Arc>();20 private final LinkedList<Arc> connectFrom = new LinkedList<Arc>();
2121
22 protected boolean attributesVisible = false;22 protected boolean attributesVisible = true;
2323
24 public PlaceTransitionObject(24 public PlaceTransitionObject(
25 double componentWidth,25 double componentWidth,
26 double componentHeight,26 double componentHeight,
27 int positionXInput,27 int positionXInput,
2828
=== modified file 'src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java'
--- src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2021-04-04 09:31:12 +0000
+++ src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2021-08-03 09:29:22 +0000
@@ -55,7 +55,6 @@
55 this.place = place;55 this.place = place;
56 this.place.addTimedPlaceListener(listener);56 this.place.addTimedPlaceListener(listener);
57 this.lens = lens;57 this.lens = lens;
58 attributesVisible = true;
5958
60 }59 }
6160
6261
=== modified file 'src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java'
--- src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2020-08-19 11:36:09 +0000
+++ src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2021-08-03 09:29:22 +0000
@@ -42,7 +42,6 @@
42 this.transition = transition;42 this.transition = transition;
43 listener = timedTransitionListener();43 listener = timedTransitionListener();
44 transition.addTimedTransitionListener(listener);44 transition.addTimedTransitionListener(listener);
45 attributesVisible = true;
46 this.lens = lens;45 this.lens = lens;
4746
48 }47 }
4948
=== modified file 'src/pipe/gui/widgets/PlaceEditorPanel.java'
--- src/pipe/gui/widgets/PlaceEditorPanel.java 2021-04-08 08:30:29 +0000
+++ src/pipe/gui/widgets/PlaceEditorPanel.java 2021-08-03 09:29:22 +0000
@@ -6,10 +6,7 @@
6import java.awt.GridBagLayout;6import java.awt.GridBagLayout;
7import java.awt.Insets;7import java.awt.Insets;
8import java.awt.event.ItemEvent;8import java.awt.event.ItemEvent;
9import java.util.Arrays;9import java.util.*;
10import java.util.Collection;
11import java.util.Set;
12import java.util.Vector;
1310
14import javax.swing.ButtonGroup;11import javax.swing.ButtonGroup;
15import javax.swing.DefaultComboBoxModel;12import javax.swing.DefaultComboBoxModel;
@@ -23,6 +20,7 @@
23import javax.swing.event.ChangeListener;20import javax.swing.event.ChangeListener;
2421
25import dk.aau.cs.gui.TabContent;22import dk.aau.cs.gui.TabContent;
23import dk.aau.cs.gui.undo.*;
26import net.tapaal.swinghelpers.CustomJSpinner;24import net.tapaal.swinghelpers.CustomJSpinner;
27import net.tapaal.swinghelpers.GridBagHelper;25import net.tapaal.swinghelpers.GridBagHelper;
28import net.tapaal.swinghelpers.SwingHelper;26import net.tapaal.swinghelpers.SwingHelper;
@@ -30,16 +28,9 @@
30import pipe.dataLayer.Template;28import pipe.dataLayer.Template;
31import pipe.gui.CreateGui;29import pipe.gui.CreateGui;
32import pipe.gui.Pipe;30import pipe.gui.Pipe;
31import pipe.gui.graphicElements.PetriNetObject;
33import pipe.gui.graphicElements.tapn.TimedPlaceComponent;32import pipe.gui.graphicElements.tapn.TimedPlaceComponent;
34import dk.aau.cs.gui.Context;33import dk.aau.cs.gui.Context;
35import dk.aau.cs.gui.undo.ChangedInvariantCommand;
36import dk.aau.cs.gui.undo.Command;
37import dk.aau.cs.gui.undo.MakePlaceSharedCommand;
38import dk.aau.cs.gui.undo.MakePlaceNewSharedCommand;
39import dk.aau.cs.gui.undo.MakePlaceNewSharedMultiCommand;
40import dk.aau.cs.gui.undo.RenameTimedPlaceCommand;
41import dk.aau.cs.gui.undo.TimedPlaceMarkingEdit;
42import dk.aau.cs.gui.undo.UnsharePlaceCommand;
43import dk.aau.cs.model.tapn.Bound.InfBound;34import dk.aau.cs.model.tapn.Bound.InfBound;
44import dk.aau.cs.model.tapn.Constant;35import dk.aau.cs.model.tapn.Constant;
45import dk.aau.cs.model.tapn.ConstantBound;36import dk.aau.cs.model.tapn.ConstantBound;
@@ -585,17 +576,19 @@
585 JOptionPane.showMessageDialog(this, "The specified name is already used by another place or transition.", "Error", JOptionPane.ERROR_MESSAGE);576 JOptionPane.showMessageDialog(this, "The specified name is already used by another place or transition.", "Error", JOptionPane.ERROR_MESSAGE);
586 return false;577 return false;
587 } 578 }
588 579
589 Command renameCommand = new RenameTimedPlaceCommand(context.tabContent(), (LocalTimedPlace)place.underlyingPlace(), oldName, newName);580 if (!oldName.equals(newName)) {
590 context.undoManager().addEdit(renameCommand);581 Command renameCommand = new RenameTimedPlaceCommand(context.tabContent(), (LocalTimedPlace) place.underlyingPlace(), oldName, newName);
591 try{ // set name582 context.undoManager().addEdit(renameCommand);
592 renameCommand.redo();583 try { // set name
593 }catch(RequireException e){584 renameCommand.redo();
594 context.undoManager().undo(); 585 } catch (RequireException e) {
595 JOptionPane.showMessageDialog(this, "Acceptable names for transitions are defined by the regular expression:\n[a-zA-Z][_a-zA-Z0-9]*\n\nNote that \"true\" and \"false\" are reserved keywords.", "Error", JOptionPane.ERROR_MESSAGE);586 context.undoManager().undo();
596 return false;587 JOptionPane.showMessageDialog(this, "Acceptable names for transitions are defined by the regular expression:\n[a-zA-Z][_a-zA-Z0-9]*\n\nNote that \"true\" and \"false\" are reserved keywords.", "Error", JOptionPane.ERROR_MESSAGE);
597 }588 return false;
598 context.nameGenerator().updateIndices(context.activeModel(), newName);589 }
590 context.nameGenerator().updateIndices(context.activeModel(), newName);
591 }
599 592
600 if(makeNewShared){593 if(makeNewShared){
601 Command command = new MakePlaceNewSharedCommand(context.activeModel(), newName, place.underlyingPlace(), place, context.tabContent(), false);594 Command command = new MakePlaceNewSharedCommand(context.activeModel(), newName, place.underlyingPlace(), place, context.tabContent(), false);
@@ -637,6 +630,12 @@
637630
638 if ((place.getAttributesVisible() && !attributesCheckBox.isSelected()) || (!place.getAttributesVisible() && attributesCheckBox.isSelected())) {631 if ((place.getAttributesVisible() && !attributesCheckBox.isSelected()) || (!place.getAttributesVisible() && attributesCheckBox.isSelected())) {
639 place.toggleAttributesVisible();632 place.toggleAttributesVisible();
633
634 Map<PetriNetObject, Boolean> map = new HashMap<>();
635 map.put(place, !place.getAttributesVisible());
636
637 Command changeVisibility = new ChangeAllNamesVisibilityCommand(currentTab, map, null, place.getAttributesVisible());
638 context.undoManager().addEdit(changeVisibility);
640 }639 }
641 place.update(true);640 place.update(true);
642 place.repaint();641 place.repaint();
643642
=== modified file 'src/pipe/gui/widgets/QueryDialog.java'
--- src/pipe/gui/widgets/QueryDialog.java 2021-03-29 10:08:13 +0000
+++ src/pipe/gui/widgets/QueryDialog.java 2021-08-03 09:29:22 +0000
@@ -314,7 +314,7 @@
314 private final static String TOOL_TIP_SAVE_AND_VERIFY_BUTTON = "Save and verify the query.";314 private final static String TOOL_TIP_SAVE_AND_VERIFY_BUTTON = "Save and verify the query.";
315 private final static String TOOL_TIP_CANCEL_BUTTON = "Cancel the changes made in this dialog.";315 private final static String TOOL_TIP_CANCEL_BUTTON = "Cancel the changes made in this dialog.";
316 private final static String TOOL_TIP_SAVE_UPPAAL_BUTTON = "Export an xml file that can be opened in UPPAAL GUI.";316 private final static String TOOL_TIP_SAVE_UPPAAL_BUTTON = "Export an xml file that can be opened in UPPAAL GUI.";
317 private final static String TOOL_TIP_SAVE_COMPOSED_BUTTON = "Export an xml file of composed net and approximated net if enabled";317 private final static String TOOL_TIP_SAVE_COMPOSED_BUTTON = "Open a composed net in a new tab and use approximated net if enabled";
318 private final static String TOOL_TIP_OPEN_REDUCED_BUTTON = "Open the net produced after applying structural reduction rules";318 private final static String TOOL_TIP_OPEN_REDUCED_BUTTON = "Open the net produced after applying structural reduction rules";
319 private final static String TOOL_TIP_SAVE_TAPAAL_BUTTON = "Export an xml file that can be used as input for the TAPAAL engine.";319 private final static String TOOL_TIP_SAVE_TAPAAL_BUTTON = "Export an xml file that can be used as input for the TAPAAL engine.";
320 private final static String TOOL_TIP_SAVE_PN_BUTTON = "Export an xml file that can be used as input for the untimed Petri net engine.";320 private final static String TOOL_TIP_SAVE_PN_BUTTON = "Export an xml file that can be used as input for the untimed Petri net engine.";
321321
=== modified file 'src/pipe/gui/widgets/TAPNTransitionEditor.java'
--- src/pipe/gui/widgets/TAPNTransitionEditor.java 2021-04-08 08:30:29 +0000
+++ src/pipe/gui/widgets/TAPNTransitionEditor.java 2021-08-03 09:29:22 +0000
@@ -4,6 +4,8 @@
4import java.awt.event.ActionEvent;4import java.awt.event.ActionEvent;
5import java.awt.event.ActionListener;5import java.awt.event.ActionListener;
6import java.util.ArrayList;6import java.util.ArrayList;
7import java.util.HashMap;
8import java.util.Map;
7import java.util.Vector;9import java.util.Vector;
810
9import javax.swing.DefaultComboBoxModel;11import javax.swing.DefaultComboBoxModel;
@@ -21,6 +23,7 @@
21import net.tapaal.swinghelpers.SwingHelper;23import net.tapaal.swinghelpers.SwingHelper;
22import net.tapaal.swinghelpers.WidthAdjustingComboBox;24import net.tapaal.swinghelpers.WidthAdjustingComboBox;
23import pipe.gui.CreateGui;25import pipe.gui.CreateGui;
26import pipe.gui.graphicElements.PetriNetObject;
24import pipe.gui.graphicElements.tapn.TimedTransitionComponent;27import pipe.gui.graphicElements.tapn.TimedTransitionComponent;
25import dk.aau.cs.gui.Context;28import dk.aau.cs.gui.Context;
26import dk.aau.cs.model.tapn.Bound;29import dk.aau.cs.model.tapn.Bound;
@@ -383,11 +386,13 @@
383 }386 }
384 try{387 try{
385 String oldName = transition.underlyingTransition().name();388 String oldName = transition.underlyingTransition().name();
389 if (!oldName.equals(newName)) {
386 transition.underlyingTransition().setName(newName);390 transition.underlyingTransition().setName(newName);
387 Command renameCommand = new RenameTimedTransitionCommand(context.tabContent(), transition.underlyingTransition(), oldName, newName);391 Command renameCommand = new RenameTimedTransitionCommand(context.tabContent(), transition.underlyingTransition(), oldName, newName);
388 context.undoManager().addEdit(renameCommand);392 context.undoManager().addEdit(renameCommand);
389 // set name393 // set name
390 renameCommand.redo();394 renameCommand.redo();
395 }
391 }catch(RequireException e){396 }catch(RequireException e){
392 context.undoManager().undo(); 397 context.undoManager().undo();
393 JOptionPane.showMessageDialog(this,398 JOptionPane.showMessageDialog(this,
@@ -457,6 +462,12 @@
457 462
458 if(transition.getAttributesVisible() && !attributesCheckBox.isSelected() || (!transition.getAttributesVisible() && attributesCheckBox.isSelected())) {463 if(transition.getAttributesVisible() && !attributesCheckBox.isSelected() || (!transition.getAttributesVisible() && attributesCheckBox.isSelected())) {
459 transition.toggleAttributesVisible();464 transition.toggleAttributesVisible();
465
466 Map<PetriNetObject, Boolean> map = new HashMap<>();
467 map.put(transition, !transition.getAttributesVisible());
468
469 Command changeVisibility = new ChangeAllNamesVisibilityCommand(context.tabContent(), null, map, transition.getAttributesVisible());
470 context.undoManager().addEdit(changeVisibility);
460 }471 }
461 472
462 transition.update(true);473 transition.update(true);

Subscribers

People subscribed via source and target branches