01: package org.enhydra.jawe.base.controller.actions;
02:
03: import java.awt.event.ActionEvent;
04:
05: import org.enhydra.jawe.ActionBase;
06: import org.enhydra.jawe.JaWEComponent;
07: import org.enhydra.jawe.base.controller.JaWEController;
08: import org.enhydra.shark.xpdl.XMLElement;
09: import org.enhydra.shark.xpdl.elements.Package;
10:
11: /**
12: * Removes external package from the system.
13: * @author Sasa Bojanic
14: */
15: public class PackageRemoveExternalPackage extends ActionBase {
16:
17: public PackageRemoveExternalPackage(JaWEComponent jawecomponent) {
18: super (jawecomponent);
19: }
20:
21: public void enableDisableAction() {
22: JaWEController jc = (JaWEController) jawecomponent;
23: Package mainPkg = jc.getMainPackage();
24: XMLElement firstSelected = null;
25: if (mainPkg != null
26: && (firstSelected = jc.getSelectionManager()
27: .getSelectedElement()) instanceof Package) {
28: String epId = ((Package) firstSelected).getId();
29: boolean en = mainPkg.getExternalPackageIds().contains(epId);
30: setEnabled(en);
31: } else {
32: setEnabled(false);
33: }
34: }
35:
36: public void actionPerformed(ActionEvent e) {
37: JaWEController jc = (JaWEController) jawecomponent;
38: Package mainPkg = jc.getMainPackage();
39: if (mainPkg == null)
40: return;
41: jc.removeExternalPackage();
42: }
43: }
|