KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > ui > platform > PlatformInfoVisualPanel


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.platform;
21
22 import java.io.File JavaDoc;
23 import java.io.IOException JavaDoc;
24 import javax.swing.event.DocumentEvent JavaDoc;
25 import org.netbeans.modules.apisupport.project.ui.UIUtil;
26 import org.netbeans.modules.apisupport.project.ui.wizard.BasicVisualPanel;
27 import org.netbeans.modules.apisupport.project.universe.NbPlatform;
28 import org.openide.WizardDescriptor;
29 import org.openide.util.NbBundle;
30
31 /**
32  * Second panel from <em>Adding New Platform</em> wizard panels. Allows user to
33  * add additional info about a selected platform.
34  *
35  * @author Martin Krauskopf
36  */

37 public class PlatformInfoVisualPanel extends BasicVisualPanel {
38     
39     private boolean attached;
40     
41     /** Creates new form BasicInfoVisualPanel */
42     public PlatformInfoVisualPanel(WizardDescriptor setting) {
43         super(setting);
44         initComponents();
45         initAccessibility();
46         setName(NbPlatformCustomizer.INFO_STEP);
47     }
48     
49     void refreshData() {
50         String JavaDoc destDir = (String JavaDoc) getSettings().getProperty(NbPlatformCustomizer.PLAF_DIR_PROPERTY);
51         try {
52             plafNameValue.setText(NbPlatform.computeDisplayName(new File JavaDoc(destDir)));
53         } catch (IOException JavaDoc e) {
54             plafNameValue.setText(destDir);
55         }
56         checkForm();
57     }
58     
59     private void checkForm() {
60         String JavaDoc plafName = plafNameValue.getText().trim();
61         if (plafName.equals("")) {
62             setError(getMessage("MSG_BlankPlatformName"));
63         } else if (!NbPlatform.isLabelValid(plafName)) {
64             setError(getMessage("MSG_NameIsAlreadyUsed"));
65         } else {
66             markValid();
67         }
68     }
69     
70     void storeData() {
71         getSettings().putProperty(NbPlatformCustomizer.PLAF_LABEL_PROPERTY,
72                 plafNameValue.getText().trim());
73     }
74     
75     public void addNotify() {
76         super.addNotify();
77         if (!attached) {
78             plafNameValue.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
79                 public void insertUpdate(DocumentEvent JavaDoc e) {
80                     checkForm();
81                 }
82             });
83             attached = true;
84         }
85     }
86     
87     private static String JavaDoc getMessage(String JavaDoc key) {
88         return NbBundle.getMessage(PlatformInfoVisualPanel.class, key);
89     }
90     
91     /** This method is called from within the constructor to
92      * initialize the form.
93      * WARNING: Do NOT modify this code. The content of this method is
94      * always regenerated by the Form Editor.
95      */

96     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
97
private void initComponents() {
98         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
99
100         plafName = new javax.swing.JLabel JavaDoc();
101         plafNameValue = new javax.swing.JTextField JavaDoc();
102         filler = new javax.swing.JLabel JavaDoc();
103
104         setLayout(new java.awt.GridBagLayout JavaDoc());
105
106         org.openide.awt.Mnemonics.setLocalizedText(plafName, org.openide.util.NbBundle.getMessage(PlatformInfoVisualPanel.class, "LBL_PlatformName_P"));
107         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
108         gridBagConstraints.gridx = 0;
109         gridBagConstraints.gridy = 0;
110         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
111         add(plafName, gridBagConstraints);
112
113         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
114         gridBagConstraints.gridx = 1;
115         gridBagConstraints.gridy = 0;
116         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
117         gridBagConstraints.weightx = 1.0;
118         add(plafNameValue, gridBagConstraints);
119
120         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
121         gridBagConstraints.gridx = 0;
122         gridBagConstraints.gridy = 1;
123         gridBagConstraints.weighty = 1.0;
124         add(filler, gridBagConstraints);
125
126     }
127     // </editor-fold>//GEN-END:initComponents
128

129     // Variables declaration - do not modify//GEN-BEGIN:variables
130
private javax.swing.JLabel JavaDoc filler;
131     private javax.swing.JLabel JavaDoc plafName;
132     private javax.swing.JTextField JavaDoc plafNameValue;
133     // End of variables declaration//GEN-END:variables
134

135     private void initAccessibility() {
136         this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_PlatformInfoVisualPanel"));
137         plafNameValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_plafNameValue"));
138     }
139 }
140
Popular Tags