1 19 package org.netbeans.modules.j2ee.websphere6.ui.nodes; 20 21 import java.awt.*; 22 import java.beans.*; 23 import java.io.File ; 24 25 import javax.enterprise.deploy.spi.*; 26 import javax.swing.Action ; 27 import org.netbeans.modules.j2ee.websphere6.ui.nodes.actions.ShowAdminConsoleAction; 28 import org.netbeans.modules.j2ee.websphere6.ui.nodes.actions.ShowServerLogAction; 29 30 import org.openide.util.*; 31 import org.openide.nodes.*; 32 import org.netbeans.modules.j2ee.deployment.plugins.api.*; 33 34 import org.netbeans.modules.j2ee.websphere6.*; 35 import org.netbeans.modules.j2ee.websphere6.j2ee.DeploymentManagerProperties; 36 import org.netbeans.modules.j2ee.websphere6.j2ee.WSJ2eePlatformFactory; 37 import org.netbeans.modules.j2ee.websphere6.ui.nodes.editors.*; 38 import org.openide.util.actions.SystemAction; 39 40 46 public class WSManagerNode extends AbstractNode implements Node.Cookie { 47 48 52 private WSDeploymentManager deploymentManager; 53 54 private static final String DISPLAY_NAME = "displayName"; private static final String URL = "url"; private static final String USERNAME = "username"; private static final String PASSWORD = "password"; private static final String SERVER_ROOT = "serverRoot"; private static final String DOMAIN_ROOT = "domainRoot"; private static final String DEBUGGER_PORT = "debuggerPort"; 63 66 private static final String ICON = "org/netbeans/modules/j2ee/" + "websphere6/resources/16x16.gif"; 69 76 public WSManagerNode(Children children, Lookup lookup) { 77 super(children); 78 79 81 this.deploymentManager = (WSDeploymentManager) lookup.lookup( 82 DeploymentManager.class); 83 84 getCookieSet().add(this); 86 } 87 88 93 public String getDisplayName() { 94 return deploymentManager.getInstanceProperties().getProperty( 95 InstanceProperties.URL_ATTR); 96 } 97 98 103 public Image getIcon(int type) { 104 return Utilities.loadImage(ICON); 105 } 106 107 112 public Image getOpenedIcon(int type) { 113 return Utilities.loadImage(ICON); 114 } 115 116 121 public HelpCtx getHelpCtx() { 122 return new HelpCtx("j2eeplugins_property_sheet_server_" + 123 "node_websphere"); } 125 126 public Action [] getActions(boolean context) { 127 Action [] newActions = new Action [3] ; 128 129 newActions[0] = null; 130 newActions[1] = SystemAction.get(ShowAdminConsoleAction.class); 131 newActions[2] = SystemAction.get(ShowServerLogAction.class); 132 133 return newActions; 134 } 135 136 141 protected Sheet createSheet() { 142 Sheet sheet = super.createSheet(); 144 145 Sheet.Set properties = sheet.get(Sheet.PROPERTIES); 147 if (properties == null) { 148 properties = Sheet.createPropertiesSet(); 149 sheet.put(properties); 150 } 151 152 Node.Property property; 154 155 property = new PropertySupport.ReadWrite( 157 DISPLAY_NAME, 158 String .class, 159 NbBundle.getMessage(WSManagerNode.class, 160 "PROP_displayName"), NbBundle.getMessage(WSManagerNode.class, 162 "HINT_displayName") ) { 164 public Object getValue() { 165 return deploymentManager.getInstanceProperties(). 166 getProperty( 167 InstanceProperties.DISPLAY_NAME_ATTR); 168 } 169 170 public void setValue(Object value) { 171 deploymentManager.getInstanceProperties(). 172 setProperty( 173 InstanceProperties.DISPLAY_NAME_ATTR, 174 (String ) value); 175 } 176 }; 177 properties.put(property); 178 179 property = new PropertySupport.ReadOnly( 181 URL, 182 String .class, 183 NbBundle.getMessage(WSManagerNode.class, 184 "PROP_url"), NbBundle.getMessage(WSManagerNode.class, 186 "HINT_url") ) { 188 public Object getValue() { 189 return deploymentManager.getURI(); 190 } 191 }; 192 properties.put(property); 193 194 property = new PropertySupport.ReadWrite( 196 USERNAME, 197 String .class, 198 NbBundle.getMessage(WSManagerNode.class, 199 "PROP_username"), NbBundle.getMessage(WSManagerNode.class, 201 "HINT_username") ) { 203 public Object getValue() { 204 return deploymentManager.getInstanceProperties(). 205 getProperty(InstanceProperties. 206 USERNAME_ATTR); 207 } 208 209 public void setValue(Object value) { 210 deploymentManager.getInstanceProperties(). 211 setProperty(InstanceProperties. 212 USERNAME_ATTR, (String ) value); 213 } 214 }; 215 properties.put(property); 216 217 property = new PropertySupport.ReadWrite( 219 PASSWORD, 220 String .class, 221 NbBundle.getMessage(WSManagerNode.class, 222 "PROP_password"), NbBundle.getMessage(WSManagerNode.class, 224 "HINT_password") ) { 226 public Object getValue() { 227 String password = deploymentManager. 228 getInstanceProperties().getProperty( 229 InstanceProperties.PASSWORD_ATTR); 230 return password; 232 } 233 234 public void setValue(Object value) { 235 deploymentManager.getInstanceProperties(). 236 setProperty(InstanceProperties.PASSWORD_ATTR, 237 (String ) value); 238 } 239 240 public PropertyEditor getPropertyEditor() { 241 return new WSPasswordEditor(); 242 } 243 }; 244 245 properties.put(property); 246 247 property = new PropertySupport.ReadOnly( 249 SERVER_ROOT, 250 String .class, 251 NbBundle.getMessage(WSManagerNode.class, 252 "PROP_serverRoot"), NbBundle.getMessage(WSManagerNode.class, 254 "HINT_serverRoot") ) { 256 public Object getValue() { 257 return deploymentManager.getInstanceProperties(). 258 getProperty(WSDeploymentFactory. 259 SERVER_ROOT_ATTR); 260 } 261 }; 262 properties.put(property); 263 264 property = new PropertySupport.ReadOnly( 266 DOMAIN_ROOT, 267 String .class, 268 NbBundle.getMessage(WSManagerNode.class, 269 "PROP_domainRoot"), NbBundle.getMessage(WSManagerNode.class, 271 "HINT_domainRoot") ) { 273 public Object getValue() { 274 return deploymentManager.getInstanceProperties(). 275 getProperty( 276 WSDeploymentFactory.DOMAIN_ROOT_ATTR); 277 } 278 }; 279 properties.put(property); 280 281 property = new PropertySupport.ReadWrite( 283 DEBUGGER_PORT, 284 Integer .class, 285 NbBundle.getMessage(WSManagerNode.class, 286 "PROP_debuggerPort"), NbBundle.getMessage(WSManagerNode.class, 288 "HINT_debuggerPort") ) { 290 public Object getValue() { 291 String debuggerPort = deploymentManager. 292 getInstanceProperties().getProperty( 293 WSDeploymentFactory.DEBUGGER_PORT_ATTR); 294 return new Integer (debuggerPort); 295 } 296 297 public void setValue(Object value) { 298 deploymentManager.getInstanceProperties(). 299 setProperty(WSDeploymentFactory. 300 DEBUGGER_PORT_ATTR, value.toString()); 301 } 302 }; 303 properties.put(property); 304 305 return sheet; 306 } 307 308 312 public int hashCode() { 313 return super.hashCode(); 314 } 315 316 320 public boolean equals(Object obj) { 321 return super.equals(obj); 322 } 323 324 public boolean hasCustomizer() { 325 return true; 326 } 327 328 public Component getCustomizer() { 329 return new org.netbeans.modules.j2ee.websphere6.ui.Customizer( 330 new WSJ2eePlatformFactory() 331 .getJ2eePlatformImpl(deploymentManager), 332 new DeploymentManagerProperties(deploymentManager)); 333 } 334 335 public WSDeploymentManager getDeploymentManager() { 336 return deploymentManager; 337 } 338 339 public String getAdminConsoleURL() { 340 return "http://" + deploymentManager.getHost() + ":" + deploymentManager.getInstanceProperties(). 342 getProperty(WSDeploymentFactory.ADMIN_PORT_ATTR) + 343 "/ibm/console"; } 345 346 public String getLogFilePath() { 347 return deploymentManager.getLogFilePath(); 348 } 349 } | Popular Tags |