KickJava   Java API By Example, From Geeks To Geeks.

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


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.Dialog JavaDoc;
23 import java.awt.Dimension JavaDoc;
24 import java.awt.event.KeyEvent JavaDoc;
25 import java.awt.event.MouseAdapter JavaDoc;
26 import java.awt.event.MouseEvent JavaDoc;
27 import java.beans.PropertyChangeEvent JavaDoc;
28 import java.beans.PropertyChangeListener JavaDoc;
29 import javax.swing.AbstractAction JavaDoc;
30 import javax.swing.Action JavaDoc;
31 import javax.swing.JButton JavaDoc;
32 import javax.swing.JCheckBox JavaDoc;
33 import javax.swing.KeyStroke JavaDoc;
34 import javax.swing.ListSelectionModel JavaDoc;
35 import javax.swing.event.DocumentEvent JavaDoc;
36 import javax.swing.event.ListSelectionListener JavaDoc;
37 import org.netbeans.modules.apisupport.project.ui.UIUtil;
38 import org.netbeans.spi.project.ui.support.ProjectCustomizer;
39 import org.openide.DialogDescriptor;
40 import org.openide.DialogDisplayer;
41 import org.openide.util.HelpCtx;
42 import org.openide.util.NbBundle;
43
44 /**
45  * Represents <em>Versioning</em> panel in Netbeans Module customizer.
46  *
47  * @author Martin Krauskopf
48  */

49 final class CustomizerVersioning extends NbPropertyPanel.Single {
50     
51     private static final int CHECKBOX_WIDTH = new JCheckBox JavaDoc().getWidth();
52     
53     private boolean lastAppImplChecked;
54     
55     private Dimension JavaDoc lastSize;
56     private ProjectCustomizer.Category cat;
57     BasicCustomizer.SubCategoryProvider provider;
58     
59     
60     /** Creates new form CustomizerVersioning */
61     CustomizerVersioning(SingleModuleProperties props, ProjectCustomizer.Category cat, BasicCustomizer.SubCategoryProvider prov) {
62         super(props, CustomizerVersioning.class);
63         this.cat = cat;
64         initComponents();
65         initAccesibility();
66         initPublicPackageTable();
67         refresh();
68         attachListeners();
69         checkValidity();
70         provider = prov;
71     }
72     
73     public void addNotify() {
74         super.addNotify();
75         if (provider != null) {
76             showSubCategory(provider);
77             //do preselection on first showing the panel only..
78
provider = null;
79         }
80     }
81     
82     void refresh() {
83         UIUtil.setText(majorRelVerValue, getProperties().getMajorReleaseVersion());
84         UIUtil.setText(tokensValue, getProperties().getProvidedTokens());
85         String JavaDoc specVersion = getProperties().getSpecificationVersion();
86         if (null == specVersion || "".equals(specVersion)) { // NOI18N
87
appendImpl.setSelected(true);
88             UIUtil.setText(specificationVerValue, getProperty(SingleModuleProperties.SPEC_VERSION_BASE));
89         } else {
90             UIUtil.setText(specificationVerValue, specVersion);
91         }
92         UIUtil.setText(implVerValue, getProperties().getImplementationVersion());
93         friendsList.setModel(getProperties().getFriendListModel());
94         UIUtil.setText(cnbValue, getProperties().getCodeNameBase());
95         regularMod.setSelected(true);
96         autoloadMod.setSelected(getBooleanProperty(SingleModuleProperties.IS_AUTOLOAD));
97         eagerMod.setSelected(getBooleanProperty(SingleModuleProperties.IS_EAGER));
98         removeFriendButton.setEnabled(false);
99         updateAppendImpl();
100     }
101     
102     private void attachListeners() {
103         implVerValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
104             public void insertUpdate(DocumentEvent JavaDoc e) {
105                 updateAppendImpl();
106             }
107         });
108         friendsList.addListSelectionListener(new ListSelectionListener JavaDoc() {
109             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc e) {
110                 if (!e.getValueIsAdjusting()) {
111                     removeFriendButton.setEnabled(friendsList.getSelectedIndex() != -1);
112                 }
113             }
114         });
115         majorRelVerValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
116             public void insertUpdate(DocumentEvent JavaDoc e) {
117                 checkValidity();
118             }
119         });
120         implVerValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
121             public void insertUpdate(DocumentEvent JavaDoc e) {
122                 updateAppendImpl();
123                 checkValidity();
124             }
125         });
126     }
127     
128     boolean isCustomizerValid() {
129         return checkMajorReleaseVersion();
130     }
131     
132     private boolean checkMajorReleaseVersion() {
133         boolean valid;
134         String JavaDoc mrv = majorRelVerValue.getText().trim();
135         try {
136             valid = (mrv.length() == 0 || Integer.parseInt(mrv) >= 0);
137         } catch (NumberFormatException JavaDoc nfe) {
138             valid = false;
139         }
140         return valid;
141     }
142     
143     protected void checkValidity() {
144         exportOnlyToFriend.setSelected(getFriendModel().getSize() > 0);
145         // check major release version
146
if (!checkMajorReleaseVersion()) {
147             cat.setErrorMessage(getMessage("MSG_MajorReleaseVersionIsInvalid")); // NOI18N
148
cat.setValid(true);
149         } else if (exportOnlyToFriend.isSelected() && getPublicPackagesModel().getSelectedPackages().length < 1) {
150             cat.setErrorMessage(getMessage("MSG_PublicPackageMustBeSelected"));
151             cat.setValid(false);
152         } else if (implVerValue.getText().matches(".*[^0-9].*")) { // NOI18N
153
cat.setErrorMessage(getMessage("MSG_integer_impl_version_recommended"));
154             cat.setValid(true);
155         } else {
156             cat.setErrorMessage(null);
157             cat.setValid(true);
158         }
159     }
160     
161     private void initPublicPackageTable() {
162         publicPkgsTable.setModel(getProperties().getPublicPackagesModel());
163         publicPkgsTable.getColumnModel().getColumn(0).setMaxWidth(CHECKBOX_WIDTH + 20);
164         publicPkgsTable.setRowHeight(publicPkgsTable.getFontMetrics(publicPkgsTable.getFont()).getHeight() +
165                 (2 * publicPkgsTable.getRowMargin()));
166         publicPkgsTable.setTableHeader(null);
167         publicPkgsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
168         publicPkgsSP.getViewport().setBackground(publicPkgsTable.getBackground());
169         final Action JavaDoc switchAction = new AbstractAction JavaDoc() {
170             public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
171                 int row = publicPkgsTable.getSelectedRow();
172                 if (row == -1) {
173                     // Nothing selected; e.g. user has tabbed into the table but not pressed Down key.
174
return;
175                 }
176                 Boolean JavaDoc b = (Boolean JavaDoc) publicPkgsTable.
177                         getValueAt(row, 0);
178                 publicPkgsTable.setValueAt(Boolean.valueOf(!b.booleanValue()),
179                         row, 0);
180                 checkForm();
181             }
182         };
183         publicPkgsTable.addMouseListener(new MouseAdapter JavaDoc() {
184             public void mouseClicked(MouseEvent JavaDoc e) {
185                 switchAction.actionPerformed(null);
186             }
187         });
188         publicPkgsTable.getInputMap().put(
189                 KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "startEditing"); // NOI18N
190
publicPkgsTable.getActionMap().put("startEditing", switchAction); // NOI18N
191
}
192     
193     private void updateAppendImpl() {
194         boolean isImplVerFiled = !"".equals(implVerValue.getText().trim()); // NOI18N
195
boolean shouldEnable = isImplVerFiled || getProperties().dependingOnImplDependency();
196         if (shouldEnable && !appendImpl.isEnabled()) {
197             appendImpl.setEnabled(true);
198             appendImpl.setSelected(lastAppImplChecked);
199         } else if (!shouldEnable && appendImpl.isEnabled()) {
200             appendImpl.setEnabled(false);
201             lastAppImplChecked = appendImpl.isSelected();
202             appendImpl.setSelected(false);
203         }
204     }
205     
206     public void store() {
207         getProperties().setMajorReleaseVersion(majorRelVerValue.getText().trim());
208         String JavaDoc specVer = specificationVerValue.getText().trim();
209         if (appendImpl.isSelected()) {
210             getProperties().setSpecificationVersion(""); // NOI18N
211
setProperty(SingleModuleProperties.SPEC_VERSION_BASE, specVer);
212         } else {
213             getProperties().setSpecificationVersion(specVer);
214             setProperty(SingleModuleProperties.SPEC_VERSION_BASE, ""); // NOI18N
215
}
216         getProperties().setImplementationVersion(implVerValue.getText().trim());
217         getProperties().setProvidedTokens(tokensValue.getText().trim());
218         setBooleanProperty(SingleModuleProperties.IS_AUTOLOAD, autoloadMod.isSelected());
219         setBooleanProperty(SingleModuleProperties.IS_EAGER, eagerMod.isSelected());
220     }
221     
222     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
223         String JavaDoc pName = evt.getPropertyName();
224         if (SingleModuleProperties.DEPENDENCIES_PROPERTY == pName) {
225             updateAppendImpl();
226         } else if (ModuleProperties.PROPERTIES_REFRESHED == pName) {
227             refresh();
228             checkForm();
229         }
230     }
231     
232     private CustomizerComponentFactory.FriendListModel getFriendModel() {
233         return (CustomizerComponentFactory.FriendListModel) friendsList.getModel();
234     }
235     
236     private CustomizerComponentFactory.PublicPackagesTableModel getPublicPackagesModel() {
237         return (CustomizerComponentFactory.PublicPackagesTableModel) publicPkgsTable.getModel();
238     }
239     
240     /** This method is called from within the constructor to
241      * initialize the form.
242      * WARNING: Do NOT modify this code. The content of this method is
243      * always regenerated by the Form Editor.
244      */

245     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
246
private void initComponents() {
247         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
248
249         moduleTypeGroup = new javax.swing.ButtonGroup JavaDoc();
250         cnb = new javax.swing.JLabel JavaDoc();
251         cnbValue = new javax.swing.JTextField JavaDoc();
252         majorRelVer = new javax.swing.JLabel JavaDoc();
253         majorRelVerValue = new javax.swing.JTextField JavaDoc();
254         specificationVer = new javax.swing.JLabel JavaDoc();
255         specificationVerValue = new javax.swing.JTextField JavaDoc();
256         implVer = new javax.swing.JLabel JavaDoc();
257         implVerValue = new javax.swing.JTextField JavaDoc();
258         tokens = new javax.swing.JLabel JavaDoc();
259         tokensValue = new javax.swing.JTextField JavaDoc();
260         appendImpl = new javax.swing.JCheckBox JavaDoc();
261         publicPkgs = new javax.swing.JLabel JavaDoc();
262         publicPkgsSP = new javax.swing.JScrollPane JavaDoc();
263         publicPkgsTable = new javax.swing.JTable JavaDoc();
264         bottomPanel = new javax.swing.JPanel JavaDoc();
265         buttonPanel = new javax.swing.JPanel JavaDoc();
266         addFriendButton = new javax.swing.JButton JavaDoc();
267         removeFriendButton = new javax.swing.JButton JavaDoc();
268         filler1 = new javax.swing.JLabel JavaDoc();
269         friendsSP = new javax.swing.JScrollPane JavaDoc();
270         friendsList = new javax.swing.JList JavaDoc();
271         exportOnlyToFriend = new javax.swing.JCheckBox JavaDoc();
272         typePanel = new javax.swing.JPanel JavaDoc();
273         regularMod = new javax.swing.JRadioButton JavaDoc();
274         autoloadMod = new javax.swing.JRadioButton JavaDoc();
275         eagerMod = new javax.swing.JRadioButton JavaDoc();
276         typeTxt = new javax.swing.JLabel JavaDoc();
277
278         setLayout(new java.awt.GridBagLayout JavaDoc());
279
280         cnb.setLabelFor(cnbValue);
281         org.openide.awt.Mnemonics.setLocalizedText(cnb, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_CNB"));
282         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
283         gridBagConstraints.gridx = 0;
284         gridBagConstraints.gridy = 0;
285         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
286         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
287         add(cnb, gridBagConstraints);
288
289         cnbValue.setEditable(false);
290         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
291         gridBagConstraints.gridx = 1;
292         gridBagConstraints.gridy = 0;
293         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
294         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
295         gridBagConstraints.weightx = 1.0;
296         add(cnbValue, gridBagConstraints);
297
298         majorRelVer.setLabelFor(majorRelVerValue);
299         org.openide.awt.Mnemonics.setLocalizedText(majorRelVer, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_MajorReleaseVersion"));
300         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
301         gridBagConstraints.gridx = 0;
302         gridBagConstraints.gridy = 1;
303         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
304         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
305         add(majorRelVer, gridBagConstraints);
306
307         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
308         gridBagConstraints.gridx = 1;
309         gridBagConstraints.gridy = 1;
310         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
311         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
312         gridBagConstraints.weightx = 1.0;
313         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
314         add(majorRelVerValue, gridBagConstraints);
315
316         specificationVer.setLabelFor(specificationVerValue);
317         org.openide.awt.Mnemonics.setLocalizedText(specificationVer, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_SpecificationVersion"));
318         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
319         gridBagConstraints.gridx = 0;
320         gridBagConstraints.gridy = 2;
321         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
322         gridBagConstraints.insets = new java.awt.Insets JavaDoc(24, 0, 0, 12);
323         add(specificationVer, gridBagConstraints);
324
325         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
326         gridBagConstraints.gridx = 1;
327         gridBagConstraints.gridy = 2;
328         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
329         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
330         gridBagConstraints.weightx = 1.0;
331         gridBagConstraints.insets = new java.awt.Insets JavaDoc(24, 0, 0, 0);
332         add(specificationVerValue, gridBagConstraints);
333
334         implVer.setLabelFor(implVerValue);
335         org.openide.awt.Mnemonics.setLocalizedText(implVer, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_ImplementationVersion"));
336         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
337         gridBagConstraints.gridx = 0;
338         gridBagConstraints.gridy = 4;
339         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
340         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
341         add(implVer, gridBagConstraints);
342
343         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
344         gridBagConstraints.gridx = 1;
345         gridBagConstraints.gridy = 4;
346         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
347         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
348         gridBagConstraints.weightx = 1.0;
349         add(implVerValue, gridBagConstraints);
350
351         tokens.setLabelFor(tokensValue);
352         org.openide.awt.Mnemonics.setLocalizedText(tokens, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_ProvidedTokens"));
353         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
354         gridBagConstraints.gridx = 0;
355         gridBagConstraints.gridy = 12;
356         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
357         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 0, 12);
358         add(tokens, gridBagConstraints);
359
360         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
361         gridBagConstraints.gridx = 1;
362         gridBagConstraints.gridy = 12;
363         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
364         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
365         gridBagConstraints.weightx = 1.0;
366         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 0, 0);
367         add(tokensValue, gridBagConstraints);
368
369         org.openide.awt.Mnemonics.setLocalizedText(appendImpl, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_AppendImplementation"));
370         appendImpl.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
371         appendImpl.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
372         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
373         gridBagConstraints.gridx = 0;
374         gridBagConstraints.gridy = 3;
375         gridBagConstraints.gridwidth = 2;
376         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
377         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 6, 0);
378         add(appendImpl, gridBagConstraints);
379
380         publicPkgs.setLabelFor(publicPkgsTable);
381         org.openide.awt.Mnemonics.setLocalizedText(publicPkgs, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_PublicPackages"));
382         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
383         gridBagConstraints.gridx = 0;
384         gridBagConstraints.gridy = 8;
385         gridBagConstraints.gridwidth = 2;
386         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
387         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 2, 12);
388         add(publicPkgs, gridBagConstraints);
389
390         publicPkgsTable.setShowHorizontalLines(false);
391         publicPkgsSP.setViewportView(publicPkgsTable);
392
393         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
394         gridBagConstraints.gridx = 0;
395         gridBagConstraints.gridy = 9;
396         gridBagConstraints.gridwidth = 2;
397         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
398         gridBagConstraints.weighty = 0.8;
399         add(publicPkgsSP, gridBagConstraints);
400
401         bottomPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
402
403         buttonPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
404
405         org.openide.awt.Mnemonics.setLocalizedText(addFriendButton, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_AddButton"));
406         addFriendButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
407             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
408                 addFriend(evt);
409             }
410         });
411
412         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
413         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
414         buttonPanel.add(addFriendButton, gridBagConstraints);
415
416         org.openide.awt.Mnemonics.setLocalizedText(removeFriendButton, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_RemoveButton"));
417         removeFriendButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
418             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
419                 removeFriend(evt);
420             }
421         });
422
423         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
424         gridBagConstraints.gridx = 0;
425         gridBagConstraints.gridy = 1;
426         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
427         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 0, 0, 0);
428         buttonPanel.add(removeFriendButton, gridBagConstraints);
429
430         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
431         gridBagConstraints.gridx = 0;
432         gridBagConstraints.gridy = 2;
433         gridBagConstraints.weighty = 1.0;
434         buttonPanel.add(filler1, gridBagConstraints);
435
436         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
437         gridBagConstraints.gridx = 1;
438         gridBagConstraints.gridy = 0;
439         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
440         bottomPanel.add(buttonPanel, gridBagConstraints);
441
442         friendsSP.setViewportView(friendsList);
443
444         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
445         gridBagConstraints.gridx = 0;
446         gridBagConstraints.gridy = 0;
447         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
448         gridBagConstraints.weightx = 1.0;
449         gridBagConstraints.weighty = 1.0;
450         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
451         bottomPanel.add(friendsSP, gridBagConstraints);
452
453         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
454         gridBagConstraints.gridx = 0;
455         gridBagConstraints.gridy = 11;
456         gridBagConstraints.gridwidth = 2;
457         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
458         gridBagConstraints.weighty = 0.2;
459         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 0, 0, 0);
460         add(bottomPanel, gridBagConstraints);
461
462         org.openide.awt.Mnemonics.setLocalizedText(exportOnlyToFriend, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_ExportOnlyToFriends"));
463         exportOnlyToFriend.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
464         exportOnlyToFriend.setEnabled(false);
465         exportOnlyToFriend.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
466         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
467         gridBagConstraints.gridx = 0;
468         gridBagConstraints.gridy = 10;
469         gridBagConstraints.gridwidth = 2;
470         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
471         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 0, 12);
472         add(exportOnlyToFriend, gridBagConstraints);
473
474         typePanel.setLayout(new java.awt.GridBagLayout JavaDoc());
475
476         moduleTypeGroup.add(regularMod);
477         regularMod.setSelected(true);
478         org.openide.awt.Mnemonics.setLocalizedText(regularMod, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_RegularModule"));
479         regularMod.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
480         regularMod.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
481         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
482         gridBagConstraints.gridx = 1;
483         gridBagConstraints.gridy = 0;
484         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
485         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 0);
486         typePanel.add(regularMod, gridBagConstraints);
487
488         moduleTypeGroup.add(autoloadMod);
489         org.openide.awt.Mnemonics.setLocalizedText(autoloadMod, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_AutoloadModule"));
490         autoloadMod.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
491         autoloadMod.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
492         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
493         gridBagConstraints.gridx = 2;
494         gridBagConstraints.gridy = 0;
495         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
496         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 0);
497         typePanel.add(autoloadMod, gridBagConstraints);
498
499         moduleTypeGroup.add(eagerMod);
500         org.openide.awt.Mnemonics.setLocalizedText(eagerMod, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "CTL_EagerModule"));
501         eagerMod.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
502         eagerMod.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
503         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
504         gridBagConstraints.gridx = 3;
505         gridBagConstraints.gridy = 0;
506         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
507         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
508         gridBagConstraints.weightx = 1.0;
509         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 0);
510         typePanel.add(eagerMod, gridBagConstraints);
511
512         org.openide.awt.Mnemonics.setLocalizedText(typeTxt, org.openide.util.NbBundle.getMessage(CustomizerVersioning.class, "LBL_ModuleType"));
513         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
514         gridBagConstraints.gridx = 0;
515         gridBagConstraints.gridy = 0;
516         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
517         typePanel.add(typeTxt, gridBagConstraints);
518
519         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
520         gridBagConstraints.gridx = 0;
521         gridBagConstraints.gridy = 5;
522         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
523         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
524         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 0, 0);
525         add(typePanel, gridBagConstraints);
526
527     }// </editor-fold>//GEN-END:initComponents
528

529     private void removeFriend(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_removeFriend
530
getFriendModel().removeFriend((String JavaDoc) friendsList.getSelectedValue());
531         if (getFriendModel().getSize() > 0) {
532             friendsList.setSelectedIndex(0);
533         }
534         friendsList.requestFocus();
535         checkForm();
536     }//GEN-LAST:event_removeFriend
537

538     private void addFriend(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_addFriend
539
AddFriendPanel addFriend = new AddFriendPanel(getProperties());
540         DialogDescriptor descriptor = new DialogDescriptor(addFriend, getMessage("CTL_AddNewFriend_Title"));
541         descriptor.setHelpCtx(new HelpCtx(AddFriendPanel.class));
542         final JButton JavaDoc okButton = new JButton JavaDoc(getMessage("CTL_OK"));
543         JButton JavaDoc cancel = new JButton JavaDoc(getMessage("CTL_Cancel"));
544         okButton.setEnabled(false);
545         Object JavaDoc[] options = new Object JavaDoc[] { okButton , cancel };
546         descriptor.setOptions(options);
547         descriptor.setClosingOptions(options);
548         final Dialog JavaDoc d = DialogDisplayer.getDefault().createDialog(descriptor);
549         addFriend.addPropertyChangeListener(new PropertyChangeListener JavaDoc() {
550             public void propertyChange(PropertyChangeEvent JavaDoc pce) {
551                 if (pce.getPropertyName() == AddFriendPanel.VALID_PROPERTY) {
552                     okButton.setEnabled(((Boolean JavaDoc) pce.getNewValue()).booleanValue());
553                 }
554             }
555         });
556         d.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CTL_AddNewFriend_Title"));
557         okButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CTL_OK"));
558         cancel.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CTL_Cancel"));
559         if (lastSize != null) {
560             d.setSize(lastSize);
561         } else {
562             d.pack();
563         }
564         d.setLocationRelativeTo(null);
565         d.setVisible(true);
566         lastSize = d.getSize();
567         if (descriptor.getValue().equals(okButton)) {
568             String JavaDoc newFriendCNB = addFriend.getFriendCNB();
569             getFriendModel().addFriend(newFriendCNB);
570             friendsList.setSelectedValue(newFriendCNB, true);
571         }
572         d.dispose();
573         friendsList.requestFocus();
574         checkForm();
575     }//GEN-LAST:event_addFriend
576

577     private String JavaDoc getMessage(String JavaDoc key) {
578         return NbBundle.getMessage(CustomizerVersioning.class, key);
579     }
580     
581     public void showSubCategory(BasicCustomizer.SubCategoryProvider prov) {
582         if (CustomizerProviderImpl.CATEGORY_VERSIONING.equals(prov.getCategory()) &&
583             CustomizerProviderImpl.SUBCATEGORY_VERSIONING_PUBLIC_PACKAGES.equals(prov.getSubcategory())) {
584             publicPkgsTable.requestFocus();
585             /* XXX does not work quite right under Ocean; have to press TAB once; this does not help:
586             if (publicPkgsTable.getModel().getRowCount() > 0) {
587                 publicPkgsTable.setEditingRow(0);
588                 publicPkgsTable.setEditingColumn(1);
589             }
590              */

591         }
592     }
593     
594     // Variables declaration - do not modify//GEN-BEGIN:variables
595
private javax.swing.JButton JavaDoc addFriendButton;
596     private javax.swing.JCheckBox JavaDoc appendImpl;
597     private javax.swing.JRadioButton JavaDoc autoloadMod;
598     private javax.swing.JPanel JavaDoc bottomPanel;
599     private javax.swing.JPanel JavaDoc buttonPanel;
600     private javax.swing.JLabel JavaDoc cnb;
601     private javax.swing.JTextField JavaDoc cnbValue;
602     private javax.swing.JRadioButton JavaDoc eagerMod;
603     private javax.swing.JCheckBox JavaDoc exportOnlyToFriend;
604     private javax.swing.JLabel JavaDoc filler1;
605     private javax.swing.JList JavaDoc friendsList;
606     private javax.swing.JScrollPane JavaDoc friendsSP;
607     private javax.swing.JLabel JavaDoc implVer;
608     private javax.swing.JTextField JavaDoc implVerValue;
609     private javax.swing.JLabel JavaDoc majorRelVer;
610     private javax.swing.JTextField JavaDoc majorRelVerValue;
611     private javax.swing.ButtonGroup JavaDoc moduleTypeGroup;
612     private javax.swing.JLabel JavaDoc publicPkgs;
613     private javax.swing.JScrollPane JavaDoc publicPkgsSP;
614     private javax.swing.JTable JavaDoc publicPkgsTable;
615     private javax.swing.JRadioButton JavaDoc regularMod;
616     private javax.swing.JButton JavaDoc removeFriendButton;
617     private javax.swing.JLabel JavaDoc specificationVer;
618     private javax.swing.JTextField JavaDoc specificationVerValue;
619     private javax.swing.JLabel JavaDoc tokens;
620     private javax.swing.JTextField JavaDoc tokensValue;
621     private javax.swing.JPanel JavaDoc typePanel;
622     private javax.swing.JLabel JavaDoc typeTxt;
623     // End of variables declaration//GEN-END:variables
624

625     private void initAccesibility() {
626         addFriendButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_AddFriendButton"));
627         removeFriendButton.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_RemoveFriendButton"));
628         cnbValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CnbValue"));
629         majorRelVerValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_MajorRelVerValue"));
630         specificationVerValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_SpecificationVerValuea"));
631         appendImpl.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_AppendImpl"));
632         implVerValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_ImplVerValue"));
633         regularMod.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_RegularMod"));
634         autoloadMod.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_AutoloadMod"));
635         eagerMod.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_EagerMod"));
636         publicPkgsTable.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_PublicPkgsTable"));
637         tokensValue.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_TokensValue"));
638     }
639     
640 }
641
Popular Tags