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
=== modified file 'src/pipe/gui/widgets/PlaceEditorPanel.java'
--- src/pipe/gui/widgets/PlaceEditorPanel.java 2021-08-03 08:36:57 +0000
+++ src/pipe/gui/widgets/PlaceEditorPanel.java 2021-08-24 08:34:20 +0000
@@ -60,6 +60,7 @@
60 private final Context context;60 private final Context context;
61 private boolean makeNewShared = false;61 private boolean makeNewShared = false;
62 private boolean doNewEdit = true;62 private boolean doNewEdit = true;
63 private boolean doOKChecked = false;
63 private final TabContent currentTab;64 private final TabContent currentTab;
64 65
65 private Vector<TimedPlace> sharedPlaces;66 private Vector<TimedPlace> sharedPlaces;
@@ -124,7 +125,12 @@
124 cancelButton.setMaximumSize(new java.awt.Dimension(100, 25));125 cancelButton.setMaximumSize(new java.awt.Dimension(100, 25));
125 cancelButton.setMinimumSize(new java.awt.Dimension(100, 25));126 cancelButton.setMinimumSize(new java.awt.Dimension(100, 25));
126 cancelButton.setPreferredSize(new java.awt.Dimension(100, 25));127 cancelButton.setPreferredSize(new java.awt.Dimension(100, 25));
127 cancelButton.addActionListener(evt -> exit());128 cancelButton.addActionListener(evt -> {
129 if (doOKChecked) {
130 context.undoManager().undo();
131 }
132 exit();
133 });
128134
129 gridBagConstraints = GridBagHelper.as(0,0,EAST, new Insets(5, 5, 5, 5));135 gridBagConstraints = GridBagHelper.as(0,0,EAST, new Insets(5, 5, 5, 5));
130 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;136 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
@@ -224,21 +230,24 @@
224 230
225 makeSharedButton.addActionListener(evt -> {231 makeSharedButton.addActionListener(evt -> {
226 makeNewShared = true;232 makeNewShared = true;
233 makeSharedButton.setEnabled(false);
227 if(doOK()){234 if(doOK()){
228 setupInitialState();235 setupInitialState();
229 makeSharedButton.setEnabled(false);
230 sharedCheckBox.setEnabled(true);236 sharedCheckBox.setEnabled(true);
231 sharedCheckBox.setSelected(true);237 sharedCheckBox.setSelected(true);
232 switchToNameDropDown();238 switchToNameDropDown();
233 sharedPlacesComboBox.setSelectedItem(place.underlyingPlace());239 sharedPlacesComboBox.setSelectedItem(place.underlyingPlace());
234 }240 } else {
235 makeNewShared = false;241 makeSharedButton.setEnabled(true);
242 doOKChecked = false;
243 }
236 });244 });
237 245
238 gridBagConstraints = GridBagHelper.as(3,1, WEST, new Insets(5, 5, 5, 5));246 gridBagConstraints = GridBagHelper.as(3,1, WEST, new Insets(5, 5, 5, 5));
239 basicPropertiesPanel.add(makeSharedButton, gridBagConstraints);247 basicPropertiesPanel.add(makeSharedButton, gridBagConstraints);
240 248
241 nameLabel = new javax.swing.JLabel("Name:");249 nameLabel = new javax.swing.JLabel("Name:");
250 nameLabel = new javax.swing.JLabel("Name:");
242 gridBagConstraints = GridBagHelper.as(0,1, EAST, new Insets(3, 3, 3, 3));251 gridBagConstraints = GridBagHelper.as(0,1, EAST, new Insets(3, 3, 3, 3));
243 basicPropertiesPanel.add(nameLabel, gridBagConstraints);252 basicPropertiesPanel.add(nameLabel, gridBagConstraints);
244253
@@ -590,7 +599,7 @@
590 context.nameGenerator().updateIndices(context.activeModel(), newName);599 context.nameGenerator().updateIndices(context.activeModel(), newName);
591 }600 }
592 601
593 if(makeNewShared){602 if(makeNewShared && !makeSharedButton.isEnabled()){
594 Command command = new MakePlaceNewSharedCommand(context.activeModel(), newName, place.underlyingPlace(), place, context.tabContent(), false);603 Command command = new MakePlaceNewSharedCommand(context.activeModel(), newName, place.underlyingPlace(), place, context.tabContent(), false);
595 context.undoManager().addEdit(command);604 context.undoManager().addEdit(command);
596 try{605 try{
@@ -641,8 +650,10 @@
641 place.repaint();650 place.repaint();
642651
643 context.network().buildConstraints();652 context.network().buildConstraints();
644 653
645 return true;654 doOKChecked = true;
655
656 return true;
646 }657 }
647658
648 private TimeInvariant constructInvariant() {659 private TimeInvariant constructInvariant() {
649660
=== modified file 'src/pipe/gui/widgets/TAPNTransitionEditor.java'
--- src/pipe/gui/widgets/TAPNTransitionEditor.java 2021-08-03 08:36:57 +0000
+++ src/pipe/gui/widgets/TAPNTransitionEditor.java 2021-08-24 08:34:20 +0000
@@ -45,6 +45,8 @@
45 private final TimedTransitionComponent transition;45 private final TimedTransitionComponent transition;
46 private final JRootPane rootPane;46 private final JRootPane rootPane;
47 private final Context context;47 private final Context context;
48
49 private boolean doOKChecked = false;
48 50
49 private final int maxNumberOfTransitionsToShowAtOnce = 20;51 private final int maxNumberOfTransitionsToShowAtOnce = 20;
50 boolean doNewEdit = true;52 boolean doNewEdit = true;
@@ -124,13 +126,15 @@
124 126
125 makeSharedButton.addActionListener(evt -> {127 makeSharedButton.addActionListener(evt -> {
126 makeNewShared = true;128 makeNewShared = true;
129 makeSharedButton.setEnabled(false);
127 if(okButtonHandler(evt)){130 if(okButtonHandler(evt)){
128 makeSharedButton.setEnabled(false);
129 sharedCheckBox.setEnabled(true);131 sharedCheckBox.setEnabled(true);
130 sharedCheckBox.setSelected(true);132 sharedCheckBox.setSelected(true);
131 setupInitialState();133 setupInitialState();
134 } else {
135 makeSharedButton.setEnabled(true);
136 doOKChecked = false;
132 }137 }
133 makeNewShared = false;
134 });138 });
135 139
136 gridBagConstraints = GridBagHelper.as(3,1, Anchor.WEST, new Insets(5, 5, 5, 5));140 gridBagConstraints = GridBagHelper.as(3,1, Anchor.WEST, new Insets(5, 5, 5, 5));
@@ -403,7 +407,7 @@
403 context.nameGenerator().updateIndices(transition.underlyingTransition().model(), newName);407 context.nameGenerator().updateIndices(transition.underlyingTransition().model(), newName);
404 408
405 409
406 if(makeNewShared){410 if(makeNewShared && !makeSharedButton.isEnabled()){
407 Command command = new MakeTransitionNewSharedCommand(context.activeModel(), newName, transition.underlyingTransition(), context.tabContent(), false);411 Command command = new MakeTransitionNewSharedCommand(context.activeModel(), newName, transition.underlyingTransition(), context.tabContent(), false);
408 context.undoManager().addEdit(command);412 context.undoManager().addEdit(command);
409 try{413 try{
@@ -471,6 +475,8 @@
471 }475 }
472 476
473 transition.update(true);477 transition.update(true);
478
479 doOKChecked = true;
474 480
475 return true;481 return true;
476 }482 }
@@ -480,6 +486,9 @@
480 }486 }
481487
482 private void cancelButtonHandler(java.awt.event.ActionEvent evt) {488 private void cancelButtonHandler(java.awt.event.ActionEvent evt) {
489 if (doOKChecked) {
490 context.undoManager().undo();
491 }
483 exit();492 exit();
484 }493 }
485494

Subscribers

People subscribed via source and target branches