~tapaal-contributor/tapaal/disappearing-tokens-1940098

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/gui/undo/RenameTimedPlaceCommand.java

  • Committer: Kenneth Yrke Jørgensen
  • Date: 2011-04-12 09:50:16 UTC
  • mfrom: (329.1.188 tapaal-1.5)
  • Revision ID: mail@yrke.dk-20110412095016-e4hqdgab5596ja09
Merged with branch addning support for new 1.5 features

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package dk.aau.cs.gui.undo;
 
2
 
 
3
import pipe.dataLayer.TAPNQuery;
 
4
import dk.aau.cs.TCTL.visitors.RenamePlaceTCTLVisitor;
 
5
import dk.aau.cs.gui.TabContent;
 
6
import dk.aau.cs.model.tapn.LocalTimedPlace;
 
7
 
 
8
public class RenameTimedPlaceCommand extends Command {
 
9
        private final LocalTimedPlace place;
 
10
        private final String oldName;
 
11
        private final String newName;
 
12
        private final TabContent tabContent;
 
13
 
 
14
        public RenameTimedPlaceCommand(TabContent tabContent, LocalTimedPlace place, String oldName, String newName) {
 
15
                this.tabContent = tabContent;
 
16
                this.place = place;
 
17
                this.oldName = oldName;
 
18
                this.newName = newName;
 
19
        }
 
20
 
 
21
        @Override
 
22
        public void redo() {
 
23
                place.setName(newName);
 
24
                updateQueries(oldName, newName);
 
25
        }
 
26
 
 
27
        @Override
 
28
        public void undo() {
 
29
                place.setName(oldName);
 
30
                updateQueries(newName,oldName);
 
31
        }
 
32
        
 
33
        private void updateQueries(String nameToFind, String nameToInsert){
 
34
                RenamePlaceTCTLVisitor renameVisitor = new RenamePlaceTCTLVisitor(nameToFind, nameToInsert);
 
35
                for (TAPNQuery q : tabContent.queries()) {
 
36
                        q.getProperty().accept(renameVisitor, null);
 
37
                }
 
38
        }
 
39
}