Merge lp:~tapaal-contributor/tapaal/incorrectly-shared-components-1940403 into lp:tapaal

Proposed by Lena Ernstsen
Status: Merged
Approved by: Jiri Srba
Approved revision: 1139
Merged at revision: 1142
Proposed branch: lp:~tapaal-contributor/tapaal/incorrectly-shared-components-1940403
Merge into: lp:tapaal
Diff against target: 133 lines (+30/-10)
2 files modified
src/pipe/gui/widgets/PlaceEditorPanel.java (+18/-7)
src/pipe/gui/widgets/TAPNTransitionEditor.java (+12/-3)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/incorrectly-shared-components-1940403
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+407596@code.launchpad.net

Commit message

Cancelling edit place/transition dialog, will cancel making them shared

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

Tested and works fine

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/pipe/gui/widgets/PlaceEditorPanel.java'
2--- src/pipe/gui/widgets/PlaceEditorPanel.java 2021-08-03 08:36:57 +0000
3+++ src/pipe/gui/widgets/PlaceEditorPanel.java 2021-08-24 08:34:20 +0000
4@@ -60,6 +60,7 @@
5 private final Context context;
6 private boolean makeNewShared = false;
7 private boolean doNewEdit = true;
8+ private boolean doOKChecked = false;
9 private final TabContent currentTab;
10
11 private Vector<TimedPlace> sharedPlaces;
12@@ -124,7 +125,12 @@
13 cancelButton.setMaximumSize(new java.awt.Dimension(100, 25));
14 cancelButton.setMinimumSize(new java.awt.Dimension(100, 25));
15 cancelButton.setPreferredSize(new java.awt.Dimension(100, 25));
16- cancelButton.addActionListener(evt -> exit());
17+ cancelButton.addActionListener(evt -> {
18+ if (doOKChecked) {
19+ context.undoManager().undo();
20+ }
21+ exit();
22+ });
23
24 gridBagConstraints = GridBagHelper.as(0,0,EAST, new Insets(5, 5, 5, 5));
25 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
26@@ -224,21 +230,24 @@
27
28 makeSharedButton.addActionListener(evt -> {
29 makeNewShared = true;
30+ makeSharedButton.setEnabled(false);
31 if(doOK()){
32 setupInitialState();
33- makeSharedButton.setEnabled(false);
34 sharedCheckBox.setEnabled(true);
35 sharedCheckBox.setSelected(true);
36 switchToNameDropDown();
37 sharedPlacesComboBox.setSelectedItem(place.underlyingPlace());
38- }
39- makeNewShared = false;
40+ } else {
41+ makeSharedButton.setEnabled(true);
42+ doOKChecked = false;
43+ }
44 });
45
46 gridBagConstraints = GridBagHelper.as(3,1, WEST, new Insets(5, 5, 5, 5));
47 basicPropertiesPanel.add(makeSharedButton, gridBagConstraints);
48
49 nameLabel = new javax.swing.JLabel("Name:");
50+ nameLabel = new javax.swing.JLabel("Name:");
51 gridBagConstraints = GridBagHelper.as(0,1, EAST, new Insets(3, 3, 3, 3));
52 basicPropertiesPanel.add(nameLabel, gridBagConstraints);
53
54@@ -590,7 +599,7 @@
55 context.nameGenerator().updateIndices(context.activeModel(), newName);
56 }
57
58- if(makeNewShared){
59+ if(makeNewShared && !makeSharedButton.isEnabled()){
60 Command command = new MakePlaceNewSharedCommand(context.activeModel(), newName, place.underlyingPlace(), place, context.tabContent(), false);
61 context.undoManager().addEdit(command);
62 try{
63@@ -641,8 +650,10 @@
64 place.repaint();
65
66 context.network().buildConstraints();
67-
68- return true;
69+
70+ doOKChecked = true;
71+
72+ return true;
73 }
74
75 private TimeInvariant constructInvariant() {
76
77=== modified file 'src/pipe/gui/widgets/TAPNTransitionEditor.java'
78--- src/pipe/gui/widgets/TAPNTransitionEditor.java 2021-08-03 08:36:57 +0000
79+++ src/pipe/gui/widgets/TAPNTransitionEditor.java 2021-08-24 08:34:20 +0000
80@@ -45,6 +45,8 @@
81 private final TimedTransitionComponent transition;
82 private final JRootPane rootPane;
83 private final Context context;
84+
85+ private boolean doOKChecked = false;
86
87 private final int maxNumberOfTransitionsToShowAtOnce = 20;
88 boolean doNewEdit = true;
89@@ -124,13 +126,15 @@
90
91 makeSharedButton.addActionListener(evt -> {
92 makeNewShared = true;
93+ makeSharedButton.setEnabled(false);
94 if(okButtonHandler(evt)){
95- makeSharedButton.setEnabled(false);
96 sharedCheckBox.setEnabled(true);
97 sharedCheckBox.setSelected(true);
98 setupInitialState();
99+ } else {
100+ makeSharedButton.setEnabled(true);
101+ doOKChecked = false;
102 }
103- makeNewShared = false;
104 });
105
106 gridBagConstraints = GridBagHelper.as(3,1, Anchor.WEST, new Insets(5, 5, 5, 5));
107@@ -403,7 +407,7 @@
108 context.nameGenerator().updateIndices(transition.underlyingTransition().model(), newName);
109
110
111- if(makeNewShared){
112+ if(makeNewShared && !makeSharedButton.isEnabled()){
113 Command command = new MakeTransitionNewSharedCommand(context.activeModel(), newName, transition.underlyingTransition(), context.tabContent(), false);
114 context.undoManager().addEdit(command);
115 try{
116@@ -471,6 +475,8 @@
117 }
118
119 transition.update(true);
120+
121+ doOKChecked = true;
122
123 return true;
124 }
125@@ -480,6 +486,9 @@
126 }
127
128 private void cancelButtonHandler(java.awt.event.ActionEvent evt) {
129+ if (doOKChecked) {
130+ context.undoManager().undo();
131+ }
132 exit();
133 }
134

Subscribers

People subscribed via source and target branches