001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.apisupport.project.ui.customizer;
043:
044: import java.awt.BorderLayout;
045: import java.awt.Dialog;
046: import java.awt.event.ItemEvent;
047: import java.awt.event.ItemListener;
048: import java.io.IOException;
049: import java.util.Arrays;
050: import javax.swing.BorderFactory;
051: import javax.swing.JLabel;
052: import javax.swing.JList;
053: import javax.swing.JPanel;
054: import javax.swing.JScrollPane;
055: import javax.swing.event.ListDataEvent;
056: import javax.swing.event.ListDataListener;
057: import javax.swing.event.ListSelectionListener;
058: import org.netbeans.api.java.platform.JavaPlatform;
059: import org.netbeans.api.java.platform.PlatformsCustomizer;
060: import org.netbeans.modules.apisupport.project.NbModuleProject;
061: import org.netbeans.modules.apisupport.project.ui.UIUtil;
062: import org.netbeans.modules.apisupport.project.ui.platform.NbPlatformCustomizer;
063: import org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory;
064: import org.netbeans.modules.apisupport.project.universe.NbPlatform;
065: import org.netbeans.spi.project.ui.support.ProjectCustomizer;
066: import org.openide.DialogDescriptor;
067: import org.openide.DialogDisplayer;
068: import org.openide.awt.Mnemonics;
069: import org.openide.util.HelpCtx;
070: import org.openide.util.NbBundle;
071: import org.openide.util.NbCollections;
072:
073: /**
074: * Represents <em>Libraries</em> panel in NetBeans Module customizer.
075: *
076: * @author mkrauskopf
077: */
078: public class CustomizerLibraries extends NbPropertyPanel.Single {
079:
080: /** Creates new form CustomizerLibraries */
081: public CustomizerLibraries(final SingleModuleProperties props,
082: ProjectCustomizer.Category category) {
083: super (props, CustomizerLibraries.class, category);
084: initComponents();
085: initAccessibility();
086: if (!getProperties().isSuiteComponent()) {
087: addLibrary.setVisible(false);
088: Mnemonics.setLocalizedText(addDepButton,
089: getMessage("CTL_AddButton"));
090: }
091: refresh();
092: dependencyList.setCellRenderer(CustomizerComponentFactory
093: .getDependencyCellRenderer(false));
094: javaPlatformCombo.setRenderer(JavaPlatformComponentFactory
095: .javaPlatformListCellRenderer());
096: removeTokenButton.setEnabled(false);
097: attachListeners();
098: }
099:
100: void refresh() {
101: refreshJavaPlatforms();
102: refreshPlatforms();
103: platformValue.setEnabled(getProperties().isStandalone());
104: managePlafsButton.setEnabled(getProperties().isStandalone());
105: updateEnabled();
106: reqTokenList.setModel(getProperties()
107: .getRequiredTokenListModel());
108: dependencyList.setModel(getProperties()
109: .getDependenciesListModel());
110: dependencyList.getModel().addListDataListener(
111: new ListDataListener() {
112: public void contentsChanged(ListDataEvent e) {
113: updateEnabled();
114: }
115:
116: public void intervalAdded(ListDataEvent e) {
117: updateEnabled();
118: }
119:
120: public void intervalRemoved(ListDataEvent e) {
121: updateEnabled();
122: }
123: });
124: }
125:
126: private void attachListeners() {
127: platformValue.addItemListener(new ItemListener() {
128: public void itemStateChanged(ItemEvent e) {
129: if (e.getStateChange() == ItemEvent.SELECTED) {
130: // set new platform
131: getProperties().setActivePlatform(
132: (NbPlatform) platformValue
133: .getSelectedItem());
134: // refresh dependencies list
135: dependencyList.setModel(getProperties()
136: .getDependenciesListModel());
137: updateEnabled();
138: }
139: }
140: });
141: dependencyList
142: .addListSelectionListener(new ListSelectionListener() {
143: public void valueChanged(
144: javax.swing.event.ListSelectionEvent e) {
145: if (!e.getValueIsAdjusting()) {
146: updateEnabled();
147: }
148: }
149: });
150: javaPlatformCombo.addItemListener(new ItemListener() {
151: public void itemStateChanged(ItemEvent e) {
152: if (e.getStateChange() == ItemEvent.SELECTED) {
153: // set new platform
154: getProperties().setActiveJavaPlatform(
155: (JavaPlatform) javaPlatformCombo
156: .getSelectedItem());
157: }
158: }
159: });
160: reqTokenList
161: .addListSelectionListener(new ListSelectionListener() {
162: public void valueChanged(
163: javax.swing.event.ListSelectionEvent e) {
164: if (!e.getValueIsAdjusting()) {
165: removeTokenButton.setEnabled(reqTokenList
166: .getSelectedIndex() != -1);
167: }
168: }
169: });
170: }
171:
172: private void refreshJavaPlatforms() {
173: javaPlatformCombo.setModel(JavaPlatformComponentFactory
174: .javaPlatformListModel());
175: javaPlatformCombo.setSelectedItem(getProperties()
176: .getActiveJavaPlatform());
177: }
178:
179: private void refreshPlatforms() {
180: platformValue
181: .setModel(new PlatformComponentFactory.NbPlatformListModel(
182: getProperties().getActivePlatform())); // refresh
183: platformValue.requestFocusInWindow();
184: }
185:
186: private void updateEnabled() {
187: // if there is no selection disable edit/remove buttons
188: boolean enabled = dependencyList.getModel().getSize() > 0
189: && getProperties().isActivePlatformValid()
190: && dependencyList.getSelectedIndex() != -1;
191: editDepButton.setEnabled(enabled);
192: removeDepButton.setEnabled(enabled);
193: addDepButton
194: .setEnabled(getProperties().isActivePlatformValid());
195: boolean javaEnabled = getProperties().isNetBeansOrg()
196: || (getProperties().isStandalone() &&
197: /* #71631 */((NbPlatform) platformValue
198: .getSelectedItem()).getHarnessVersion() >= NbPlatform.HARNESS_VERSION_50u1);
199: javaPlatformCombo.setEnabled(javaEnabled);
200: javaPlatformButton.setEnabled(javaEnabled);
201: }
202:
203: private CustomizerComponentFactory.DependencyListModel getDepListModel() {
204: return (CustomizerComponentFactory.DependencyListModel) dependencyList
205: .getModel();
206: }
207:
208: private String getMessage(String key) {
209: return NbBundle.getMessage(CustomizerLibraries.class, key);
210: }
211:
212: /** This method is called from within the constructor to
213: * initialize the form.
214: * WARNING: Do NOT modify this code. The content of this method is
215: * always regenerated by the Form Editor.
216: */
217: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
218: private void initComponents() {
219: java.awt.GridBagConstraints gridBagConstraints;
220:
221: modDepLabel = new javax.swing.JLabel();
222: depButtonPanel = new javax.swing.JPanel();
223: addDepButton = new javax.swing.JButton();
224: addLibrary = new javax.swing.JButton();
225: removeDepButton = new javax.swing.JButton();
226: space1 = new javax.swing.JLabel();
227: editDepButton = new javax.swing.JButton();
228: dependencySP = new javax.swing.JScrollPane();
229: dependencyList = new javax.swing.JList();
230: platformsPanel = new javax.swing.JPanel();
231: platformValue = org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory
232: .getNbPlatformsComboxBox();
233: platform = new javax.swing.JLabel();
234: managePlafsButton = new javax.swing.JButton();
235: javaPlatformLabel = new javax.swing.JLabel();
236: javaPlatformCombo = new javax.swing.JComboBox();
237: javaPlatformButton = new javax.swing.JButton();
238: reqTokens = new javax.swing.JLabel();
239: reqTokenSP = new javax.swing.JScrollPane();
240: reqTokenList = new javax.swing.JList();
241: tokenButtonPanel = new javax.swing.JPanel();
242: addTokenButton = new javax.swing.JButton();
243: removeTokenButton = new javax.swing.JButton();
244:
245: setLayout(new java.awt.GridBagLayout());
246:
247: modDepLabel.setLabelFor(dependencyList);
248: org.openide.awt.Mnemonics.setLocalizedText(modDepLabel,
249: org.openide.util.NbBundle.getMessage(
250: CustomizerLibraries.class,
251: "LBL_ModuleDependencies")); // NOI18N
252: gridBagConstraints = new java.awt.GridBagConstraints();
253: gridBagConstraints.gridx = 0;
254: gridBagConstraints.gridy = 1;
255: gridBagConstraints.gridwidth = 2;
256: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
257: gridBagConstraints.insets = new java.awt.Insets(18, 0, 2, 0);
258: add(modDepLabel, gridBagConstraints);
259:
260: depButtonPanel.setLayout(new java.awt.GridBagLayout());
261:
262: org.openide.awt.Mnemonics
263: .setLocalizedText(addDepButton,
264: org.openide.util.NbBundle.getMessage(
265: CustomizerLibraries.class,
266: "CTL_AddDependency")); // NOI18N
267: addDepButton
268: .addActionListener(new java.awt.event.ActionListener() {
269: public void actionPerformed(
270: java.awt.event.ActionEvent evt) {
271: addModuleDependency(evt);
272: }
273: });
274: gridBagConstraints = new java.awt.GridBagConstraints();
275: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
276: depButtonPanel.add(addDepButton, gridBagConstraints);
277:
278: org.openide.awt.Mnemonics
279: .setLocalizedText(addLibrary, org.openide.util.NbBundle
280: .getMessage(CustomizerLibraries.class,
281: "CTL_AddNewLibrary")); // NOI18N
282: addLibrary
283: .addActionListener(new java.awt.event.ActionListener() {
284: public void actionPerformed(
285: java.awt.event.ActionEvent evt) {
286: addLibraryActionPerformed(evt);
287: }
288: });
289: gridBagConstraints = new java.awt.GridBagConstraints();
290: gridBagConstraints.gridx = 0;
291: gridBagConstraints.gridy = 1;
292: gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
293: depButtonPanel.add(addLibrary, gridBagConstraints);
294:
295: org.openide.awt.Mnemonics.setLocalizedText(removeDepButton,
296: org.openide.util.NbBundle.getMessage(
297: CustomizerLibraries.class, "CTL_RemoveButton")); // NOI18N
298: removeDepButton
299: .addActionListener(new java.awt.event.ActionListener() {
300: public void actionPerformed(
301: java.awt.event.ActionEvent evt) {
302: removeModuleDependency(evt);
303: }
304: });
305: gridBagConstraints = new java.awt.GridBagConstraints();
306: gridBagConstraints.gridx = 0;
307: gridBagConstraints.gridy = 2;
308: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
309: gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
310: depButtonPanel.add(removeDepButton, gridBagConstraints);
311: gridBagConstraints = new java.awt.GridBagConstraints();
312: gridBagConstraints.gridx = 0;
313: gridBagConstraints.gridy = 4;
314: gridBagConstraints.weighty = 1.0;
315: depButtonPanel.add(space1, gridBagConstraints);
316:
317: org.openide.awt.Mnemonics.setLocalizedText(editDepButton,
318: org.openide.util.NbBundle.getMessage(
319: CustomizerLibraries.class, "CTL_EditButton")); // NOI18N
320: editDepButton
321: .addActionListener(new java.awt.event.ActionListener() {
322: public void actionPerformed(
323: java.awt.event.ActionEvent evt) {
324: editModuleDependency(evt);
325: }
326: });
327: gridBagConstraints = new java.awt.GridBagConstraints();
328: gridBagConstraints.gridx = 0;
329: gridBagConstraints.gridy = 3;
330: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
331: gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 0);
332: depButtonPanel.add(editDepButton, gridBagConstraints);
333:
334: gridBagConstraints = new java.awt.GridBagConstraints();
335: gridBagConstraints.gridx = 1;
336: gridBagConstraints.gridy = 2;
337: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
338: add(depButtonPanel, gridBagConstraints);
339:
340: dependencySP.setViewportView(dependencyList);
341:
342: gridBagConstraints = new java.awt.GridBagConstraints();
343: gridBagConstraints.gridx = 0;
344: gridBagConstraints.gridy = 2;
345: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
346: gridBagConstraints.weightx = 1.0;
347: gridBagConstraints.weighty = 1.0;
348: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
349: add(dependencySP, gridBagConstraints);
350:
351: platformsPanel.setLayout(new java.awt.GridBagLayout());
352: gridBagConstraints = new java.awt.GridBagConstraints();
353: gridBagConstraints.gridx = 1;
354: gridBagConstraints.gridy = 1;
355: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
356: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
357: gridBagConstraints.weightx = 1.0;
358: gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 12);
359: platformsPanel.add(platformValue, gridBagConstraints);
360:
361: platform.setLabelFor(platformValue);
362: org.openide.awt.Mnemonics.setLocalizedText(platform,
363: org.openide.util.NbBundle.getMessage(
364: CustomizerLibraries.class,
365: "LBL_NetBeansPlatform")); // NOI18N
366: gridBagConstraints = new java.awt.GridBagConstraints();
367: gridBagConstraints.gridx = 0;
368: gridBagConstraints.gridy = 1;
369: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
370: gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 12);
371: platformsPanel.add(platform, gridBagConstraints);
372:
373: org.openide.awt.Mnemonics.setLocalizedText(managePlafsButton,
374: org.openide.util.NbBundle
375: .getMessage(CustomizerLibraries.class,
376: "CTL_ManagePlatform")); // NOI18N
377: managePlafsButton
378: .addActionListener(new java.awt.event.ActionListener() {
379: public void actionPerformed(
380: java.awt.event.ActionEvent evt) {
381: managePlatforms(evt);
382: }
383: });
384: gridBagConstraints = new java.awt.GridBagConstraints();
385: gridBagConstraints.gridx = 2;
386: gridBagConstraints.gridy = 1;
387: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
388: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
389: gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
390: platformsPanel.add(managePlafsButton, gridBagConstraints);
391:
392: javaPlatformLabel.setLabelFor(javaPlatformCombo);
393: org.openide.awt.Mnemonics.setLocalizedText(javaPlatformLabel,
394: NbBundle.getMessage(CustomizerLibraries.class,
395: "LBL_Java_Platform")); // NOI18N
396: gridBagConstraints = new java.awt.GridBagConstraints();
397: gridBagConstraints.gridx = 0;
398: gridBagConstraints.gridy = 0;
399: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
400: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
401: platformsPanel.add(javaPlatformLabel, gridBagConstraints);
402: gridBagConstraints = new java.awt.GridBagConstraints();
403: gridBagConstraints.gridx = 1;
404: gridBagConstraints.gridy = 0;
405: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
406: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
407: gridBagConstraints.weightx = 1.0;
408: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
409: platformsPanel.add(javaPlatformCombo, gridBagConstraints);
410:
411: org.openide.awt.Mnemonics.setLocalizedText(javaPlatformButton,
412: NbBundle.getMessage(CustomizerLibraries.class,
413: "LBL_Manage_Java_Platforms")); // NOI18N
414: javaPlatformButton
415: .addActionListener(new java.awt.event.ActionListener() {
416: public void actionPerformed(
417: java.awt.event.ActionEvent evt) {
418: javaPlatformButtonActionPerformed(evt);
419: }
420: });
421: gridBagConstraints = new java.awt.GridBagConstraints();
422: gridBagConstraints.gridx = 2;
423: gridBagConstraints.gridy = 0;
424: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
425: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
426: platformsPanel.add(javaPlatformButton, gridBagConstraints);
427:
428: gridBagConstraints = new java.awt.GridBagConstraints();
429: gridBagConstraints.gridx = 0;
430: gridBagConstraints.gridy = 0;
431: gridBagConstraints.gridwidth = 2;
432: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
433: add(platformsPanel, gridBagConstraints);
434:
435: reqTokens.setLabelFor(reqTokenList);
436: org.openide.awt.Mnemonics.setLocalizedText(reqTokens,
437: org.openide.util.NbBundle
438: .getMessage(CustomizerLibraries.class,
439: "LBL_RequiredTokens")); // NOI18N
440: gridBagConstraints = new java.awt.GridBagConstraints();
441: gridBagConstraints.gridx = 0;
442: gridBagConstraints.gridy = 3;
443: gridBagConstraints.gridwidth = 2;
444: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
445: gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 12);
446: add(reqTokens, gridBagConstraints);
447:
448: reqTokenSP.setViewportView(reqTokenList);
449:
450: gridBagConstraints = new java.awt.GridBagConstraints();
451: gridBagConstraints.gridx = 0;
452: gridBagConstraints.gridy = 4;
453: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
454: gridBagConstraints.weightx = 1.0;
455: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
456: add(reqTokenSP, gridBagConstraints);
457:
458: tokenButtonPanel.setLayout(new java.awt.GridBagLayout());
459:
460: org.openide.awt.Mnemonics.setLocalizedText(addTokenButton,
461: org.openide.util.NbBundle.getMessage(
462: CustomizerLibraries.class, "CTL_AddButton_d")); // NOI18N
463: addTokenButton
464: .addActionListener(new java.awt.event.ActionListener() {
465: public void actionPerformed(
466: java.awt.event.ActionEvent evt) {
467: addToken(evt);
468: }
469: });
470: gridBagConstraints = new java.awt.GridBagConstraints();
471: gridBagConstraints.gridx = 0;
472: gridBagConstraints.gridy = 0;
473: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
474: gridBagConstraints.weightx = 1.0;
475: tokenButtonPanel.add(addTokenButton, gridBagConstraints);
476:
477: org.openide.awt.Mnemonics.setLocalizedText(removeTokenButton,
478: org.openide.util.NbBundle
479: .getMessage(CustomizerLibraries.class,
480: "CTL_RemoveButton_v")); // NOI18N
481: removeTokenButton
482: .addActionListener(new java.awt.event.ActionListener() {
483: public void actionPerformed(
484: java.awt.event.ActionEvent evt) {
485: removeToken(evt);
486: }
487: });
488: gridBagConstraints = new java.awt.GridBagConstraints();
489: gridBagConstraints.gridx = 0;
490: gridBagConstraints.gridy = 1;
491: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
492: gridBagConstraints.weightx = 1.0;
493: gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
494: tokenButtonPanel.add(removeTokenButton, gridBagConstraints);
495:
496: gridBagConstraints = new java.awt.GridBagConstraints();
497: gridBagConstraints.gridx = 1;
498: gridBagConstraints.gridy = 4;
499: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
500: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
501: add(tokenButtonPanel, gridBagConstraints);
502: }// </editor-fold>//GEN-END:initComponents
503:
504: private void addLibraryActionPerformed(
505: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addLibraryActionPerformed
506: NbModuleProject project = UIUtil
507: .runLibraryWrapperWizard(getProperties().getProject());
508: if (project != null) {
509: try {
510: getProperties().libraryWrapperAdded();
511: ModuleDependency dep = new ModuleDependency(
512: getProperties().getModuleList().getEntry(
513: project.getCodeNameBase()));
514: getDepListModel().addDependency(dep);
515: } catch (IOException e) {
516: assert false : e;
517: }
518: }
519: }//GEN-LAST:event_addLibraryActionPerformed
520:
521: private void javaPlatformButtonActionPerformed(
522: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaPlatformButtonActionPerformed
523: PlatformsCustomizer
524: .showCustomizer((JavaPlatform) javaPlatformCombo
525: .getSelectedItem());
526: refreshJavaPlatforms();
527: }//GEN-LAST:event_javaPlatformButtonActionPerformed
528:
529: private void removeToken(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeToken
530: CustomizerComponentFactory.RequiredTokenListModel model = (CustomizerComponentFactory.RequiredTokenListModel) reqTokenList
531: .getModel();
532: Object[] selected = reqTokenList.getSelectedValues();
533: for (int i = 0; i < selected.length; i++) {
534: model.removeToken((String) selected[i]);
535: }
536: if (model.getSize() > 0) {
537: reqTokenList.setSelectedIndex(0);
538: }
539: reqTokenList.requestFocusInWindow();
540: }//GEN-LAST:event_removeToken
541:
542: private void addToken(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToken
543: // create add panel
544: JPanel panel = new JPanel();
545: panel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
546: panel.setLayout(new BorderLayout(0, 2));
547: JList tokenList = new JList(getProperties().getAllTokens());
548: JScrollPane tokenListSP = new JScrollPane(tokenList);
549: JLabel provTokensTxt = new JLabel();
550: provTokensTxt.setLabelFor(tokenList);
551: Mnemonics.setLocalizedText(provTokensTxt,
552: getMessage("LBL_ProvidedTokens_T"));
553: panel.getAccessibleContext().setAccessibleDescription(
554: getMessage("ACS_ProvidedTokensTitle"));
555: tokenList.getAccessibleContext().setAccessibleDescription(
556: getMessage("ACS_LBL_ProvidedTokens"));
557: tokenListSP
558: .getVerticalScrollBar()
559: .getAccessibleContext()
560: .setAccessibleName(
561: getMessage("ACS_CTL_ProvidedTokensVerticalScroll"));
562: tokenListSP
563: .getVerticalScrollBar()
564: .getAccessibleContext()
565: .setAccessibleDescription(
566: getMessage("ACSD_CTL_ProvidedTokensVerticalScroll"));
567: tokenListSP
568: .getHorizontalScrollBar()
569: .getAccessibleContext()
570: .setAccessibleName(
571: getMessage("ACS_CTL_ProvidedTokensHorizontalScroll"));
572: tokenListSP
573: .getHorizontalScrollBar()
574: .getAccessibleContext()
575: .setAccessibleDescription(
576: getMessage("ACSD_CTL_ProvidedTokensHorizontalScroll"));
577:
578: panel.add(provTokensTxt, BorderLayout.NORTH);
579: panel.add(tokenListSP, BorderLayout.CENTER);
580:
581: DialogDescriptor descriptor = new DialogDescriptor(panel,
582: getMessage("LBL_ProvidedTokens_NoMnem"));
583: Dialog d = DialogDisplayer.getDefault()
584: .createDialog(descriptor);
585: d.setVisible(true);
586: d.dispose();
587: if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
588: Object[] selected = tokenList.getSelectedValues();
589: CustomizerComponentFactory.RequiredTokenListModel model = (CustomizerComponentFactory.RequiredTokenListModel) reqTokenList
590: .getModel();
591: for (int i = 0; i < selected.length; i++) {
592: model.addToken((String) selected[i]);
593: }
594: if (selected.length > 0) {
595: reqTokenList.clearSelection();
596: reqTokenList.setSelectedValue(selected[0], true);
597: }
598: }
599: reqTokenList.requestFocusInWindow();
600: }//GEN-LAST:event_addToken
601:
602: private void managePlatforms(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_managePlatforms
603: NbPlatformCustomizer.showCustomizer();
604: refreshPlatforms();
605: }//GEN-LAST:event_managePlatforms
606:
607: private void editModuleDependency(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editModuleDependency
608: ModuleDependency origDep = getDepListModel().getDependency(
609: dependencyList.getSelectedIndex());
610: ModuleDependency editedDep = getDepListModel().findEdited(
611: origDep);
612: EditDependencyPanel editPanel = new EditDependencyPanel(
613: editedDep == null ? origDep : editedDep,
614: getProperties().getActivePlatform());
615: DialogDescriptor descriptor = new DialogDescriptor(editPanel,
616: getMessage("CTL_EditModuleDependencyTitle"));
617: descriptor.setHelpCtx(new HelpCtx(EditDependencyPanel.class));
618: Dialog d = DialogDisplayer.getDefault()
619: .createDialog(descriptor);
620: d.setVisible(true);
621: if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
622: getDepListModel().editDependency(origDep,
623: editPanel.getEditedDependency());
624: }
625: d.dispose();
626: dependencyList.requestFocusInWindow();
627: }//GEN-LAST:event_editModuleDependency
628:
629: private void removeModuleDependency(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeModuleDependency
630: getDepListModel().removeDependencies(
631: NbCollections.checkedListByCopy(Arrays
632: .asList(dependencyList.getSelectedValues()),
633: ModuleDependency.class, true));
634: if (dependencyList.getModel().getSize() > 0) {
635: dependencyList.setSelectedIndex(0);
636: }
637: dependencyList.requestFocusInWindow();
638: }//GEN-LAST:event_removeModuleDependency
639:
640: private void addModuleDependency(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addModuleDependency
641: ModuleDependency[] newDeps = AddModulePanel
642: .selectDependencies(getProperties());
643: for (int i = 0; i < newDeps.length; i++) {
644: ModuleDependency dep = newDeps[i];
645: if ("0".equals(dep.getReleaseVersion())) { // #72216 NOI18N
646: getDepListModel().addDependency(
647: new ModuleDependency(dep.getModuleEntry(),
648: "0-1",
649: dep.getSpecificationVersion(), // NOI18N
650: dep.hasCompileDependency(),
651: dep.hasImplementationDepedendency()));
652: } else {
653: getDepListModel().addDependency(dep);
654: }
655: dependencyList.setSelectedValue(dep, true);
656: }
657: dependencyList.requestFocusInWindow();
658: }//GEN-LAST:event_addModuleDependency
659:
660: // Variables declaration - do not modify//GEN-BEGIN:variables
661: private javax.swing.JButton addDepButton;
662: private javax.swing.JButton addLibrary;
663: private javax.swing.JButton addTokenButton;
664: private javax.swing.JPanel depButtonPanel;
665: private javax.swing.JList dependencyList;
666: private javax.swing.JScrollPane dependencySP;
667: private javax.swing.JButton editDepButton;
668: private javax.swing.JButton javaPlatformButton;
669: private javax.swing.JComboBox javaPlatformCombo;
670: private javax.swing.JLabel javaPlatformLabel;
671: private javax.swing.JButton managePlafsButton;
672: private javax.swing.JLabel modDepLabel;
673: private javax.swing.JLabel platform;
674: private javax.swing.JComboBox platformValue;
675: private javax.swing.JPanel platformsPanel;
676: private javax.swing.JButton removeDepButton;
677: private javax.swing.JButton removeTokenButton;
678: private javax.swing.JList reqTokenList;
679: private javax.swing.JScrollPane reqTokenSP;
680: private javax.swing.JLabel reqTokens;
681: private javax.swing.JLabel space1;
682: private javax.swing.JPanel tokenButtonPanel;
683:
684: // End of variables declaration//GEN-END:variables
685:
686: private void initAccessibility() {
687: addTokenButton.getAccessibleContext().setAccessibleDescription(
688: getMessage("ACSD_AddTokenButton"));
689: dependencyList.getAccessibleContext().setAccessibleDescription(
690: getMessage("ACSD_DependencyList"));
691: editDepButton.getAccessibleContext().setAccessibleDescription(
692: getMessage("ACSD_EditDepButton"));
693: removeDepButton.getAccessibleContext()
694: .setAccessibleDescription(
695: getMessage("ACSD_RemoveDepButton"));
696: removeTokenButton.getAccessibleContext()
697: .setAccessibleDescription(
698: getMessage("ACSD_RemoveTokenButton"));
699: addDepButton.getAccessibleContext().setAccessibleDescription(
700: getMessage("ACSD_AddDepButton"));
701: reqTokenList.getAccessibleContext().setAccessibleDescription(
702: getMessage("ACSD_ReqTokenList"));
703: managePlafsButton.getAccessibleContext()
704: .setAccessibleDescription(
705: getMessage("ACSD_ManagePlafsButton"));
706: platformValue.getAccessibleContext().setAccessibleDescription(
707: getMessage("ACSD_PlatformValue"));
708: javaPlatformCombo.getAccessibleContext()
709: .setAccessibleDescription(
710: getMessage("ACSD_JavaPlatformCombo"));
711: javaPlatformButton.getAccessibleContext()
712: .setAccessibleDescription(
713: getMessage("ACSD_JavaPlatformButton"));
714:
715: javaPlatformLabel.getAccessibleContext()
716: .setAccessibleDescription(
717: getMessage("ACSD_JavaPlatformLbl"));
718: platform.getAccessibleContext().setAccessibleDescription(
719: getMessage("ACSD_PlatformLbl"));
720: }
721:
722: }
|