KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > ui > customizer > CustomizerLibraries


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project.ui.customizer;
21
22 import java.awt.BorderLayout JavaDoc;
23 import java.awt.Dialog JavaDoc;
24 import java.awt.Rectangle JavaDoc;
25 import java.awt.event.ActionEvent JavaDoc;
26 import java.awt.event.ActionListener JavaDoc;
27 import java.awt.event.ItemEvent JavaDoc;
28 import java.awt.event.ItemListener JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.util.Arrays JavaDoc;
31 import javax.swing.BorderFactory JavaDoc;
32 import javax.swing.JLabel JavaDoc;
33 import javax.swing.JList JavaDoc;
34 import javax.swing.JPanel JavaDoc;
35 import javax.swing.JScrollPane JavaDoc;
36 import javax.swing.event.ListDataEvent JavaDoc;
37 import javax.swing.event.ListDataListener JavaDoc;
38 import javax.swing.event.ListSelectionListener JavaDoc;
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 /**
54  * Represents <em>Libraries</em> panel in NetBeans Module customizer.
55  *
56  * @author mkrauskopf
57  */

58 public class CustomizerLibraries extends NbPropertyPanel.Single {
59     
60     private static Rectangle JavaDoc lastSize;
61     
62     /** Creates new form CustomizerLibraries */
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 JavaDoc() {
87             public void contentsChanged(ListDataEvent JavaDoc e) { updateEnabled(); }
88             public void intervalAdded(ListDataEvent JavaDoc e) { updateEnabled(); }
89             public void intervalRemoved(ListDataEvent JavaDoc e) { updateEnabled(); }
90         });
91     }
92     
93     private void attachListeners() {
94         platformValue.addItemListener(new ItemListener JavaDoc() {
95             public void itemStateChanged(ItemEvent JavaDoc e) {
96                 if (e.getStateChange() == ItemEvent.SELECTED) {
97                     // set new platform
98
getProperties().setActivePlatform((NbPlatform) platformValue.getSelectedItem());
99                     // refresh dependencies list
100
dependencyList.setModel(getProperties().getDependenciesListModel());
101                     updateEnabled();
102                 }
103             }
104         });
105         dependencyList.addListSelectionListener(new ListSelectionListener JavaDoc() {
106             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc e) {
107                 if (!e.getValueIsAdjusting()) {
108                     updateEnabled();
109                 }
110             }
111         });
112         javaPlatformCombo.addItemListener(new ItemListener JavaDoc() {
113             public void itemStateChanged(ItemEvent JavaDoc e) {
114                 if (e.getStateChange() == ItemEvent.SELECTED) {
115                     // set new platform
116
getProperties().setActiveJavaPlatform((JavaPlatform) javaPlatformCombo.getSelectedItem());
117                 }
118             }
119         });
120         reqTokenList.addListSelectionListener(new ListSelectionListener JavaDoc() {
121             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc 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()); // refresh
136
platformValue.setSelectedItem(getProperties().getActivePlatform());
137         platformValue.requestFocusInWindow();
138     }
139     
140     private void updateEnabled() {
141         // if there is no selection disable edit/remove buttons
142
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                 /* #71631 */ ((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 JavaDoc getMessage(String JavaDoc key) {
159         return NbBundle.getMessage(CustomizerLibraries.class, key);
160     }
161     
162     /** This method is called from within the constructor to
163      * initialize the form.
164      * WARNING: Do NOT modify this code. The content of this method is
165      * always regenerated by the Form Editor.
166      */

167     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
168
private void initComponents() {
169         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
170
171         modDepLabel = new javax.swing.JLabel JavaDoc();
172         depButtonPanel = new javax.swing.JPanel JavaDoc();
173         addDepButton = new javax.swing.JButton JavaDoc();
174         addLibrary = new javax.swing.JButton JavaDoc();
175         removeDepButton = new javax.swing.JButton JavaDoc();
176         space1 = new javax.swing.JLabel JavaDoc();
177         editDepButton = new javax.swing.JButton JavaDoc();
178         dependencySP = new javax.swing.JScrollPane JavaDoc();
179         dependencyList = new javax.swing.JList JavaDoc();
180         platformsPanel = new javax.swing.JPanel JavaDoc();
181         platformValue = org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory.getNbPlatformsComboxBox();
182         platform = new javax.swing.JLabel JavaDoc();
183         managePlafsButton = new javax.swing.JButton JavaDoc();
184         javaPlatformLabel = new javax.swing.JLabel JavaDoc();
185         javaPlatformCombo = new javax.swing.JComboBox JavaDoc();
186         javaPlatformButton = new javax.swing.JButton JavaDoc();
187         reqTokens = new javax.swing.JLabel JavaDoc();
188         reqTokenSP = new javax.swing.JScrollPane JavaDoc();
189         reqTokenList = new javax.swing.JList JavaDoc();
190         tokenButtonPanel = new javax.swing.JPanel JavaDoc();
191         addTokenButton = new javax.swing.JButton JavaDoc();
192         removeTokenButton = new javax.swing.JButton JavaDoc();
193
194         setLayout(new java.awt.GridBagLayout JavaDoc());
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 JavaDoc();
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 JavaDoc(18, 0, 2, 0);
204         add(modDepLabel, gridBagConstraints);
205
206         depButtonPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
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 JavaDoc() {
210             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
211                 addModuleDependency(evt);
212             }
213         });
214
215         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc() {
221             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
222                 addLibraryActionPerformed(evt);
223             }
224         });
225
226         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
227         gridBagConstraints.gridx = 0;
228         gridBagConstraints.gridy = 1;
229         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc() {
234             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
235                 removeModuleDependency(evt);
236             }
237         });
238
239         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
240         gridBagConstraints.gridx = 0;
241         gridBagConstraints.gridy = 2;
242         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
243         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 0, 0, 0);
244         depButtonPanel.add(removeDepButton, gridBagConstraints);
245
246         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc() {
254             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
255                 editModuleDependency(evt);
256             }
257         });
258
259         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
260         gridBagConstraints.gridx = 0;
261         gridBagConstraints.gridy = 3;
262         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
263         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 0, 0);
264         depButtonPanel.add(editDepButton, gridBagConstraints);
265
266         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc();
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 JavaDoc(0, 0, 0, 12);
281         add(dependencySP, gridBagConstraints);
282
283         platformsPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
284
285         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
297         gridBagConstraints.gridx = 0;
298         gridBagConstraints.gridy = 1;
299         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
300         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc() {
305             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
306                 managePlatforms(evt);
307             }
308         });
309
310         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
321         gridBagConstraints.gridx = 0;
322         gridBagConstraints.gridy = 0;
323         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
324         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
325         platformsPanel.add(javaPlatformLabel, gridBagConstraints);
326
327         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc() {
338             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
339                 javaPlatformButtonActionPerformed(evt);
340             }
341         });
342
343         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc();
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 JavaDoc();
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 JavaDoc(18, 0, 0, 12);
365         add(reqTokens, gridBagConstraints);
366
367         reqTokenSP.setViewportView(reqTokenList);
368
369         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(0, 0, 0, 12);
375         add(reqTokenSP, gridBagConstraints);
376
377         tokenButtonPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
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 JavaDoc() {
381             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
382                 addToken(evt);
383             }
384         });
385
386         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc() {
395             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
396                 removeToken(evt);
397             }
398         });
399
400         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(2, 0, 0, 0);
406         tokenButtonPanel.add(removeTokenButton, gridBagConstraints);
407
408         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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     }// </editor-fold>//GEN-END:initComponents
416

417     private void addLibraryActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_addLibraryActionPerformed
418
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 JavaDoc e) {
426                 assert false : e;
427             }
428         }
429     }//GEN-LAST:event_addLibraryActionPerformed
430

431     private void javaPlatformButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_javaPlatformButtonActionPerformed
432
PlatformsCustomizer.showCustomizer((JavaPlatform) javaPlatformCombo.getSelectedItem());
433         refreshJavaPlatforms();
434     }//GEN-LAST:event_javaPlatformButtonActionPerformed
435

436     private void removeToken(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_removeToken
437
CustomizerComponentFactory.RequiredTokenListModel model = (CustomizerComponentFactory.RequiredTokenListModel) reqTokenList.getModel();
438         Object JavaDoc[] selected = reqTokenList.getSelectedValues();
439         for (int i = 0; i < selected.length; i++) {
440             model.removeToken((String JavaDoc) selected[i]);
441         }
442         if (model.getSize() > 0) {
443             reqTokenList.setSelectedIndex(0);
444         }
445         reqTokenList.requestFocusInWindow();
446     }//GEN-LAST:event_removeToken
447

448     private void addToken(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_addToken
449
// create add panel
450
JPanel JavaDoc panel = new JPanel JavaDoc();
451         panel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
452         panel.setLayout(new BorderLayout JavaDoc(0, 2));
453         JList JavaDoc tokenList = new JList JavaDoc(getProperties().getAllTokens());
454         JScrollPane JavaDoc tokenListSP = new JScrollPane JavaDoc(tokenList);
455         JLabel JavaDoc provTokensTxt = new JLabel JavaDoc();
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 JavaDoc d = DialogDisplayer.getDefault().createDialog(descriptor);
471         d.setVisible(true);
472         d.dispose();
473         if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
474             Object JavaDoc[] selected = tokenList.getSelectedValues();
475             CustomizerComponentFactory.RequiredTokenListModel model = (CustomizerComponentFactory.RequiredTokenListModel) reqTokenList.getModel();
476             for (int i = 0; i < selected.length; i++) {
477                 model.addToken((String JavaDoc) selected[i]);
478             }
479             if (selected.length > 0) {
480                 reqTokenList.clearSelection();
481                 reqTokenList.setSelectedValue(selected[0], true);
482             }
483         }
484         reqTokenList.requestFocusInWindow();
485     }//GEN-LAST:event_addToken
486

487     private void managePlatforms(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_managePlatforms
488
NbPlatformCustomizer.showCustomizer();
489         refreshPlatforms();
490     }//GEN-LAST:event_managePlatforms
491

492     private void editModuleDependency(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_editModuleDependency
493
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 JavaDoc 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     }//GEN-LAST:event_editModuleDependency
509

510     private void removeModuleDependency(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_removeModuleDependency
511
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     }//GEN-LAST:event_removeModuleDependency
517

518     private void addModuleDependency(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_addModuleDependency
519
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 JavaDoc[0]);
524         final Dialog JavaDoc d = DialogDisplayer.getDefault().createDialog(descriptor);
525         descriptor.setButtonListener(new ActionListener JavaDoc() {
526             public void actionPerformed(ActionEvent JavaDoc 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())) { // #72216 NOI18N
546
getDepListModel().addDependency(new ModuleDependency(
547                             dep.getModuleEntry(), "0-1", dep.getSpecificationVersion(), // NOI18N
548
dep.hasCompileDependency(), dep.hasImplementationDepedendency()));
549                 } else {
550                     getDepListModel().addDependency(dep);
551                 }
552                 dependencyList.setSelectedValue(dep, true);
553             }
554         }
555         dependencyList.requestFocusInWindow();
556     }//GEN-LAST:event_addModuleDependency
557

558     // Variables declaration - do not modify//GEN-BEGIN:variables
559
private javax.swing.JButton JavaDoc addDepButton;
560     private javax.swing.JButton JavaDoc addLibrary;
561     private javax.swing.JButton JavaDoc addTokenButton;
562     private javax.swing.JPanel JavaDoc depButtonPanel;
563     private javax.swing.JList JavaDoc dependencyList;
564     private javax.swing.JScrollPane JavaDoc dependencySP;
565     private javax.swing.JButton JavaDoc editDepButton;
566     private javax.swing.JButton JavaDoc javaPlatformButton;
567     private javax.swing.JComboBox JavaDoc javaPlatformCombo;
568     private javax.swing.JLabel JavaDoc javaPlatformLabel;
569     private javax.swing.JButton JavaDoc managePlafsButton;
570     private javax.swing.JLabel JavaDoc modDepLabel;
571     private javax.swing.JLabel JavaDoc platform;
572     private javax.swing.JComboBox JavaDoc platformValue;
573     private javax.swing.JPanel JavaDoc platformsPanel;
574     private javax.swing.JButton JavaDoc removeDepButton;
575     private javax.swing.JButton JavaDoc removeTokenButton;
576     private javax.swing.JList JavaDoc reqTokenList;
577     private javax.swing.JScrollPane JavaDoc reqTokenSP;
578     private javax.swing.JLabel JavaDoc reqTokens;
579     private javax.swing.JLabel JavaDoc space1;
580     private javax.swing.JPanel JavaDoc tokenButtonPanel;
581     // End of variables declaration//GEN-END:variables
582

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