KickJava   Java API By Example, From Geeks To Geeks.

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


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.EventQueue JavaDoc;
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25 import org.netbeans.modules.apisupport.project.ui.UIUtil;
26 import org.openide.NotifyDescriptor;
27 import org.openide.modules.SpecificationVersion;
28 import org.openide.util.NbBundle;
29
30 /**
31  * Represents <em>Sources</em> panel in Netbeans Module customizer.
32  *
33  * @author mkrauskopf
34  */

35 final class CustomizerSources extends NbPropertyPanel.Single {
36
37     private boolean srcLevelValueBeingUpdated;
38     
39     CustomizerSources(final SingleModuleProperties props) {
40         super(props, CustomizerSources.class);
41         initComponents();
42         initAccessibility();
43         refresh();
44         srcLevelValue.addActionListener(new ActionListener JavaDoc() { // #66278
45
public void actionPerformed(ActionEvent JavaDoc e) {
46                 if (srcLevelValueBeingUpdated) {
47                     return;
48                 }
49                 final String JavaDoc oldLevel = getProperty(SingleModuleProperties.JAVAC_SOURCES);
50                 final String JavaDoc newLevel = (String JavaDoc) srcLevelValue.getSelectedItem();
51                 SpecificationVersion jdk5 = new SpecificationVersion("1.5"); // NOI18N
52
if (new SpecificationVersion(oldLevel).compareTo(jdk5) < 0 && new SpecificationVersion(newLevel).compareTo(jdk5) >= 0) {
53                     EventQueue.invokeLater(new Runnable JavaDoc() { // wait for combo to close, at least
54
public void run() {
55                             if (!UIUtil.showAcceptCancelDialog(
56                                     getMessage("CustomizerSources.title.enable_lint_unchecked"),
57                                     getMessage("CustomizerSources.text.enable_lint_unchecked"),
58                                     getMessage("CustomizerSources.button.enable_lint_unchecked"),
59                                     getMessage("CustomizerSources.button.skip_lint_unchecked"),
60                                     NotifyDescriptor.QUESTION_MESSAGE)) {
61                                 return;
62                             }
63                             String JavaDoc options = getProperty(SingleModuleProperties.JAVAC_COMPILERARGS);
64                             String JavaDoc added = "-Xlint:unchecked"; // NOI18N
65
if (options == null || options.length() == 0) {
66                                 options = added;
67                             } else {
68                                 options = options + " " + added; // NOI18N
69
}
70                             setProperty(SingleModuleProperties.JAVAC_COMPILERARGS, options);
71                         }
72                     });
73                 }
74             }
75         });
76     }
77     
78     void refresh() {
79         if (getProperties().getSuiteDirectoryPath() == null) {
80             moduleSuite.setVisible(false);
81             moduleSuiteValue.setVisible(false);
82         } else {
83             UIUtil.setText(moduleSuiteValue, getProperties().getSuiteDirectoryPath());
84         }
85         assert !srcLevelValueBeingUpdated;
86         srcLevelValueBeingUpdated = true;
87         try {
88             srcLevelValue.removeAllItems();
89             for (int i = 0; i < SingleModuleProperties.SOURCE_LEVELS.length; i++) {
90                 srcLevelValue.addItem(SingleModuleProperties.SOURCE_LEVELS[i]);
91             }
92             srcLevelValue.setSelectedItem(getProperty(SingleModuleProperties.JAVAC_SOURCES));
93         } finally {
94             srcLevelValueBeingUpdated = false;
95         }
96         UIUtil.setText(prjFolderValue, getProperties().getProjectDirectory());
97     }
98     
99     public void store() {
100         setProperty(SingleModuleProperties.JAVAC_SOURCES,
101                 (String JavaDoc) srcLevelValue.getSelectedItem());
102     }
103     
104     /** This method is called from within the constructor to
105      * initialize the form.
106      * WARNING: Do NOT modify this code. The content of this method is
107      * always regenerated by the Form Editor.
108      */

109     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
110
private void initComponents() {
111         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
112
113         prjFolder = new javax.swing.JLabel JavaDoc();
114         srcLevel = new javax.swing.JLabel JavaDoc();
115         srcLevelValue = new javax.swing.JComboBox JavaDoc();
116         filler = new javax.swing.JLabel JavaDoc();
117         prjFolderValue = new javax.swing.JTextField JavaDoc();
118         moduleSuite = new javax.swing.JLabel JavaDoc();
119         moduleSuiteValue = new javax.swing.JTextField JavaDoc();
120
121         setLayout(new java.awt.GridBagLayout JavaDoc());
122
123         prjFolder.setLabelFor(prjFolderValue);
124         org.openide.awt.Mnemonics.setLocalizedText(prjFolder, org.openide.util.NbBundle.getMessage(CustomizerSources.class, "LBL_ProjectFolder"));
125         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
126         gridBagConstraints.gridx = 0;
127         gridBagConstraints.gridy = 0;
128         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
129         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
130         add(prjFolder, gridBagConstraints);
131
132         srcLevel.setLabelFor(srcLevelValue);
133         org.openide.awt.Mnemonics.setLocalizedText(srcLevel, org.openide.util.NbBundle.getMessage(CustomizerSources.class, "LBL_SourceLevel"));
134         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
135         gridBagConstraints.gridx = 0;
136         gridBagConstraints.gridy = 2;
137         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
138         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 0, 12);
139         add(srcLevel, gridBagConstraints);
140
141         srcLevelValue.setPrototypeDisplayValue("mmm");
142         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
143         gridBagConstraints.gridx = 1;
144         gridBagConstraints.gridy = 2;
145         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
146         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 0, 0);
147         add(srcLevelValue, gridBagConstraints);
148
149         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
150         gridBagConstraints.gridx = 0;
151         gridBagConstraints.gridy = 3;
152         gridBagConstraints.weighty = 1.0;
153         add(filler, gridBagConstraints);
154
155         prjFolderValue.setEditable(false);
156         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
157         gridBagConstraints.gridx = 1;
158         gridBagConstraints.gridy = 0;
159         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
160         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
161         gridBagConstraints.weightx = 1.0;
162         add(prjFolderValue, gridBagConstraints);
163
164         moduleSuite.setLabelFor(moduleSuiteValue);
165         org.openide.awt.Mnemonics.setLocalizedText(moduleSuite, org.openide.util.NbBundle.getMessage(CustomizerSources.class, "LBL_ModeleSuite"));
166         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
167         gridBagConstraints.gridx = 0;
168         gridBagConstraints.gridy = 1;
169         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
170         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
171         add(moduleSuite, gridBagConstraints);
172
173         moduleSuiteValue.setEditable(false);
174         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
175         gridBagConstraints.gridx = 1;
176         gridBagConstraints.gridy = 1;
177         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
178         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
179         gridBagConstraints.weightx = 1.0;
180         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
181         add(moduleSuiteValue, gridBagConstraints);
182
183     }
184     // </editor-fold>//GEN-END:initComponents
185

186     // Variables declaration - do not modify//GEN-BEGIN:variables
187
private javax.swing.JLabel JavaDoc filler;
188     private javax.swing.JLabel JavaDoc moduleSuite;
189     private javax.swing.JTextField JavaDoc moduleSuiteValue;
190     private javax.swing.JLabel JavaDoc prjFolder;
191     private javax.swing.JTextField JavaDoc prjFolderValue;
192     private javax.swing.JLabel JavaDoc srcLevel;
193     private javax.swing.JComboBox JavaDoc srcLevelValue;
194     // End of variables declaration//GEN-END:variables
195

196     private static String JavaDoc getMessage(String JavaDoc key) {
197         return NbBundle.getMessage(CustomizerSources.class, key);
198     }
199     
200     private void initAccessibility() {
201         srcLevelValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_SrcLevelValue"));
202         moduleSuiteValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_ModuleSuiteValue"));
203         prjFolderValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_PrjFolderValue"));
204     }
205     
206 }
207
Popular Tags