1 19 20 package org.netbeans.modules.j2ee.oc4j.nodes; 21 22 import java.awt.Component ; 23 import javax.swing.Action ; 24 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 25 import org.netbeans.modules.j2ee.oc4j.OC4JDeploymentManager; 26 import org.netbeans.modules.j2ee.oc4j.customizer.OC4JCustomizer; 27 import org.netbeans.modules.j2ee.oc4j.customizer.OC4JCustomizerDataSupport; 28 import org.netbeans.modules.j2ee.oc4j.ide.OC4JJ2eePlatformFactory; 29 import org.netbeans.modules.j2ee.oc4j.nodes.actions.ShowAdminToolAction; 30 import org.netbeans.modules.j2ee.oc4j.util.OC4JPluginProperties; 31 import org.openide.nodes.AbstractNode; 32 import org.openide.nodes.Children; 33 import org.openide.nodes.Node; 34 import org.openide.util.Lookup; 35 import org.openide.util.NbBundle; 36 import org.openide.util.actions.SystemAction; 37 38 42 public class OC4JInstanceNode extends AbstractNode implements Node.Cookie { 43 44 private static String ICON_BASE = "org/netbeans/modules/j2ee/oc4j/resources/16x16.png"; private static final String ADMIN_URL = "/em/"; private static final String HTTP_HEADER = "http://"; 47 private Lookup lookup; 48 49 public OC4JInstanceNode(Lookup lookup) { 50 super(new Children.Array()); 51 this.lookup = lookup; 52 getCookieSet().add(this); 53 setIconBaseWithExtension(ICON_BASE); 54 } 55 56 public String getAdminURL() { 57 InstanceProperties ip = getDeploymentManager().getProperties().getInstanceProperties(); 58 String host = ip.getProperty(OC4JPluginProperties.PROPERTY_HOST); 59 String httpPort = ip.getProperty(InstanceProperties.HTTP_PORT_NUMBER); 60 return HTTP_HEADER + host + ":" + httpPort + ADMIN_URL; 61 } 62 63 public String getDisplayName() { 64 return NbBundle.getMessage(OC4JInstanceNode.class, "TXT_MyInstanceNode"); 65 } 66 67 public javax.swing.Action [] getActions(boolean context) { 68 Action [] actions = new Action [2]; 69 actions[0] = null; 70 actions[1] = (SystemAction.get(ShowAdminToolAction.class)); 71 return actions; 72 } 73 74 public boolean hasCustomizer() { 75 return true; 76 } 77 78 public Component getCustomizer() { 79 OC4JCustomizerDataSupport dataSup = new OC4JCustomizerDataSupport(getDeploymentManager()); 80 return new OC4JCustomizer(dataSup, new OC4JJ2eePlatformFactory().getJ2eePlatformImpl(getDeploymentManager())); 81 } 82 83 public OC4JDeploymentManager getDeploymentManager() { 84 return ((OC4JDeploymentManager) lookup.lookup(OC4JDeploymentManager.class)); 85 } 86 } | Popular Tags |