01: /**
02: * Miroslav Popov, Aug 29, 2005
03: */package org.enhydra.jawe.components.graph.actions;
04:
05: import java.awt.event.ActionEvent;
06: import java.util.ArrayList;
07: import java.util.List;
08:
09: import org.enhydra.jawe.ActionBase;
10: import org.enhydra.jawe.JaWEComponent;
11: import org.enhydra.jawe.JaWEConstants;
12: import org.enhydra.jawe.JaWEManager;
13: import org.enhydra.jawe.base.controller.JaWEController;
14: import org.enhydra.jawe.components.graph.GraphController;
15: import org.enhydra.jawe.components.graph.GraphUtilities;
16: import org.enhydra.shark.xpdl.XMLCollectionElement;
17: import org.enhydra.shark.xpdl.XMLUtil;
18: import org.enhydra.shark.xpdl.elements.ActivitySet;
19: import org.enhydra.shark.xpdl.elements.WorkflowProcess;
20:
21: /**
22: * @author Miroslav Popov
23: *
24: */
25: public class InsertActivitySet extends ActionBase {
26:
27: public InsertActivitySet(JaWEComponent jawecomponent) {
28: super (jawecomponent);
29: }
30:
31: public void enableDisableAction() {
32: JaWEController jc = JaWEManager.getInstance()
33: .getJaWEController();
34: GraphController gc = (GraphController) jawecomponent;
35:
36: if (gc.getSelectedGraph() != null)
37: if (gc.getSelectedGraph().getXPDLObject() instanceof WorkflowProcess)
38: if (XMLUtil.getPackage(gc.getSelectedGraph()
39: .getXPDLObject()) == jc.getMainPackage()) {
40: setEnabled(true);
41: return;
42: }
43:
44: setEnabled(false);
45: }
46:
47: public void actionPerformed(ActionEvent e) {
48: GraphController gc = GraphUtilities.getGraphController();
49: XMLCollectionElement wpOrAs = gc.getDisplayedXPDLObject();
50: if (wpOrAs != null) {
51: WorkflowProcess wp = XMLUtil.getWorkflowProcess(wpOrAs);
52: if (wp != null) {
53: JaWEManager.getInstance().getJaWEController()
54: .startUndouableChange();
55: ActivitySet as = JaWEManager
56: .getInstance()
57: .getXPDLObjectFactory()
58: .createXPDLObject(
59: wp.getActivitySets(),
60: JaWEConstants.ACTIVITY_SET_TYPE_DEFAULT,
61: true);
62: List toSelect = new ArrayList();
63: toSelect.add(as);
64: JaWEManager.getInstance().getJaWEController()
65: .endUndouableChange(toSelect);
66: // ((GraphController) jawecomponent).selectGraphForElement(as);
67: }
68: }
69: }
70: }
|