1 19 20 package org.netbeans.modules.apisupport.project.ui.customizer; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Dialog ; 24 import java.awt.Rectangle ; 25 import java.awt.event.ActionEvent ; 26 import java.awt.event.ActionListener ; 27 import java.awt.event.ItemEvent ; 28 import java.awt.event.ItemListener ; 29 import java.io.IOException ; 30 import java.util.Arrays ; 31 import javax.swing.BorderFactory ; 32 import javax.swing.JLabel ; 33 import javax.swing.JList ; 34 import javax.swing.JPanel ; 35 import javax.swing.JScrollPane ; 36 import javax.swing.event.ListDataEvent ; 37 import javax.swing.event.ListDataListener ; 38 import javax.swing.event.ListSelectionListener ; 39 import org.netbeans.api.java.platform.JavaPlatform; 40 import org.netbeans.api.java.platform.PlatformsCustomizer; 41 import org.netbeans.modules.apisupport.project.NbModuleProject; 42 import org.netbeans.modules.apisupport.project.ui.UIUtil; 43 import org.netbeans.modules.apisupport.project.ui.platform.NbPlatformCustomizer; 44 import org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory; 45 import org.netbeans.modules.apisupport.project.universe.NbPlatform; 46 import org.openide.DialogDescriptor; 47 import org.openide.DialogDisplayer; 48 import org.openide.awt.Mnemonics; 49 import org.openide.util.HelpCtx; 50 import org.openide.util.NbBundle; 51 import org.openide.util.NbCollections; 52 53 58 public class CustomizerLibraries extends NbPropertyPanel.Single { 59 60 private static Rectangle lastSize; 61 62 63 public CustomizerLibraries(final SingleModuleProperties props) { 64 super(props, CustomizerLibraries.class); 65 initComponents(); 66 initAccessibility(); 67 if (!getProperties().isSuiteComponent()) { 68 addLibrary.setVisible(false); 69 Mnemonics.setLocalizedText(addDepButton, getMessage("CTL_AddButton")); 70 } 71 refresh(); 72 dependencyList.setCellRenderer(CustomizerComponentFactory.getDependencyCellRenderer(false)); 73 javaPlatformCombo.setRenderer(JavaPlatformComponentFactory.javaPlatformListCellRenderer()); 74 removeTokenButton.setEnabled(false); 75 attachListeners(); 76 } 77 78 void refresh() { 79 refreshJavaPlatforms(); 80 refreshPlatforms(); 81 platformValue.setEnabled(getProperties().isStandalone()); 82 managePlafsButton.setEnabled(getProperties().isStandalone()); 83 updateEnabled(); 84 reqTokenList.setModel(getProperties().getRequiredTokenListModel()); 85 dependencyList.setModel(getProperties().getDependenciesListModel()); 86 dependencyList.getModel().addListDataListener(new ListDataListener () { 87 public void contentsChanged(ListDataEvent e) { updateEnabled(); } 88 public void intervalAdded(ListDataEvent e) { updateEnabled(); } 89 public void intervalRemoved(ListDataEvent e) { updateEnabled(); } 90 }); 91 } 92 93 private void attachListeners() { 94 platformValue.addItemListener(new ItemListener () { 95 public void itemStateChanged(ItemEvent e) { 96 if (e.getStateChange() == ItemEvent.SELECTED) { 97 getProperties().setActivePlatform((NbPlatform) platformValue.getSelectedItem()); 99 dependencyList.setModel(getProperties().getDependenciesListModel()); 101 updateEnabled(); 102 } 103 } 104 }); 105 dependencyList.addListSelectionListener(new ListSelectionListener () { 106 public void valueChanged(javax.swing.event.ListSelectionEvent e) { 107 if (!e.getValueIsAdjusting()) { 108 updateEnabled(); 109 } 110 } 111 }); 112 javaPlatformCombo.addItemListener(new ItemListener () { 113 public void itemStateChanged(ItemEvent e) { 114 if (e.getStateChange() == ItemEvent.SELECTED) { 115 getProperties().setActiveJavaPlatform((JavaPlatform) javaPlatformCombo.getSelectedItem()); 117 } 118 } 119 }); 120 reqTokenList.addListSelectionListener(new ListSelectionListener () { 121 public void valueChanged(javax.swing.event.ListSelectionEvent e) { 122 if (!e.getValueIsAdjusting()) { 123 removeTokenButton.setEnabled(reqTokenList.getSelectedIndex() != -1); 124 } 125 } 126 }); 127 } 128 129 private void refreshJavaPlatforms() { 130 javaPlatformCombo.setModel(JavaPlatformComponentFactory.javaPlatformListModel()); 131 javaPlatformCombo.setSelectedItem(getProperties().getActiveJavaPlatform()); 132 } 133 134 private void refreshPlatforms() { 135 platformValue.setModel(new PlatformComponentFactory.NbPlatformListModel()); platformValue.setSelectedItem(getProperties().getActivePlatform()); 137 platformValue.requestFocusInWindow(); 138 } 139 140 private void updateEnabled() { 141 boolean enabled = dependencyList.getModel().getSize() > 0 && 143 getProperties().isActivePlatformValid() && dependencyList.getSelectedIndex() != -1; 144 editDepButton.setEnabled(enabled); 145 removeDepButton.setEnabled(enabled); 146 addDepButton.setEnabled(getProperties().isActivePlatformValid()); 147 boolean javaEnabled = getProperties().isNetBeansOrg() || 148 (getProperties().isStandalone() && 149 ((NbPlatform) platformValue.getSelectedItem()).getHarnessVersion() >= NbPlatform.HARNESS_VERSION_50u1); 150 javaPlatformCombo.setEnabled(javaEnabled); 151 javaPlatformButton.setEnabled(javaEnabled); 152 } 153 154 private CustomizerComponentFactory.DependencyListModel getDepListModel() { 155 return (CustomizerComponentFactory.DependencyListModel) dependencyList.getModel(); 156 } 157 158 private String getMessage(String key) { 159 return NbBundle.getMessage(CustomizerLibraries.class, key); 160 } 161 162 167 private void initComponents() { 169 java.awt.GridBagConstraints gridBagConstraints; 170 171 modDepLabel = new javax.swing.JLabel (); 172 depButtonPanel = new javax.swing.JPanel (); 173 addDepButton = new javax.swing.JButton (); 174 addLibrary = new javax.swing.JButton (); 175 removeDepButton = new javax.swing.JButton (); 176 space1 = new javax.swing.JLabel (); 177 editDepButton = new javax.swing.JButton (); 178 dependencySP = new javax.swing.JScrollPane (); 179 dependencyList = new javax.swing.JList (); 180 platformsPanel = new javax.swing.JPanel (); 181 platformValue = org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory.getNbPlatformsComboxBox(); 182 platform = new javax.swing.JLabel (); 183 managePlafsButton = new javax.swing.JButton (); 184 javaPlatformLabel = new javax.swing.JLabel (); 185 javaPlatformCombo = new javax.swing.JComboBox (); 186 javaPlatformButton = new javax.swing.JButton (); 187 reqTokens = new javax.swing.JLabel (); 188 reqTokenSP = new javax.swing.JScrollPane (); 189 reqTokenList = new javax.swing.JList (); 190 tokenButtonPanel = new javax.swing.JPanel (); 191 addTokenButton = new javax.swing.JButton (); 192 removeTokenButton = new javax.swing.JButton (); 193 194 setLayout(new java.awt.GridBagLayout ()); 195 196 modDepLabel.setLabelFor(dependencyList); 197 org.openide.awt.Mnemonics.setLocalizedText(modDepLabel, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "LBL_ModuleDependencies")); 198 gridBagConstraints = new java.awt.GridBagConstraints (); 199 gridBagConstraints.gridx = 0; 200 gridBagConstraints.gridy = 1; 201 gridBagConstraints.gridwidth = 2; 202 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 203 gridBagConstraints.insets = new java.awt.Insets (18, 0, 2, 0); 204 add(modDepLabel, gridBagConstraints); 205 206 depButtonPanel.setLayout(new java.awt.GridBagLayout ()); 207 208 org.openide.awt.Mnemonics.setLocalizedText(addDepButton, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "CTL_AddDependency")); 209 addDepButton.addActionListener(new java.awt.event.ActionListener () { 210 public void actionPerformed(java.awt.event.ActionEvent evt) { 211 addModuleDependency(evt); 212 } 213 }); 214 215 gridBagConstraints = new java.awt.GridBagConstraints (); 216 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 217 depButtonPanel.add(addDepButton, gridBagConstraints); 218 219 org.openide.awt.Mnemonics.setLocalizedText(addLibrary, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "CTL_AddNewLibrary")); 220 addLibrary.addActionListener(new java.awt.event.ActionListener () { 221 public void actionPerformed(java.awt.event.ActionEvent evt) { 222 addLibraryActionPerformed(evt); 223 } 224 }); 225 226 gridBagConstraints = new java.awt.GridBagConstraints (); 227 gridBagConstraints.gridx = 0; 228 gridBagConstraints.gridy = 1; 229 gridBagConstraints.insets = new java.awt.Insets (2, 0, 0, 0); 230 depButtonPanel.add(addLibrary, gridBagConstraints); 231 232 org.openide.awt.Mnemonics.setLocalizedText(removeDepButton, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "CTL_RemoveButton")); 233 removeDepButton.addActionListener(new java.awt.event.ActionListener () { 234 public void actionPerformed(java.awt.event.ActionEvent evt) { 235 removeModuleDependency(evt); 236 } 237 }); 238 239 gridBagConstraints = new java.awt.GridBagConstraints (); 240 gridBagConstraints.gridx = 0; 241 gridBagConstraints.gridy = 2; 242 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 243 gridBagConstraints.insets = new java.awt.Insets (2, 0, 0, 0); 244 depButtonPanel.add(removeDepButton, gridBagConstraints); 245 246 gridBagConstraints = new java.awt.GridBagConstraints (); 247 gridBagConstraints.gridx = 0; 248 gridBagConstraints.gridy = 4; 249 gridBagConstraints.weighty = 1.0; 250 depButtonPanel.add(space1, gridBagConstraints); 251 252 org.openide.awt.Mnemonics.setLocalizedText(editDepButton, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "CTL_EditButton")); 253 editDepButton.addActionListener(new java.awt.event.ActionListener () { 254 public void actionPerformed(java.awt.event.ActionEvent evt) { 255 editModuleDependency(evt); 256 } 257 }); 258 259 gridBagConstraints = new java.awt.GridBagConstraints (); 260 gridBagConstraints.gridx = 0; 261 gridBagConstraints.gridy = 3; 262 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 263 gridBagConstraints.insets = new java.awt.Insets (18, 0, 0, 0); 264 depButtonPanel.add(editDepButton, gridBagConstraints); 265 266 gridBagConstraints = new java.awt.GridBagConstraints (); 267 gridBagConstraints.gridx = 1; 268 gridBagConstraints.gridy = 2; 269 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 270 add(depButtonPanel, gridBagConstraints); 271 272 dependencySP.setViewportView(dependencyList); 273 274 gridBagConstraints = new java.awt.GridBagConstraints (); 275 gridBagConstraints.gridx = 0; 276 gridBagConstraints.gridy = 2; 277 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 278 gridBagConstraints.weightx = 1.0; 279 gridBagConstraints.weighty = 1.0; 280 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 281 add(dependencySP, gridBagConstraints); 282 283 platformsPanel.setLayout(new java.awt.GridBagLayout ()); 284 285 gridBagConstraints = new java.awt.GridBagConstraints (); 286 gridBagConstraints.gridx = 1; 287 gridBagConstraints.gridy = 1; 288 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 289 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 290 gridBagConstraints.weightx = 1.0; 291 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 12); 292 platformsPanel.add(platformValue, gridBagConstraints); 293 294 platform.setLabelFor(platformValue); 295 org.openide.awt.Mnemonics.setLocalizedText(platform, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "LBL_NetBeansPlatform")); 296 gridBagConstraints = new java.awt.GridBagConstraints (); 297 gridBagConstraints.gridx = 0; 298 gridBagConstraints.gridy = 1; 299 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 300 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 12); 301 platformsPanel.add(platform, gridBagConstraints); 302 303 org.openide.awt.Mnemonics.setLocalizedText(managePlafsButton, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "CTL_ManagePlatform")); 304 managePlafsButton.addActionListener(new java.awt.event.ActionListener () { 305 public void actionPerformed(java.awt.event.ActionEvent evt) { 306 managePlatforms(evt); 307 } 308 }); 309 310 gridBagConstraints = new java.awt.GridBagConstraints (); 311 gridBagConstraints.gridx = 2; 312 gridBagConstraints.gridy = 1; 313 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 314 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 315 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 316 platformsPanel.add(managePlafsButton, gridBagConstraints); 317 318 javaPlatformLabel.setLabelFor(javaPlatformCombo); 319 org.openide.awt.Mnemonics.setLocalizedText(javaPlatformLabel, NbBundle.getMessage(CustomizerLibraries.class, "LBL_Java_Platform")); 320 gridBagConstraints = new java.awt.GridBagConstraints (); 321 gridBagConstraints.gridx = 0; 322 gridBagConstraints.gridy = 0; 323 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 324 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 325 platformsPanel.add(javaPlatformLabel, gridBagConstraints); 326 327 gridBagConstraints = new java.awt.GridBagConstraints (); 328 gridBagConstraints.gridx = 1; 329 gridBagConstraints.gridy = 0; 330 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 331 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 332 gridBagConstraints.weightx = 1.0; 333 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 334 platformsPanel.add(javaPlatformCombo, gridBagConstraints); 335 336 org.openide.awt.Mnemonics.setLocalizedText(javaPlatformButton, NbBundle.getMessage(CustomizerLibraries.class, "LBL_Manage_Java_Platforms")); 337 javaPlatformButton.addActionListener(new java.awt.event.ActionListener () { 338 public void actionPerformed(java.awt.event.ActionEvent evt) { 339 javaPlatformButtonActionPerformed(evt); 340 } 341 }); 342 343 gridBagConstraints = new java.awt.GridBagConstraints (); 344 gridBagConstraints.gridx = 2; 345 gridBagConstraints.gridy = 0; 346 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 347 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 348 platformsPanel.add(javaPlatformButton, gridBagConstraints); 349 350 gridBagConstraints = new java.awt.GridBagConstraints (); 351 gridBagConstraints.gridx = 0; 352 gridBagConstraints.gridy = 0; 353 gridBagConstraints.gridwidth = 2; 354 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 355 add(platformsPanel, gridBagConstraints); 356 357 reqTokens.setLabelFor(reqTokenList); 358 org.openide.awt.Mnemonics.setLocalizedText(reqTokens, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "LBL_RequiredTokens")); 359 gridBagConstraints = new java.awt.GridBagConstraints (); 360 gridBagConstraints.gridx = 0; 361 gridBagConstraints.gridy = 3; 362 gridBagConstraints.gridwidth = 2; 363 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 364 gridBagConstraints.insets = new java.awt.Insets (18, 0, 0, 12); 365 add(reqTokens, gridBagConstraints); 366 367 reqTokenSP.setViewportView(reqTokenList); 368 369 gridBagConstraints = new java.awt.GridBagConstraints (); 370 gridBagConstraints.gridx = 0; 371 gridBagConstraints.gridy = 4; 372 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 373 gridBagConstraints.weightx = 1.0; 374 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 375 add(reqTokenSP, gridBagConstraints); 376 377 tokenButtonPanel.setLayout(new java.awt.GridBagLayout ()); 378 379 org.openide.awt.Mnemonics.setLocalizedText(addTokenButton, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "CTL_AddButton_d")); 380 addTokenButton.addActionListener(new java.awt.event.ActionListener () { 381 public void actionPerformed(java.awt.event.ActionEvent evt) { 382 addToken(evt); 383 } 384 }); 385 386 gridBagConstraints = new java.awt.GridBagConstraints (); 387 gridBagConstraints.gridx = 0; 388 gridBagConstraints.gridy = 0; 389 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 390 gridBagConstraints.weightx = 1.0; 391 tokenButtonPanel.add(addTokenButton, gridBagConstraints); 392 393 org.openide.awt.Mnemonics.setLocalizedText(removeTokenButton, org.openide.util.NbBundle.getMessage(CustomizerLibraries.class, "CTL_RemoveButton_v")); 394 removeTokenButton.addActionListener(new java.awt.event.ActionListener () { 395 public void actionPerformed(java.awt.event.ActionEvent evt) { 396 removeToken(evt); 397 } 398 }); 399 400 gridBagConstraints = new java.awt.GridBagConstraints (); 401 gridBagConstraints.gridx = 0; 402 gridBagConstraints.gridy = 1; 403 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 404 gridBagConstraints.weightx = 1.0; 405 gridBagConstraints.insets = new java.awt.Insets (2, 0, 0, 0); 406 tokenButtonPanel.add(removeTokenButton, gridBagConstraints); 407 408 gridBagConstraints = new java.awt.GridBagConstraints (); 409 gridBagConstraints.gridx = 1; 410 gridBagConstraints.gridy = 4; 411 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 412 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 413 add(tokenButtonPanel, gridBagConstraints); 414 415 } 417 private void addLibraryActionPerformed(java.awt.event.ActionEvent evt) { NbModuleProject project = UIUtil.runLibraryWrapperWizard(getProperties().getProject()); 419 if (project != null) { 420 try { 421 getProperties().libraryWrapperAdded(); 422 ModuleDependency dep = new ModuleDependency( 423 getProperties().getModuleList().getEntry(project.getCodeNameBase())); 424 getDepListModel().addDependency(dep); 425 } catch (IOException e) { 426 assert false : e; 427 } 428 } 429 } 431 private void javaPlatformButtonActionPerformed(java.awt.event.ActionEvent evt) { PlatformsCustomizer.showCustomizer((JavaPlatform) javaPlatformCombo.getSelectedItem()); 433 refreshJavaPlatforms(); 434 } 436 private void removeToken(java.awt.event.ActionEvent evt) { CustomizerComponentFactory.RequiredTokenListModel model = (CustomizerComponentFactory.RequiredTokenListModel) reqTokenList.getModel(); 438 Object [] selected = reqTokenList.getSelectedValues(); 439 for (int i = 0; i < selected.length; i++) { 440 model.removeToken((String ) selected[i]); 441 } 442 if (model.getSize() > 0) { 443 reqTokenList.setSelectedIndex(0); 444 } 445 reqTokenList.requestFocusInWindow(); 446 } 448 private void addToken(java.awt.event.ActionEvent evt) { JPanel panel = new JPanel (); 451 panel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); 452 panel.setLayout(new BorderLayout (0, 2)); 453 JList tokenList = new JList (getProperties().getAllTokens()); 454 JScrollPane tokenListSP = new JScrollPane (tokenList); 455 JLabel provTokensTxt = new JLabel (); 456 provTokensTxt.setLabelFor(tokenList); 457 Mnemonics.setLocalizedText(provTokensTxt, getMessage("LBL_ProvidedTokens_T")); 458 panel.getAccessibleContext().setAccessibleDescription(getMessage("ACS_ProvidedTokensTitle")); 459 tokenList.getAccessibleContext().setAccessibleDescription(getMessage("ACS_LBL_ProvidedTokens")); 460 tokenListSP.getVerticalScrollBar().getAccessibleContext().setAccessibleName(getMessage("ACS_CTL_ProvidedTokensVerticalScroll")); 461 tokenListSP.getVerticalScrollBar().getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CTL_ProvidedTokensVerticalScroll")); 462 tokenListSP.getHorizontalScrollBar().getAccessibleContext().setAccessibleName(getMessage("ACS_CTL_ProvidedTokensHorizontalScroll")); 463 tokenListSP.getHorizontalScrollBar().getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CTL_ProvidedTokensHorizontalScroll")); 464 465 panel.add(provTokensTxt, BorderLayout.NORTH); 466 panel.add(tokenListSP, BorderLayout.CENTER); 467 468 DialogDescriptor descriptor = new DialogDescriptor(panel, 469 getMessage("LBL_ProvidedTokens_NoMnem")); 470 Dialog d = DialogDisplayer.getDefault().createDialog(descriptor); 471 d.setVisible(true); 472 d.dispose(); 473 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 474 Object [] selected = tokenList.getSelectedValues(); 475 CustomizerComponentFactory.RequiredTokenListModel model = (CustomizerComponentFactory.RequiredTokenListModel) reqTokenList.getModel(); 476 for (int i = 0; i < selected.length; i++) { 477 model.addToken((String ) selected[i]); 478 } 479 if (selected.length > 0) { 480 reqTokenList.clearSelection(); 481 reqTokenList.setSelectedValue(selected[0], true); 482 } 483 } 484 reqTokenList.requestFocusInWindow(); 485 } 487 private void managePlatforms(java.awt.event.ActionEvent evt) { NbPlatformCustomizer.showCustomizer(); 489 refreshPlatforms(); 490 } 492 private void editModuleDependency(java.awt.event.ActionEvent evt) { ModuleDependency origDep = getDepListModel().getDependency( 494 dependencyList.getSelectedIndex()); 495 ModuleDependency editedDep = getDepListModel().findEdited(origDep); 496 EditDependencyPanel editPanel = new EditDependencyPanel( 497 editedDep == null ? origDep : editedDep, getProperties().getActivePlatform()); 498 DialogDescriptor descriptor = new DialogDescriptor(editPanel, 499 getMessage("CTL_EditModuleDependencyTitle")); 500 descriptor.setHelpCtx(new HelpCtx(EditDependencyPanel.class)); 501 Dialog d = DialogDisplayer.getDefault().createDialog(descriptor); 502 d.setVisible(true); 503 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 504 getDepListModel().editDependency(origDep, editPanel.getEditedDependency()); 505 } 506 d.dispose(); 507 dependencyList.requestFocusInWindow(); 508 } 510 private void removeModuleDependency(java.awt.event.ActionEvent evt) { getDepListModel().removeDependencies(NbCollections.checkedListByCopy(Arrays.asList(dependencyList.getSelectedValues()), ModuleDependency.class, true)); 512 if (dependencyList.getModel().getSize() > 0) { 513 dependencyList.setSelectedIndex(0); 514 } 515 dependencyList.requestFocusInWindow(); 516 } 518 private void addModuleDependency(java.awt.event.ActionEvent evt) { final AddModulePanel addPanel = new AddModulePanel(getProperties()); 520 final DialogDescriptor descriptor = new DialogDescriptor(addPanel, 521 getMessage("CTL_AddModuleDependencyTitle")); 522 descriptor.setHelpCtx(new HelpCtx(AddModulePanel.class)); 523 descriptor.setClosingOptions(new Object [0]); 524 final Dialog d = DialogDisplayer.getDefault().createDialog(descriptor); 525 descriptor.setButtonListener(new ActionListener () { 526 public void actionPerformed(ActionEvent e) { 527 if (DialogDescriptor.OK_OPTION.equals(e.getSource()) && 528 addPanel.getSelectedDependencies().length == 0) { 529 return; 530 } 531 d.setVisible(false); 532 d.dispose(); 533 } 534 }); 535 if (lastSize != null) { 536 d.setBounds(lastSize); 537 } 538 d.setVisible(true); 539 lastSize = d.getBounds(); 540 d.dispose(); 541 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 542 ModuleDependency[] newDeps = addPanel.getSelectedDependencies(); 543 for (int i = 0; i < newDeps.length; i++) { 544 ModuleDependency dep = newDeps[i]; 545 if ("0".equals(dep.getReleaseVersion())) { getDepListModel().addDependency(new ModuleDependency( 547 dep.getModuleEntry(), "0-1", dep.getSpecificationVersion(), dep.hasCompileDependency(), dep.hasImplementationDepedendency())); 549 } else { 550 getDepListModel().addDependency(dep); 551 } 552 dependencyList.setSelectedValue(dep, true); 553 } 554 } 555 dependencyList.requestFocusInWindow(); 556 } 558 private javax.swing.JButton addDepButton; 560 private javax.swing.JButton addLibrary; 561 private javax.swing.JButton addTokenButton; 562 private javax.swing.JPanel depButtonPanel; 563 private javax.swing.JList dependencyList; 564 private javax.swing.JScrollPane dependencySP; 565 private javax.swing.JButton editDepButton; 566 private javax.swing.JButton javaPlatformButton; 567 private javax.swing.JComboBox javaPlatformCombo; 568 private javax.swing.JLabel javaPlatformLabel; 569 private javax.swing.JButton managePlafsButton; 570 private javax.swing.JLabel modDepLabel; 571 private javax.swing.JLabel platform; 572 private javax.swing.JComboBox platformValue; 573 private javax.swing.JPanel platformsPanel; 574 private javax.swing.JButton removeDepButton; 575 private javax.swing.JButton removeTokenButton; 576 private javax.swing.JList reqTokenList; 577 private javax.swing.JScrollPane reqTokenSP; 578 private javax.swing.JLabel reqTokens; 579 private javax.swing.JLabel space1; 580 private javax.swing.JPanel tokenButtonPanel; 581 583 private void initAccessibility() { 584 addTokenButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_SrcLevelValue")); 585 dependencyList.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_DependencyList")); 586 editDepButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_EditDepButton")); 587 removeDepButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_RemoveDepButton")); 588 removeTokenButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_RemoveTokenButton")); 589 addDepButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_AddDepButton")); 590 reqTokenList.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_ReqTokenList")); 591 } 592 593 } 594 | Popular Tags |