01: /**
02: * Miroslav Popov, Sep 27, 2005
03: * miroslav.popov@gmail.com
04: */package org.enhydra.jawe.components.graph.actions;
05:
06: import java.awt.event.ActionEvent;
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.GraphController;
13: import org.enhydra.shark.xpdl.XMLElement;
14: import org.enhydra.shark.xpdl.XMLUtil;
15: import org.enhydra.shark.xpdl.XPDLConstants;
16: import org.enhydra.shark.xpdl.elements.Activity;
17: import org.enhydra.shark.xpdl.elements.ActivitySet;
18: import org.enhydra.shark.xpdl.elements.BlockActivity;
19: import org.enhydra.shark.xpdl.elements.WorkflowProcess;
20:
21: /**
22: * @author Miroslav Popov
23: *
24: */
25: public class DescendInto extends ActionBase {
26:
27: public DescendInto(JaWEComponent jawecomponent) {
28: super (jawecomponent);
29: }
30:
31: public void enableDisableAction() {
32: JaWEController jc = JaWEManager.getInstance()
33: .getJaWEController();
34:
35: boolean isEnabled = false;
36: if (jc.getSelectionManager().getSelectedElements().size() == 1) {
37: XMLElement el = (XMLElement) jc.getSelectionManager()
38: .getSelectedElements().toArray()[0];
39: if (el instanceof Activity) {
40: Activity a = (Activity) el;
41:
42: XMLElement implementation = null;
43: if (a.getActivityType() == XPDLConstants.ACTIVITY_TYPE_SUBFLOW) {
44: implementation = XMLUtil.getSubflowProcess(
45: JaWEManager.getInstance().getXPDLHandler(),
46: a);
47: } else {
48: implementation = XMLUtil.getBlockActivitySet(a);
49: }
50:
51: if (implementation != null)
52: isEnabled = true;
53: }
54: }
55:
56: setEnabled(isEnabled);
57: }
58:
59: public void actionPerformed(ActionEvent e) {
60: JaWEController jc = JaWEManager.getInstance()
61: .getJaWEController();
62: GraphController gc = (GraphController) jawecomponent;
63:
64: XMLElement el = (XMLElement) jc.getSelectionManager()
65: .getSelectedElements().toArray()[0];
66:
67: if (el instanceof Activity) {
68: Activity a = (Activity) el;
69:
70: if (a.getActivityType() == XPDLConstants.ACTIVITY_TYPE_SUBFLOW) {
71: WorkflowProcess wp = XMLUtil.getSubflowProcess(
72: JaWEManager.getInstance().getXPDLHandler(), a);
73: gc.selectGraphForElement(wp);
74: } else {
75: BlockActivity blk = a.getActivityTypes()
76: .getBlockActivity();
77: String blockId = blk.getBlockId();
78: // check if the activity set exists
79: ActivitySet as = XMLUtil.getWorkflowProcess(a)
80: .getActivitySet(blockId);
81: gc.selectGraphForElement(as);
82: }
83: }
84: }
85: }
|