1 19 23 24 25 package org.netbeans.modules.j2ee.sun.ide.sunresources.wizards; 26 27 import java.awt.event.KeyEvent ; 28 import java.awt.event.ActionEvent ; 29 import java.awt.event.ActionListener ; 30 import java.util.Vector ; 31 import java.util.ArrayList ; 32 import javax.swing.JComponent ; 33 import javax.swing.KeyStroke ; 34 import javax.swing.ButtonGroup ; 35 import javax.swing.event.ChangeListener ; 36 import javax.swing.event.ListDataListener ; 37 import javax.swing.event.DocumentListener ; 38 import org.netbeans.api.db.explorer.ConnectionManager; 39 import org.netbeans.api.db.explorer.DatabaseConnection; 40 41 import org.openide.util.HelpCtx; 42 import org.openide.loaders.TemplateWizard; 43 44 import org.netbeans.modules.j2ee.sun.ide.sunresources.beans.ResourceUtils; 45 import org.netbeans.modules.j2ee.sun.sunresources.beans.Field; 46 import org.netbeans.modules.j2ee.sun.sunresources.beans.FieldGroup; 47 import org.netbeans.modules.j2ee.sun.sunresources.beans.Wizard; 48 import org.netbeans.modules.j2ee.sun.sunresources.beans.FieldGroupHelper; 49 import org.netbeans.modules.j2ee.sun.sunresources.beans.FieldHelper; 50 import org.openide.WizardDescriptor; 51 import org.openide.filesystems.FileObject; 52 53 public class CPVendorPanel extends ResourceWizardPanel implements ChangeListener , DocumentListener , ListDataListener { 54 55 static final long serialVersionUID = 93474632245456421L; 56 57 private ArrayList dbconns; 58 private ResourceConfigHelper helper; 59 private FieldGroup generalGroup, propGroup, vendorGroup; 60 private boolean useExistingConnection = true; 61 private String [] vendors; 62 private boolean firstTime = true; 63 private boolean setupValid = true; 64 65 private static final String CONST_TRUE = "true"; 67 68 public CPVendorPanel(ResourceConfigHelper helper, Wizard wiardInfo) { 69 this.firstTime = true; 70 this.helper = helper; 71 this.generalGroup = FieldGroupHelper.getFieldGroup(wiardInfo, __General); 72 this.propGroup = FieldGroupHelper.getFieldGroup(wiardInfo, __Properties); 73 this.vendorGroup = FieldGroupHelper.getFieldGroup(wiardInfo, __PropertiesURL); 74 ButtonGroup bg = new ButtonGroup (); 75 dbconns = new ArrayList (); 76 77 setName(bundle.getString("TITLE_ConnPoolWizardPanel_dbConn")); 79 initComponents (); 80 initAccessibility(); 81 82 nameLabel.setLabelFor(nameField); 83 nameLabel.setDisplayedMnemonic(bundle.getString("LBL_pool-name_Mnemonic").charAt(0)); existingConnRadioButton.setMnemonic(bundle.getString("ExistingConnection_Mnemonic").charAt(0)); newCofigRadioButton.setMnemonic(bundle.getString("NewConfiguration_Mnemonic").charAt(0)); isXA.setMnemonic(bundle.getString("isXA_Mnemonic").charAt(0)); 88 nameComboBox.registerKeyboardAction(new ActionListener () { 89 public void actionPerformed(ActionEvent e) { 90 nameComboBox.requestFocus(); 91 } 92 }, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW); 93 94 bg.add(existingConnRadioButton); 95 bg.add(newCofigRadioButton); 96 bg.getSelection().addChangeListener(this); 97 try{ 98 DatabaseConnection[] cons = ConnectionManager.getDefault().getConnections(); 99 for(int i=0; i < cons.length; i++){ 100 existingConnComboBox.addItem(cons[i].getName()); 101 dbconns.add(cons[i]); 102 } 103 }catch(Exception ex){ 104 } 106 if (existingConnComboBox.getItemCount() == 0) { 107 existingConnComboBox.insertItemAt(bundle.getString("NoConnection"), 0); newCofigRadioButton.setSelected(true); 109 } else { 110 existingConnComboBox.insertItemAt(bundle.getString("SelectFromTheList"), 0); existingConnRadioButton.setSelected(true); 112 setExistingConnData(); 113 } 114 115 existingConnRadioButton.setEnabled(true); 117 existingConnComboBox.setEnabled(true); 118 newCofigRadioButton.setEnabled(true); 119 nameComboBox.setEnabled(true); 120 121 Field vendorField = FieldHelper.getField(this.generalGroup, __DatabaseVendor); 122 vendors = FieldHelper.getTags(vendorField); 123 for (int i = 0; i < vendors.length; i++) { 124 nameComboBox.addItem(bundle.getString("DBVendor_" + vendors[i])); } 126 127 if (nameComboBox.getItemCount() == 0) 128 nameComboBox.insertItemAt(bundle.getString("NoTemplate"), 0); else 130 nameComboBox.insertItemAt(bundle.getString("SelectFromTheList"), 0); nameComboBox.setSelectedIndex(0); 132 133 existingConnComboBox.getModel().addListDataListener(this); 134 nameComboBox.getModel().addListDataListener(this); 135 isXA.setSelected(helper.getData().getString(__IsXA).equals(CONST_TRUE)); isXA.addChangeListener(this); 137 newCofigRadioButton.addChangeListener(this); 138 139 getAccessibleContext().setAccessibleName(bundle.getString("TITLE_ConnPoolWizardPanel_dbConn")); 140 getAccessibleContext().setAccessibleDescription(bundle.getString("TITLE_ConnPoolWizardPanel_dbConn")); 141 142 this.firstTime = false; 143 } 144 145 private void initAccessibility(){ 146 descriptionTextArea.getAccessibleContext().setAccessibleName(bundle.getString("ACS_DescriptionA11yName")); descriptionTextArea.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_DescriptionA11yDesc")); 149 nameLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ToolTip_pool-name")); nameField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_pool-nameA11yDesc")); 152 existingConnRadioButton.getAccessibleContext().setAccessibleName(bundle.getString("ExistingConnection")); existingConnRadioButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_ExistingConnectionA11yDesc")); existingConnComboBox.getAccessibleContext().setAccessibleName(bundle.getString("ACS_ExistingConnectionComboBoxA11yName")); existingConnComboBox.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_ExistingConnectionComboBoxA11yDesc")); 157 newCofigRadioButton.getAccessibleContext().setAccessibleName(bundle.getString("NewConfiguration")); newCofigRadioButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_NewConnectionA11yDesc")); nameComboBox.getAccessibleContext().setAccessibleName(bundle.getString("ACS_NewConnectionComboBoxA11yName")); nameComboBox.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_NewConnectionComboBoxA11yDesc")); 162 isXA.getAccessibleContext().setAccessibleName(bundle.getString("isXA")); isXA.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_isXA_A11yDesc")); } 165 166 171 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 173 174 descriptionTextArea = new javax.swing.JTextArea (); 175 jPanel1 = new javax.swing.JPanel (); 176 nameLabel = new javax.swing.JLabel (); 177 nameField = new javax.swing.JTextField (); 178 existingConnRadioButton = new javax.swing.JRadioButton (); 179 existingConnComboBox = new javax.swing.JComboBox (); 180 newCofigRadioButton = new javax.swing.JRadioButton (); 181 nameComboBox = new javax.swing.JComboBox (); 182 isXA = new javax.swing.JCheckBox (); 183 184 setLayout(new java.awt.GridBagLayout ()); 185 186 setMaximumSize(new java.awt.Dimension (600, 350)); 187 setMinimumSize(new java.awt.Dimension (600, 350)); 188 setPreferredSize(new java.awt.Dimension (600, 350)); 189 descriptionTextArea.setEditable(false); 190 descriptionTextArea.setFont(javax.swing.UIManager.getFont("Label.font")); 191 descriptionTextArea.setText(bundle.getString("Description")); 192 descriptionTextArea.setDisabledTextColor(javax.swing.UIManager.getColor("Label.foreground")); 193 descriptionTextArea.setRequestFocusEnabled(false); 194 descriptionTextArea.setEnabled(false); 195 descriptionTextArea.setOpaque(false); 196 gridBagConstraints = new java.awt.GridBagConstraints (); 197 gridBagConstraints.gridx = 0; 198 gridBagConstraints.gridy = 0; 199 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 200 gridBagConstraints.weightx = 1.0; 201 gridBagConstraints.weighty = 1.0; 202 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 203 add(descriptionTextArea, gridBagConstraints); 204 205 jPanel1.setLayout(new java.awt.GridBagLayout ()); 206 207 nameLabel.setText(bundle.getString("LBL_pool-name")); 208 gridBagConstraints = new java.awt.GridBagConstraints (); 209 gridBagConstraints.gridx = 0; 210 gridBagConstraints.gridy = 0; 211 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 212 gridBagConstraints.weighty = 1.0; 213 gridBagConstraints.insets = new java.awt.Insets (12, 0, 12, 0); 214 jPanel1.add(nameLabel, gridBagConstraints); 215 216 nameField.setText(this.helper.getData().getString(__Name)); 217 nameField.setMinimumSize(new java.awt.Dimension (60, 21)); 218 nameField.addActionListener(new java.awt.event.ActionListener () { 219 public void actionPerformed(java.awt.event.ActionEvent evt) { 220 CPVendorPanel.this.nameFieldActionPerformed(evt); 221 } 222 }); 223 nameField.addKeyListener(new java.awt.event.KeyAdapter () { 224 public void keyReleased(java.awt.event.KeyEvent evt) { 225 CPVendorPanel.this.nameFieldKeyReleased(evt); 226 } 227 }); 228 229 gridBagConstraints = new java.awt.GridBagConstraints (); 230 gridBagConstraints.gridx = 1; 231 gridBagConstraints.gridy = 0; 232 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 233 gridBagConstraints.weightx = 1.0; 234 gridBagConstraints.weighty = 1.0; 235 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 0); 236 jPanel1.add(nameField, gridBagConstraints); 237 238 gridBagConstraints = new java.awt.GridBagConstraints (); 239 gridBagConstraints.gridx = 0; 240 gridBagConstraints.gridy = 2; 241 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 242 gridBagConstraints.insets = new java.awt.Insets (10, 12, 20, 12); 243 add(jPanel1, gridBagConstraints); 244 245 existingConnRadioButton.setSelected(true); 246 existingConnRadioButton.setText(bundle.getString("ExistingConnection")); 247 existingConnRadioButton.setToolTipText(bundle.getString("ACS_ExistingConnectionA11yDesc")); 248 gridBagConstraints = new java.awt.GridBagConstraints (); 249 gridBagConstraints.gridx = 0; 250 gridBagConstraints.gridy = 3; 251 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 252 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 253 add(existingConnRadioButton, gridBagConstraints); 254 255 existingConnComboBox.setToolTipText(bundle.getString("ACS_ExistingConnectionComboBoxA11yDesc")); 256 existingConnComboBox.addActionListener(new java.awt.event.ActionListener () { 257 public void actionPerformed(java.awt.event.ActionEvent evt) { 258 CPVendorPanel.this.existingConnComboBoxActionPerformed(evt); 259 } 260 }); 261 262 gridBagConstraints = new java.awt.GridBagConstraints (); 263 gridBagConstraints.gridx = 0; 264 gridBagConstraints.gridy = 4; 265 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 266 gridBagConstraints.insets = new java.awt.Insets (12, 24, 0, 11); 267 add(existingConnComboBox, gridBagConstraints); 268 269 newCofigRadioButton.setText(bundle.getString("NewConfiguration")); 270 newCofigRadioButton.setToolTipText(bundle.getString("ACS_NewConnectionA11yDesc")); 271 gridBagConstraints = new java.awt.GridBagConstraints (); 272 gridBagConstraints.gridx = 0; 273 gridBagConstraints.gridy = 5; 274 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 275 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 276 add(newCofigRadioButton, gridBagConstraints); 277 278 nameComboBox.setToolTipText(bundle.getString("ACS_NewConnectionComboBoxA11yDesc")); 279 nameComboBox.addActionListener(new java.awt.event.ActionListener () { 280 public void actionPerformed(java.awt.event.ActionEvent evt) { 281 CPVendorPanel.this.nameComboBoxActionPerformed(evt); 282 } 283 }); 284 285 gridBagConstraints = new java.awt.GridBagConstraints (); 286 gridBagConstraints.gridx = 0; 287 gridBagConstraints.gridy = 6; 288 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 289 gridBagConstraints.weightx = 1.0; 290 gridBagConstraints.insets = new java.awt.Insets (12, 24, 50, 11); 291 add(nameComboBox, gridBagConstraints); 292 293 isXA.setText(bundle.getString("isXA")); 294 isXA.addActionListener(new java.awt.event.ActionListener () { 295 public void actionPerformed(java.awt.event.ActionEvent evt) { 296 CPVendorPanel.this.isXAActionPerformed(evt); 297 } 298 }); 299 300 gridBagConstraints = new java.awt.GridBagConstraints (); 301 gridBagConstraints.gridx = 0; 302 gridBagConstraints.gridy = 7; 303 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 304 gridBagConstraints.insets = new java.awt.Insets (12, 12, 5, 11); 305 add(isXA, gridBagConstraints); 306 307 } 309 private void nameFieldKeyReleased(java.awt.event.KeyEvent evt) { ResourceConfigData data = this.helper.getData(); 312 String value = data.getString(__Name); 313 String newValue = nameField.getText(); 314 if (!value.equals(newValue)) { 315 this.helper.getData().setString(__Name, newValue); 316 } 317 fireChange(this); 318 } 320 private void nameFieldActionPerformed(java.awt.event.ActionEvent evt) { setResourceName(); 323 } 325 public String getNameField() { 326 return nameField.getText(); 327 } 328 329 private void setResourceName() { 330 ResourceConfigData data = this.helper.getData(); 331 String value = data.getString(__Name); 332 String newValue = nameField.getText(); 333 if (!value.equals(newValue)) { 334 this.helper.getData().setString(__Name, newValue); 335 fireChange(this); 336 } 337 338 if((this.getRootPane().getDefaultButton() != null) && (this.getRootPane().getDefaultButton().isEnabled())){ 339 this.getRootPane().getDefaultButton().doClick(); 340 } 341 } 342 343 private void isXAActionPerformed(java.awt.event.ActionEvent evt) { setNewConfigData(false); 346 } 348 private void nameComboBoxActionPerformed(java.awt.event.ActionEvent evt) { setNewConfigData(true); 351 359 } 361 private void setNewConfigData(boolean replaceProps) { 362 if (firstTime) { 363 return; 364 } 365 int index = nameComboBox.getSelectedIndex(); 366 367 if (index > 0) { 368 if (useExistingConnection) { 369 useExistingConnection = false; 370 } 371 ResourceConfigData data = this.helper.getData(); 372 data.setString(__IsCPExisting, "false"); String vendorName = vendors[index - 1]; 374 String savedVendorName = data.getString(__DatabaseVendor); 375 String savedXA = data.getString(__IsXA); 376 String XA = isXA.isSelected()?CONST_TRUE:"false"; boolean vendorNotChanged = vendorName.equals(savedVendorName); 378 boolean isXANotChanged = XA.equals(savedXA); 379 380 if (vendorNotChanged && isXANotChanged) { 381 return; 382 } 383 if (!vendorNotChanged) { 384 data.setString(__DatabaseVendor, vendorName); 385 } 386 if (!isXANotChanged) { 387 data.setString(__IsXA, XA); 388 } 389 390 setDataSourceClassNameAndResTypeInData(vendorName); 391 392 if (replaceProps) { 393 setPropertiesInData(vendorName); 394 } 395 } 396 } 397 398 private void setDataSourceClassNameAndResTypeInData(String vendorName) { 399 ResourceConfigData data = this.helper.getData(); 401 Field dsField; 402 if (isXA.isSelected()) 403 dsField = FieldHelper.getField(this.generalGroup, __XADatasourceClassname); 404 else 405 dsField = FieldHelper.getField(this.generalGroup, __DatasourceClassname); 406 data.setString(__DatasourceClassname, FieldHelper.getConditionalFieldValue(dsField, vendorName)); 407 408 if (isXA.isSelected()) { 409 data.setString(__ResType, "javax.sql.XADataSource"); data.setString(__IsXA, CONST_TRUE); }else { 412 data.setString(__ResType, "javax.sql.DataSource"); data.setString(__IsXA, "false"); } 415 } 416 417 private void setPropertiesInData(String vendorName) { 418 ResourceConfigData data = this.helper.getData(); 420 data.setProperties(new Vector ()); 421 Field[] propFields = this.propGroup.getField(); 422 for (int i = 0; i < propFields.length; i++) { 423 String value = FieldHelper.getConditionalFieldValue(propFields[i], vendorName); 424 String name = propFields[i].getName(); 425 if (name.equals(__Url) && value.length() > 0) 426 data.addProperty(name, FieldHelper.toUrl(value)); 427 else if (name.equals(__DatabaseName) && value.length() > 0) 428 data.addProperty(name, FieldHelper.toUrl(value)); 429 else if (name.equals(__User) || name.equals(__Password)) { 430 data.addProperty(propFields[i].getName(), value); 431 }else{ 432 if(value.length() > 0 && (value.equals(__NotApplicable))){ 434 data.addProperty(propFields[i].getName(), ""); } 436 } 437 } 438 } 439 440 441 private void existingConnComboBoxActionPerformed(java.awt.event.ActionEvent evt) { setExistingConnData(); 443 } 445 public void setExistingConnData() { 446 if(existingConnComboBox.getSelectedIndex() > 0) { 447 if (!useExistingConnection) { 448 this.helper.getData().setResourceName(__JdbcConnectionPool); 449 useExistingConnection = true; 450 } 451 this.helper.getData().setString(__IsCPExisting, CONST_TRUE); DatabaseConnection dbconn = (DatabaseConnection)dbconns.get(existingConnComboBox.getSelectedIndex() - 1); 453 String url = dbconn.getDatabaseURL(); 454 String user = dbconn.getUser(); 455 String password = dbconn.getPassword(); 456 String tmpStr = url; 457 458 Field urlField = FieldHelper.getField(this.vendorGroup, "vendorUrls"); String vendorName = FieldHelper.getOptionNameFromValue(urlField, tmpStr); 460 461 ResourceConfigData data = this.helper.getData(); 462 data.setProperties(new Vector ()); 463 data.setString(__DatabaseVendor, vendorName); 464 465 if (vendorName.equals("pointbase")) { data.addProperty(__DatabaseName, dbconn.getDatabaseURL()); 467 }else if(vendorName.startsWith("derby")) { setDerbyProps(vendorName, url); 469 }else 470 data.addProperty(__Url, url); 471 data.addProperty(__User, user); 472 data.addProperty(__Password, password); 473 474 setDataSourceClassNameAndResTypeInData(vendorName); 475 } 476 477 } 478 479 private void setDerbyProps(String vendorName, String url) { 480 ResourceConfigData data = this.helper.getData(); 482 data.setProperties(new Vector ()); 483 Field[] propFields = this.propGroup.getField(); 484 for (int i = 0; i < propFields.length; i++) { 485 String value = FieldHelper.getConditionalFieldValue(propFields[i], vendorName); 486 if(value.equals(__NotApplicable)){ 487 String name = propFields[i].getName(); 488 if(vendorName.equals("derby_net")) { String hostName = ""; 490 String portNumber = ""; 491 String databaseName = ""; 492 try{ 493 String workingUrl = url.substring(url.indexOf("//") + 2, url.length()); 494 if(workingUrl.indexOf(":") != -1){ 495 hostName = workingUrl.substring(0, workingUrl.indexOf(":")); 496 if(workingUrl.indexOf("/") != -1){ 497 portNumber = workingUrl.substring(workingUrl.indexOf(":") + 1, workingUrl.indexOf("/")); 498 int braceIndex = workingUrl.indexOf("["); 499 if(braceIndex == -1) 500 databaseName = workingUrl.substring(workingUrl.indexOf("/") + 1, workingUrl.length()); 501 else 502 databaseName = workingUrl.substring(workingUrl.indexOf("/") + 1, braceIndex + 1).trim(); 503 } 504 } 505 }catch(java.lang.StringIndexOutOfBoundsException ex){ 506 } 507 if (name.equals(__DerbyPortNumber)) { 508 data.addProperty(name, portNumber); 509 } else if (name.equals(__DerbyDatabaseName)) { 510 data.addProperty(name, databaseName); 511 } else if (name.equals(__ServerName)) { 512 data.addProperty(name, hostName); 513 } 514 } 515 } 516 } 517 } 518 private javax.swing.JTextField nameField; 520 private javax.swing.JTextArea descriptionTextArea; 521 private javax.swing.JLabel nameLabel; 522 private javax.swing.JComboBox nameComboBox; 523 private javax.swing.JRadioButton newCofigRadioButton; 524 private javax.swing.JRadioButton existingConnRadioButton; 525 private javax.swing.JPanel jPanel1; 526 private javax.swing.JComboBox existingConnComboBox; 527 private javax.swing.JCheckBox isXA; 528 530 532 public boolean isValid() { 533 if(! setupValid){ 534 setErrorMsg(bundle.getString("Err_InvalidSetup")); 535 return false; 536 } 537 setErrorMsg(bundle.getString("Empty_String")); 538 String name = nameField.getText(); 539 if (name == null || name.length() == 0){ 540 setErrorMsg(bundle.getString("Err_InvalidName")); 541 return false; 542 }else if(! ResourceUtils.isLegalResourceName(name)) 543 return false; 544 else if(! ResourceUtils.isUniqueFileName(name, this.helper.getData().getTargetFileObject(), __ConnectionPoolResource)){ 545 setErrorMsg(bundle.getString("Err_DuplFileName")); 546 return false; 547 } 548 549 if (existingConnRadioButton.isSelected()) { 550 if (existingConnComboBox.getSelectedIndex() > 0) 551 return true; 552 else 553 setErrorMsg(bundle.getString("Err_ChooseDBConn")); 554 }else if (newCofigRadioButton.isSelected()) { 555 if (nameComboBox.getSelectedIndex() > 0) 556 return true; 557 else 558 setErrorMsg(bundle.getString("Err_ChooseDBVendor")); 559 } 560 561 return false; 562 } 563 564 public void removeUpdate(final javax.swing.event.DocumentEvent event) { 565 fireChange(this); 566 } 567 568 public void changedUpdate(final javax.swing.event.DocumentEvent event) { 569 fireChange(this); 570 } 571 572 public void insertUpdate(final javax.swing.event.DocumentEvent event) { 573 fireChange(this); 574 } 575 576 public void intervalAdded(final javax.swing.event.ListDataEvent p1) { 577 fireChange(this); 578 } 579 580 public void intervalRemoved(final javax.swing.event.ListDataEvent p1) { 581 fireChange(this); 582 } 583 584 public void contentsChanged(final javax.swing.event.ListDataEvent p1) { 585 fireChange(this); 586 } 587 588 public void stateChanged(final javax.swing.event.ChangeEvent p1) { 589 if (firstTime) { 590 return; 591 } 592 if (p1.getSource().getClass() == javax.swing.JToggleButton.ToggleButtonModel.class) { 593 if (existingConnRadioButton.isSelected()) { 594 if (firstTime) { 596 return; 597 } 598 existingConnComboBox.setEnabled(true); 599 nameComboBox.setEnabled(false); 600 setExistingConnData(); 602 } else { 603 existingConnComboBox.setEnabled(false); 604 nameComboBox.setEnabled(true); 605 setNewConfigData(true); 606 } 607 } 608 fireChange(this); 609 } 610 611 public CPVendorPanel setFirstTime(boolean first) { 612 this.firstTime = first; 613 return this; 614 } 615 616 protected void initData() { 617 635 } 636 637 public HelpCtx getHelp() { 638 return new HelpCtx("AS_Wiz_ConnPool_chooseDB"); } 640 641 public void readSettings(Object settings) { 642 this.wizDescriptor = (WizardDescriptor)settings; 643 TemplateWizard wizard = (TemplateWizard)settings; 644 String targetName = wizard.getTargetName(); 645 if(this.helper.getData().getString(__DynamicWizPanel).equals(CONST_TRUE)){ targetName = null; 647 } 648 FileObject setupFolder = ResourceUtils.getResourceDirectory(this.helper.getData().getTargetFileObject()); 649 this.helper.getData().setTargetFileObject (setupFolder); 650 if(setupFolder != null){ 651 targetName = ResourceUtils.createUniqueFileName (targetName, setupFolder, __ConnectionPoolResource); 652 this.nameField.setText (targetName); 653 this.helper.getData ().setString (__Name, targetName); 654 this.helper.getData ().setTargetFile (targetName); 655 }else 656 setupValid = false; 657 } 658 659 public void setInitialFocus(){ 660 new setFocus(nameField); 661 } 662 663 } 667 | Popular Tags |