1 19 20 package org.netbeans.modules.j2ee.deployment.impl.ui.actions; 21 22 import org.openide.util.actions.*; 23 import org.openide.actions.*; 24 import org.openide.nodes.*; 25 import org.openide.util.HelpCtx; 26 import org.netbeans.modules.j2ee.deployment.impl.*; 27 import org.netbeans.modules.j2ee.deployment.impl.ui.*; 28 import org.openide.NotifyDescriptor; 29 import org.openide.util.NbBundle; 30 import org.openide.DialogDisplayer; 31 32 39 public class RemoveInstanceAction extends CookieAction { 40 41 protected void performAction(org.openide.nodes.Node[] nodes) { 42 for (int i=0; i<nodes.length; i++) { 43 ServerInstance instance = (ServerInstance) nodes[i].getCookie(ServerInstance.class); 44 if (instance == null || instance.isRemoveForbidden()) { 45 continue; 46 } 47 String title = NbBundle.getMessage(RemoveInstanceAction.class, "MSG_RemoveInstanceTitle", instance.getDisplayName()); 48 String msg = NbBundle.getMessage(RemoveInstanceAction.class, "MSG_ReallyRemoveInstance", instance.getDisplayName()); 49 NotifyDescriptor d = new NotifyDescriptor.Confirmation(msg, title, NotifyDescriptor.OK_CANCEL_OPTION); 50 if (DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.OK_OPTION) { 51 instance.remove(); 52 } 53 } 54 } 55 56 protected boolean enable (Node[] nodes) { 57 for (int i = 0; i < nodes.length; i++) { 58 ServerInstance instance = (ServerInstance)nodes[i].getCookie(ServerInstance.class); 59 if (instance == null || instance.isRemoveForbidden() 60 || instance.getServerState() == ServerInstance.STATE_WAITING) { 61 return false; 62 } 63 } 64 return true; 65 } 66 67 protected Class [] cookieClasses() { 68 return new Class [] { 69 ServerInstance.class 70 }; 71 } 72 73 protected int mode() { 74 return MODE_ALL; 75 } 76 77 public String getName() { 78 return NbBundle.getMessage(RemoveInstanceAction.class, "LBL_Remove"); 79 } 80 81 public org.openide.util.HelpCtx getHelpCtx() { 82 return HelpCtx.DEFAULT_HELP; 83 } 84 85 protected boolean asynchronous() { 86 return false; 87 } 88 89 } 90 | Popular Tags |