01: package org.enhydra.jawe.base.editor.actions;
02:
03: import java.awt.event.ActionEvent;
04:
05: import javax.swing.JOptionPane;
06:
07: import org.enhydra.jawe.ActionBase;
08: import org.enhydra.jawe.JaWEComponent;
09: import org.enhydra.jawe.base.editor.NewStandardXPDLElementEditor;
10: import org.enhydra.jawe.base.panel.InlinePanel;
11: import org.enhydra.shark.xpdl.XMLComplexChoice;
12: import org.enhydra.shark.xpdl.XMLElement;
13: import org.enhydra.shark.xpdl.XMLUtil;
14:
15: /**
16: * @author Sasa Bojanic
17: */
18: public class DisplayParentElementPanel extends ActionBase {
19:
20: protected InlinePanel ipc;
21:
22: public DisplayParentElementPanel(JaWEComponent jawecomponent) {
23: super (jawecomponent);
24: this .ipc = (InlinePanel) ((NewStandardXPDLElementEditor) jawecomponent)
25: .getView();
26: setEnabled(false);
27: }
28:
29: public void enableDisableAction() {
30: XMLElement el = ipc.getActiveElement();
31: if (el != null && el.getParent() != null) {
32: setEnabled(true);
33: return;
34: }
35:
36: setEnabled(false);
37: }
38:
39: public void actionPerformed(ActionEvent e) {
40: XMLElement el = ipc.getActiveElement();
41: XMLElement parent = null;
42: if (el != null) {
43: parent = el.getParent();
44: if (parent != null) {
45: XMLElement choice = null;
46: while ((choice = XMLUtil
47: .getParentElementByAssignableType(
48: XMLComplexChoice.class, parent)) != null) {
49: parent = choice.getParent();
50: }
51: }
52: }
53:
54: if (el != null) {
55: if (ipc.isModified()) {
56: int sw = ipc.showModifiedWarning();
57: if (sw == JOptionPane.CANCEL_OPTION
58: || (sw == JOptionPane.YES_OPTION && ipc
59: .isModified())) {
60: return;
61: }
62: }
63: ((NewStandardXPDLElementEditor) jawecomponent)
64: .editXPDLElement(parent);
65: }
66: }
67: }
|