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

Proposed by Lena Said
Status: Needs review
Proposed branch: lp:~tapaal-contributor/tapaal/hide-show-names-1921393
Merge into: lp:tapaal
Diff against target: 266 lines (+97/-6)
8 files modified
src/dk/aau/cs/gui/TabContent.java (+28/-2)
src/dk/aau/cs/gui/TabContentActions.java (+4/-0)
src/pipe/gui/GuiFrame.java (+27/-0)
src/pipe/gui/GuiFrameActions.java (+2/-0)
src/pipe/gui/GuiFrameController.java (+28/-0)
src/pipe/gui/GuiFrameControllerActions.java (+4/-0)
src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java (+2/-2)
src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java (+2/-2)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/hide-show-names-1921393
Reviewer Review Type Date Requested Status
Jiri Srba Needs Fixing
Review via email: mp+400298@code.launchpad.net

Commit message

Place/transition names are hidden when turned off in 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 either "Display place names" or "Display transition names" to hide them.

To post a comment you must log in.
Jiri Srba (srba) wrote :

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

Unmerged revisions

1126. By Lena Said on 2021-03-27

Place/transition names stays hidden when changing templates

1125. By Lena Said on 2021-03-27

Place/transition names stays hidden when changing tabs

1124. By Lena Said on 2021-03-27

Transition names are displayed correctly when 'display all transition' is ticked

1123. By Lena Said on 2021-03-27

Refactored parameter name

1122. By Lena Said on 2021-03-27

Added 'show/hide all transition/place names' in the view. Transition names are not displayed properly.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dk/aau/cs/gui/TabContent.java'
2--- src/dk/aau/cs/gui/TabContent.java 2020-10-30 21:14:42 +0000
3+++ src/dk/aau/cs/gui/TabContent.java 2021-03-28 08:35:53 +0000
4@@ -161,7 +161,7 @@
5 Require.notNull(p, "Point can't be null");
6
7 dk.aau.cs.model.tapn.LocalTimedPlace tp = new dk.aau.cs.model.tapn.LocalTimedPlace(drawingSurface.getNameGenerator().getNewPlaceName(guiModelToModel.get(c)));
8- TimedPlaceComponent pnObject = new TimedPlaceComponent(p.x, p.y, tp, lens);
9+ TimedPlaceComponent pnObject = new TimedPlaceComponent(p.x, p.y, tp, lens, isPlaceNameVisible);
10 guiModelToModel.get(c).add(tp);
11 c.addPetriNetObject(pnObject);
12
13@@ -173,7 +173,7 @@
14 dk.aau.cs.model.tapn.TimedTransition transition = new dk.aau.cs.model.tapn.TimedTransition(drawingSurface.getNameGenerator().getNewTransitionName(guiModelToModel.get(c)));
15
16 transition.setUncontrollable(isUncontrollable);
17- TimedTransitionComponent pnObject = new TimedTransitionComponent(p.x, p.y, transition, lens);
18+ TimedTransitionComponent pnObject = new TimedTransitionComponent(p.x, p.y, transition, lens, isTransitionNameVisible);
19
20 guiModelToModel.get(c).add(transition);
21 c.addPetriNetObject(pnObject);
22@@ -843,6 +843,8 @@
23
24 private WorkflowDialog workflowDialog = null;
25
26+ private boolean isPlaceNameVisible = true;
27+ private boolean isTransitionNameVisible = true;
28
29 private TabContent(boolean isTimed, boolean isGame) {
30 this(new TimedArcPetriNetNetwork(), new ArrayList<>(), new TAPNLens(isTimed,isGame));
31@@ -1621,6 +1623,28 @@
32 }
33 }
34
35+ @Override
36+ public void showPlaceNames(boolean isVisible) {
37+ Component[] components = drawingSurface.getComponents();
38+ for (Component component : components) {
39+ if (component instanceof TimedPlaceComponent) {
40+ ((TimedPlaceComponent) component).getNameLabel().displayName(isVisible);
41+ }
42+ }
43+ isPlaceNameVisible = isVisible;
44+ }
45+
46+ @Override
47+ public void showTransitionNames(boolean isVisible) {
48+ Component[] components = drawingSurface.getComponents();
49+ for (Component component : components) {
50+ if (component instanceof TimedTransitionComponent) {
51+ ((TimedTransitionComponent) component).getNameLabel().setVisible(isVisible);
52+ }
53+ }
54+ isTransitionNameVisible = isVisible;
55+ }
56+
57 public static Split getEditorModelRoot(){
58 return editorModelroot;
59 }
60@@ -1674,6 +1698,8 @@
61 drawingSurface.getSelectionObject().clearSelection();
62
63 }
64+ showPlaceNames(isPlaceNameVisible);
65+ showTransitionNames(isTransitionNameVisible);
66 }
67
68
69
70=== modified file 'src/dk/aau/cs/gui/TabContentActions.java'
71--- src/dk/aau/cs/gui/TabContentActions.java 2020-08-11 11:51:55 +0000
72+++ src/dk/aau/cs/gui/TabContentActions.java 2021-03-28 08:35:53 +0000
73@@ -96,4 +96,8 @@
74
75 void changeGameFeature(boolean isGame);
76
77+ void showPlaceNames(boolean isVisible);
78+
79+ void showTransitionNames(boolean isVisible);
80+
81 }
82
83=== modified file 'src/pipe/gui/GuiFrame.java'
84--- src/pipe/gui/GuiFrame.java 2020-12-16 08:38:28 +0000
85+++ src/pipe/gui/GuiFrame.java 2021-03-28 08:35:53 +0000
86@@ -333,6 +333,16 @@
87 guiFrameController.ifPresent(GuiFrameControllerActions::toggleDisplayToolTips);
88 }
89 };
90+ private final GuiAction showPlaceNames = new GuiAction("Display place names ", "Show/hide names of all places", true) {
91+ public void actionPerformed(ActionEvent e) {
92+ guiFrameController.ifPresent(GuiFrameControllerActions::toggleDisplayPlaceNames);
93+ }
94+ };
95+ private final GuiAction showTransitionNames = new GuiAction("Display transition names", "Show/hide names of all transitions", true) {
96+ public void actionPerformed(ActionEvent e) {
97+ guiFrameController.ifPresent(GuiFrameControllerActions::toggleDisplayTransitionNames);
98+ }
99+ };
100 private final GuiAction showAdvancedWorkspaceAction = new GuiAction("Show advanced workspace", "Show all panels", false) {
101 public void actionPerformed(ActionEvent e) {
102 guiFrameController.ifPresent(GuiFrameControllerActions::showAdvancedWorkspace);
103@@ -674,6 +684,9 @@
104
105 showTokenAgeCheckBox = addCheckboxMenuItem(viewMenu, showTokenAge(), showTokenAgeAction);
106
107+ addCheckboxMenuItem(viewMenu, showPlaceNames);
108+ addCheckboxMenuItem(viewMenu, showTransitionNames);
109+
110 viewMenu.addSeparator();
111
112 viewMenu.add(showSimpleWorkspaceAction);
113@@ -1067,6 +1080,8 @@
114 showDelayEnabledTransitionsAction.setEnabled(enable);
115 showToolTipsAction.setEnabled(enable);
116 showTokenAgeAction.setEnabled(enable);
117+ showPlaceNames.setEnabled(enable);
118+ showTransitionNames.setEnabled(enable);
119 showAdvancedWorkspaceAction.setEnabled(enable);
120 showSimpleWorkspaceAction.setEnabled(enable);
121 saveWorkSpaceAction.setEnabled(enable);
122@@ -1255,6 +1270,8 @@
123 // create a tabChanged event loop.
124 // Throw exception if tab is not found
125 appTab.setSelectedComponent(tab);
126+ guiFrameController.ifPresent(GuiFrameControllerActions::updateDisplayPlaceNames);
127+ guiFrameController.ifPresent(GuiFrameControllerActions::updateDisplayTransitionNames);
128 }
129 }
130
131@@ -1294,6 +1311,16 @@
132 }
133
134 @Override
135+ public void setShowPlaceNames(boolean b) {
136+ showPlaceNames.setSelected(b);
137+ }
138+
139+ @Override
140+ public void setShowTransitionNames(boolean b) {
141+ showTransitionNames.setSelected(b);
142+ }
143+
144+ @Override
145 public void setShowZeroToInfinityIntervalsSelected(boolean b) {
146 showZeroToInfinityIntervalsAction.setSelected(b);
147 }
148
149=== modified file 'src/pipe/gui/GuiFrameActions.java'
150--- src/pipe/gui/GuiFrameActions.java 2020-08-11 11:51:55 +0000
151+++ src/pipe/gui/GuiFrameActions.java 2021-03-28 08:35:53 +0000
152@@ -48,6 +48,8 @@
153 void setShowEnabledTransitionsSelected(boolean b);
154 void setShowDelayEnabledTransitionsSelected(boolean b);
155 void setShowToolTipsSelected(boolean b);
156+ void setShowPlaceNames(boolean b);
157+ void setShowTransitionNames(boolean b);
158 void setShowZeroToInfinityIntervalsSelected(boolean b);
159 void setShowTokenAgeSelected(boolean b);
160
161
162=== modified file 'src/pipe/gui/GuiFrameController.java'
163--- src/pipe/gui/GuiFrameController.java 2020-08-17 06:18:11 +0000
164+++ src/pipe/gui/GuiFrameController.java 2021-03-28 08:35:53 +0000
165@@ -58,6 +58,8 @@
166 boolean showEnabledTransitions = true;
167 boolean showDelayEnabledTransitions = true;
168 private boolean showToolTips = true;
169+ private boolean showPlaceNames = true;
170+ private boolean showTransitionNames = true;
171 private boolean showZeroToInfinityIntervals = true;
172 private boolean showTokenAge = true;
173
174@@ -114,6 +116,8 @@
175 //XXX fixes an issue where on first open of a net the time intervals are not shown
176 tab.drawingSurface().repaintAll();
177
178+ updateDisplayPlaceNames();
179+ updateDisplayTransitionNames();
180 }
181
182 //If needed, add boolean forceClose, where net is not checkedForSave and just closed
183@@ -691,6 +695,30 @@
184 }
185
186 @Override
187+ public void toggleDisplayPlaceNames() {
188+ showPlaceNames = !showPlaceNames;
189+ updateDisplayPlaceNames();
190+ }
191+
192+ @Override
193+ public void toggleDisplayTransitionNames() {
194+ showTransitionNames = !showTransitionNames;
195+ updateDisplayTransitionNames();
196+ }
197+
198+ @Override
199+ public void updateDisplayPlaceNames() {
200+ guiFrame.setShowPlaceNames(showPlaceNames);
201+ CreateGui.getTabs().forEach(o -> o.showPlaceNames(showPlaceNames));
202+ }
203+
204+ @Override
205+ public void updateDisplayTransitionNames() {
206+ guiFrame.setShowTransitionNames(showTransitionNames);
207+ CreateGui.getTabs().forEach(o -> o.showTransitionNames(showTransitionNames));
208+ }
209+
210+ @Override
211 public void showAdvancedWorkspace() {
212 showAdvancedWorkspace(true);
213 }
214
215=== modified file 'src/pipe/gui/GuiFrameControllerActions.java'
216--- src/pipe/gui/GuiFrameControllerActions.java 2020-05-18 18:17:06 +0000
217+++ src/pipe/gui/GuiFrameControllerActions.java 2021-03-28 08:35:53 +0000
218@@ -50,6 +50,10 @@
219 void toggleEnabledTransitionsList();
220 void toggleDelayEnabledTransitions();
221 void toggleDisplayToolTips();
222+ void toggleDisplayPlaceNames();
223+ void toggleDisplayTransitionNames();
224+ void updateDisplayPlaceNames();
225+ void updateDisplayTransitionNames();
226
227 void showAdvancedWorkspace();
228
229
230=== modified file 'src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java'
231--- src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2020-08-19 11:34:44 +0000
232+++ src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2021-03-28 08:35:53 +0000
233@@ -50,12 +50,12 @@
234 private Window ageOfTokensWindow = new Window(new Frame());
235 private final Shape dashedOutline = createDashedOutline();
236
237- public TimedPlaceComponent(int positionXInput, int positionYInput, dk.aau.cs.model.tapn.TimedPlace place, TabContent.TAPNLens lens) {
238+ public TimedPlaceComponent(int positionXInput, int positionYInput, dk.aau.cs.model.tapn.TimedPlace place, TabContent.TAPNLens lens, boolean placeNamesVisible) {
239 super(positionXInput, positionYInput);
240 this.place = place;
241 this.place.addTimedPlaceListener(listener);
242 this.lens = lens;
243- attributesVisible = true;
244+ attributesVisible = placeNamesVisible;
245
246 }
247
248
249=== modified file 'src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java'
250--- src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2020-08-19 11:36:09 +0000
251+++ src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2021-03-28 08:35:53 +0000
252@@ -37,12 +37,12 @@
253 private final dk.aau.cs.model.tapn.event.TimedTransitionListener listener;
254 private GeneralPath dashedOutline;
255
256- public TimedTransitionComponent(int positionXInput, int positionYInput, dk.aau.cs.model.tapn.TimedTransition transition, TabContent.TAPNLens lens) {
257+ public TimedTransitionComponent(int positionXInput, int positionYInput, dk.aau.cs.model.tapn.TimedTransition transition, TabContent.TAPNLens lens, boolean transitionNamesVisible) {
258 super(positionXInput, positionYInput);
259 this.transition = transition;
260 listener = timedTransitionListener();
261 transition.addTimedTransitionListener(listener);
262- attributesVisible = true;
263+ attributesVisible = transitionNamesVisible;
264 this.lens = lens;
265
266 }

Subscribers

People subscribed via source and target branches