1 19 package org.netbeans.modules.j2ee.jboss4.nodes; 20 21 import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager; 22 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 23 import org.netbeans.modules.j2ee.jboss4.customizer.CustomizerDataSupport; 24 import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties; 25 import org.netbeans.modules.j2ee.jboss4.nodes.actions.OpenServerLogAction; 26 import org.netbeans.modules.j2ee.jboss4.nodes.actions.ShowAdminToolAction; 27 import org.netbeans.modules.j2ee.jboss4.nodes.actions.ShowJMXConsoleAction; 28 import org.openide.nodes.*; 29 import org.openide.util.Lookup; 30 import org.openide.util.NbBundle; 31 import java.awt.Image ; 32 import java.awt.Toolkit ; 33 import java.beans.BeanInfo ; 34 import java.net.URL ; 35 import org.netbeans.modules.j2ee.jboss4.customizer.Customizer; 36 import org.netbeans.modules.j2ee.jboss4.ide.JBJ2eePlatformFactory; 37 import java.awt.Component ; 38 import org.openide.util.Utilities; 39 import org.openide.util.actions.SystemAction; 40 41 45 public class JBManagerNode extends AbstractNode implements Node.Cookie { 46 47 private Lookup lookup; 48 private static final String ADMIN_URL = "/web-console/"; private static final String JMX_CONSOLE_URL = "/jmx-console/"; private static final String HTTP_HEADER = "http://"; 51 52 public JBManagerNode(Children children, Lookup lookup) { 53 super(children); 54 this.lookup = lookup; 55 getCookieSet().add(this); 56 } 57 58 public org.openide.util.HelpCtx getHelpCtx() { 59 return new org.openide.util.HelpCtx("j2eeplugins_property_sheet_server_node_jboss"); } 61 62 public boolean hasCustomizer() { 63 return true; 64 } 65 66 public Component getCustomizer() { 67 CustomizerDataSupport dataSup = new CustomizerDataSupport(getDeploymentManager().getProperties()); 68 return new Customizer(dataSup, new JBJ2eePlatformFactory().getJ2eePlatformImpl(getDeploymentManager())); 69 } 70 71 public String getAdminURL() { 72 return HTTP_HEADER+getDeploymentManager().getHost()+":"+getDeploymentManager().getPort()+ ADMIN_URL; 73 } 74 75 public String getJMXConsoleURL() { 76 return HTTP_HEADER+getDeploymentManager().getHost()+":"+getDeploymentManager().getPort()+ JMX_CONSOLE_URL; 77 } 78 79 public javax.swing.Action [] getActions(boolean context) { 80 javax.swing.Action [] newActions = new javax.swing.Action [4] ; 81 newActions[0]=(null); 82 newActions[1]= (SystemAction.get(ShowAdminToolAction.class)); 83 newActions[2]= (SystemAction.get(ShowJMXConsoleAction.class)); 84 newActions[3]= (SystemAction.get(OpenServerLogAction.class)); 85 return newActions; 86 } 87 88 public Sheet createSheet(){ 89 Sheet sheet = super.createSheet(); 90 Sheet.Set properties = sheet.get(Sheet.PROPERTIES); 91 if (properties == null) { 92 properties = Sheet.createPropertiesSet(); 93 sheet.put(properties); 94 } 95 final InstanceProperties ip = getDeploymentManager().getInstanceProperties(); 96 97 Node.Property property=null; 98 99 property = new PropertySupport.ReadWrite( 101 NbBundle.getMessage(JBManagerNode.class, "LBL_DISPLAY_NAME"), String .class, 103 NbBundle.getMessage(JBManagerNode.class, "LBL_DISPLAY_NAME"), NbBundle.getMessage(JBManagerNode.class, "HINT_DISPLAY_NAME") ) { 106 public Object getValue() { 107 return ip.getProperty(JBPluginProperties.PROPERTY_DISPLAY_NAME); 108 } 109 110 public void setValue(Object val) { 111 ip.setProperty(JBPluginProperties.PROPERTY_DISPLAY_NAME, (String )val); 112 } 113 }; 114 115 properties.put(property); 116 117 property = new PropertySupport.ReadOnly( 119 NbBundle.getMessage(JBManagerNode.class, "LBL_SERVER_NAME"), String .class, 121 NbBundle.getMessage(JBManagerNode.class, "LBL_SERVER_NAME"), NbBundle.getMessage(JBManagerNode.class, "HINT_SERVER_NAME") ) { 124 public Object getValue() { 125 return ip.getProperty(JBPluginProperties.PROPERTY_SERVER); 126 } 127 }; 128 properties.put(property); 129 130 property = new PropertySupport.ReadOnly( 132 NbBundle.getMessage(JBManagerNode.class, "LBL_SERVER_PATH"), String .class, 134 NbBundle.getMessage(JBManagerNode.class, "LBL_SERVER_PATH"), NbBundle.getMessage(JBManagerNode.class, "HINT_SERVER_PATH") ) { 137 public Object getValue() { 138 return ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR); 139 } 140 }; 141 properties.put(property); 142 143 property = new PropertySupport.ReadOnly( 145 NbBundle.getMessage(JBManagerNode.class, "LBL_HOST"), String .class, 147 NbBundle.getMessage(JBManagerNode.class, "LBL_HOST"), NbBundle.getMessage(JBManagerNode.class, "HINT_HOST") ) { 150 public Object getValue() { 151 return ip.getProperty(JBPluginProperties.PROPERTY_HOST); 152 } 153 }; 154 properties.put(property); 155 156 property = new PropertySupport.ReadOnly( 158 NbBundle.getMessage(JBManagerNode.class, "LBL_PORT"), Integer.TYPE, 160 NbBundle.getMessage(JBManagerNode.class, "LBL_PORT"), NbBundle.getMessage(JBManagerNode.class, "HINT_PORT") ) { 163 public Object getValue() { 164 return new Integer (ip.getProperty(JBPluginProperties.PROPERTY_PORT)); 165 } 166 }; 167 properties.put(property); 168 169 return sheet; 170 } 171 172 public Image getIcon(int type) { 173 if (type == BeanInfo.ICON_COLOR_16x16) { 174 return Utilities.loadImage("org/netbeans/modules/j2ee/jboss4/resources/16x16.gif"); } 176 return super.getIcon(type); 177 } 178 179 public Image getOpenedIcon(int type) { 180 return getIcon(type); 181 } 182 183 public String getShortDescription() { 184 InstanceProperties ip = InstanceProperties.getInstanceProperties(getDeploymentManager().getUrl()); 185 String host = ip.getProperty(JBPluginProperties.PROPERTY_HOST); 186 String port = ip.getProperty(JBPluginProperties.PROPERTY_PORT); 187 return HTTP_HEADER + host + ":" + port + "/"; } 189 190 public JBDeploymentManager getDeploymentManager() { 191 return ((JBDeploymentManager) lookup.lookup(JBDeploymentManager.class)); 192 } 193 } | Popular Tags |