Merge lp:~tapaal-contributor/tapaal/hide-show-names-1921393 into lp:tapaal
- hide-show-names-1921393
- Merge into trunk
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 | ||||
Related bugs: |
|
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.
Jiri Srba (srba) wrote : Posted in a previous version of this proposal | # |
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).
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).
- 1145. By Lena Ernstsen
-
Changed tooltip for 'Merge Composed Net'
- 1146. By Lena Ernstsen
-
Changed tooltip for 'Merge Composed Net'
Jiri Srba (srba) : | # |
Preview Diff
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-08-03 09:29:22 +0000 | |||
4 | @@ -16,6 +16,7 @@ | |||
5 | 16 | import dk.aau.cs.TCTL.*; | 16 | import dk.aau.cs.TCTL.*; |
6 | 17 | import dk.aau.cs.debug.Logger; | 17 | import dk.aau.cs.debug.Logger; |
7 | 18 | import dk.aau.cs.gui.components.BugHandledJXMultisplitPane; | 18 | import dk.aau.cs.gui.components.BugHandledJXMultisplitPane; |
8 | 19 | import dk.aau.cs.gui.components.NameVisibilityPanel; | ||
9 | 19 | import dk.aau.cs.gui.components.StatisticsPanel; | 20 | import dk.aau.cs.gui.components.StatisticsPanel; |
10 | 20 | import dk.aau.cs.gui.components.TransitionFireingComponent; | 21 | import dk.aau.cs.gui.components.TransitionFireingComponent; |
11 | 21 | import dk.aau.cs.gui.undo.*; | 22 | import dk.aau.cs.gui.undo.*; |
12 | @@ -843,8 +844,14 @@ | |||
13 | 843 | 844 | ||
14 | 844 | private WorkflowDialog workflowDialog = null; | 845 | private WorkflowDialog workflowDialog = null; |
15 | 845 | 846 | ||
18 | 846 | 847 | private NameVisibilityPanel nameVisibilityPanel = null; | |
19 | 847 | private TabContent(boolean isTimed, boolean isGame) { | 848 | |
20 | 849 | private Boolean showNamesOption = null; | ||
21 | 850 | private Boolean isSelectedComponentOption = null; | ||
22 | 851 | private Boolean isPlaceOption = null; | ||
23 | 852 | private Boolean isTransitionOption = null; | ||
24 | 853 | |||
25 | 854 | private TabContent(boolean isTimed, boolean isGame) { | ||
26 | 848 | this(new TimedArcPetriNetNetwork(), new ArrayList<>(), new TAPNLens(isTimed,isGame)); | 855 | this(new TimedArcPetriNetNetwork(), new ArrayList<>(), new TAPNLens(isTimed,isGame)); |
27 | 849 | } | 856 | } |
28 | 850 | 857 | ||
29 | @@ -903,6 +910,8 @@ | |||
30 | 903 | this.setDividerSize(8); | 910 | this.setDividerSize(8); |
31 | 904 | //XXX must be after the animationcontroller is created | 911 | //XXX must be after the animationcontroller is created |
32 | 905 | animationModeController = new CanvasAnimationController(getAnimator()); | 912 | animationModeController = new CanvasAnimationController(getAnimator()); |
33 | 913 | |||
34 | 914 | nameVisibilityPanel = new NameVisibilityPanel(this); | ||
35 | 906 | } | 915 | } |
36 | 907 | 916 | ||
37 | 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) { |
38 | @@ -1621,6 +1630,39 @@ | |||
39 | 1621 | } | 1630 | } |
40 | 1622 | } | 1631 | } |
41 | 1623 | 1632 | ||
42 | 1633 | @Override | ||
43 | 1634 | public Map<PetriNetObject, Boolean> showNames(boolean showNames, boolean placeNames, boolean selectedComponent) { | ||
44 | 1635 | Map<PetriNetObject, Boolean> map = new HashMap<>(); | ||
45 | 1636 | List<PetriNetObject> components = new ArrayList<>(); | ||
46 | 1637 | |||
47 | 1638 | if (selectedComponent) { | ||
48 | 1639 | Template template = currentTemplate(); | ||
49 | 1640 | template.guiModel().getPetriNetObjects().forEach(components::add); | ||
50 | 1641 | } else { | ||
51 | 1642 | Iterable<Template> templates = allTemplates(); | ||
52 | 1643 | for (Template template : templates) { | ||
53 | 1644 | template.guiModel().getPetriNetObjects().forEach(components::add); | ||
54 | 1645 | } | ||
55 | 1646 | } | ||
56 | 1647 | |||
57 | 1648 | for (Component component : components) { | ||
58 | 1649 | if (placeNames && component instanceof TimedPlaceComponent) { | ||
59 | 1650 | TimedPlaceComponent place = (TimedPlaceComponent) component; | ||
60 | 1651 | map.put(place, place.getAttributesVisible()); | ||
61 | 1652 | place.setAttributesVisible(showNames); | ||
62 | 1653 | place.update(true); | ||
63 | 1654 | repaint(); | ||
64 | 1655 | } else if (!placeNames && component instanceof TimedTransitionComponent) { | ||
65 | 1656 | TimedTransitionComponent transition = (TimedTransitionComponent) component; | ||
66 | 1657 | map.put(transition, transition.getAttributesVisible()); | ||
67 | 1658 | transition.setAttributesVisible(showNames); | ||
68 | 1659 | transition.update(true); | ||
69 | 1660 | repaint(); | ||
70 | 1661 | } | ||
71 | 1662 | } | ||
72 | 1663 | return map; | ||
73 | 1664 | } | ||
74 | 1665 | |||
75 | 1624 | public static Split getEditorModelRoot(){ | 1666 | public static Split getEditorModelRoot(){ |
76 | 1625 | return editorModelroot; | 1667 | return editorModelroot; |
77 | 1626 | } | 1668 | } |
78 | @@ -1839,6 +1881,21 @@ | |||
79 | 1839 | StatisticsPanel.showStatisticsPanel(drawingSurface().getModel().getStatistics()); | 1881 | StatisticsPanel.showStatisticsPanel(drawingSurface().getModel().getStatistics()); |
80 | 1840 | } | 1882 | } |
81 | 1841 | 1883 | ||
82 | 1884 | @Override | ||
83 | 1885 | public void showChangeNameVisibility() { | ||
84 | 1886 | NameVisibilityPanel panel = new NameVisibilityPanel(this); | ||
85 | 1887 | if (showNamesOption != null && isSelectedComponentOption != null && isPlaceOption != null && isTransitionOption != null) { | ||
86 | 1888 | panel.showNameVisibilityPanel(showNamesOption, isPlaceOption, isTransitionOption, isSelectedComponentOption); | ||
87 | 1889 | } else { | ||
88 | 1890 | panel.showNameVisibilityPanel(); | ||
89 | 1891 | } | ||
90 | 1892 | |||
91 | 1893 | showNamesOption = panel.isShowNamesOption(); | ||
92 | 1894 | isPlaceOption = panel.isPlaceOption(); | ||
93 | 1895 | isTransitionOption = panel.isTransitionOption(); | ||
94 | 1896 | isSelectedComponentOption = panel.isSelectedComponentOption(); | ||
95 | 1897 | } | ||
96 | 1898 | |||
97 | 1842 | @Override | 1899 | @Override |
98 | 1843 | public void importSUMOQueries() { | 1900 | public void importSUMOQueries() { |
99 | 1844 | File[] files = FileBrowser.constructor("Import SUMO", "txt", FileBrowser.userPath).openFiles(); | 1901 | File[] files = FileBrowser.constructor("Import SUMO", "txt", FileBrowser.userPath).openFiles(); |
100 | 1845 | 1902 | ||
101 | === modified file 'src/dk/aau/cs/gui/TabContentActions.java' | |||
102 | --- src/dk/aau/cs/gui/TabContentActions.java 2020-08-11 11:51:55 +0000 | |||
103 | +++ src/dk/aau/cs/gui/TabContentActions.java 2021-08-03 09:29:22 +0000 | |||
104 | @@ -4,8 +4,10 @@ | |||
105 | 4 | import pipe.gui.GuiFrameActions; | 4 | import pipe.gui.GuiFrameActions; |
106 | 5 | import pipe.gui.Pipe; | 5 | import pipe.gui.Pipe; |
107 | 6 | import pipe.gui.SafeGuiFrameActions; | 6 | import pipe.gui.SafeGuiFrameActions; |
108 | 7 | import pipe.gui.graphicElements.PetriNetObject; | ||
109 | 7 | 8 | ||
110 | 8 | import java.io.File; | 9 | import java.io.File; |
111 | 10 | import java.util.Map; | ||
112 | 9 | 11 | ||
113 | 10 | public interface TabContentActions { | 12 | public interface TabContentActions { |
114 | 11 | 13 | ||
115 | @@ -96,4 +98,9 @@ | |||
116 | 96 | 98 | ||
117 | 97 | void changeGameFeature(boolean isGame); | 99 | void changeGameFeature(boolean isGame); |
118 | 98 | 100 | ||
119 | 101 | Map<PetriNetObject, Boolean> showNames(boolean isVisible, boolean placeNames, boolean selectedComponent); | ||
120 | 102 | |||
121 | 103 | void showChangeNameVisibility(); | ||
122 | 104 | |||
123 | 105 | |||
124 | 99 | } | 106 | } |
125 | 100 | 107 | ||
126 | === added file 'src/dk/aau/cs/gui/components/NameVisibilityPanel.java' | |||
127 | --- src/dk/aau/cs/gui/components/NameVisibilityPanel.java 1970-01-01 00:00:00 +0000 | |||
128 | +++ src/dk/aau/cs/gui/components/NameVisibilityPanel.java 2021-08-03 09:29:22 +0000 | |||
129 | @@ -0,0 +1,247 @@ | |||
130 | 1 | package dk.aau.cs.gui.components; | ||
131 | 2 | |||
132 | 3 | import dk.aau.cs.gui.TabContent; | ||
133 | 4 | import dk.aau.cs.gui.undo.ChangeAllNamesVisibilityCommand; | ||
134 | 5 | import dk.aau.cs.gui.undo.Command; | ||
135 | 6 | import pipe.gui.graphicElements.PetriNetObject; | ||
136 | 7 | |||
137 | 8 | import javax.swing.*; | ||
138 | 9 | import java.awt.*; | ||
139 | 10 | import java.util.HashMap; | ||
140 | 11 | import java.util.Map; | ||
141 | 12 | |||
142 | 13 | public class NameVisibilityPanel extends JPanel { | ||
143 | 14 | private static final String DIALOG_TITLE = "Change Name Visibility"; | ||
144 | 15 | |||
145 | 16 | private static JDialog dialog; | ||
146 | 17 | private JRadioButton showNames; | ||
147 | 18 | private JRadioButton hideNames; | ||
148 | 19 | private JRadioButton placeOption; | ||
149 | 20 | private JRadioButton transitionOption; | ||
150 | 21 | private JRadioButton bothOption; | ||
151 | 22 | private JRadioButton selectedComponent; | ||
152 | 23 | private JRadioButton allComponents; | ||
153 | 24 | |||
154 | 25 | ButtonGroup visibilityRadioButtonGroup; | ||
155 | 26 | ButtonGroup objectRadioButtonGroup; | ||
156 | 27 | ButtonGroup componentRadioButtonGroup; | ||
157 | 28 | |||
158 | 29 | JPanel visibilityPanel; | ||
159 | 30 | JPanel placeTransitionPanel; | ||
160 | 31 | JPanel componentPanel; | ||
161 | 32 | |||
162 | 33 | private final TabContent tab; | ||
163 | 34 | |||
164 | 35 | public NameVisibilityPanel(TabContent tab) { | ||
165 | 36 | super(new GridBagLayout()); | ||
166 | 37 | |||
167 | 38 | this.tab = tab; | ||
168 | 39 | |||
169 | 40 | init(); | ||
170 | 41 | } | ||
171 | 42 | |||
172 | 43 | public void showNameVisibilityPanel() { | ||
173 | 44 | JOptionPane optionPane = new JOptionPane(this, JOptionPane.INFORMATION_MESSAGE); | ||
174 | 45 | |||
175 | 46 | dialog = optionPane.createDialog(DIALOG_TITLE); | ||
176 | 47 | dialog.pack(); | ||
177 | 48 | dialog.setVisible(true); | ||
178 | 49 | |||
179 | 50 | Object selectedValue = optionPane.getValue(); | ||
180 | 51 | |||
181 | 52 | if (selectedValue != null) ChangeNameVisibilityBasedOnSelection(); | ||
182 | 53 | } | ||
183 | 54 | |||
184 | 55 | public void showNameVisibilityPanel(boolean isVisible, boolean isPlace, boolean isTransition, boolean isSelectedComponent) { | ||
185 | 56 | JOptionPane optionPane = new JOptionPane(this, JOptionPane.INFORMATION_MESSAGE); | ||
186 | 57 | |||
187 | 58 | showNames.setSelected(isVisible); | ||
188 | 59 | hideNames.setSelected(!isVisible); | ||
189 | 60 | placeOption.setSelected(isPlace && !isTransition); | ||
190 | 61 | transitionOption.setSelected(isTransition && !isPlace); | ||
191 | 62 | bothOption.setSelected(isPlace && isTransition); | ||
192 | 63 | selectedComponent.setSelected(isSelectedComponent); | ||
193 | 64 | allComponents.setSelected(!isSelectedComponent); | ||
194 | 65 | |||
195 | 66 | dialog = optionPane.createDialog(DIALOG_TITLE); | ||
196 | 67 | dialog.pack(); | ||
197 | 68 | dialog.setVisible(true); | ||
198 | 69 | |||
199 | 70 | Object selectedValue = optionPane.getValue(); | ||
200 | 71 | |||
201 | 72 | if (selectedValue != null) ChangeNameVisibilityBasedOnSelection(); | ||
202 | 73 | } | ||
203 | 74 | |||
204 | 75 | private void init() { | ||
205 | 76 | visibilityPanel = initVisibilityOptions(); | ||
206 | 77 | placeTransitionPanel = initPlaceTransitionOptions(); | ||
207 | 78 | componentPanel = initComponentOptions(); | ||
208 | 79 | |||
209 | 80 | GridBagConstraints gbc = new GridBagConstraints(); | ||
210 | 81 | gbc.gridx = 0; | ||
211 | 82 | gbc.gridy = 0; | ||
212 | 83 | gbc.anchor = GridBagConstraints.WEST; | ||
213 | 84 | gbc.gridwidth = 3; | ||
214 | 85 | gbc.insets = new Insets(5, 5, 5, 5); | ||
215 | 86 | |||
216 | 87 | this.add(visibilityPanel, gbc); | ||
217 | 88 | gbc.gridy = 1; | ||
218 | 89 | this.add(placeTransitionPanel, gbc); | ||
219 | 90 | gbc.gridy = 2; | ||
220 | 91 | this.add(componentPanel, gbc); | ||
221 | 92 | |||
222 | 93 | this.setVisible(true); | ||
223 | 94 | } | ||
224 | 95 | |||
225 | 96 | private JPanel initVisibilityOptions() { | ||
226 | 97 | JPanel panel = new JPanel(new GridBagLayout()); | ||
227 | 98 | visibilityRadioButtonGroup = new ButtonGroup(); | ||
228 | 99 | |||
229 | 100 | JLabel text = new JLabel("Choose visibility: "); | ||
230 | 101 | GridBagConstraints gbc = new GridBagConstraints(); | ||
231 | 102 | gbc.gridx = 0; | ||
232 | 103 | gbc.gridy = 0; | ||
233 | 104 | gbc.weightx = 0; | ||
234 | 105 | gbc.anchor = GridBagConstraints.WEST; | ||
235 | 106 | gbc.insets = new Insets(3, 3, 3, 3); | ||
236 | 107 | panel.add(text, gbc); | ||
237 | 108 | |||
238 | 109 | showNames = new JRadioButton("Show"); | ||
239 | 110 | showNames.setSelected(true); | ||
240 | 111 | gbc = new GridBagConstraints(); | ||
241 | 112 | gbc.gridx = 1; | ||
242 | 113 | gbc.gridy = 0; | ||
243 | 114 | gbc.weightx = 0; | ||
244 | 115 | gbc.anchor = GridBagConstraints.WEST; | ||
245 | 116 | gbc.insets = new Insets(3, 3, 3, 3); | ||
246 | 117 | panel.add(showNames, gbc); | ||
247 | 118 | visibilityRadioButtonGroup.add(showNames); | ||
248 | 119 | |||
249 | 120 | hideNames = new JRadioButton("Hide"); | ||
250 | 121 | gbc = new GridBagConstraints(); | ||
251 | 122 | gbc.gridx = 2; | ||
252 | 123 | gbc.gridy = 0; | ||
253 | 124 | gbc.weightx = 0; | ||
254 | 125 | gbc.anchor = GridBagConstraints.WEST; | ||
255 | 126 | gbc.insets = new Insets(3, 3, 3, 3); | ||
256 | 127 | panel.add(hideNames, gbc); | ||
257 | 128 | visibilityRadioButtonGroup.add(hideNames); | ||
258 | 129 | |||
259 | 130 | return panel; | ||
260 | 131 | } | ||
261 | 132 | |||
262 | 133 | private JPanel initPlaceTransitionOptions() { | ||
263 | 134 | JPanel panel = new JPanel(new GridBagLayout()); | ||
264 | 135 | objectRadioButtonGroup = new ButtonGroup(); | ||
265 | 136 | |||
266 | 137 | JLabel text = new JLabel("Choose group: "); | ||
267 | 138 | GridBagConstraints gbc = new GridBagConstraints(); | ||
268 | 139 | gbc.gridx = 0; | ||
269 | 140 | gbc.gridy = 0; | ||
270 | 141 | gbc.weightx = 0; | ||
271 | 142 | gbc.anchor = GridBagConstraints.WEST; | ||
272 | 143 | gbc.insets = new Insets(3, 3, 3, 3); | ||
273 | 144 | panel.add(text, gbc); | ||
274 | 145 | |||
275 | 146 | placeOption = new JRadioButton("Places"); | ||
276 | 147 | placeOption.setSelected(true); | ||
277 | 148 | gbc = new GridBagConstraints(); | ||
278 | 149 | gbc.gridx = 1; | ||
279 | 150 | gbc.gridy = 0; | ||
280 | 151 | gbc.weightx = 0; | ||
281 | 152 | gbc.anchor = GridBagConstraints.WEST; | ||
282 | 153 | gbc.insets = new Insets(3, 3, 3, 3); | ||
283 | 154 | panel.add(placeOption, gbc); | ||
284 | 155 | objectRadioButtonGroup.add(placeOption); | ||
285 | 156 | |||
286 | 157 | transitionOption = new JRadioButton("Transitions"); | ||
287 | 158 | gbc = new GridBagConstraints(); | ||
288 | 159 | gbc.gridx = 2; | ||
289 | 160 | gbc.gridy = 0; | ||
290 | 161 | gbc.weightx = 0; | ||
291 | 162 | gbc.anchor = GridBagConstraints.WEST; | ||
292 | 163 | gbc.insets = new Insets(3, 3, 3, 3); | ||
293 | 164 | panel.add(transitionOption, gbc); | ||
294 | 165 | objectRadioButtonGroup.add(transitionOption); | ||
295 | 166 | |||
296 | 167 | bothOption = new JRadioButton("Both"); | ||
297 | 168 | gbc = new GridBagConstraints(); | ||
298 | 169 | gbc.gridx = 3; | ||
299 | 170 | gbc.gridy = 0; | ||
300 | 171 | gbc.weightx = 0; | ||
301 | 172 | gbc.anchor = GridBagConstraints.WEST; | ||
302 | 173 | gbc.insets = new Insets(3, 3, 3, 3); | ||
303 | 174 | panel.add(bothOption, gbc); | ||
304 | 175 | objectRadioButtonGroup.add(bothOption); | ||
305 | 176 | |||
306 | 177 | return panel; | ||
307 | 178 | } | ||
308 | 179 | |||
309 | 180 | private JPanel initComponentOptions() { | ||
310 | 181 | JPanel panel = new JPanel(new GridBagLayout()); | ||
311 | 182 | componentRadioButtonGroup = new ButtonGroup(); | ||
312 | 183 | |||
313 | 184 | JLabel text = new JLabel("Choose components: "); | ||
314 | 185 | GridBagConstraints gbc = new GridBagConstraints(); | ||
315 | 186 | gbc.gridx = 0; | ||
316 | 187 | gbc.gridy = 0; | ||
317 | 188 | gbc.weightx = 0; | ||
318 | 189 | gbc.anchor = GridBagConstraints.WEST; | ||
319 | 190 | gbc.insets = new Insets(3, 3, 3, 3); | ||
320 | 191 | panel.add(text, gbc); | ||
321 | 192 | |||
322 | 193 | selectedComponent = new JRadioButton("Selected component"); | ||
323 | 194 | selectedComponent.setSelected(true); | ||
324 | 195 | gbc = new GridBagConstraints(); | ||
325 | 196 | gbc.gridx = 1; | ||
326 | 197 | gbc.gridy = 0; | ||
327 | 198 | gbc.weightx = 0; | ||
328 | 199 | gbc.anchor = GridBagConstraints.WEST; | ||
329 | 200 | gbc.insets = new Insets(3, 3, 3, 3); | ||
330 | 201 | panel.add(selectedComponent, gbc); | ||
331 | 202 | componentRadioButtonGroup.add(selectedComponent); | ||
332 | 203 | |||
333 | 204 | allComponents = new JRadioButton("All components"); | ||
334 | 205 | gbc = new GridBagConstraints(); | ||
335 | 206 | gbc.gridx = 2; | ||
336 | 207 | gbc.gridy = 0; | ||
337 | 208 | gbc.weightx = 0; | ||
338 | 209 | gbc.anchor = GridBagConstraints.WEST; | ||
339 | 210 | gbc.insets = new Insets(3, 3, 3, 3); | ||
340 | 211 | panel.add(allComponents, gbc); | ||
341 | 212 | componentRadioButtonGroup.add(allComponents); | ||
342 | 213 | |||
343 | 214 | return panel; | ||
344 | 215 | } | ||
345 | 216 | |||
346 | 217 | protected void ChangeNameVisibilityBasedOnSelection() { | ||
347 | 218 | Map<PetriNetObject, Boolean> places = new HashMap<>(); | ||
348 | 219 | Map<PetriNetObject, Boolean> transitions = new HashMap<>(); | ||
349 | 220 | |||
350 | 221 | if (placeOption.isSelected() || bothOption.isSelected()) { | ||
351 | 222 | places = tab.showNames(showNames.isSelected(), true, selectedComponent.isSelected()); | ||
352 | 223 | } | ||
353 | 224 | if (transitionOption.isSelected() || bothOption.isSelected()) { | ||
354 | 225 | transitions = tab.showNames(showNames.isSelected(), false, selectedComponent.isSelected()); | ||
355 | 226 | } | ||
356 | 227 | |||
357 | 228 | Command changeVisibilityCommand = new ChangeAllNamesVisibilityCommand(tab, places, transitions, showNames.isSelected()); | ||
358 | 229 | tab.getUndoManager().addNewEdit(changeVisibilityCommand); | ||
359 | 230 | } | ||
360 | 231 | |||
361 | 232 | public boolean isShowNamesOption() { | ||
362 | 233 | return showNames.isSelected(); | ||
363 | 234 | } | ||
364 | 235 | |||
365 | 236 | public boolean isSelectedComponentOption() { | ||
366 | 237 | return selectedComponent.isSelected(); | ||
367 | 238 | } | ||
368 | 239 | |||
369 | 240 | public boolean isPlaceOption() { | ||
370 | 241 | return placeOption.isSelected() || bothOption.isSelected(); | ||
371 | 242 | } | ||
372 | 243 | |||
373 | 244 | public boolean isTransitionOption() { | ||
374 | 245 | return transitionOption.isSelected() || bothOption.isSelected(); | ||
375 | 246 | } | ||
376 | 247 | } | ||
377 | 0 | 248 | ||
378 | === added file 'src/dk/aau/cs/gui/undo/ChangeAllNamesVisibilityCommand.java' | |||
379 | --- src/dk/aau/cs/gui/undo/ChangeAllNamesVisibilityCommand.java 1970-01-01 00:00:00 +0000 | |||
380 | +++ src/dk/aau/cs/gui/undo/ChangeAllNamesVisibilityCommand.java 2021-08-03 09:29:22 +0000 | |||
381 | @@ -0,0 +1,70 @@ | |||
382 | 1 | package dk.aau.cs.gui.undo; | ||
383 | 2 | |||
384 | 3 | import dk.aau.cs.gui.TabContent; | ||
385 | 4 | import pipe.gui.graphicElements.PetriNetObject; | ||
386 | 5 | import pipe.gui.graphicElements.tapn.TimedPlaceComponent; | ||
387 | 6 | import pipe.gui.graphicElements.tapn.TimedTransitionComponent; | ||
388 | 7 | |||
389 | 8 | import java.util.Map; | ||
390 | 9 | |||
391 | 10 | public class ChangeAllNamesVisibilityCommand extends Command { | ||
392 | 11 | private final Map<PetriNetObject, Boolean> places; | ||
393 | 12 | private final Map<PetriNetObject, Boolean> transitions; | ||
394 | 13 | private final boolean isVisible; | ||
395 | 14 | private final TabContent tabContent; | ||
396 | 15 | |||
397 | 16 | public ChangeAllNamesVisibilityCommand(TabContent tabContent, Map<PetriNetObject, Boolean> places, Map<PetriNetObject, Boolean> transitions, boolean isVisible) { | ||
398 | 17 | this.tabContent = tabContent; | ||
399 | 18 | this.places = places; | ||
400 | 19 | this.transitions= transitions; | ||
401 | 20 | this.isVisible = isVisible; | ||
402 | 21 | } | ||
403 | 22 | |||
404 | 23 | @Override | ||
405 | 24 | public void redo() { | ||
406 | 25 | if (places != null) { | ||
407 | 26 | for (PetriNetObject place : places.keySet()) { | ||
408 | 27 | if (place instanceof TimedPlaceComponent) { | ||
409 | 28 | TimedPlaceComponent component = (TimedPlaceComponent) place; | ||
410 | 29 | component.setAttributesVisible(isVisible); | ||
411 | 30 | component.update(true); | ||
412 | 31 | tabContent.repaint(); | ||
413 | 32 | } | ||
414 | 33 | } | ||
415 | 34 | } | ||
416 | 35 | if (transitions != null) { | ||
417 | 36 | for (PetriNetObject transition : transitions.keySet()) { | ||
418 | 37 | if (transition instanceof TimedTransitionComponent) { | ||
419 | 38 | TimedTransitionComponent component = (TimedTransitionComponent) transition; | ||
420 | 39 | component.setAttributesVisible(isVisible); | ||
421 | 40 | component.update(true); | ||
422 | 41 | tabContent.repaint(); | ||
423 | 42 | } | ||
424 | 43 | } | ||
425 | 44 | } | ||
426 | 45 | } | ||
427 | 46 | |||
428 | 47 | @Override | ||
429 | 48 | public void undo() { | ||
430 | 49 | if (places != null) { | ||
431 | 50 | for (PetriNetObject place : places.keySet()) { | ||
432 | 51 | if (place instanceof TimedPlaceComponent) { | ||
433 | 52 | TimedPlaceComponent component = (TimedPlaceComponent) place; | ||
434 | 53 | component.setAttributesVisible(places.get(component)); | ||
435 | 54 | component.update(true); | ||
436 | 55 | tabContent.repaint(); | ||
437 | 56 | } | ||
438 | 57 | } | ||
439 | 58 | } | ||
440 | 59 | if (transitions != null) { | ||
441 | 60 | for (PetriNetObject transition : transitions.keySet()) { | ||
442 | 61 | if (transition instanceof TimedTransitionComponent) { | ||
443 | 62 | TimedTransitionComponent component = (TimedTransitionComponent) transition; | ||
444 | 63 | component.setAttributesVisible(transitions.get(component)); | ||
445 | 64 | component.update(true); | ||
446 | 65 | tabContent.repaint(); | ||
447 | 66 | } | ||
448 | 67 | } | ||
449 | 68 | } | ||
450 | 69 | } | ||
451 | 70 | } | ||
452 | 0 | 71 | ||
453 | === modified file 'src/dk/aau/cs/gui/undo/RenameTimedPlaceCommand.java' | |||
454 | --- src/dk/aau/cs/gui/undo/RenameTimedPlaceCommand.java 2011-03-12 12:12:12 +0000 | |||
455 | +++ src/dk/aau/cs/gui/undo/RenameTimedPlaceCommand.java 2021-08-03 09:29:22 +0000 | |||
456 | @@ -22,13 +22,13 @@ | |||
457 | 22 | public void redo() { | 22 | public void redo() { |
458 | 23 | place.setName(newName); | 23 | place.setName(newName); |
459 | 24 | updateQueries(oldName, newName); | 24 | updateQueries(oldName, newName); |
461 | 25 | } | 25 | } |
462 | 26 | 26 | ||
463 | 27 | @Override | 27 | @Override |
464 | 28 | public void undo() { | 28 | public void undo() { |
465 | 29 | place.setName(oldName); | 29 | place.setName(oldName); |
466 | 30 | updateQueries(newName,oldName); | 30 | updateQueries(newName,oldName); |
468 | 31 | } | 31 | } |
469 | 32 | 32 | ||
470 | 33 | private void updateQueries(String nameToFind, String nameToInsert){ | 33 | private void updateQueries(String nameToFind, String nameToInsert){ |
471 | 34 | RenamePlaceTCTLVisitor renameVisitor = new RenamePlaceTCTLVisitor(nameToFind, nameToInsert); | 34 | RenamePlaceTCTLVisitor renameVisitor = new RenamePlaceTCTLVisitor(nameToFind, nameToInsert); |
472 | 35 | 35 | ||
473 | === modified file 'src/pipe/gui/GuiFrame.java' | |||
474 | --- src/pipe/gui/GuiFrame.java 2021-04-08 08:39:05 +0000 | |||
475 | +++ src/pipe/gui/GuiFrame.java 2021-08-03 09:29:22 +0000 | |||
476 | @@ -18,10 +18,8 @@ | |||
477 | 18 | 18 | ||
478 | 19 | import com.sun.jna.Platform; | 19 | import com.sun.jna.Platform; |
479 | 20 | import dk.aau.cs.gui.*; | 20 | import dk.aau.cs.gui.*; |
480 | 21 | import dk.aau.cs.model.tapn.TimedArcPetriNet; | ||
481 | 22 | import dk.aau.cs.util.JavaUtil; | 21 | import dk.aau.cs.util.JavaUtil; |
482 | 23 | import dk.aau.cs.verification.VerifyTAPN.VerifyPN; | 22 | import dk.aau.cs.verification.VerifyTAPN.VerifyPN; |
483 | 24 | import dk.aau.cs.verification.VerifyTAPN.VerifyTAPNExporter; | ||
484 | 25 | import net.tapaal.Preferences; | 23 | import net.tapaal.Preferences; |
485 | 26 | import net.tapaal.TAPAAL; | 24 | import net.tapaal.TAPAAL; |
486 | 27 | import net.tapaal.helpers.Reference.MutableReference; | 25 | import net.tapaal.helpers.Reference.MutableReference; |
487 | @@ -30,10 +28,8 @@ | |||
488 | 30 | import net.tapaal.swinghelpers.SwingHelper; | 28 | import net.tapaal.swinghelpers.SwingHelper; |
489 | 31 | import net.tapaal.swinghelpers.ToggleButtonWithoutText; | 29 | import net.tapaal.swinghelpers.ToggleButtonWithoutText; |
490 | 32 | import org.jetbrains.annotations.NotNull; | 30 | import org.jetbrains.annotations.NotNull; |
491 | 33 | import pipe.dataLayer.TAPNQuery; | ||
492 | 34 | import pipe.gui.Pipe.ElementType; | 31 | import pipe.gui.Pipe.ElementType; |
493 | 35 | import pipe.gui.action.GuiAction; | 32 | import pipe.gui.action.GuiAction; |
494 | 36 | import pipe.gui.widgets.WorkflowDialog; | ||
495 | 37 | import dk.aau.cs.debug.Logger; | 33 | import dk.aau.cs.debug.Logger; |
496 | 38 | import dk.aau.cs.gui.smartDraw.SmartDrawDialog; | 34 | import dk.aau.cs.gui.smartDraw.SmartDrawDialog; |
497 | 39 | import net.tapaal.resourcemanager.ResourceManager; | 35 | import net.tapaal.resourcemanager.ResourceManager; |
498 | @@ -241,7 +237,7 @@ | |||
499 | 241 | SmartDrawDialog.showSmartDrawDialog(); | 237 | SmartDrawDialog.showSmartDrawDialog(); |
500 | 242 | } | 238 | } |
501 | 243 | }; | 239 | }; |
503 | 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))) { |
504 | 245 | public void actionPerformed(ActionEvent e) { | 241 | public void actionPerformed(ActionEvent e) { |
505 | 246 | currentTab.ifPresent(TabContentActions::mergeNetComponents); | 242 | currentTab.ifPresent(TabContentActions::mergeNetComponents); |
506 | 247 | } | 243 | } |
507 | @@ -334,6 +330,11 @@ | |||
508 | 334 | guiFrameController.ifPresent(GuiFrameControllerActions::toggleDisplayToolTips); | 330 | guiFrameController.ifPresent(GuiFrameControllerActions::toggleDisplayToolTips); |
509 | 335 | } | 331 | } |
510 | 336 | }; | 332 | }; |
511 | 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) { | ||
512 | 334 | public void actionPerformed(ActionEvent e) { | ||
513 | 335 | currentTab.ifPresent(TabContentActions::showChangeNameVisibility); | ||
514 | 336 | } | ||
515 | 337 | }; | ||
516 | 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) { |
517 | 338 | public void actionPerformed(ActionEvent e) { | 339 | public void actionPerformed(ActionEvent e) { |
518 | 339 | guiFrameController.ifPresent(GuiFrameControllerActions::showAdvancedWorkspace); | 340 | guiFrameController.ifPresent(GuiFrameControllerActions::showAdvancedWorkspace); |
519 | @@ -677,6 +678,10 @@ | |||
520 | 677 | 678 | ||
521 | 678 | viewMenu.addSeparator(); | 679 | viewMenu.addSeparator(); |
522 | 679 | 680 | ||
523 | 681 | viewMenu.add(changeNameVisibility); | ||
524 | 682 | |||
525 | 683 | viewMenu.addSeparator(); | ||
526 | 684 | |||
527 | 680 | viewMenu.add(showSimpleWorkspaceAction); | 685 | viewMenu.add(showSimpleWorkspaceAction); |
528 | 681 | viewMenu.add(showAdvancedWorkspaceAction); | 686 | viewMenu.add(showAdvancedWorkspaceAction); |
529 | 682 | viewMenu.add(saveWorkSpaceAction); | 687 | viewMenu.add(saveWorkSpaceAction); |
530 | @@ -1066,6 +1071,7 @@ | |||
531 | 1066 | showDelayEnabledTransitionsAction.setEnabled(enable); | 1071 | showDelayEnabledTransitionsAction.setEnabled(enable); |
532 | 1067 | showToolTipsAction.setEnabled(enable); | 1072 | showToolTipsAction.setEnabled(enable); |
533 | 1068 | showTokenAgeAction.setEnabled(enable); | 1073 | showTokenAgeAction.setEnabled(enable); |
534 | 1074 | changeNameVisibility.setEnabled(enable); | ||
535 | 1069 | showAdvancedWorkspaceAction.setEnabled(enable); | 1075 | showAdvancedWorkspaceAction.setEnabled(enable); |
536 | 1070 | showSimpleWorkspaceAction.setEnabled(enable); | 1076 | showSimpleWorkspaceAction.setEnabled(enable); |
537 | 1071 | saveWorkSpaceAction.setEnabled(enable); | 1077 | saveWorkSpaceAction.setEnabled(enable); |
538 | 1072 | 1078 | ||
539 | === modified file 'src/pipe/gui/GuiFrameActions.java' | |||
540 | --- src/pipe/gui/GuiFrameActions.java 2020-08-11 11:51:55 +0000 | |||
541 | +++ src/pipe/gui/GuiFrameActions.java 2021-08-03 09:29:22 +0000 | |||
542 | @@ -47,7 +47,7 @@ | |||
543 | 47 | void setShowQueriesSelected(boolean b); | 47 | void setShowQueriesSelected(boolean b); |
544 | 48 | void setShowEnabledTransitionsSelected(boolean b); | 48 | void setShowEnabledTransitionsSelected(boolean b); |
545 | 49 | void setShowDelayEnabledTransitionsSelected(boolean b); | 49 | void setShowDelayEnabledTransitionsSelected(boolean b); |
547 | 50 | void setShowToolTipsSelected(boolean b); | 50 | void setShowToolTipsSelected(boolean b);; |
548 | 51 | void setShowZeroToInfinityIntervalsSelected(boolean b); | 51 | void setShowZeroToInfinityIntervalsSelected(boolean b); |
549 | 52 | void setShowTokenAgeSelected(boolean b); | 52 | void setShowTokenAgeSelected(boolean b); |
550 | 53 | 53 | ||
551 | 54 | 54 | ||
552 | === modified file 'src/pipe/gui/GuiFrameController.java' | |||
553 | --- src/pipe/gui/GuiFrameController.java 2021-04-05 10:10:17 +0000 | |||
554 | +++ src/pipe/gui/GuiFrameController.java 2021-08-03 09:29:22 +0000 | |||
555 | @@ -113,7 +113,6 @@ | |||
556 | 113 | guiFrame.changeToTab(tab); | 113 | guiFrame.changeToTab(tab); |
557 | 114 | //XXX fixes an issue where on first open of a net the time intervals are not shown | 114 | //XXX fixes an issue where on first open of a net the time intervals are not shown |
558 | 115 | tab.drawingSurface().repaintAll(); | 115 | tab.drawingSurface().repaintAll(); |
559 | 116 | |||
560 | 117 | } | 116 | } |
561 | 118 | 117 | ||
562 | 119 | //If needed, add boolean forceClose, where net is not checkedForSave and just closed | 118 | //If needed, add boolean forceClose, where net is not checkedForSave and just closed |
563 | 120 | 119 | ||
564 | === modified file 'src/pipe/gui/canvas/DrawingSurfaceImpl.java' | |||
565 | --- src/pipe/gui/canvas/DrawingSurfaceImpl.java 2020-08-11 06:00:12 +0000 | |||
566 | +++ src/pipe/gui/canvas/DrawingSurfaceImpl.java 2021-08-03 09:29:22 +0000 | |||
567 | @@ -495,9 +495,11 @@ | |||
568 | 495 | 495 | ||
569 | 496 | 496 | ||
570 | 497 | public void translateSelection(ArrayList<PetriNetObject> objects, int transX, int transY) { | 497 | public void translateSelection(ArrayList<PetriNetObject> objects, int transX, int transY) { |
575 | 498 | tabContent.getUndoManager().newEdit(); // new "transaction"" | 498 | if (transX != 0 || transY != 0) { |
576 | 499 | for (PetriNetObject pnobject : objects) { | 499 | tabContent.getUndoManager().newEdit(); // new "transaction"" |
577 | 500 | tabContent.getUndoManager().addEdit(new TranslatePetriNetObjectEdit(pnobject, transX, transY, this)); | 500 | for (PetriNetObject pnobject : objects) { |
578 | 501 | } | 501 | tabContent.getUndoManager().addEdit(new TranslatePetriNetObjectEdit(pnobject, transX, transY, this)); |
579 | 502 | } | ||
580 | 503 | } | ||
581 | 502 | } | 504 | } |
582 | 503 | } | 505 | } |
583 | 504 | 506 | ||
584 | === modified file 'src/pipe/gui/graphicElements/PlaceTransitionObject.java' | |||
585 | --- src/pipe/gui/graphicElements/PlaceTransitionObject.java 2020-08-20 20:45:38 +0000 | |||
586 | +++ src/pipe/gui/graphicElements/PlaceTransitionObject.java 2021-08-03 09:29:22 +0000 | |||
587 | @@ -19,9 +19,9 @@ | |||
588 | 19 | private final LinkedList<Arc> connectTo = new LinkedList<Arc>(); | 19 | private final LinkedList<Arc> connectTo = new LinkedList<Arc>(); |
589 | 20 | private final LinkedList<Arc> connectFrom = new LinkedList<Arc>(); | 20 | private final LinkedList<Arc> connectFrom = new LinkedList<Arc>(); |
590 | 21 | 21 | ||
592 | 22 | protected boolean attributesVisible = false; | 22 | protected boolean attributesVisible = true; |
593 | 23 | 23 | ||
595 | 24 | public PlaceTransitionObject( | 24 | public PlaceTransitionObject( |
596 | 25 | double componentWidth, | 25 | double componentWidth, |
597 | 26 | double componentHeight, | 26 | double componentHeight, |
598 | 27 | int positionXInput, | 27 | int positionXInput, |
599 | 28 | 28 | ||
600 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java' | |||
601 | --- src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2021-04-04 09:31:12 +0000 | |||
602 | +++ src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2021-08-03 09:29:22 +0000 | |||
603 | @@ -55,7 +55,6 @@ | |||
604 | 55 | this.place = place; | 55 | this.place = place; |
605 | 56 | this.place.addTimedPlaceListener(listener); | 56 | this.place.addTimedPlaceListener(listener); |
606 | 57 | this.lens = lens; | 57 | this.lens = lens; |
607 | 58 | attributesVisible = true; | ||
608 | 59 | 58 | ||
609 | 60 | } | 59 | } |
610 | 61 | 60 | ||
611 | 62 | 61 | ||
612 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java' | |||
613 | --- src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2020-08-19 11:36:09 +0000 | |||
614 | +++ src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2021-08-03 09:29:22 +0000 | |||
615 | @@ -42,7 +42,6 @@ | |||
616 | 42 | this.transition = transition; | 42 | this.transition = transition; |
617 | 43 | listener = timedTransitionListener(); | 43 | listener = timedTransitionListener(); |
618 | 44 | transition.addTimedTransitionListener(listener); | 44 | transition.addTimedTransitionListener(listener); |
619 | 45 | attributesVisible = true; | ||
620 | 46 | this.lens = lens; | 45 | this.lens = lens; |
621 | 47 | 46 | ||
622 | 48 | } | 47 | } |
623 | 49 | 48 | ||
624 | === modified file 'src/pipe/gui/widgets/PlaceEditorPanel.java' | |||
625 | --- src/pipe/gui/widgets/PlaceEditorPanel.java 2021-04-08 08:30:29 +0000 | |||
626 | +++ src/pipe/gui/widgets/PlaceEditorPanel.java 2021-08-03 09:29:22 +0000 | |||
627 | @@ -6,10 +6,7 @@ | |||
628 | 6 | import java.awt.GridBagLayout; | 6 | import java.awt.GridBagLayout; |
629 | 7 | import java.awt.Insets; | 7 | import java.awt.Insets; |
630 | 8 | import java.awt.event.ItemEvent; | 8 | import java.awt.event.ItemEvent; |
635 | 9 | import java.util.Arrays; | 9 | import java.util.*; |
632 | 10 | import java.util.Collection; | ||
633 | 11 | import java.util.Set; | ||
634 | 12 | import java.util.Vector; | ||
636 | 13 | 10 | ||
637 | 14 | import javax.swing.ButtonGroup; | 11 | import javax.swing.ButtonGroup; |
638 | 15 | import javax.swing.DefaultComboBoxModel; | 12 | import javax.swing.DefaultComboBoxModel; |
639 | @@ -23,6 +20,7 @@ | |||
640 | 23 | import javax.swing.event.ChangeListener; | 20 | import javax.swing.event.ChangeListener; |
641 | 24 | 21 | ||
642 | 25 | import dk.aau.cs.gui.TabContent; | 22 | import dk.aau.cs.gui.TabContent; |
643 | 23 | import dk.aau.cs.gui.undo.*; | ||
644 | 26 | import net.tapaal.swinghelpers.CustomJSpinner; | 24 | import net.tapaal.swinghelpers.CustomJSpinner; |
645 | 27 | import net.tapaal.swinghelpers.GridBagHelper; | 25 | import net.tapaal.swinghelpers.GridBagHelper; |
646 | 28 | import net.tapaal.swinghelpers.SwingHelper; | 26 | import net.tapaal.swinghelpers.SwingHelper; |
647 | @@ -30,16 +28,9 @@ | |||
648 | 30 | import pipe.dataLayer.Template; | 28 | import pipe.dataLayer.Template; |
649 | 31 | import pipe.gui.CreateGui; | 29 | import pipe.gui.CreateGui; |
650 | 32 | import pipe.gui.Pipe; | 30 | import pipe.gui.Pipe; |
651 | 31 | import pipe.gui.graphicElements.PetriNetObject; | ||
652 | 33 | import pipe.gui.graphicElements.tapn.TimedPlaceComponent; | 32 | import pipe.gui.graphicElements.tapn.TimedPlaceComponent; |
653 | 34 | import dk.aau.cs.gui.Context; | 33 | import dk.aau.cs.gui.Context; |
654 | 35 | import dk.aau.cs.gui.undo.ChangedInvariantCommand; | ||
655 | 36 | import dk.aau.cs.gui.undo.Command; | ||
656 | 37 | import dk.aau.cs.gui.undo.MakePlaceSharedCommand; | ||
657 | 38 | import dk.aau.cs.gui.undo.MakePlaceNewSharedCommand; | ||
658 | 39 | import dk.aau.cs.gui.undo.MakePlaceNewSharedMultiCommand; | ||
659 | 40 | import dk.aau.cs.gui.undo.RenameTimedPlaceCommand; | ||
660 | 41 | import dk.aau.cs.gui.undo.TimedPlaceMarkingEdit; | ||
661 | 42 | import dk.aau.cs.gui.undo.UnsharePlaceCommand; | ||
662 | 43 | import dk.aau.cs.model.tapn.Bound.InfBound; | 34 | import dk.aau.cs.model.tapn.Bound.InfBound; |
663 | 44 | import dk.aau.cs.model.tapn.Constant; | 35 | import dk.aau.cs.model.tapn.Constant; |
664 | 45 | import dk.aau.cs.model.tapn.ConstantBound; | 36 | import dk.aau.cs.model.tapn.ConstantBound; |
665 | @@ -585,17 +576,19 @@ | |||
666 | 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); |
667 | 586 | return false; | 577 | return false; |
668 | 587 | } | 578 | } |
680 | 588 | 579 | ||
681 | 589 | Command renameCommand = new RenameTimedPlaceCommand(context.tabContent(), (LocalTimedPlace)place.underlyingPlace(), oldName, newName); | 580 | if (!oldName.equals(newName)) { |
682 | 590 | context.undoManager().addEdit(renameCommand); | 581 | Command renameCommand = new RenameTimedPlaceCommand(context.tabContent(), (LocalTimedPlace) place.underlyingPlace(), oldName, newName); |
683 | 591 | try{ // set name | 582 | context.undoManager().addEdit(renameCommand); |
684 | 592 | renameCommand.redo(); | 583 | try { // set name |
685 | 593 | }catch(RequireException e){ | 584 | renameCommand.redo(); |
686 | 594 | context.undoManager().undo(); | 585 | } catch (RequireException e) { |
687 | 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(); |
688 | 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); |
689 | 597 | } | 588 | return false; |
690 | 598 | context.nameGenerator().updateIndices(context.activeModel(), newName); | 589 | } |
691 | 590 | context.nameGenerator().updateIndices(context.activeModel(), newName); | ||
692 | 591 | } | ||
693 | 599 | 592 | ||
694 | 600 | if(makeNewShared){ | 593 | if(makeNewShared){ |
695 | 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); |
696 | @@ -637,6 +630,12 @@ | |||
697 | 637 | 630 | ||
698 | 638 | if ((place.getAttributesVisible() && !attributesCheckBox.isSelected()) || (!place.getAttributesVisible() && attributesCheckBox.isSelected())) { | 631 | if ((place.getAttributesVisible() && !attributesCheckBox.isSelected()) || (!place.getAttributesVisible() && attributesCheckBox.isSelected())) { |
699 | 639 | place.toggleAttributesVisible(); | 632 | place.toggleAttributesVisible(); |
700 | 633 | |||
701 | 634 | Map<PetriNetObject, Boolean> map = new HashMap<>(); | ||
702 | 635 | map.put(place, !place.getAttributesVisible()); | ||
703 | 636 | |||
704 | 637 | Command changeVisibility = new ChangeAllNamesVisibilityCommand(currentTab, map, null, place.getAttributesVisible()); | ||
705 | 638 | context.undoManager().addEdit(changeVisibility); | ||
706 | 640 | } | 639 | } |
707 | 641 | place.update(true); | 640 | place.update(true); |
708 | 642 | place.repaint(); | 641 | place.repaint(); |
709 | 643 | 642 | ||
710 | === modified file 'src/pipe/gui/widgets/QueryDialog.java' | |||
711 | --- src/pipe/gui/widgets/QueryDialog.java 2021-03-29 10:08:13 +0000 | |||
712 | +++ src/pipe/gui/widgets/QueryDialog.java 2021-08-03 09:29:22 +0000 | |||
713 | @@ -314,7 +314,7 @@ | |||
714 | 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."; |
715 | 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."; |
716 | 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."; |
718 | 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"; |
719 | 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"; |
720 | 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."; |
721 | 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."; |
722 | 321 | 321 | ||
723 | === modified file 'src/pipe/gui/widgets/TAPNTransitionEditor.java' | |||
724 | --- src/pipe/gui/widgets/TAPNTransitionEditor.java 2021-04-08 08:30:29 +0000 | |||
725 | +++ src/pipe/gui/widgets/TAPNTransitionEditor.java 2021-08-03 09:29:22 +0000 | |||
726 | @@ -4,6 +4,8 @@ | |||
727 | 4 | import java.awt.event.ActionEvent; | 4 | import java.awt.event.ActionEvent; |
728 | 5 | import java.awt.event.ActionListener; | 5 | import java.awt.event.ActionListener; |
729 | 6 | import java.util.ArrayList; | 6 | import java.util.ArrayList; |
730 | 7 | import java.util.HashMap; | ||
731 | 8 | import java.util.Map; | ||
732 | 7 | import java.util.Vector; | 9 | import java.util.Vector; |
733 | 8 | 10 | ||
734 | 9 | import javax.swing.DefaultComboBoxModel; | 11 | import javax.swing.DefaultComboBoxModel; |
735 | @@ -21,6 +23,7 @@ | |||
736 | 21 | import net.tapaal.swinghelpers.SwingHelper; | 23 | import net.tapaal.swinghelpers.SwingHelper; |
737 | 22 | import net.tapaal.swinghelpers.WidthAdjustingComboBox; | 24 | import net.tapaal.swinghelpers.WidthAdjustingComboBox; |
738 | 23 | import pipe.gui.CreateGui; | 25 | import pipe.gui.CreateGui; |
739 | 26 | import pipe.gui.graphicElements.PetriNetObject; | ||
740 | 24 | import pipe.gui.graphicElements.tapn.TimedTransitionComponent; | 27 | import pipe.gui.graphicElements.tapn.TimedTransitionComponent; |
741 | 25 | import dk.aau.cs.gui.Context; | 28 | import dk.aau.cs.gui.Context; |
742 | 26 | import dk.aau.cs.model.tapn.Bound; | 29 | import dk.aau.cs.model.tapn.Bound; |
743 | @@ -383,11 +386,13 @@ | |||
744 | 383 | } | 386 | } |
745 | 384 | try{ | 387 | try{ |
746 | 385 | String oldName = transition.underlyingTransition().name(); | 388 | String oldName = transition.underlyingTransition().name(); |
747 | 389 | if (!oldName.equals(newName)) { | ||
748 | 386 | transition.underlyingTransition().setName(newName); | 390 | transition.underlyingTransition().setName(newName); |
749 | 387 | Command renameCommand = new RenameTimedTransitionCommand(context.tabContent(), transition.underlyingTransition(), oldName, newName); | 391 | Command renameCommand = new RenameTimedTransitionCommand(context.tabContent(), transition.underlyingTransition(), oldName, newName); |
750 | 388 | context.undoManager().addEdit(renameCommand); | 392 | context.undoManager().addEdit(renameCommand); |
751 | 389 | // set name | 393 | // set name |
752 | 390 | renameCommand.redo(); | 394 | renameCommand.redo(); |
753 | 395 | } | ||
754 | 391 | }catch(RequireException e){ | 396 | }catch(RequireException e){ |
755 | 392 | context.undoManager().undo(); | 397 | context.undoManager().undo(); |
756 | 393 | JOptionPane.showMessageDialog(this, | 398 | JOptionPane.showMessageDialog(this, |
757 | @@ -457,6 +462,12 @@ | |||
758 | 457 | 462 | ||
759 | 458 | if(transition.getAttributesVisible() && !attributesCheckBox.isSelected() || (!transition.getAttributesVisible() && attributesCheckBox.isSelected())) { | 463 | if(transition.getAttributesVisible() && !attributesCheckBox.isSelected() || (!transition.getAttributesVisible() && attributesCheckBox.isSelected())) { |
760 | 459 | transition.toggleAttributesVisible(); | 464 | transition.toggleAttributesVisible(); |
761 | 465 | |||
762 | 466 | Map<PetriNetObject, Boolean> map = new HashMap<>(); | ||
763 | 467 | map.put(transition, !transition.getAttributesVisible()); | ||
764 | 468 | |||
765 | 469 | Command changeVisibility = new ChangeAllNamesVisibilityCommand(context.tabContent(), null, map, transition.getAttributesVisible()); | ||
766 | 470 | context.undoManager().addEdit(changeVisibility); | ||
767 | 460 | } | 471 | } |
768 | 461 | 472 | ||
769 | 462 | transition.update(true); | 473 | transition.update(true); |
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).