1 19 20 package org.netbeans.modules.apisupport.project.ui.customizer; 21 22 import java.awt.EventQueue ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 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 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 () { public void actionPerformed(ActionEvent e) { 46 if (srcLevelValueBeingUpdated) { 47 return; 48 } 49 final String oldLevel = getProperty(SingleModuleProperties.JAVAC_SOURCES); 50 final String newLevel = (String ) srcLevelValue.getSelectedItem(); 51 SpecificationVersion jdk5 = new SpecificationVersion("1.5"); if (new SpecificationVersion(oldLevel).compareTo(jdk5) < 0 && new SpecificationVersion(newLevel).compareTo(jdk5) >= 0) { 53 EventQueue.invokeLater(new Runnable () { 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 options = getProperty(SingleModuleProperties.JAVAC_COMPILERARGS); 64 String added = "-Xlint:unchecked"; if (options == null || options.length() == 0) { 66 options = added; 67 } else { 68 options = options + " " + added; } 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 ) srcLevelValue.getSelectedItem()); 102 } 103 104 109 private void initComponents() { 111 java.awt.GridBagConstraints gridBagConstraints; 112 113 prjFolder = new javax.swing.JLabel (); 114 srcLevel = new javax.swing.JLabel (); 115 srcLevelValue = new javax.swing.JComboBox (); 116 filler = new javax.swing.JLabel (); 117 prjFolderValue = new javax.swing.JTextField (); 118 moduleSuite = new javax.swing.JLabel (); 119 moduleSuiteValue = new javax.swing.JTextField (); 120 121 setLayout(new java.awt.GridBagLayout ()); 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 (); 126 gridBagConstraints.gridx = 0; 127 gridBagConstraints.gridy = 0; 128 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 129 gridBagConstraints.insets = new java.awt.Insets (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 (); 135 gridBagConstraints.gridx = 0; 136 gridBagConstraints.gridy = 2; 137 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 138 gridBagConstraints.insets = new java.awt.Insets (18, 0, 0, 12); 139 add(srcLevel, gridBagConstraints); 140 141 srcLevelValue.setPrototypeDisplayValue("mmm"); 142 gridBagConstraints = new java.awt.GridBagConstraints (); 143 gridBagConstraints.gridx = 1; 144 gridBagConstraints.gridy = 2; 145 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 146 gridBagConstraints.insets = new java.awt.Insets (18, 0, 0, 0); 147 add(srcLevelValue, gridBagConstraints); 148 149 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (); 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 (); 167 gridBagConstraints.gridx = 0; 168 gridBagConstraints.gridy = 1; 169 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 170 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 12); 171 add(moduleSuite, gridBagConstraints); 172 173 moduleSuiteValue.setEditable(false); 174 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (6, 0, 0, 0); 181 add(moduleSuiteValue, gridBagConstraints); 182 183 } 184 186 private javax.swing.JLabel filler; 188 private javax.swing.JLabel moduleSuite; 189 private javax.swing.JTextField moduleSuiteValue; 190 private javax.swing.JLabel prjFolder; 191 private javax.swing.JTextField prjFolderValue; 192 private javax.swing.JLabel srcLevel; 193 private javax.swing.JComboBox srcLevelValue; 194 196 private static String getMessage(String 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 |