01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19: package org.netbeans.modules.bpel.nodes.actions;
20:
21: import org.netbeans.modules.bpel.nodes.actions.BpelNodeAction;
22: import org.netbeans.modules.bpel.editors.api.nodes.actions.ActionType;
23: import javax.swing.KeyStroke;
24: import javax.swing.UIManager;
25: import org.netbeans.modules.bpel.model.api.BpelContainer;
26: import org.netbeans.modules.bpel.model.api.BpelEntity;
27: import org.netbeans.modules.bpel.model.api.Else;
28: import org.netbeans.modules.bpel.model.api.Process;
29: import org.openide.nodes.Node;
30: import org.openide.util.NbBundle;
31:
32: /**
33: *
34: * @author Vitaly Bychkov
35: * @version 23 March 2006
36: *
37: */
38: public class DeleteAction extends BpelNodeAction {
39: private static final long serialVersionUID = 1L;
40: private static final String DELETE_KEYSTROKE = "DELETE"; // NOI18N
41:
42: public DeleteAction() {
43: super ();
44: putValue(DeleteAction.ACCELERATOR_KEY, KeyStroke
45: .getKeyStroke(DELETE_KEYSTROKE));
46: }
47:
48: protected String getBundleName() {
49: return NbBundle.getMessage(DeleteAction.class,
50: "CTL_DeleteAction"); // NOI18N
51: }
52:
53: /**
54: * Used just to declare public scope instead protected
55: */
56: public boolean enable(Node[] nodes) {
57: return super .enable(nodes);
58: }
59:
60: /**
61: * Used just to declare public scope instead protected
62: */
63: public void performAction(Node[] nodes) {
64: super .performAction(nodes);
65: }
66:
67: protected void performAction(BpelEntity[] bpelEntities) {
68: if (!enable(bpelEntities)) {
69: return;
70: }
71:
72: for (BpelEntity entity : bpelEntities) {
73: assert entity != null;
74: BpelContainer parent = entity.getParent();
75: assert parent != null;
76: parent.remove(entity);
77:
78: if (parent instanceof Else) {
79: BpelContainer if_elem = parent.getParent();
80: if (if_elem != null) {
81: if_elem.remove(parent);
82: }
83: }
84: }
85: }
86:
87: protected boolean enable(BpelEntity[] bpelEntities) {
88: return super .enable(bpelEntities)
89: && !(bpelEntities[0] instanceof Process);
90: }
91:
92: public ActionType getType() {
93: return ActionType.REMOVE;
94: }
95: }
|