KickJava   Java API By Example, From Geeks To Geeks.

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


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.ErrorManager;
29 import org.openide.awt.StatusDisplayer;
30 import java.io.IOException JavaDoc;
31 import org.netbeans.modules.websvc.registry.nodes.WebServicesCookie;
32 import org.netbeans.modules.websvc.registry.model.WebServiceListModel;
33 import org.netbeans.modules.websvc.registry.model.WebServiceData;
34 /**
35  * This action will delete a web service from the server navigator
36  * @author Lukas Jungman, Milan Kuchtiak
37  */

38
39 public class DeleteWebServiceAction extends NodeAction {
40
41     protected boolean enable(Node[] nodes) {
42         if(nodes != null && nodes.length > 0)
43             for (int i = 0; i < nodes.length; i++) {
44                 if (nodes[i].getCookie(WebServicesCookie.class) == null) {
45                     return false;
46                 }
47             }
48         return true;
49     }
50
51     public org.openide.util.HelpCtx getHelpCtx() {
52         return HelpCtx.DEFAULT_HELP;
53         // If you will provide context help then use:
54
// return new AddToFormAction.class);
55
}
56
57     protected String JavaDoc iconResource() {
58         return "org/netbeans/modules/websvc/registry/resources/MyActionIcon.gif"; //NOI18N
59
}
60
61     public String JavaDoc getName() {
62         return NbBundle.getMessage(DeleteWebServiceAction.class, "DELETE");
63     }
64
65     protected void performAction(Node[] nodes) {
66         if(null != nodes) {
67             String JavaDoc msg = NbBundle.getMessage(DeleteWebServiceAction.class, "WS_DELETE", Integer.toString(nodes.length));
68             NotifyDescriptor d = new NotifyDescriptor.Confirmation(msg, NotifyDescriptor.YES_NO_OPTION);
69             Object JavaDoc response = DialogDisplayer.getDefault().notify(d);
70             if(response.equals(NotifyDescriptor.YES_OPTION)) {
71                 for (int i = 0; i < nodes.length; i++) {
72                     try {
73                         nodes[i].destroy();
74                     } catch(IOException JavaDoc ioe) {
75                         ErrorManager.getDefault().notify(ioe);
76                         StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(DeleteWebServiceAction.class, "ERROR_DELETING"));
77                     }
78                 }
79             }
80         }
81     }
82
83     protected boolean asynchronous() {
84         return false;
85     }
86 }
87
Popular Tags