KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > registry > actions > DeleteWebServiceGroupAction


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * 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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.registry.actions;
21
22 import org.openide.util.actions.NodeAction;
23 import org.openide.util.HelpCtx;
24 import org.openide.util.NbBundle;
25 import org.openide.nodes.Node;
26 import org.openide.DialogDisplayer;
27 import org.openide.NotifyDescriptor;
28 import org.openide.windows.*;
29 import org.openide.ErrorManager;
30 import org.openide.awt.MouseUtils;
31 import org.openide.awt.StatusDisplayer;
32
33 import java.awt.event.MouseAdapter JavaDoc;
34 import java.awt.event.MouseEvent JavaDoc;
35 import java.awt.Dimension JavaDoc;
36 import java.awt.datatransfer.Transferable JavaDoc;
37 import java.awt.datatransfer.DataFlavor JavaDoc;
38 import java.awt.datatransfer.StringSelection JavaDoc;
39 import java.awt.Container JavaDoc;
40 import java.awt.Toolkit JavaDoc;
41 import java.awt.Point JavaDoc;
42 import java.awt.event.MouseListener JavaDoc;
43 import java.awt.event.MouseEvent JavaDoc;
44 import java.awt.event.MouseMotionListener JavaDoc;
45 import java.awt.event.ActionListener JavaDoc;
46 import java.awt.event.ActionEvent JavaDoc;
47 import java.awt.event.FocusListener JavaDoc;
48 import java.awt.event.FocusEvent JavaDoc;
49 import java.awt.event.InputEvent JavaDoc;
50
51 import javax.swing.JEditorPane JavaDoc;
52 import javax.swing.JComponent JavaDoc;
53 import javax.swing.TransferHandler JavaDoc;
54 import javax.swing.Icon JavaDoc;
55 import javax.swing.JButton JavaDoc;
56
57 import java.lang.reflect.Method JavaDoc;
58 import java.util.Set JavaDoc;
59 import java.util.Iterator JavaDoc;
60 import java.io.IOException JavaDoc;
61
62 //import com.sun.rave.designer.DesignerTopComp;
63
//import com.sun.rave.designer.DesignerPane;
64

65
66 //import org.netbeans.modules.websvc.registry.designer.*;
67
import org.netbeans.modules.websvc.registry.nodes.WebServiceGroupCookie;
68 import org.netbeans.modules.websvc.registry.model.WebServiceListModel;
69 import org.netbeans.modules.websvc.registry.model.WebServiceGroup;
70
71 /**
72  * This action will delete a web service group from the server navigator
73  * @author David Botterill
74  */

75
76 public class DeleteWebServiceGroupAction extends NodeAction {
77
78     protected boolean enable(Node[] nodes) {
79         // !PW this does not handle multiple selection (or rather, it does, but
80
// only acts on the first node, ignoring the remainder. See also performAction()
81
// which is written the same way.
82
if(nodes != null && nodes.length > 0 && nodes[0].getCookie(WebServiceGroupCookie.class) != null) {
83             return true;
84         } else {
85             return false;
86         }
87     }
88
89     public org.openide.util.HelpCtx getHelpCtx() {
90         return HelpCtx.DEFAULT_HELP;
91         // If you will provide context help then use:
92
// return new AddToFormAction.class);
93
}
94
95     protected String JavaDoc iconResource() {
96         return "org/netbeans/modules/websvc/registry/resources/MyActionIcon.gif";
97     }
98
99     public String JavaDoc getName() {
100         return NbBundle.getMessage(DeleteWebServiceGroupAction.class, "DELETE");
101     }
102
103     protected void performAction(Node[] nodes) {
104         if(null != nodes && nodes.length > 0) {
105             WebServiceGroupCookie groupCookie = (WebServiceGroupCookie) nodes[0].getCookie(WebServiceGroupCookie.class);
106             if(groupCookie != null) {
107                 WebServiceGroup wsGroup = groupCookie.getWebServiceGroup();
108                 String JavaDoc groupName = null;
109                 if(null != wsGroup) {
110                     groupName = wsGroup.getName();
111                 }
112                 String JavaDoc msg = NbBundle.getMessage(this.getClass(), "WS_DELETE_GROUP") + " " + groupName;
113                 NotifyDescriptor d = new NotifyDescriptor.Confirmation(msg, NotifyDescriptor.YES_NO_OPTION);
114                 Object JavaDoc response = DialogDisplayer.getDefault().notify(d);
115
116                 if(null != response && response.equals(NotifyDescriptor.YES_OPTION)) {
117                     try {
118                         // !PW DELEGATING_DESTROY bit appears to be turned on for the FilterNodes
119
// that are passed through here.
120
nodes[0].destroy();
121                     } catch(IOException JavaDoc ioe) {
122                         ErrorManager.getDefault().notify(ioe);
123                         StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(DeleteWebServiceGroupAction.class, "ERROR_DELETING"));
124                     }
125                 }
126             }
127         }
128     }
129
130     protected boolean asynchronous() {
131         return false;
132     }
133 }
134
Popular Tags