Merge lp:~tapaal-contributor/tapaal/disappearing-tokens-1940098 into lp:tapaal

Proposed by Lena Ernstsen
Status: Merged
Approved by: Jiri Srba
Approved revision: 1136
Merged at revision: 1137
Proposed branch: lp:~tapaal-contributor/tapaal/disappearing-tokens-1940098
Merge into: lp:tapaal
Diff against target: 41 lines (+16/-4)
2 files modified
src/dk/aau/cs/gui/SharedPlaceNamePanel.java (+1/-1)
src/dk/aau/cs/model/tapn/TimedPlace.java (+15/-3)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/disappearing-tokens-1940098
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+407251@code.launchpad.net

Commit message

Stopped tokens from disappearing when shared place names are changed

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

Tested and fixes the problem

review: Approve

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/SharedPlaceNamePanel.java'
2--- src/dk/aau/cs/gui/SharedPlaceNamePanel.java 2021-04-08 08:30:29 +0000
3+++ src/dk/aau/cs/gui/SharedPlaceNamePanel.java 2021-08-17 11:36:29 +0000
4@@ -150,7 +150,7 @@
5
6 try{
7 placeToEdit.setName(name);
8- }catch(RequireException e){
9+ }catch(RequireException e){
10 JOptionPane.showMessageDialog(SharedPlaceNamePanel.this, "The specified name is invalid.\nAcceptable names 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);
11 nameField.requestFocusInWindow();
12 return false;
13
14=== modified file 'src/dk/aau/cs/model/tapn/TimedPlace.java'
15--- src/dk/aau/cs/model/tapn/TimedPlace.java 2020-08-04 08:53:19 +0000
16+++ src/dk/aau/cs/model/tapn/TimedPlace.java 2021-08-17 11:36:29 +0000
17@@ -37,9 +37,21 @@
18 public void setName(String newName) {
19 Require.that(newName != null && !newName.isEmpty(), "A timed place must have a name");
20 Require.that(isValid(newName) && !newName.toLowerCase().equals("true") && !newName.toLowerCase().equals("false"), "The specified name must conform to the pattern [a-zA-Z_][a-zA-Z0-9_]*");
21- this.name = newName;
22- fireNameChanged();
23- }
24+ List<TimedToken> tokens = null;
25+
26+ if (currentMarking != null) {
27+ if (currentMarking.getTokensFor(this).size() != 0) {
28+ tokens = tokens();
29+ currentMarking.removePlaceFromMarking(this);
30+ }
31+ this.name = newName;
32+ if (tokens != null) addTokens(tokens);
33+ fireNameChanged();
34+ } else {
35+ this.name = newName;
36+ fireNameChanged();
37+ }
38+ }
39
40 public TimeInvariant invariant(){
41 return invariant;

Subscribers

People subscribed via source and target branches