01: // The UMLet source code is distributed under the terms of the GPL; see license.txt
02: package com.umlet.control;
03:
04: import java.util.*;
05:
06: import com.umlet.element.base.*;
07:
08: /**
09: * <p>Title: </p>
10: * <p>Description: </p>
11: * <p>Copyright: Copyright (c) 2001</p>
12: * <p>Company: </p>
13: * @author unascribed
14: * @version 1.0
15: */
16:
17: public class RemoveElement extends Command {
18: Vector<Entity> _entities;
19:
20: public RemoveElement(Vector v) {
21: _entities = v;
22: }
23:
24: public void execute() {
25: super .execute();
26:
27: for (int i = 0; i < _entities.size(); i++) {
28: Entity e = (Entity) _entities.elementAt(i);
29: if (e instanceof Group) {
30: Group g = (Group) e;
31: Vector<Entity> groupElements = g.getMembers();
32: _entities.addAll(groupElements);
33: }
34: }
35:
36: for (int i = 0; i < _entities.size(); i++) {
37: Entity e = (Entity) _entities.elementAt(i);
38: Umlet.getInstance().getPanel().remove(e);
39: }
40: Umlet.getInstance().getPanel().repaint();
41: Selector.getInstance().deselectAll();
42: }
43:
44: public void undo() {
45: super .undo();
46: for (int i = 0; i < _entities.size(); i++) {
47: Entity e = (Entity) _entities.elementAt(i);
48: /* if(e instanceof Group) {
49: Group g = (Group)e;
50: Vector<Entity> gm = g.getMembers();
51: for(int j=0;gm!=null&&j<gm.size();j++) {
52: Umlet.getInstance().getPanel().add(gm.get(j));
53: }
54: }*/
55: Umlet.getInstance().getPanel().add(e);
56: }
57: Umlet.getInstance().getPanel().repaint();
58: }
59: }
|