1 19 20 package org.netbeans.modules.j2ee.jboss4.nodes; 21 22 import java.awt.Image ; 23 import javax.enterprise.deploy.shared.ModuleType ; 24 import javax.swing.Action ; 25 import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport; 26 import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport.ServerIcon; 27 import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager; 28 import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils; 29 import org.netbeans.modules.j2ee.jboss4.nodes.actions.OpenURLAction; 30 import org.netbeans.modules.j2ee.jboss4.nodes.actions.OpenURLActionCookie; 31 import org.netbeans.modules.j2ee.jboss4.nodes.actions.UndeployModuleAction; 32 import org.netbeans.modules.j2ee.jboss4.nodes.actions.UndeployModuleCookieImpl; 33 import org.openide.nodes.AbstractNode; 34 import org.openide.util.Lookup; 35 import org.openide.util.actions.SystemAction; 36 37 42 public class JBWebModuleNode extends AbstractNode { 43 44 final boolean isRemoteManagementSupported; 45 final boolean isJB4x; 46 47 public JBWebModuleNode(String fileName, Lookup lookup, String url) { 48 super(new JBServletsChildren(fileName, lookup)); 49 setDisplayName(fileName.substring(0, fileName.indexOf('.'))); 50 isRemoteManagementSupported = Util.isRemoteManagementSupported(lookup); 51 isJB4x = JBPluginUtils.isGoodJBServerLocation4x((JBDeploymentManager)lookup.lookup(JBDeploymentManager.class)); 52 if (isRemoteManagementSupported && isJB4x) { 53 getCookieSet().add(new UndeployModuleCookieImpl(fileName, ModuleType.WAR, lookup)); 55 } 56 57 if(url != null) 58 getCookieSet().add(new OpenURLActionCookieImpl(url)); 59 } 60 61 public Action [] getActions(boolean context){ 62 if (getParentNode() instanceof JBEarApplicationNode) { 63 return new SystemAction[] { 64 SystemAction.get(OpenURLAction.class) 65 }; 66 } 67 else { 68 if (isRemoteManagementSupported && isJB4x) { 69 return new SystemAction[] { 70 SystemAction.get(OpenURLAction.class), 71 SystemAction.get(UndeployModuleAction.class) 72 }; 73 } 74 else { 75 return new SystemAction[] { 77 SystemAction.get(OpenURLAction.class), 78 }; 79 } 80 } 81 } 82 83 public Image getIcon(int type) { 84 return UISupport.getIcon(ServerIcon.WAR_ARCHIVE); 85 } 86 87 public Image getOpenedIcon(int type) { 88 return getIcon(type); 89 } 90 91 private static class OpenURLActionCookieImpl implements OpenURLActionCookie { 92 93 private String url; 94 95 public OpenURLActionCookieImpl(String url) { 96 this.url = url; 97 } 98 99 public String getWebURL() { 100 return url; 101 } 102 } 103 } 104 | Popular Tags |