01: package org.enhydra.jawe.components.graph.actions;
02:
03: import java.awt.Point;
04: import java.awt.event.ActionEvent;
05: import java.util.ArrayList;
06: import java.util.List;
07:
08: import org.enhydra.jawe.ActionBase;
09: import org.enhydra.jawe.JaWEComponent;
10: import org.enhydra.jawe.JaWEManager;
11: import org.enhydra.jawe.base.controller.JaWEController;
12: import org.enhydra.jawe.components.graph.Graph;
13: import org.enhydra.jawe.components.graph.GraphController;
14: import org.enhydra.jawe.components.graph.GraphMarqueeHandler;
15: import org.enhydra.jawe.components.graph.GraphTransitionInterface;
16: import org.enhydra.jawe.components.graph.GraphUtilities;
17: import org.enhydra.shark.xpdl.elements.Transition;
18:
19: /**
20: * Class that realizes <B>RemovePoint</B> action.
21: * "Breaking point" is removed from transition at the popup
22: * position (if there is one near).
23: * @author Sasa Bojanic
24: */
25: public class RemovePoint extends ActionBase {
26:
27: public RemovePoint(JaWEComponent jawecomponent) {
28: super (jawecomponent);
29: }
30:
31: public void enableDisableAction() {
32: JaWEController jc = JaWEManager.getInstance()
33: .getJaWEController();
34: GraphController gc = (GraphController) jawecomponent;
35: Graph g = gc.getSelectedGraph();
36: if (getPackage() == jc.getMainPackage() && g != null) {
37: Object[] sc = g.getSelectionCells();
38: if (sc != null && sc.length == 1
39: && sc[0] instanceof GraphTransitionInterface) {
40: setEnabled(true);
41: }
42: } else {
43: setEnabled(false);
44: }
45: }
46:
47: public void actionPerformed(ActionEvent e) {
48: GraphController gc = (GraphController) jawecomponent;
49: GraphMarqueeHandler mh = gc.getGraphMarqueeHandler();
50: Graph graph = gc.getSelectedGraph();
51: Point addAt = mh.getPopupPoint();
52: // double scale = gc.getSelectedGraph().getScale();
53: // addAt.setLocation(addAt.getX()/scale, addAt.getY()/scale);
54: Object cell = graph.getSelectionCell();
55: if (cell instanceof GraphTransitionInterface) {
56: GraphTransitionInterface gtra = (GraphTransitionInterface) cell;
57: JaWEController jc = JaWEManager.getInstance()
58: .getJaWEController();
59: gc.setUpdateInProgress(true);
60: jc.startUndouableChange();
61: List pnts = graph.getGraphManager().addOrRemoveBreakPoint(
62: gtra, addAt, false);
63: Transition tra = (Transition) gtra.getPropertyObject();
64: GraphUtilities.setBreakpoints(tra, pnts);
65: List toSelect = new ArrayList();
66: toSelect.add(tra);
67: jc.endUndouableChange(toSelect);
68: gc.setUpdateInProgress(false);
69: }
70: }
71: }
|