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>AddPoint</B> action.
21: * "Breaking point" is added on transition at the popup position.
22: * @author Sasa Bojanic
23: */
24: public class AddPoint extends ActionBase {
25:
26: public AddPoint(JaWEComponent jawecomponent) {
27: super (jawecomponent);
28: }
29:
30: public void enableDisableAction() {
31: JaWEController jc = JaWEManager.getInstance()
32: .getJaWEController();
33: GraphController gc = (GraphController) jawecomponent;
34: Graph g = gc.getSelectedGraph();
35: if (getPackage() == jc.getMainPackage() && g != null) {
36: Object[] sc = g.getSelectionCells();
37: if (sc != null && sc.length == 1
38: && sc[0] instanceof GraphTransitionInterface) {
39: setEnabled(true);
40: }
41: } else {
42: setEnabled(false);
43: }
44: }
45:
46: public void actionPerformed(ActionEvent e) {
47: GraphController gc = (GraphController) jawecomponent;
48: GraphMarqueeHandler mh = gc.getGraphMarqueeHandler();
49: Graph graph = gc.getSelectedGraph();
50: Point addAt = mh.getPopupPoint();
51: // double scale = gc.getSelectedGraph().getScale();
52: // addAt.setLocation(addAt.getX()/scale, addAt.getY()/scale);
53: Object cell = graph.getSelectionCell();
54: if (cell instanceof GraphTransitionInterface) {
55: GraphTransitionInterface gtra = (GraphTransitionInterface) cell;
56: JaWEController jc = JaWEManager.getInstance()
57: .getJaWEController();
58: gc.setUpdateInProgress(true);
59: jc.startUndouableChange();
60: List pnts = graph.getGraphManager().addOrRemoveBreakPoint(
61: gtra, addAt, true);
62: Transition tra = (Transition) gtra.getPropertyObject();
63: GraphUtilities.setBreakpoints(tra, pnts);
64: List toSelect = new ArrayList();
65: toSelect.add(tra);
66: jc.endUndouableChange(toSelect);
67: gc.setUpdateInProgress(false);
68: }
69: }
70: }
|