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.draw2d.geometry.Point;
22 import org.eclipse.gef.commands.Command;
23 import org.eclipse.osgi.util.NLS;
24
25 import pl.edu.agh.cast.model.visual.backward.IDiagram;
26 import pl.edu.agh.cast.model.visual.backward.Node;
27 import pl.edu.agh.cast.util.Messages;
28
29
30
31
32
33
34 public class AddNodeCommand extends Command {
35
36 private IDiagram model;
37
38 private Point location;
39
40 private Node node;
41
42 private String imageId;
43
44
45
46
47
48
49
50
51
52
53
54
55
56 public AddNodeCommand(IDiagram model, Node node, Point location, String imageId) {
57 this.model = model;
58 this.location = location;
59 this.imageId = imageId;
60 this.node = node;
61 setLabel(NLS.bind(Messages.SchemaCreationCommand_0, node.getLabel()));
62 }
63
64
65
66
67
68
69 @Override
70 public void execute() {
71 node.setLocation(location);
72 node.setImageId(imageId);
73 model.addNode(node);
74 }
75
76
77
78
79
80
81 @Override
82 public void undo() {
83 model.removeNode(model.findNode(node.getId()));
84 }
85
86 }