1 19 package org.netbeans.modules.j2ee.weblogic9.ui.wizard; 20 21 import java.util.*; 22 import java.io.*; 23 import javax.swing.event.*; 24 25 import org.openide.*; 26 import org.openide.util.*; 27 import org.netbeans.modules.j2ee.deployment.plugins.api.*; 28 29 import org.netbeans.modules.j2ee.weblogic9.*; 30 31 38 public class WLInstantiatingIterator implements WizardDescriptor.InstantiatingIterator { 39 40 44 private final static String PROP_DISPLAY_NAME = "ServInstWizard_displayName"; 46 50 private static final String DEFAULT_DEBUGGER_PORT = "8787"; 52 55 private WizardDescriptor wizardDescriptor; 56 57 62 public void uninitialize(WizardDescriptor wizardDescriptor) { 63 } 65 66 72 public void initialize(WizardDescriptor wizardDescriptor) { 73 this.wizardDescriptor = wizardDescriptor; 74 } 75 76 82 public String name() { 83 return ""; } 85 86 94 public Set instantiate() throws IOException { 95 Set result = new HashSet(); 97 98 String url = WLDeploymentFactory.URI_PREFIX + this.host + ":" + this.port + ":" + serverRoot; 101 String username = this.username; 103 String password = this.password; 104 105 String displayName = (String )wizardDescriptor.getProperty(PROP_DISPLAY_NAME); 106 107 String serverRoot = this.serverRoot; 111 String domainRoot = this.domainRoot; 112 String isLocal = this.isLocal; 113 114 InstanceProperties ip = InstanceProperties.createInstanceProperties(url, username, password, displayName); 117 ip.setProperty(WLPluginProperties.SERVER_ROOT_ATTR, serverRoot); 118 ip.setProperty(WLPluginProperties.DOMAIN_ROOT_ATTR, domainRoot); 119 ip.setProperty(WLPluginProperties.IS_LOCAL_ATTR, isLocal); 120 ip.setProperty(WLPluginProperties.DEBUGGER_PORT_ATTR, DEFAULT_DEBUGGER_PORT); 121 122 result.add(ip); 124 125 return result; 127 } 128 129 private String serverRoot; 131 private String domainRoot; 132 private String isLocal; 133 private String host; 134 private String port; 135 private String username; 136 private String password; 137 138 143 public void setServerRoot(String serverRoot) { 144 this.serverRoot = serverRoot; 145 146 serverPropertiesPanel.updateInstancesList(); 148 } 149 150 155 public String getServerRoot() { 156 return this.serverRoot; 157 } 158 159 164 public void setDomainRoot(String domainRoot) { 165 this.domainRoot = domainRoot; 166 } 167 168 173 public String getDomainRoot() { 174 return domainRoot; 175 } 176 177 182 public String getHost() { 183 return host; 184 } 185 186 191 public void setHost(String host) { 192 this.host = host; 193 } 194 195 200 public String getPort() { 201 return port; 202 } 203 204 209 public void setPort(String port) { 210 this.port = port; 211 } 212 213 218 public String getUsername() { 219 return username; 220 } 221 222 227 public void setUsername(String username) { 228 this.username = username; 229 } 230 231 236 public String getPassword() { 237 return password; 238 } 239 240 245 public void setPassword(String password) { 246 this.password = password; 247 } 248 249 254 public String getIsLocal() { 255 return this.isLocal; 256 } 257 258 263 public void setIsLocal(String isLocal) { 264 this.isLocal = isLocal; 265 } 266 267 273 private Vector steps = new Vector(); 274 { 275 steps.add(NbBundle.getMessage(ServerPropertiesPanel.class, "SERVER_LOCATION_STEP")); steps.add(NbBundle.getMessage(ServerPropertiesPanel.class, "SERVER_PROPERTIES_STEP")); } 278 279 282 private WizardDescriptor.Panel[] panels; 283 private ServerLocationPanel serverLocationPanel; 284 private ServerPropertiesPanel serverPropertiesPanel; 285 286 289 private int index = 0; 290 291 295 public boolean hasPrevious() { 296 return index > 0; 297 } 298 299 304 public void previousPanel() { 305 if (!hasPrevious()) { 306 throw new NoSuchElementException(); 307 } 308 index--; 309 } 310 311 315 public boolean hasNext() { 316 return index < panels.length - 1; 317 } 318 319 324 public void nextPanel() { 325 if (!hasNext()) { 326 throw new NoSuchElementException(); 327 } 328 index++; 329 } 330 331 336 public WizardDescriptor.Panel current() { 337 getPanels(); 338 return panels[index]; 339 } 340 341 protected final WizardDescriptor.Panel[] getPanels() { 342 if (panels == null) { 343 panels = createPanels(); 344 } 345 return panels; 346 } 347 348 protected WizardDescriptor.Panel[] createPanels() { 349 350 serverLocationPanel = new ServerLocationPanel((String []) steps.toArray(new String [steps.size()]), 0, new IteratorListener(), this); 351 serverPropertiesPanel = new ServerPropertiesPanel((String []) steps.toArray(new String [steps.size()]), 1, new IteratorListener(), this); 352 353 return new WizardDescriptor.Panel[] { serverLocationPanel, serverPropertiesPanel }; 354 } 355 356 357 363 private Vector listeners = new Vector(); 364 365 370 public void removeChangeListener(ChangeListener listener) { 371 if (listeners != null) { 372 synchronized (listeners) { 373 listeners.remove(listener); 374 } 375 } 376 } 377 378 383 public void addChangeListener(ChangeListener listener) { 384 synchronized (listeners) { 385 listeners.add(listener); 386 } 387 } 388 389 394 private void fireChangeEvent(ChangeEvent event) { 395 Vector targetListeners; 398 synchronized (listeners) { 399 targetListeners = (Vector) listeners.clone(); 400 } 401 402 for (int i = 0; i < targetListeners.size(); i++) { 404 ChangeListener listener = (ChangeListener) targetListeners.elementAt(i); 405 listener.stateChanged(event); 406 } 407 } 408 409 415 private class IteratorListener implements ChangeListener { 416 421 public void stateChanged(ChangeEvent event) { 422 fireChangeEvent(event); 423 } 424 } 425 426 } 427 | Popular Tags |