1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.vectomatic.client.rep.command;
19
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import org.vectomatic.client.rep.RepApplication;
24 import org.vectomatic.common.model.Shape;
25
26
27
28
29 public class PasteCommand extends CommandBase {
30 private List<Shape> _shapes;
31
32 public PasteCommand(RepApplication app, List<Shape> clonedShapes) {
33 super(app);
34 _shapes = new ArrayList<Shape>(clonedShapes);
35 }
36
37 public String getDescription() {
38 return _app.getConstants().pasteCommand();
39 }
40
41 public void execute() {
42 for (int i = 0, size = _shapes.size(); i < size; i++) {
43 Shape shape = _shapes.get(i);
44 _app.getModel().addShape(shape);
45 }
46 _app.getModel().fireModelHasChanged();
47 _app.getSelection().select(_shapes);
48 }
49
50 public void unexecute() {
51 for (int i = 0, size = _shapes.size(); i < size; i++) {
52 Shape shape = _shapes.get(i);
53 _app.getModel().removeShape(shape);
54 }
55 _app.getModel().fireModelHasChanged();
56 _app.getSelection().select(new ArrayList<Shape>());
57 }
58 }