01: package org.enhydra.jawe.components.graph.actions;
02:
03: import java.awt.event.ActionEvent;
04: import java.util.ArrayList;
05: import java.util.List;
06:
07: import org.enhydra.jawe.ActionBase;
08: import org.enhydra.jawe.JaWEComponent;
09: import org.enhydra.jawe.JaWEManager;
10: import org.enhydra.jawe.base.controller.JaWEController;
11: import org.enhydra.jawe.components.graph.Graph;
12: import org.enhydra.jawe.components.graph.GraphController;
13: import org.enhydra.jawe.components.graph.GraphTransitionInterface;
14: import org.enhydra.jawe.components.graph.GraphUtilities;
15: import org.enhydra.shark.xpdl.elements.Transition;
16:
17: /**
18: * Class that realizes <B>SetTransitionType</B> action.
19: * @author Sasa Bojanic
20: */
21: public abstract class SetTransitionStyle extends ActionBase {
22:
23: protected String style;
24:
25: public SetTransitionStyle(JaWEComponent jawecomponent) {
26: super (jawecomponent);
27: }
28:
29: public SetTransitionStyle(JaWEComponent jawecomponent, String style) {
30: super (jawecomponent);
31: this .style = style;
32: }
33:
34: public void enableDisableAction() {
35: JaWEController jc = JaWEManager.getInstance()
36: .getJaWEController();
37: GraphController gc = (GraphController) jawecomponent;
38: Graph g = gc.getSelectedGraph();
39: if (getPackage() == jc.getMainPackage() && g != null) {
40: Object[] sc = g.getSelectionCells();
41: if (sc != null && sc.length == 1
42: && sc[0] instanceof GraphTransitionInterface) {
43: setEnabled(true);
44: }
45: } else {
46: setEnabled(false);
47: }
48: }
49:
50: public void actionPerformed(ActionEvent e) {
51: GraphController gc = (GraphController) jawecomponent;
52: Graph graph = gc.getSelectedGraph();
53: Object cell = graph.getSelectionCell();
54: if (cell instanceof GraphTransitionInterface) {
55: JaWEController jc = JaWEManager.getInstance()
56: .getJaWEController();
57: gc.setUpdateInProgress(true);
58: jc.startUndouableChange();
59: GraphTransitionInterface gtra = (GraphTransitionInterface) cell;
60: Transition tra = (Transition) gtra.getUserObject();
61: GraphUtilities.setStyle(tra, style);
62: graph.getGraphManager().updateStyle(gtra);
63: List toSelect = new ArrayList();
64: toSelect.add(tra);
65: JaWEManager.getInstance().getJaWEController()
66: .endUndouableChange(toSelect);
67: gc.setUpdateInProgress(false);
68: }
69: }
70: }
|