1 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 ; 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 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 } 56 57 protected String iconResource() { 58 return "org/netbeans/modules/websvc/registry/resources/MyActionIcon.gif"; } 60 61 public String getName() { 62 return NbBundle.getMessage(DeleteWebServiceAction.class, "DELETE"); 63 } 64 65 protected void performAction(Node[] nodes) { 66 if(null != nodes) { 67 String msg = NbBundle.getMessage(DeleteWebServiceAction.class, "WS_DELETE", Integer.toString(nodes.length)); 68 NotifyDescriptor d = new NotifyDescriptor.Confirmation(msg, NotifyDescriptor.YES_NO_OPTION); 69 Object 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 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 |