01: package org.enhydra.jawe.base.controller.actions;
02:
03: import java.awt.event.ActionEvent;
04: import java.util.ArrayList;
05: import java.util.List;
06:
07: import org.enhydra.jawe.JaWEComponent;
08: import org.enhydra.jawe.JaWEManager;
09: import org.enhydra.jawe.NewActionBase;
10: import org.enhydra.jawe.base.controller.JaWEController;
11: import org.enhydra.jawe.base.controller.JaWETypeChoiceButton;
12: import org.enhydra.jawe.base.xpdlobjectfactory.XPDLObjectFactory;
13: import org.enhydra.shark.xpdl.elements.Package;
14: import org.enhydra.shark.xpdl.elements.WorkflowProcess;
15:
16: /**
17: * Class that realizes <B>new</B> action.
18: *
19: * @author Sasa Bojanic
20: */
21: public class PackageNewProcess extends NewActionBase {
22:
23: public PackageNewProcess(JaWEComponent jawecomponent) {
24: super (jawecomponent, WorkflowProcess.class);
25: }
26:
27: public void enableDisableAction() {
28: JaWEController jc = (JaWEController) jawecomponent;
29: if (jc.getMainPackage() != null)
30: setEnabled(true);
31: else
32: setEnabled(false);
33: }
34:
35: public void actionPerformed(ActionEvent e) {
36: if (!(e.getSource() instanceof JaWETypeChoiceButton)) {
37: JaWEController jc = JaWEManager.getInstance()
38: .getJaWEController();
39: Package pkg = jc.getMainPackage();
40: if (pkg == null)
41: return;
42: jc.startUndouableChange();
43: XPDLObjectFactory of = JaWEManager.getInstance()
44: .getXPDLObjectFactory();
45: WorkflowProcess wp = of.createXPDLObject(pkg
46: .getWorkflowProcesses(), jc.getJaWETypes()
47: .getDefaultType(WorkflowProcess.class), true);
48: List toSelect = new ArrayList();
49: toSelect.add(wp);
50: jc.endUndouableChange(toSelect);
51: }
52: }
53:
54: }
|