01: /*
02: * To change this template, choose Tools | Templates
03: * and open the template in the editor.
04: */
05: package org.netbeans.modules.bpel.design.actions;
06:
07: import java.awt.event.ActionEvent;
08: import javax.swing.Action;
09: import org.netbeans.modules.bpel.design.DesignView;
10: import org.netbeans.modules.bpel.design.model.patterns.Pattern;
11: import org.netbeans.modules.bpel.editors.api.nodes.actions.ActionType;
12: import org.netbeans.modules.bpel.nodes.actions.BpelNodeAction;
13: import org.openide.nodes.Node;
14:
15: /**
16: *
17: * @author Alexey
18: */
19: public class DeleteAction extends DesignModeAction {
20:
21: private static final long serialVersionUID = 1L;
22:
23: public DeleteAction(DesignView view) {
24: super (view);
25: }
26:
27: public void actionPerformed(ActionEvent e) {
28: if (!isEnabled()) {
29: return;
30: }
31:
32: Pattern selected = getDesignView().getSelectionModel()
33: .getSelectedPattern();
34:
35: if (selected == null) {
36: return;
37: }
38:
39: Node node = getDesignView().getNodeForPattern(selected);
40:
41: if (node == null) {
42: return;
43: }
44:
45: Action[] actions = node.getActions(true);
46: if (actions == null) {
47: return;
48: }
49:
50: for (int i = actions.length - 1; i >= 0; i--) {
51: Action action = actions[i];
52: if (action instanceof BpelNodeAction) {
53: if (((BpelNodeAction) action).getType() == ActionType.REMOVE) {
54: action.actionPerformed(e);
55: return;
56: }
57: }
58: }
59: }
60: }
|