1 19 20 package org.netbeans.modules.apisupport.project.ui.wizard; 21 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.ActionListener ; 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.text.MessageFormat ; 27 import javax.swing.ButtonModel ; 28 import javax.swing.JComboBox ; 29 import javax.swing.JFileChooser ; 30 import javax.swing.event.DocumentEvent ; 31 import javax.swing.event.DocumentListener ; 32 import org.netbeans.api.project.Project; 33 import org.netbeans.api.project.ProjectManager; 34 import org.netbeans.api.project.ProjectUtils; 35 import org.netbeans.modules.apisupport.project.ui.ModuleUISettings; 36 import org.netbeans.modules.apisupport.project.universe.ModuleList; 37 import org.netbeans.modules.apisupport.project.universe.NbPlatform; 38 import org.netbeans.modules.apisupport.project.ui.UIUtil; 39 import org.netbeans.modules.apisupport.project.ui.customizer.SuiteUtils; 40 import org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory; 41 import org.netbeans.modules.apisupport.project.ui.platform.NbPlatformCustomizer; 42 import org.netbeans.spi.project.ui.support.ProjectChooser; 43 import org.openide.DialogDescriptor; 44 import org.openide.DialogDisplayer; 45 import org.openide.ErrorManager; 46 import org.openide.filesystems.FileUtil; 47 import org.openide.util.NbBundle; 48 49 64 public class BasicInfoVisualPanel extends BasicVisualPanel.NewTemplatePanel { 65 66 private ButtonModel lastSelectedType; 67 private static String lastSelectedSuite; 68 private boolean locationUpdated; 69 private boolean nameUpdated; 70 private boolean moduleTypeGroupAttached = true; 71 private boolean mainProjectTouched; 72 73 74 public BasicInfoVisualPanel(final NewModuleProjectData data) { 75 super(data); 76 initComponents(); 77 initAccessibility(); 78 initPlatformCombos(); 79 setComponentsVisibility(); 80 switch (data.getWizardType()) { 81 case NewNbModuleWizardIterator.TYPE_SUITE: 82 detachModuleTypeGroup(); 83 break; 84 case NewNbModuleWizardIterator.TYPE_MODULE: 85 case NewNbModuleWizardIterator.TYPE_SUITE_COMPONENT: 86 if (moduleSuiteValue.getItemCount() > 0) { 87 restoreSelectedSuite(); 88 suiteComponent.setSelected(true); 89 mainProject.setSelected(false); 90 } 91 break; 92 case NewNbModuleWizardIterator.TYPE_LIBRARY_MODULE: 93 moduleSuite.setText(getMessage("LBL_Add_to_Suite")); suiteComponent.setSelected(true); 95 if (moduleSuiteValue.getItemCount() > 0) { 96 restoreSelectedSuite(); 97 } 98 break; 99 default: 100 assert false : "Unknown wizard type = " + data.getWizardType(); 101 } 102 attachDocumentListeners(); 103 setInitialLocation(); 104 setInitialProjectName(); 105 updateEnabled(); 106 } 107 108 private void setInitialLocation() { 109 if (isSuiteComponent()) { 110 computeAndSetLocation((String ) moduleSuiteValue.getSelectedItem(), true); 111 } else { String location = computeLocationValue(ProjectChooser.getProjectsFolder().getAbsolutePath()); 113 File locationF = new File (location); 114 if (SuiteUtils.isSuite(locationF)) { 115 computeAndSetLocation(locationF.getParent(), true); 116 } else { 117 setLocation(location, true); 118 } 119 } 120 } 121 122 private void initAccessibility() { 123 this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_BasicInfoVisualPanel")); 124 browseButton.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_BrowseButton")); 125 browseSuiteButton.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_BrowseSuiteButton")); 126 folderValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_FolderValue")); 127 locationValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_LocationValue")); 128 mainProject.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_MainProject")); 129 managePlatform.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ManagePlatform")); 130 manageSuitePlatform.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ManageSuitePlatform")); 131 moduleSuiteValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ModuleSuiteValue")); 132 nameValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_NameValue")); 133 platformValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_PlatformValue")); 134 standAloneModule.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_StandAloneModule")); 135 suiteComponent.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_SuiteModule")); 136 suitePlatformValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_SuitePlatformValue")); 137 } 138 139 private void setComponentsVisibility() { 140 boolean isSuiteWizard = isSuiteWizard(); 141 boolean isSuiteComponentWizard = isSuiteComponentWizard(); 142 boolean isLibraryWizard = isLibraryWizard(); 143 144 typeChooserPanel.setVisible(!isSuiteWizard); 145 suitePlatform.setVisible(isSuiteWizard); 146 suitePlatformValue.setVisible(isSuiteWizard); 147 manageSuitePlatform.setVisible(isSuiteWizard); 148 mainProject.setVisible(!isLibraryWizard); 149 150 suiteComponent.setVisible(!isLibraryWizard); 151 platform.setVisible(!isLibraryWizard); 152 platformValue.setVisible(!isLibraryWizard); 153 managePlatform.setVisible(!isLibraryWizard); 154 standAloneModule.setVisible(!isLibraryWizard); 155 mainProject.setSelected(!isLibraryWizard); 156 157 standAloneModule.setVisible(!isSuiteComponentWizard && !isLibraryWizard); 158 platform.setVisible(!isSuiteComponentWizard && !isLibraryWizard); 159 platformValue.setVisible(!isSuiteComponentWizard && !isLibraryWizard); 160 managePlatform.setVisible(!isSuiteComponentWizard && !isLibraryWizard); 161 suiteComponent.setVisible(!isSuiteComponentWizard && !isLibraryWizard); 162 } 163 164 private void restoreSelectedSuite() { 165 String preferredSuiteDir = getPreferredSuiteDir(); 166 if (preferredSuiteDir != null) { 167 lastSelectedSuite = preferredSuiteDir; 168 } 169 if (lastSelectedSuite != null) { 170 int max = moduleSuiteValue.getModel().getSize(); 171 for (int i=0; i < max; i++) { 172 if (lastSelectedSuite.equals(moduleSuiteValue.getModel().getElementAt(i))) { 173 moduleSuiteValue.setSelectedItem(lastSelectedSuite); 174 break; 175 } 176 } 177 } 178 } 179 180 private String getPreferredSuiteDir() { 181 return (String ) getSettings().getProperty(NewNbModuleWizardIterator.PREFERRED_SUITE_DIR); 182 } 183 184 private boolean isOneSuiteDedicatedMode() { 185 Boolean b = (Boolean ) getSettings().getProperty( 186 NewNbModuleWizardIterator.ONE_SUITE_DEDICATED_MODE); 187 return b != null ? b.booleanValue() : false; 188 } 189 190 private String getNameValue() { 191 return nameValue.getText().trim(); 192 } 193 194 private String getLocationValue() { 195 return locationValue.getText().trim(); 196 } 197 198 private File getLocationFile() { 199 return new File (getLocationValue()); 200 } 201 202 private void updateEnabled() { 203 boolean isNetBeansOrg = isNetBeansOrgFolder(); 204 standAloneModule.setEnabled(!isNetBeansOrg); 205 suiteComponent.setEnabled(!isNetBeansOrg); 206 207 boolean standalone = isStandAlone(); 208 boolean suiteModuleSelected = isSuiteComponent(); 209 platform.setEnabled(standalone); 210 platformValue.setEnabled(standalone); 211 managePlatform.setEnabled(standalone); 212 moduleSuite.setEnabled(suiteModuleSelected); 213 moduleSuiteValue.setEnabled(suiteModuleSelected && !isOneSuiteDedicatedMode()); 214 browseSuiteButton.setEnabled(suiteModuleSelected && !isOneSuiteDedicatedMode()); 215 } 216 217 void updateAndCheck() { 218 updateGUI(); 219 220 if ("".equals(getNameValue())) { 221 setError(getMessage("MSG_NameCannotBeEmpty")); 222 } else if ("".equals(getLocationValue())) { 223 setError(getMessage("MSG_LocationCannotBeEmpty")); 224 } else if (isLibraryWizard() && isNetBeansOrgFolder()) { 225 setError(getMessage("MSG_LibraryWrapperForNBOrgUnsupported")); 226 } else if (isSuiteComponent() && moduleSuiteValue.getSelectedItem() == null) { 227 setError(getMessage("MSG_ChooseRegularSuite")); 228 } else if (isStandAlone() && 229 (platformValue.getSelectedItem() == null || !((NbPlatform) platformValue.getSelectedItem()).isValid())) { 230 setError(getMessage("MSG_ChosenPlatformIsInvalid")); 231 } else if (isSuiteWizard() && 232 (suitePlatformValue.getSelectedItem() == null || !((NbPlatform) suitePlatformValue.getSelectedItem()).isValid())) { 233 setError(getMessage("MSG_ChosenPlatformIsInvalid")); 234 } else if (getFolder().exists()) { 235 setError(getMessage("MSG_ProjectFolderExists")); 236 } else if (!getLocationFile().exists()) { 237 setError(getMessage("MSG_LocationMustExist")); 238 } else if (!getLocationFile().canWrite()) { 239 setError(getMessage("MSG_LocationNotWritable")); 240 } else { 241 markValid(); 242 } 243 } 244 245 private void updateGUI() { 246 folderValue.setText(getFolder().getPath()); 248 249 if (isSuiteWizard() || isNetBeansOrgFolder()) { 250 detachModuleTypeGroup(); 251 } else { 252 attachModuleTypeGroup(); 253 } 254 updateEnabled(); 255 } 256 257 private void detachModuleTypeGroup() { 258 if (moduleTypeGroupAttached) { 259 lastSelectedType = moduleTypeGroup.getSelection(); 260 moduleTypeGroup.remove(standAloneModule); 261 moduleTypeGroup.remove(suiteComponent); 262 standAloneModule.setSelected(false); 263 suiteComponent.setSelected(false); 264 moduleTypeGroupAttached = false; 265 } 266 } 267 268 private void attachModuleTypeGroup() { 269 if (!moduleTypeGroupAttached) { 270 moduleTypeGroup.add(standAloneModule); 271 moduleTypeGroup.add(suiteComponent); 272 if (isLibraryWizard()) { 273 suiteComponent.setSelected(true); 274 } else { 275 moduleTypeGroup.setSelected(lastSelectedType, true); 276 } 277 moduleTypeGroupAttached = true; 278 } 279 } 280 281 282 private void setProjectName(String formater, int counter) { 283 String name; 284 while ((name = validFreeModuleName(formater, counter)) == null) { 285 counter++; 286 } 287 nameValue.setText(name); 288 } 289 290 private String validFreeModuleName(String formater, int index) { 292 String name = MessageFormat.format(formater, new Object []{ new Integer (index) }); 293 File file = new File (getLocationValue(), name); 294 return file.exists() ? null : name; 295 } 296 297 298 void storeData() { 299 getData().setProjectName(getNameValue()); 300 getData().setProjectLocation(getLocationValue()); 301 getData().setProjectFolder(folderValue.getText()); 302 getData().setMainProject(mainProject.isSelected()); 303 getData().setNetBeansOrg(isNetBeansOrgFolder()); 304 getData().setStandalone(isStandAlone()); 305 getData().setSuiteRoot((String ) moduleSuiteValue.getSelectedItem()); 306 if (isSuiteWizard() && suitePlatformValue.getSelectedItem() != null) { 307 getData().setPlatformID(((NbPlatform) suitePlatformValue.getSelectedItem()).getID()); 308 } else if (platformValue.getSelectedItem() != null) { 309 getData().setPlatformID(((NbPlatform) platformValue.getSelectedItem()).getID()); 310 } 311 } 312 313 void refreshData() { 314 if (getData().getProjectName() != null) { 315 nameValue.setText(getData().getProjectName()); 316 } else { 317 setInitialProjectName(); 318 } 319 } 320 321 private void setInitialProjectName() { 322 String bundlekey = null; 323 int counter = 0; 324 switch (getData().getWizardType()) { 325 case NewNbModuleWizardIterator.TYPE_SUITE: 326 counter = ModuleUISettings.getDefault().getNewSuiteCounter() + 1; 327 bundlekey = "TXT_Suite"; getData().setSuiteCounter(counter); 329 break; 330 case NewNbModuleWizardIterator.TYPE_MODULE: 331 case NewNbModuleWizardIterator.TYPE_SUITE_COMPONENT: 332 counter = ModuleUISettings.getDefault().getNewModuleCounter() + 1; 333 bundlekey = "TXT_Module"; getData().setModuleCounter(counter); 335 break; 336 case NewNbModuleWizardIterator.TYPE_LIBRARY_MODULE: 337 counter = ModuleUISettings.getDefault().getNewModuleCounter() + 1; 338 bundlekey = "TXT_Library"; getData().setModuleCounter(counter); 340 break; 341 default: 342 assert false : "Unknown wizard type = " + getData().getWizardType(); 343 } 344 setProjectName(getMessage(bundlekey), counter); 345 nameValue.select(0, nameValue.getText().length()); 346 nameUpdated = false; 347 } 348 349 private void attachDocumentListeners() { 350 DocumentListener fieldsDL = new UIUtil.DocumentAdapter() { 351 public void insertUpdate(DocumentEvent e) { updateAndCheck(); } 352 }; 353 nameValue.getDocument().addDocumentListener(fieldsDL); 354 nameValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 355 public void insertUpdate(DocumentEvent e) { nameUpdated = true; } 356 }); 357 locationValue.getDocument().addDocumentListener(fieldsDL); 358 locationValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 359 public void insertUpdate(DocumentEvent e) { locationUpdated = true; } 360 }); 361 ActionListener plafAL = new ActionListener () { 362 public void actionPerformed(ActionEvent e) { 363 updateAndCheck(); 364 } 365 }; 366 platformValue.addActionListener(plafAL); 367 suitePlatformValue.addActionListener(plafAL); 368 } 369 370 private File getFolder() { 371 StringBuffer destFolder = new StringBuffer (getLocationValue()); 372 if (destFolder.length() != 0) { 373 destFolder.append(File.separator); 374 } 375 destFolder.append(getNameValue()); 376 return FileUtil.normalizeFile(new File (destFolder.toString())); 377 } 378 379 private boolean isNetBeansOrgFolder() { 380 return ModuleList.findNetBeansOrg(getFolder()) != null; 381 } 382 383 private static String getMessage(String key) { 384 return NbBundle.getMessage(BasicInfoVisualPanel.class, key); 385 } 386 387 private void initPlatformCombos() { 388 if (platformValue.getItemCount() <= 0) { 389 return; 390 } 391 boolean set = false; 392 String idToSelect = ModuleUISettings.getDefault().getLastUsedPlatformID(); 393 for (int i = 0; i < platformValue.getItemCount(); i++) { 394 if (((NbPlatform) platformValue.getItemAt(i)).getID().equals(idToSelect)) { 395 platformValue.setSelectedIndex(i); 396 suitePlatformValue.setSelectedIndex(i); 397 set = true; 398 break; 399 } 400 } 401 if (!set) { 402 NbPlatform defPlaf = NbPlatform.getDefaultPlatform(); 403 platformValue.setSelectedItem(defPlaf == null ? platformValue.getItemAt(0) : defPlaf); 404 suitePlatformValue.setSelectedItem(defPlaf == null ? suitePlatformValue.getItemAt(0) : defPlaf); 405 } 406 } 407 408 private void setLocation(String location, boolean silently) { 409 boolean revert = silently && !locationUpdated; 410 locationValue.setText(location); 411 locationUpdated = revert ^ true; 412 } 413 414 private void computeAndSetLocation(String value, boolean silently) { 415 setLocation(computeLocationValue(value), silently); 416 } 417 418 private String computeLocationValue(String value) { 419 if (value == null) { 420 value = System.getProperty("user.home"); } 422 File file = new File (value); 423 if (!file.exists() && file.getParent() != null) { 424 return computeLocationValue(file.getParent()); 425 } else { 426 return file.exists() ? value : System.getProperty("user.home"); } 428 } 429 430 private boolean isStandAlone() { 431 return standAloneModule.isSelected(); 432 } 433 434 private boolean isSuiteComponent() { 435 return suiteComponent.isSelected(); 436 } 437 438 443 private void initComponents() { 445 java.awt.GridBagConstraints gridBagConstraints; 446 447 moduleTypeGroup = new javax.swing.ButtonGroup (); 448 infoPanel = new javax.swing.JPanel (); 449 nameLbl = new javax.swing.JLabel (); 450 locationLbl = new javax.swing.JLabel (); 451 folderLbl = new javax.swing.JLabel (); 452 nameValue = new javax.swing.JTextField (); 453 locationValue = new javax.swing.JTextField (); 454 browseButton = new javax.swing.JButton (); 455 filler = new javax.swing.JLabel (); 456 folderValue = new javax.swing.JTextField (); 457 suitePlatform = new javax.swing.JLabel (); 458 suitePlatformValue = PlatformComponentFactory.getNbPlatformsComboxBox(); 459 manageSuitePlatform = new javax.swing.JButton (); 460 separator3 = new javax.swing.JSeparator (); 461 mainProject = new javax.swing.JCheckBox (); 462 typeChooserPanel = new javax.swing.JPanel (); 463 standAloneModule = new javax.swing.JRadioButton (); 464 platform = new javax.swing.JLabel (); 465 platformValue = PlatformComponentFactory.getNbPlatformsComboxBox(); 466 managePlatform = new javax.swing.JButton (); 467 suiteComponent = new javax.swing.JRadioButton (); 468 moduleSuite = new javax.swing.JLabel (); 469 moduleSuiteValue = PlatformComponentFactory.getSuitesComboBox(); 470 browseSuiteButton = new javax.swing.JButton (); 471 chooserFiller = new javax.swing.JLabel (); 472 pnlThouShaltBeholdLayout = new javax.swing.JPanel (); 473 474 setLayout(new java.awt.GridBagLayout ()); 475 476 infoPanel.setLayout(new java.awt.GridBagLayout ()); 477 478 nameLbl.setLabelFor(nameValue); 479 org.openide.awt.Mnemonics.setLocalizedText(nameLbl, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ProjectName")); 480 gridBagConstraints = new java.awt.GridBagConstraints (); 481 gridBagConstraints.gridx = 0; 482 gridBagConstraints.gridy = 0; 483 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 484 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 485 infoPanel.add(nameLbl, gridBagConstraints); 486 487 locationLbl.setLabelFor(locationValue); 488 org.openide.awt.Mnemonics.setLocalizedText(locationLbl, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ProjectLocation")); 489 gridBagConstraints = new java.awt.GridBagConstraints (); 490 gridBagConstraints.gridx = 0; 491 gridBagConstraints.gridy = 1; 492 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 493 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 12); 494 infoPanel.add(locationLbl, gridBagConstraints); 495 496 folderLbl.setLabelFor(folderValue); 497 org.openide.awt.Mnemonics.setLocalizedText(folderLbl, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ProjectFolder")); 498 gridBagConstraints = new java.awt.GridBagConstraints (); 499 gridBagConstraints.gridx = 0; 500 gridBagConstraints.gridy = 2; 501 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 502 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 503 infoPanel.add(folderLbl, gridBagConstraints); 504 505 nameValue.setHorizontalAlignment(javax.swing.JTextField.LEFT); 506 gridBagConstraints = new java.awt.GridBagConstraints (); 507 gridBagConstraints.gridx = 1; 508 gridBagConstraints.gridy = 0; 509 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 510 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 511 gridBagConstraints.weightx = 1.0; 512 infoPanel.add(nameValue, gridBagConstraints); 513 514 locationValue.setHorizontalAlignment(javax.swing.JTextField.LEFT); 515 gridBagConstraints = new java.awt.GridBagConstraints (); 516 gridBagConstraints.gridx = 1; 517 gridBagConstraints.gridy = 1; 518 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 519 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 520 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 0); 521 infoPanel.add(locationValue, gridBagConstraints); 522 523 org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_BrowseButton_o")); 524 browseButton.addActionListener(new java.awt.event.ActionListener () { 525 public void actionPerformed(java.awt.event.ActionEvent evt) { 526 browseLocation(evt); 527 } 528 }); 529 530 gridBagConstraints = new java.awt.GridBagConstraints (); 531 gridBagConstraints.gridx = 2; 532 gridBagConstraints.gridy = 1; 533 gridBagConstraints.insets = new java.awt.Insets (6, 12, 6, 0); 534 infoPanel.add(browseButton, gridBagConstraints); 535 536 gridBagConstraints = new java.awt.GridBagConstraints (); 537 gridBagConstraints.gridx = 1; 538 gridBagConstraints.gridy = 5; 539 gridBagConstraints.weighty = 1.0; 540 infoPanel.add(filler, gridBagConstraints); 541 542 folderValue.setEditable(false); 543 gridBagConstraints = new java.awt.GridBagConstraints (); 544 gridBagConstraints.gridx = 1; 545 gridBagConstraints.gridy = 2; 546 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 547 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 548 infoPanel.add(folderValue, gridBagConstraints); 549 550 suitePlatform.setLabelFor(suitePlatformValue); 551 org.openide.awt.Mnemonics.setLocalizedText(suitePlatform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_NetBeansPlatform")); 552 gridBagConstraints = new java.awt.GridBagConstraints (); 553 gridBagConstraints.gridx = 0; 554 gridBagConstraints.gridy = 4; 555 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 556 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 12); 557 infoPanel.add(suitePlatform, gridBagConstraints); 558 559 gridBagConstraints = new java.awt.GridBagConstraints (); 560 gridBagConstraints.gridx = 1; 561 gridBagConstraints.gridy = 4; 562 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 563 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 564 gridBagConstraints.weightx = 1.0; 565 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 0); 566 infoPanel.add(suitePlatformValue, gridBagConstraints); 567 568 org.openide.awt.Mnemonics.setLocalizedText(manageSuitePlatform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_ManagePlatforms_g")); 569 manageSuitePlatform.addActionListener(new java.awt.event.ActionListener () { 570 public void actionPerformed(java.awt.event.ActionEvent evt) { 571 manageSuitePlatformActionPerformed(evt); 572 } 573 }); 574 575 gridBagConstraints = new java.awt.GridBagConstraints (); 576 gridBagConstraints.gridx = 2; 577 gridBagConstraints.gridy = 4; 578 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 579 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 580 gridBagConstraints.insets = new java.awt.Insets (6, 12, 6, 0); 581 infoPanel.add(manageSuitePlatform, gridBagConstraints); 582 583 gridBagConstraints = new java.awt.GridBagConstraints (); 584 gridBagConstraints.gridx = 0; 585 gridBagConstraints.gridy = 3; 586 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 587 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 588 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 589 gridBagConstraints.insets = new java.awt.Insets (12, 0, 6, 0); 590 infoPanel.add(separator3, gridBagConstraints); 591 592 gridBagConstraints = new java.awt.GridBagConstraints (); 593 gridBagConstraints.gridx = 0; 594 gridBagConstraints.gridy = 0; 595 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 596 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 597 add(infoPanel, gridBagConstraints); 598 599 mainProject.setSelected(true); 600 org.openide.awt.Mnemonics.setLocalizedText(mainProject, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_SetAsMainProject")); 601 mainProject.addActionListener(new java.awt.event.ActionListener () { 602 public void actionPerformed(java.awt.event.ActionEvent evt) { 603 mainProjectActionPerformed(evt); 604 } 605 }); 606 607 gridBagConstraints = new java.awt.GridBagConstraints (); 608 gridBagConstraints.gridx = 0; 609 gridBagConstraints.gridy = 2; 610 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 611 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 612 add(mainProject, gridBagConstraints); 613 614 typeChooserPanel.setLayout(new java.awt.GridBagLayout ()); 615 616 moduleTypeGroup.add(standAloneModule); 617 standAloneModule.setSelected(true); 618 org.openide.awt.Mnemonics.setLocalizedText(standAloneModule, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_StandaloneModule")); 619 standAloneModule.addActionListener(new java.awt.event.ActionListener () { 620 public void actionPerformed(java.awt.event.ActionEvent evt) { 621 typeChanged(evt); 622 } 623 }); 624 625 gridBagConstraints = new java.awt.GridBagConstraints (); 626 gridBagConstraints.gridx = 0; 627 gridBagConstraints.gridy = 0; 628 gridBagConstraints.gridwidth = 3; 629 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 630 gridBagConstraints.insets = new java.awt.Insets (0, 0, 6, 0); 631 typeChooserPanel.add(standAloneModule, gridBagConstraints); 632 633 platform.setLabelFor(platformValue); 634 org.openide.awt.Mnemonics.setLocalizedText(platform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_NetBeansPlatform")); 635 gridBagConstraints = new java.awt.GridBagConstraints (); 636 gridBagConstraints.gridx = 0; 637 gridBagConstraints.gridy = 1; 638 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 639 gridBagConstraints.insets = new java.awt.Insets (0, 18, 0, 12); 640 typeChooserPanel.add(platform, gridBagConstraints); 641 642 platformValue.addActionListener(new java.awt.event.ActionListener () { 643 public void actionPerformed(java.awt.event.ActionEvent evt) { 644 platformChosen(evt); 645 } 646 }); 647 648 gridBagConstraints = new java.awt.GridBagConstraints (); 649 gridBagConstraints.gridx = 1; 650 gridBagConstraints.gridy = 1; 651 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 652 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 653 gridBagConstraints.weightx = 1.0; 654 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 655 typeChooserPanel.add(platformValue, gridBagConstraints); 656 657 org.openide.awt.Mnemonics.setLocalizedText(managePlatform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_ManagePlatforms_g")); 658 managePlatform.addActionListener(new java.awt.event.ActionListener () { 659 public void actionPerformed(java.awt.event.ActionEvent evt) { 660 managePlatformActionPerformed(evt); 661 } 662 }); 663 664 gridBagConstraints = new java.awt.GridBagConstraints (); 665 gridBagConstraints.gridx = 2; 666 gridBagConstraints.gridy = 1; 667 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 668 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 669 typeChooserPanel.add(managePlatform, gridBagConstraints); 670 671 moduleTypeGroup.add(suiteComponent); 672 org.openide.awt.Mnemonics.setLocalizedText(suiteComponent, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_AddToModuleSuite")); 673 suiteComponent.addActionListener(new java.awt.event.ActionListener () { 674 public void actionPerformed(java.awt.event.ActionEvent evt) { 675 typeChanged(evt); 676 } 677 }); 678 679 gridBagConstraints = new java.awt.GridBagConstraints (); 680 gridBagConstraints.gridx = 0; 681 gridBagConstraints.gridy = 2; 682 gridBagConstraints.gridwidth = 3; 683 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 684 gridBagConstraints.insets = new java.awt.Insets (18, 0, 0, 0); 685 typeChooserPanel.add(suiteComponent, gridBagConstraints); 686 687 moduleSuite.setLabelFor(moduleSuiteValue); 688 org.openide.awt.Mnemonics.setLocalizedText(moduleSuite, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ModuleSuite")); 689 gridBagConstraints = new java.awt.GridBagConstraints (); 690 gridBagConstraints.gridx = 0; 691 gridBagConstraints.gridy = 3; 692 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 693 gridBagConstraints.insets = new java.awt.Insets (6, 18, 0, 12); 694 typeChooserPanel.add(moduleSuite, gridBagConstraints); 695 696 moduleSuiteValue.addActionListener(new java.awt.event.ActionListener () { 697 public void actionPerformed(java.awt.event.ActionEvent evt) { 698 moduleSuiteChosen(evt); 699 } 700 }); 701 702 gridBagConstraints = new java.awt.GridBagConstraints (); 703 gridBagConstraints.gridx = 1; 704 gridBagConstraints.gridy = 3; 705 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 706 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 707 gridBagConstraints.weightx = 1.0; 708 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 709 typeChooserPanel.add(moduleSuiteValue, gridBagConstraints); 710 711 org.openide.awt.Mnemonics.setLocalizedText(browseSuiteButton, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_BrowseButton_w")); 712 browseSuiteButton.addActionListener(new java.awt.event.ActionListener () { 713 public void actionPerformed(java.awt.event.ActionEvent evt) { 714 browseModuleSuite(evt); 715 } 716 }); 717 718 gridBagConstraints = new java.awt.GridBagConstraints (); 719 gridBagConstraints.gridx = 2; 720 gridBagConstraints.gridy = 3; 721 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 722 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 723 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 724 typeChooserPanel.add(browseSuiteButton, gridBagConstraints); 725 726 gridBagConstraints = new java.awt.GridBagConstraints (); 727 gridBagConstraints.gridx = 0; 728 gridBagConstraints.gridy = 4; 729 gridBagConstraints.weighty = 1.0; 730 typeChooserPanel.add(chooserFiller, gridBagConstraints); 731 732 gridBagConstraints = new java.awt.GridBagConstraints (); 733 gridBagConstraints.gridx = 0; 734 gridBagConstraints.gridy = 1; 735 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 736 add(typeChooserPanel, gridBagConstraints); 737 738 gridBagConstraints = new java.awt.GridBagConstraints (); 739 gridBagConstraints.gridx = 0; 740 gridBagConstraints.gridy = 3; 741 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 742 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 743 gridBagConstraints.weightx = 1.0; 744 gridBagConstraints.weighty = 1.0; 745 add(pnlThouShaltBeholdLayout, gridBagConstraints); 746 747 } 749 private void manageSuitePlatformActionPerformed(java.awt.event.ActionEvent evt) { managePlatform(suitePlatformValue); 751 } 753 private void mainProjectActionPerformed(java.awt.event.ActionEvent evt) { mainProjectTouched = true; 755 } 757 private void managePlatformActionPerformed(java.awt.event.ActionEvent evt) { managePlatform(platformValue); 759 } 761 private void managePlatform(final JComboBox platformCombo) { 762 NbPlatformCustomizer.showCustomizer(); 763 platformCombo.setModel(new PlatformComponentFactory.NbPlatformListModel()); platformCombo.requestFocus(); 765 updateAndCheck(); 766 } 767 768 private void platformChosen(java.awt.event.ActionEvent evt) { updateAndCheck(); 770 } 772 private void moduleSuiteChosen(java.awt.event.ActionEvent evt) { if (!locationUpdated) { 774 String suite = (String ) moduleSuiteValue.getSelectedItem(); 775 computeAndSetLocation(suite, true); 776 lastSelectedSuite = suite; 777 } 778 updateAndCheck(); 779 } 781 private void browseModuleSuite(java.awt.event.ActionEvent evt) { JFileChooser chooser = ProjectChooser.projectChooser(); 783 int option = chooser.showOpenDialog(this); 784 if (option == JFileChooser.APPROVE_OPTION) { 785 File projectDir = chooser.getSelectedFile(); 786 UIUtil.setProjectChooserDirParent(projectDir); 787 try { 788 Project suite = ProjectManager.getDefault().findProject( 789 FileUtil.toFileObject(projectDir)); 790 if (suite != null) { 791 String suiteDir = SuiteUtils.getSuiteDirectoryPath(suite); 792 if (suiteDir != null) { 793 PlatformComponentFactory.addUserSuite(suiteDir); 795 moduleSuiteValue.addItem(suiteDir); 797 moduleSuiteValue.setSelectedItem(suiteDir); 798 } else { 799 DialogDisplayer.getDefault().notify(new DialogDescriptor.Message( 800 NbBundle.getMessage(BasicInfoVisualPanel.class, "MSG_NotRegularSuite", 801 ProjectUtils.getInformation(suite).getDisplayName()))); 802 } 803 } 804 } catch (IOException e) { 805 ErrorManager.getDefault().notify(ErrorManager.WARNING, e); 806 } 807 } 808 } 810 private void typeChanged(java.awt.event.ActionEvent evt) { if (!mainProjectTouched) { 812 mainProject.setSelected(isStandAlone()); 813 } 814 if (!locationUpdated) { 815 setInitialLocation(); 816 } 817 if (!nameUpdated) { 818 setInitialProjectName(); 819 } 820 updateAndCheck(); 821 } 823 private void browseLocation(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser (getLocationValue()); 825 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 826 int ret = chooser.showOpenDialog(this); 827 if (ret == JFileChooser.APPROVE_OPTION) { 828 computeAndSetLocation(chooser.getSelectedFile().getAbsolutePath(), false); 829 } 830 } 832 private javax.swing.JButton browseButton; 834 private javax.swing.JButton browseSuiteButton; 835 private javax.swing.JLabel chooserFiller; 836 private javax.swing.JLabel filler; 837 private javax.swing.JLabel folderLbl; 838 private javax.swing.JTextField folderValue; 839 private javax.swing.JPanel infoPanel; 840 private javax.swing.JLabel locationLbl; 841 private javax.swing.JTextField locationValue; 842 private javax.swing.JCheckBox mainProject; 843 private javax.swing.JButton managePlatform; 844 private javax.swing.JButton manageSuitePlatform; 845 private javax.swing.JLabel moduleSuite; 846 private javax.swing.JComboBox moduleSuiteValue; 847 private javax.swing.ButtonGroup moduleTypeGroup; 848 private javax.swing.JLabel nameLbl; 849 javax.swing.JTextField nameValue; 850 private javax.swing.JLabel platform; 851 private javax.swing.JComboBox platformValue; 852 private javax.swing.JPanel pnlThouShaltBeholdLayout; 853 private javax.swing.JSeparator separator3; 854 private javax.swing.JRadioButton standAloneModule; 855 private javax.swing.JRadioButton suiteComponent; 856 private javax.swing.JLabel suitePlatform; 857 private javax.swing.JComboBox suitePlatformValue; 858 private javax.swing.JPanel typeChooserPanel; 859 861 } 862 | Popular Tags |