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.Dialog;
045: import java.awt.Dimension;
046: import java.awt.event.KeyEvent;
047: import java.awt.event.MouseAdapter;
048: import java.awt.event.MouseEvent;
049: import java.beans.PropertyChangeEvent;
050: import java.beans.PropertyChangeListener;
051: import javax.swing.AbstractAction;
052: import javax.swing.Action;
053: import javax.swing.JButton;
054: import javax.swing.JCheckBox;
055: import javax.swing.KeyStroke;
056: import javax.swing.ListSelectionModel;
057: import javax.swing.event.DocumentEvent;
058: import javax.swing.event.ListSelectionListener;
059: import org.netbeans.modules.apisupport.project.ui.UIUtil;
060: import org.netbeans.spi.project.ui.support.ProjectCustomizer;
061: import org.openide.DialogDescriptor;
062: import org.openide.DialogDisplayer;
063: import org.openide.util.HelpCtx;
064: import org.openide.util.NbBundle;
065:
066: /**
067: * Represents <em>Versioning</em> panel in Netbeans Module customizer.
068: *
069: * @author Martin Krauskopf
070: */
071: final class CustomizerVersioning extends NbPropertyPanel.Single {
072:
073: private static final int CHECKBOX_WIDTH = new JCheckBox()
074: .getWidth();
075:
076: private boolean lastAppImplChecked;
077:
078: private Dimension lastSize;
079: BasicCustomizer.SubCategoryProvider provider;
080:
081: /** Creates new form CustomizerVersioning */
082: CustomizerVersioning(SingleModuleProperties props,
083: ProjectCustomizer.Category cat,
084: BasicCustomizer.SubCategoryProvider prov) {
085: super (props, CustomizerVersioning.class, cat);
086: initComponents();
087: initAccesibility();
088: initPublicPackageTable();
089: refresh();
090: attachListeners();
091: checkValidity();
092: provider = prov;
093: }
094:
095: @Override
096: public void addNotify() {
097: super .addNotify();
098: if (provider != null) {
099: showSubCategory(provider);
100: //do preselection on first showing the panel only..
101: provider = null;
102: }
103: }
104:
105: void refresh() {
106: UIUtil.setText(majorRelVerValue, getProperties()
107: .getMajorReleaseVersion());
108: UIUtil
109: .setText(tokensValue, getProperties()
110: .getProvidedTokens());
111: String specVersion = getProperties().getSpecificationVersion();
112: if (null == specVersion || "".equals(specVersion)) { // NOI18N
113: appendImpl.setSelected(true);
114: UIUtil
115: .setText(
116: specificationVerValue,
117: getProperty(SingleModuleProperties.SPEC_VERSION_BASE));
118: } else {
119: UIUtil.setText(specificationVerValue, specVersion);
120: }
121: UIUtil.setText(implVerValue, getProperties()
122: .getImplementationVersion());
123: friendsList.setModel(getProperties().getFriendListModel());
124: UIUtil.setText(cnbValue, getProperties().getCodeNameBase());
125: regularMod.setSelected(true);
126: autoloadMod
127: .setSelected(getBooleanProperty(SingleModuleProperties.IS_AUTOLOAD));
128: eagerMod
129: .setSelected(getBooleanProperty(SingleModuleProperties.IS_EAGER));
130: removeFriendButton.setEnabled(false);
131: updateAppendImpl();
132: }
133:
134: private void attachListeners() {
135: implVerValue.getDocument().addDocumentListener(
136: new UIUtil.DocumentAdapter() {
137: public void insertUpdate(DocumentEvent e) {
138: updateAppendImpl();
139: }
140: });
141: friendsList
142: .addListSelectionListener(new ListSelectionListener() {
143: public void valueChanged(
144: javax.swing.event.ListSelectionEvent e) {
145: if (!e.getValueIsAdjusting()) {
146: removeFriendButton.setEnabled(friendsList
147: .getSelectedIndex() != -1);
148: }
149: }
150: });
151: majorRelVerValue.getDocument().addDocumentListener(
152: new UIUtil.DocumentAdapter() {
153: public void insertUpdate(DocumentEvent e) {
154: checkValidity();
155: }
156: });
157: implVerValue.getDocument().addDocumentListener(
158: new UIUtil.DocumentAdapter() {
159: public void insertUpdate(DocumentEvent e) {
160: updateAppendImpl();
161: checkValidity();
162: }
163: });
164: }
165:
166: boolean isCustomizerValid() {
167: return checkMajorReleaseVersion();
168: }
169:
170: private boolean checkMajorReleaseVersion() {
171: boolean valid;
172: String mrv = majorRelVerValue.getText().trim();
173: try {
174: valid = (mrv.length() == 0 || Integer.parseInt(mrv) >= 0);
175: } catch (NumberFormatException nfe) {
176: valid = false;
177: }
178: return valid;
179: }
180:
181: protected void checkValidity() {
182: exportOnlyToFriend.setSelected(getFriendModel().getSize() > 0);
183: // check major release version
184: if (!checkMajorReleaseVersion()) {
185: category
186: .setErrorMessage(getMessage("MSG_MajorReleaseVersionIsInvalid")); // NOI18N
187: category.setValid(true);
188: } else if (exportOnlyToFriend.isSelected()
189: && getPublicPackagesModel().getSelectedPackages().length < 1) {
190: category
191: .setErrorMessage(getMessage("MSG_PublicPackageMustBeSelected"));
192: category.setValid(false);
193: } else if (implVerValue.getText().matches(".*[^0-9].*")) { // NOI18N
194: category
195: .setErrorMessage(getMessage("MSG_integer_impl_version_recommended"));
196: category.setValid(true);
197: } else {
198: category.setErrorMessage(null);
199: category.setValid(true);
200: }
201: }
202:
203: private void initPublicPackageTable() {
204: publicPkgsTable.setModel(getProperties()
205: .getPublicPackagesModel());
206: publicPkgsTable.getColumnModel().getColumn(0).setMaxWidth(
207: CHECKBOX_WIDTH + 20);
208: publicPkgsTable.setRowHeight(publicPkgsTable.getFontMetrics(
209: publicPkgsTable.getFont()).getHeight()
210: + (2 * publicPkgsTable.getRowMargin()));
211: publicPkgsTable.setTableHeader(null);
212: publicPkgsTable.getSelectionModel().setSelectionMode(
213: ListSelectionModel.SINGLE_SELECTION);
214: publicPkgsSP.getViewport().setBackground(
215: publicPkgsTable.getBackground());
216: final Action switchAction = new AbstractAction() {
217: public void actionPerformed(java.awt.event.ActionEvent e) {
218: int row = publicPkgsTable.getSelectedRow();
219: if (row == -1) {
220: // Nothing selected; e.g. user has tabbed into the table but not pressed Down key.
221: return;
222: }
223: Boolean b = (Boolean) publicPkgsTable
224: .getValueAt(row, 0);
225: publicPkgsTable.setValueAt(Boolean.valueOf(!b
226: .booleanValue()), row, 0);
227: checkForm();
228: }
229: };
230: publicPkgsTable.addMouseListener(new MouseAdapter() {
231: public void mouseClicked(MouseEvent e) {
232: switchAction.actionPerformed(null);
233: }
234: });
235: publicPkgsTable.getInputMap().put(
236: KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0),
237: "startEditing"); // NOI18N
238: publicPkgsTable.getActionMap()
239: .put("startEditing", switchAction); // NOI18N
240: }
241:
242: private void updateAppendImpl() {
243: boolean isImplVerFiled = !"".equals(implVerValue.getText()
244: .trim()); // NOI18N
245: boolean shouldEnable = isImplVerFiled
246: || getProperties().dependingOnImplDependency();
247: if (shouldEnable && !appendImpl.isEnabled()) {
248: appendImpl.setEnabled(true);
249: appendImpl.setSelected(lastAppImplChecked);
250: } else if (!shouldEnable && appendImpl.isEnabled()) {
251: appendImpl.setEnabled(false);
252: lastAppImplChecked = appendImpl.isSelected();
253: appendImpl.setSelected(false);
254: }
255: }
256:
257: @Override
258: public void store() {
259: getProperties().setMajorReleaseVersion(
260: majorRelVerValue.getText().trim());
261: String specVer = specificationVerValue.getText().trim();
262: if (appendImpl.isSelected()) {
263: getProperties().setSpecificationVersion(""); // NOI18N
264: setProperty(SingleModuleProperties.SPEC_VERSION_BASE,
265: specVer);
266: } else {
267: getProperties().setSpecificationVersion(specVer);
268: setProperty(SingleModuleProperties.SPEC_VERSION_BASE, ""); // NOI18N
269: }
270: getProperties().setImplementationVersion(
271: implVerValue.getText().trim());
272: getProperties().setProvidedTokens(tokensValue.getText().trim());
273: setBooleanProperty(SingleModuleProperties.IS_AUTOLOAD,
274: autoloadMod.isSelected());
275: setBooleanProperty(SingleModuleProperties.IS_EAGER, eagerMod
276: .isSelected());
277: }
278:
279: @Override
280: public void propertyChange(PropertyChangeEvent evt) {
281: String pName = evt.getPropertyName();
282: if (SingleModuleProperties.DEPENDENCIES_PROPERTY == pName) {
283: updateAppendImpl();
284: } else if (ModuleProperties.PROPERTIES_REFRESHED == pName) {
285: refresh();
286: checkForm();
287: }
288: }
289:
290: private CustomizerComponentFactory.FriendListModel getFriendModel() {
291: return (CustomizerComponentFactory.FriendListModel) friendsList
292: .getModel();
293: }
294:
295: private CustomizerComponentFactory.PublicPackagesTableModel getPublicPackagesModel() {
296: return (CustomizerComponentFactory.PublicPackagesTableModel) publicPkgsTable
297: .getModel();
298: }
299:
300: /** This method is called from within the constructor to
301: * initialize the form.
302: * WARNING: Do NOT modify this code. The content of this method is
303: * always regenerated by the Form Editor.
304: */
305: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
306: private void initComponents() {
307: java.awt.GridBagConstraints gridBagConstraints;
308:
309: moduleTypeGroup = new javax.swing.ButtonGroup();
310: cnb = new javax.swing.JLabel();
311: cnbValue = new javax.swing.JTextField();
312: majorRelVer = new javax.swing.JLabel();
313: majorRelVerValue = new javax.swing.JTextField();
314: specificationVer = new javax.swing.JLabel();
315: specificationVerValue = new javax.swing.JTextField();
316: implVer = new javax.swing.JLabel();
317: implVerValue = new javax.swing.JTextField();
318: tokens = new javax.swing.JLabel();
319: tokensValue = new javax.swing.JTextField();
320: appendImpl = new javax.swing.JCheckBox();
321: publicPkgs = new javax.swing.JLabel();
322: publicPkgsSP = new javax.swing.JScrollPane();
323: publicPkgsTable = new javax.swing.JTable();
324: bottomPanel = new javax.swing.JPanel();
325: buttonPanel = new javax.swing.JPanel();
326: addFriendButton = new javax.swing.JButton();
327: removeFriendButton = new javax.swing.JButton();
328: filler1 = new javax.swing.JLabel();
329: friendsSP = new javax.swing.JScrollPane();
330: friendsList = new javax.swing.JList();
331: exportOnlyToFriend = new javax.swing.JCheckBox();
332: typePanel = new javax.swing.JPanel();
333: regularMod = new javax.swing.JRadioButton();
334: autoloadMod = new javax.swing.JRadioButton();
335: eagerMod = new javax.swing.JRadioButton();
336: typeTxt = new javax.swing.JLabel();
337:
338: setLayout(new java.awt.GridBagLayout());
339:
340: cnb.setLabelFor(cnbValue);
341: org.openide.awt.Mnemonics.setLocalizedText(cnb,
342: org.openide.util.NbBundle.getMessage(
343: CustomizerVersioning.class, "LBL_CNB")); // NOI18N
344: gridBagConstraints = new java.awt.GridBagConstraints();
345: gridBagConstraints.gridx = 0;
346: gridBagConstraints.gridy = 0;
347: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
348: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
349: add(cnb, gridBagConstraints);
350:
351: cnbValue.setEditable(false);
352: gridBagConstraints = new java.awt.GridBagConstraints();
353: gridBagConstraints.gridx = 1;
354: gridBagConstraints.gridy = 0;
355: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
356: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
357: gridBagConstraints.weightx = 1.0;
358: add(cnbValue, gridBagConstraints);
359:
360: majorRelVer.setLabelFor(majorRelVerValue);
361: org.openide.awt.Mnemonics.setLocalizedText(majorRelVer,
362: org.openide.util.NbBundle.getMessage(
363: CustomizerVersioning.class,
364: "LBL_MajorReleaseVersion")); // NOI18N
365: gridBagConstraints = new java.awt.GridBagConstraints();
366: gridBagConstraints.gridx = 0;
367: gridBagConstraints.gridy = 1;
368: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
369: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 12);
370: add(majorRelVer, gridBagConstraints);
371: gridBagConstraints = new java.awt.GridBagConstraints();
372: gridBagConstraints.gridx = 1;
373: gridBagConstraints.gridy = 1;
374: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
375: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
376: gridBagConstraints.weightx = 1.0;
377: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
378: add(majorRelVerValue, gridBagConstraints);
379:
380: specificationVer.setLabelFor(specificationVerValue);
381: org.openide.awt.Mnemonics.setLocalizedText(specificationVer,
382: org.openide.util.NbBundle.getMessage(
383: CustomizerVersioning.class,
384: "LBL_SpecificationVersion")); // NOI18N
385: gridBagConstraints = new java.awt.GridBagConstraints();
386: gridBagConstraints.gridx = 0;
387: gridBagConstraints.gridy = 2;
388: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
389: gridBagConstraints.insets = new java.awt.Insets(24, 0, 0, 12);
390: add(specificationVer, gridBagConstraints);
391: gridBagConstraints = new java.awt.GridBagConstraints();
392: gridBagConstraints.gridx = 1;
393: gridBagConstraints.gridy = 2;
394: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
395: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
396: gridBagConstraints.weightx = 1.0;
397: gridBagConstraints.insets = new java.awt.Insets(24, 0, 0, 0);
398: add(specificationVerValue, gridBagConstraints);
399:
400: implVer.setLabelFor(implVerValue);
401: org.openide.awt.Mnemonics.setLocalizedText(implVer,
402: org.openide.util.NbBundle.getMessage(
403: CustomizerVersioning.class,
404: "LBL_ImplementationVersion")); // NOI18N
405: gridBagConstraints = new java.awt.GridBagConstraints();
406: gridBagConstraints.gridx = 0;
407: gridBagConstraints.gridy = 4;
408: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
409: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
410: add(implVer, gridBagConstraints);
411: gridBagConstraints = new java.awt.GridBagConstraints();
412: gridBagConstraints.gridx = 1;
413: gridBagConstraints.gridy = 4;
414: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
415: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
416: gridBagConstraints.weightx = 1.0;
417: add(implVerValue, gridBagConstraints);
418:
419: tokens.setLabelFor(tokensValue);
420: org.openide.awt.Mnemonics.setLocalizedText(tokens,
421: org.openide.util.NbBundle.getMessage(
422: CustomizerVersioning.class,
423: "LBL_ProvidedTokens")); // NOI18N
424: gridBagConstraints = new java.awt.GridBagConstraints();
425: gridBagConstraints.gridx = 0;
426: gridBagConstraints.gridy = 12;
427: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
428: gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 12);
429: add(tokens, gridBagConstraints);
430:
431: tokensValue
432: .addActionListener(new java.awt.event.ActionListener() {
433: public void actionPerformed(
434: java.awt.event.ActionEvent evt) {
435: tokensValueActionPerformed(evt);
436: }
437: });
438: gridBagConstraints = new java.awt.GridBagConstraints();
439: gridBagConstraints.gridx = 1;
440: gridBagConstraints.gridy = 12;
441: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
442: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
443: gridBagConstraints.weightx = 1.0;
444: gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 0);
445: add(tokensValue, gridBagConstraints);
446:
447: org.openide.awt.Mnemonics.setLocalizedText(appendImpl,
448: org.openide.util.NbBundle.getMessage(
449: CustomizerVersioning.class,
450: "CTL_AppendImplementation")); // NOI18N
451: appendImpl.setBorder(javax.swing.BorderFactory
452: .createEmptyBorder(0, 0, 0, 0));
453: appendImpl.setMargin(new java.awt.Insets(0, 0, 0, 0));
454: gridBagConstraints = new java.awt.GridBagConstraints();
455: gridBagConstraints.gridx = 0;
456: gridBagConstraints.gridy = 3;
457: gridBagConstraints.gridwidth = 2;
458: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
459: gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
460: add(appendImpl, gridBagConstraints);
461:
462: publicPkgs.setLabelFor(publicPkgsTable);
463: org.openide.awt.Mnemonics.setLocalizedText(publicPkgs,
464: org.openide.util.NbBundle.getMessage(
465: CustomizerVersioning.class,
466: "LBL_PublicPackages")); // NOI18N
467: gridBagConstraints = new java.awt.GridBagConstraints();
468: gridBagConstraints.gridx = 0;
469: gridBagConstraints.gridy = 8;
470: gridBagConstraints.gridwidth = 2;
471: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
472: gridBagConstraints.insets = new java.awt.Insets(18, 0, 2, 12);
473: add(publicPkgs, gridBagConstraints);
474:
475: publicPkgsTable.setShowHorizontalLines(false);
476: publicPkgsSP.setViewportView(publicPkgsTable);
477:
478: gridBagConstraints = new java.awt.GridBagConstraints();
479: gridBagConstraints.gridx = 0;
480: gridBagConstraints.gridy = 9;
481: gridBagConstraints.gridwidth = 2;
482: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
483: gridBagConstraints.weighty = 0.8;
484: add(publicPkgsSP, gridBagConstraints);
485:
486: bottomPanel.setLayout(new java.awt.GridBagLayout());
487:
488: buttonPanel.setLayout(new java.awt.GridBagLayout());
489:
490: org.openide.awt.Mnemonics.setLocalizedText(addFriendButton,
491: org.openide.util.NbBundle.getMessage(
492: CustomizerVersioning.class, "CTL_AddButton")); // NOI18N
493: addFriendButton
494: .addActionListener(new java.awt.event.ActionListener() {
495: public void actionPerformed(
496: java.awt.event.ActionEvent evt) {
497: addFriend(evt);
498: }
499: });
500: gridBagConstraints = new java.awt.GridBagConstraints();
501: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
502: buttonPanel.add(addFriendButton, gridBagConstraints);
503:
504: org.openide.awt.Mnemonics
505: .setLocalizedText(removeFriendButton,
506: org.openide.util.NbBundle.getMessage(
507: CustomizerVersioning.class,
508: "CTL_RemoveButton")); // NOI18N
509: removeFriendButton
510: .addActionListener(new java.awt.event.ActionListener() {
511: public void actionPerformed(
512: java.awt.event.ActionEvent evt) {
513: removeFriend(evt);
514: }
515: });
516: gridBagConstraints = new java.awt.GridBagConstraints();
517: gridBagConstraints.gridx = 0;
518: gridBagConstraints.gridy = 1;
519: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
520: gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
521: buttonPanel.add(removeFriendButton, gridBagConstraints);
522: gridBagConstraints = new java.awt.GridBagConstraints();
523: gridBagConstraints.gridx = 0;
524: gridBagConstraints.gridy = 2;
525: gridBagConstraints.weighty = 1.0;
526: buttonPanel.add(filler1, gridBagConstraints);
527:
528: gridBagConstraints = new java.awt.GridBagConstraints();
529: gridBagConstraints.gridx = 1;
530: gridBagConstraints.gridy = 0;
531: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
532: bottomPanel.add(buttonPanel, gridBagConstraints);
533:
534: friendsSP.setViewportView(friendsList);
535: friendsList.getAccessibleContext().setAccessibleName(
536: org.openide.util.NbBundle.getMessage(
537: CustomizerVersioning.class, "ACS_FriendsList")); // NOI18N
538: friendsList.getAccessibleContext()
539: .setAccessibleDescription(
540: org.openide.util.NbBundle.getMessage(
541: CustomizerVersioning.class,
542: "ACSD_FriendsList")); // NOI18N
543:
544: gridBagConstraints = new java.awt.GridBagConstraints();
545: gridBagConstraints.gridx = 0;
546: gridBagConstraints.gridy = 0;
547: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
548: gridBagConstraints.weightx = 1.0;
549: gridBagConstraints.weighty = 1.0;
550: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
551: bottomPanel.add(friendsSP, gridBagConstraints);
552:
553: gridBagConstraints = new java.awt.GridBagConstraints();
554: gridBagConstraints.gridx = 0;
555: gridBagConstraints.gridy = 11;
556: gridBagConstraints.gridwidth = 2;
557: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
558: gridBagConstraints.weighty = 0.2;
559: gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
560: add(bottomPanel, gridBagConstraints);
561:
562: org.openide.awt.Mnemonics.setLocalizedText(exportOnlyToFriend,
563: org.openide.util.NbBundle.getMessage(
564: CustomizerVersioning.class,
565: "CTL_ExportOnlyToFriends")); // NOI18N
566: exportOnlyToFriend.setBorder(javax.swing.BorderFactory
567: .createEmptyBorder(0, 0, 0, 0));
568: exportOnlyToFriend.setEnabled(false);
569: exportOnlyToFriend.setMargin(new java.awt.Insets(0, 0, 0, 0));
570: gridBagConstraints = new java.awt.GridBagConstraints();
571: gridBagConstraints.gridx = 0;
572: gridBagConstraints.gridy = 10;
573: gridBagConstraints.gridwidth = 2;
574: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
575: gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 12);
576: add(exportOnlyToFriend, gridBagConstraints);
577:
578: typePanel.setLayout(new java.awt.GridBagLayout());
579:
580: moduleTypeGroup.add(regularMod);
581: regularMod.setSelected(true);
582: org.openide.awt.Mnemonics.setLocalizedText(regularMod,
583: org.openide.util.NbBundle
584: .getMessage(CustomizerVersioning.class,
585: "CTL_RegularModule")); // NOI18N
586: regularMod.setBorder(javax.swing.BorderFactory
587: .createEmptyBorder(0, 0, 0, 0));
588: regularMod.setMargin(new java.awt.Insets(0, 0, 0, 0));
589: gridBagConstraints = new java.awt.GridBagConstraints();
590: gridBagConstraints.gridx = 1;
591: gridBagConstraints.gridy = 0;
592: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
593: gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
594: typePanel.add(regularMod, gridBagConstraints);
595:
596: moduleTypeGroup.add(autoloadMod);
597: org.openide.awt.Mnemonics.setLocalizedText(autoloadMod,
598: org.openide.util.NbBundle.getMessage(
599: CustomizerVersioning.class,
600: "CTL_AutoloadModule")); // NOI18N
601: autoloadMod.setBorder(javax.swing.BorderFactory
602: .createEmptyBorder(0, 0, 0, 0));
603: autoloadMod.setMargin(new java.awt.Insets(0, 0, 0, 0));
604: gridBagConstraints = new java.awt.GridBagConstraints();
605: gridBagConstraints.gridx = 2;
606: gridBagConstraints.gridy = 0;
607: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
608: gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
609: typePanel.add(autoloadMod, gridBagConstraints);
610:
611: moduleTypeGroup.add(eagerMod);
612: org.openide.awt.Mnemonics.setLocalizedText(eagerMod,
613: org.openide.util.NbBundle.getMessage(
614: CustomizerVersioning.class, "CTL_EagerModule")); // NOI18N
615: eagerMod.setBorder(javax.swing.BorderFactory.createEmptyBorder(
616: 0, 0, 0, 0));
617: eagerMod.setMargin(new java.awt.Insets(0, 0, 0, 0));
618: gridBagConstraints = new java.awt.GridBagConstraints();
619: gridBagConstraints.gridx = 3;
620: gridBagConstraints.gridy = 0;
621: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
622: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
623: gridBagConstraints.weightx = 1.0;
624: gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
625: typePanel.add(eagerMod, gridBagConstraints);
626:
627: org.openide.awt.Mnemonics.setLocalizedText(typeTxt,
628: org.openide.util.NbBundle.getMessage(
629: CustomizerVersioning.class, "LBL_ModuleType")); // NOI18N
630: gridBagConstraints = new java.awt.GridBagConstraints();
631: gridBagConstraints.gridx = 0;
632: gridBagConstraints.gridy = 0;
633: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
634: typePanel.add(typeTxt, gridBagConstraints);
635:
636: gridBagConstraints = new java.awt.GridBagConstraints();
637: gridBagConstraints.gridx = 0;
638: gridBagConstraints.gridy = 5;
639: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
640: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
641: gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 0);
642: add(typePanel, gridBagConstraints);
643: }// </editor-fold>//GEN-END:initComponents
644:
645: private void removeFriend(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeFriend
646: getFriendModel().removeFriend(
647: (String) friendsList.getSelectedValue());
648: if (getFriendModel().getSize() > 0) {
649: friendsList.setSelectedIndex(0);
650: }
651: friendsList.requestFocus();
652: checkForm();
653: }//GEN-LAST:event_removeFriend
654:
655: private void addFriend(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addFriend
656: AddFriendPanel addFriend = new AddFriendPanel(getProperties());
657: DialogDescriptor descriptor = new DialogDescriptor(addFriend,
658: getMessage("CTL_AddNewFriend_Title"));
659: descriptor.setHelpCtx(new HelpCtx(AddFriendPanel.class));
660: final JButton okButton = new JButton(getMessage("CTL_OK"));
661: JButton cancel = new JButton(getMessage("CTL_Cancel"));
662: okButton.setEnabled(false);
663: Object[] options = new Object[] { okButton, cancel };
664: descriptor.setOptions(options);
665: descriptor.setClosingOptions(options);
666: final Dialog d = DialogDisplayer.getDefault().createDialog(
667: descriptor);
668: addFriend
669: .addPropertyChangeListener(new PropertyChangeListener() {
670: public void propertyChange(PropertyChangeEvent pce) {
671: if (pce.getPropertyName() == AddFriendPanel.VALID_PROPERTY) {
672: okButton.setEnabled(((Boolean) pce
673: .getNewValue()).booleanValue());
674: }
675: }
676: });
677: d.getAccessibleContext().setAccessibleDescription(
678: getMessage("ACSD_CTL_AddNewFriend_Title"));
679: okButton.getAccessibleContext().setAccessibleDescription(
680: getMessage("ACSD_CTL_OK"));
681: cancel.getAccessibleContext().setAccessibleDescription(
682: getMessage("ACSD_CTL_Cancel"));
683: if (lastSize != null) {
684: d.setSize(lastSize);
685: } else {
686: d.pack();
687: }
688: d.setLocationRelativeTo(null);
689: d.setVisible(true);
690: lastSize = d.getSize();
691: if (descriptor.getValue().equals(okButton)) {
692: String newFriendCNB = addFriend.getFriendCNB();
693: getFriendModel().addFriend(newFriendCNB);
694: friendsList.setSelectedValue(newFriendCNB, true);
695: }
696: d.dispose();
697: friendsList.requestFocus();
698: checkForm();
699: }//GEN-LAST:event_addFriend
700:
701: private void tokensValueActionPerformed(
702: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tokensValueActionPerformed
703: // TODO add your handling code here:
704: }//GEN-LAST:event_tokensValueActionPerformed
705:
706: private String getMessage(String key) {
707: return NbBundle.getMessage(CustomizerVersioning.class, key);
708: }
709:
710: public void showSubCategory(BasicCustomizer.SubCategoryProvider prov) {
711: if (CustomizerProviderImpl.CATEGORY_VERSIONING.equals(prov
712: .getCategory())
713: && CustomizerProviderImpl.SUBCATEGORY_VERSIONING_PUBLIC_PACKAGES
714: .equals(prov.getSubcategory())) {
715: publicPkgsTable.requestFocus();
716: /* XXX does not work quite right under Ocean; have to press TAB once; this does not help:
717: if (publicPkgsTable.getModel().getRowCount() > 0) {
718: publicPkgsTable.setEditingRow(0);
719: publicPkgsTable.setEditingColumn(1);
720: }
721: */
722: }
723: }
724:
725: // Variables declaration - do not modify//GEN-BEGIN:variables
726: private javax.swing.JButton addFriendButton;
727: private javax.swing.JCheckBox appendImpl;
728: private javax.swing.JRadioButton autoloadMod;
729: private javax.swing.JPanel bottomPanel;
730: private javax.swing.JPanel buttonPanel;
731: private javax.swing.JLabel cnb;
732: private javax.swing.JTextField cnbValue;
733: private javax.swing.JRadioButton eagerMod;
734: private javax.swing.JCheckBox exportOnlyToFriend;
735: private javax.swing.JLabel filler1;
736: private javax.swing.JList friendsList;
737: private javax.swing.JScrollPane friendsSP;
738: private javax.swing.JLabel implVer;
739: private javax.swing.JTextField implVerValue;
740: private javax.swing.JLabel majorRelVer;
741: private javax.swing.JTextField majorRelVerValue;
742: private javax.swing.ButtonGroup moduleTypeGroup;
743: private javax.swing.JLabel publicPkgs;
744: private javax.swing.JScrollPane publicPkgsSP;
745: private javax.swing.JTable publicPkgsTable;
746: private javax.swing.JRadioButton regularMod;
747: private javax.swing.JButton removeFriendButton;
748: private javax.swing.JLabel specificationVer;
749: private javax.swing.JTextField specificationVerValue;
750: private javax.swing.JLabel tokens;
751: private javax.swing.JTextField tokensValue;
752: private javax.swing.JPanel typePanel;
753: private javax.swing.JLabel typeTxt;
754:
755: // End of variables declaration//GEN-END:variables
756:
757: private void initAccesibility() {
758: addFriendButton.getAccessibleContext()
759: .setAccessibleDescription(
760: getMessage("ACSD_AddFriendButton"));
761: removeFriendButton.getAccessibleContext()
762: .setAccessibleDescription(
763: getMessage("ACSD_RemoveFriendButton"));
764: cnbValue.getAccessibleContext().setAccessibleDescription(
765: getMessage("ACSD_CnbValue"));
766: majorRelVerValue.getAccessibleContext()
767: .setAccessibleDescription(
768: getMessage("ACSD_MajorRelVerValue"));
769: specificationVerValue.getAccessibleContext()
770: .setAccessibleDescription(
771: getMessage("ACSD_SpecificationVerValuea"));
772: appendImpl.getAccessibleContext().setAccessibleDescription(
773: getMessage("ACSD_AppendImpl"));
774: implVerValue.getAccessibleContext().setAccessibleDescription(
775: getMessage("ACSD_ImplVerValue"));
776: regularMod.getAccessibleContext().setAccessibleDescription(
777: getMessage("ACSD_RegularMod"));
778: autoloadMod.getAccessibleContext().setAccessibleDescription(
779: getMessage("ACSD_AutoloadMod"));
780: eagerMod.getAccessibleContext().setAccessibleDescription(
781: getMessage("ACSD_EagerMod"));
782: publicPkgsTable.getAccessibleContext()
783: .setAccessibleDescription(
784: getMessage("ACSD_PublicPkgsTable"));
785: tokensValue.getAccessibleContext().setAccessibleDescription(
786: getMessage("ACSD_TokensValue"));
787: }
788:
789: }
|