1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.backward.command;
19
20
21 import org.eclipse.gef.commands.Command;
22 import org.eclipse.osgi.util.NLS;
23
24 import pl.edu.agh.cast.model.visual.backward.IDiagram;
25 import pl.edu.agh.cast.util.Messages;
26
27
28
29
30
31
32 public class RenameDiagramCommand extends Command {
33
34 private String newName;
35
36 private String oldName;
37
38 private IDiagram diagram;
39
40
41
42
43
44
45
46
47
48 public RenameDiagramCommand(IDiagram diagram, String newName) {
49 this.diagram = diagram;
50 this.newName = newName;
51 this.oldName = diagram.getDisplayName();
52 }
53
54
55
56
57
58
59 @Override
60 public void execute() {
61 diagram.setDisplayName(newName);
62 }
63
64
65
66
67
68
69 @Override
70 public void undo() {
71 diagram.setDisplayName(oldName);
72 }
73
74
75
76
77
78
79 @Override
80 public String getLabel() {
81 return NLS.bind(Messages.RenameDiagramCommand_0, new Object[] { oldName, newName });
82 }
83
84 }