1 package org.netbeans.modules.j2ee.sun.ide.runtime.actions; 2 20 import java.util.Vector ; 21 import org.openide.ErrorManager; 22 import org.openide.nodes.Node; 23 import org.openide.util.Lookup; 24 import org.openide.util.actions.NodeAction; 25 import org.openide.util.NbBundle; 26 import org.openide.util.HelpCtx; 27 import org.openide.util.RequestProcessor; 28 import org.netbeans.modules.j2ee.sun.bridge.apis.Undeployable; 29 30 import org.netbeans.modules.j2ee.sun.bridge.apis.RefreshCookie; 31 32 36 public class UndeployAction extends NodeAction { 37 38 42 protected void performAction(final Node[] activatedNodes) { 43 if (activatedNodes==null){ 44 return; 45 } 46 Vector parents = new java.util.Vector (); 47 for (int i=0;i<activatedNodes.length;i++){ 48 Node parentNode = activatedNodes[i].getParentNode(); 49 parents.add(parentNode); 50 } 51 final Object [] parentNodes = parents.toArray(); 52 53 RequestProcessor.getDefault().post(new Runnable () { 54 public void run() { 55 for (int i=0;i<activatedNodes.length;i++){ 56 Node node = activatedNodes[i]; 57 Lookup lookup = node.getLookup(); 58 Object obj = lookup.lookup(Undeployable.class); 59 60 try { 61 if(obj instanceof Undeployable) { 62 Undeployable undeployableObj = (Undeployable)obj; 63 undeployableObj.undeploy(); 64 } 65 } catch(java.lang.RuntimeException rex) { 66 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,rex); 67 } 68 } 69 for(int i=0; i<parentNodes.length; i++){ 70 Node parentNode = (Node)parentNodes[i]; 71 RefreshCookie refreshAction = 72 (RefreshCookie)parentNode.getCookie(RefreshCookie.class); 73 if (refreshAction != null){ 74 refreshAction.refresh(); 75 } 76 } 77 } 78 }); 79 } 80 81 82 86 protected boolean enable(Node[] nodes) { 87 return ((nodes != null) && (nodes.length >= 1)) ? true : false; 88 } 89 90 91 95 protected boolean asynchronous() { 96 return false; 97 } 98 99 100 104 public HelpCtx getHelpCtx() { 105 return HelpCtx.DEFAULT_HELP; 106 } 107 108 109 112 public String getName() { 113 return NbBundle.getMessage(UndeployAction.class, "LBL_UndeployAction"); 114 } 115 116 } 117 | Popular Tags |