1 19 20 package org.netbeans.modules.j2ee.oc4j.nodes.actions; 21 22 import org.openide.nodes.Node; 23 import org.openide.util.HelpCtx; 24 import org.openide.util.NbBundle; 25 import org.openide.util.RequestProcessor; 26 import org.openide.util.RequestProcessor.Task; 27 import org.openide.util.actions.NodeAction; 28 29 33 public class UndeployModuleAction extends NodeAction { 34 35 protected void performAction(Node[] nodes) { 36 if((nodes == null) || (nodes.length < 1)) 37 return; 38 39 for(Node node:nodes) { 40 UndeployModuleCookie uCookie = node.getCookie(UndeployModuleCookie.class); 41 42 if (uCookie != null) { 43 final Task t = uCookie.undeploy(); 44 final Node pNode = node.getParentNode().getParentNode(); 45 46 RequestProcessor.getDefault().post(new Runnable () { 47 public void run() { 48 t.waitFinished(); 49 if(pNode != null) { 50 Node[] nodes = pNode.getChildren().getNodes(); 51 for (Node node : nodes) { 52 RefreshModulesCookie cookie = node.getCookie(RefreshModulesCookie.class); 53 if (cookie != null) { 54 cookie.refresh(); 55 } 56 } 57 } 58 } 59 }); 60 } 61 } 62 } 63 64 protected boolean enable(Node[] nodes) { 65 for(Node node:nodes) { 66 UndeployModuleCookie cookie = node.getCookie(UndeployModuleCookie.class); 67 if (cookie == null || cookie.isRunning()) 68 return false; 69 } 70 71 return true; 72 } 73 74 public String getName() { 75 return NbBundle.getMessage(UndeployModuleAction.class, "LBL_UndeployAction"); 76 } 77 78 protected boolean asynchronous() { return false; } 79 80 public org.openide.util.HelpCtx getHelpCtx() { 81 return HelpCtx.DEFAULT_HELP; 82 } 83 } | Popular Tags |