1 11 package org.eclipse.jdt.internal.ui.preferences; 12 13 import java.util.ArrayList ; 14 import java.util.Arrays ; 15 import java.util.Map ; 16 17 import org.eclipse.core.resources.IResource; 18 import org.eclipse.core.resources.IWorkspace; 19 import org.eclipse.core.resources.ResourcesPlugin; 20 import org.eclipse.core.runtime.IStatus; 21 22 import org.eclipse.swt.SWT; 23 import org.eclipse.swt.layout.GridData; 24 import org.eclipse.swt.layout.GridLayout; 25 import org.eclipse.swt.widgets.Combo; 26 import org.eclipse.swt.widgets.Composite; 27 import org.eclipse.swt.widgets.Control; 28 import org.eclipse.swt.widgets.Group; 29 import org.eclipse.swt.widgets.Label; 30 import org.eclipse.swt.widgets.TabFolder; 31 import org.eclipse.swt.widgets.TabItem; 32 import org.eclipse.swt.widgets.Text; 33 34 import org.eclipse.jdt.core.IJavaProject; 35 import org.eclipse.jdt.core.JavaCore; 36 37 import org.eclipse.jdt.internal.corext.util.JavaModelUtil; 38 import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; 39 import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; 40 import org.eclipse.jdt.internal.ui.util.PixelConverter; 41 import org.eclipse.jdt.internal.ui.util.TabFolderLayout; 42 import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; 43 44 46 public class CompilerConfigurationBlock extends OptionsConfigurationBlock { 47 48 private static final String PREF_LOCAL_VARIABLE_ATTR= JavaCore.COMPILER_LOCAL_VARIABLE_ATTR; 50 private static final String PREF_LINE_NUMBER_ATTR= JavaCore.COMPILER_LINE_NUMBER_ATTR; 51 private static final String PREF_SOURCE_FILE_ATTR= JavaCore.COMPILER_SOURCE_FILE_ATTR; 52 private static final String PREF_CODEGEN_UNUSED_LOCAL= JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL; 53 private static final String PREF_CODEGEN_TARGET_PLATFORM= JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM; 54 private static final String PREF_CODEGEN_INLINE_JSR_BYTECODE= JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE; 55 56 private static final String PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD= JavaCore.COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD; 59 private static final String PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME; 60 private static final String PREF_PB_DEPRECATION= JavaCore.COMPILER_PB_DEPRECATION; 61 private static final String PREF_PB_DEPRECATION_WHEN_OVERRIDING= JavaCore.COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD; 62 63 private static final String PREF_PB_HIDDEN_CATCH_BLOCK= JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK; 64 private static final String PREF_PB_UNUSED_LOCAL= JavaCore.COMPILER_PB_UNUSED_LOCAL; 65 private static final String PREF_PB_UNUSED_PARAMETER= JavaCore.COMPILER_PB_UNUSED_PARAMETER; 66 private static final String PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE; 67 private static final String PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT; 68 private static final String PREF_PB_SYNTHETIC_ACCESS_EMULATION= JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION; 69 private static final String PREF_PB_NON_EXTERNALIZED_STRINGS= JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL; 70 private static final String PREF_PB_ASSERT_AS_IDENTIFIER= JavaCore.COMPILER_PB_ASSERT_IDENTIFIER; 71 private static final String PREF_PB_MAX_PER_UNIT= JavaCore.COMPILER_PB_MAX_PER_UNIT; 72 private static final String PREF_PB_UNUSED_IMPORT= JavaCore.COMPILER_PB_UNUSED_IMPORT; 73 private static final String PREF_PB_UNUSED_PRIVATE= JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER; 74 private static final String PREF_PB_STATIC_ACCESS_RECEIVER= JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER; 75 private static final String PREF_PB_NO_EFFECT_ASSIGNMENT= JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT; 76 private static final String PREF_PB_CHAR_ARRAY_IN_CONCAT= JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION; 77 private static final String PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT= JavaCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT; 78 private static final String PREF_PB_LOCAL_VARIABLE_HIDING= JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING; 79 private static final String PREF_PB_FIELD_HIDING= JavaCore.COMPILER_PB_FIELD_HIDING; 80 private static final String PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD= JavaCore.COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD; 81 private static final String PREF_PB_INDIRECT_STATIC_ACCESS= JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS; 82 private static final String PREF_PB_EMPTY_STATEMENT= JavaCore.COMPILER_PB_EMPTY_STATEMENT; 83 private static final String PREF_PB_UNNECESSARY_ELSE= JavaCore.COMPILER_PB_UNNECESSARY_ELSE; 84 private static final String PREF_PB_UNNECESSARY_TYPE_CHECK= JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK; 85 86 private static final String PREF_JAVADOC_SUPPORT= JavaCore.COMPILER_DOC_COMMENT_SUPPORT; 87 88 private static final String PREF_PB_INVALID_JAVADOC= JavaCore.COMPILER_PB_INVALID_JAVADOC; 89 private static final String PREF_PB_INVALID_JAVADOC_TAGS= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS; 90 private static final String PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY; 91 92 private static final String PREF_PB_MISSING_JAVADOC_TAGS= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS; 93 private static final String PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY; 94 private static final String PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING; 95 96 private static final String PREF_PB_MISSING_JAVADOC_COMMENTS= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS; 97 private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY; 98 private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING; 99 100 private static final String PREF_SOURCE_COMPATIBILITY= JavaCore.COMPILER_SOURCE; 101 private static final String PREF_COMPLIANCE= JavaCore.COMPILER_COMPLIANCE; 102 103 private static final String PREF_RESOURCE_FILTER= JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER; 104 private static final String PREF_BUILD_INVALID_CLASSPATH= JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH; 105 private static final String PREF_BUILD_CLEAN_OUTPUT_FOLDER= JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER; 106 private static final String PREF_ENABLE_EXCLUSION_PATTERNS= JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS; 107 private static final String PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS= JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS; 108 109 private static final String PREF_PB_INCOMPLETE_BUILDPATH= JavaCore.CORE_INCOMPLETE_CLASSPATH; 110 private static final String PREF_PB_CIRCULAR_BUILDPATH= JavaCore.CORE_CIRCULAR_CLASSPATH; 111 private static final String PREF_PB_INCOMPATIBLE_JDK_LEVEL= JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL; 112 private static final String PREF_PB_DUPLICATE_RESOURCE= JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE; 113 114 private static final String PREF_PB_DEPRECATION_IN_DEPRECATED_CODE= JavaCore.COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE; 115 private static final String PREF_PB_INCOMPATIBLE_INTERFACE_METHOD= JavaCore.COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD; 116 117 private static final String PREF_PB_UNDOCUMENTED_EMPTY_BLOCK= JavaCore.COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK; 118 private static final String PREF_PB_FINALLY_BLOCK_NOT_COMPLETING= JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING; 119 private static final String PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION= JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION; 120 private static final String PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING; 121 private static final String PREF_PB_UNQUALIFIED_FIELD_ACCESS= JavaCore.COMPILER_PB_UNQUALIFIED_FIELD_ACCESS; 122 123 private static final String PREF_15_PB_UNSAVE_TYPE_OPERATION= "org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation"; private static final String PREF_15_PB_FINAL_PARAM_BOUND= "org.eclipse.jdt.core.compiler.problem.finalParameterBound"; 126 127 private static final String INTR_DEFAULT_COMPLIANCE= "internal.default.compliance"; 129 private static final String GENERATE= JavaCore.GENERATE; 131 private static final String DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE; 132 133 private static final String PRESERVE= JavaCore.PRESERVE; 134 private static final String OPTIMIZE_OUT= JavaCore.OPTIMIZE_OUT; 135 136 private static final String VERSION_1_1= JavaCore.VERSION_1_1; 137 private static final String VERSION_1_2= JavaCore.VERSION_1_2; 138 private static final String VERSION_1_3= JavaCore.VERSION_1_3; 139 private static final String VERSION_1_4= JavaCore.VERSION_1_4; 140 private static final String VERSION_1_5= JavaCore.VERSION_1_5; 141 142 private static final String ERROR= JavaCore.ERROR; 143 private static final String WARNING= JavaCore.WARNING; 144 private static final String IGNORE= JavaCore.IGNORE; 145 146 private static final String ABORT= JavaCore.ABORT; 147 private static final String CLEAN= JavaCore.CLEAN; 148 149 private static final String ENABLED= JavaCore.ENABLED; 150 private static final String DISABLED= JavaCore.DISABLED; 151 152 private static final String PUBLIC= JavaCore.PUBLIC; 153 private static final String PROTECTED= JavaCore.PROTECTED; 154 private static final String DEFAULT= JavaCore.DEFAULT; 155 private static final String PRIVATE= JavaCore.PRIVATE; 156 157 private static final String DEFAULT_CONF= "default"; private static final String USER_CONF= "user"; 160 private ArrayList fComplianceControls; 161 private PixelConverter fPixelConverter; 162 private Composite fJavadocComposite; 163 164 private String [] fRememberedUserCompliance; 165 166 private IStatus fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus; 167 168 public CompilerConfigurationBlock(IStatusChangeListener context, IJavaProject project) { 169 super(context, project, getKeys()); 170 171 fComplianceControls= new ArrayList (); 172 173 fComplianceStatus= new StatusInfo(); 174 fMaxNumberProblemsStatus= new StatusInfo(); 175 fResourceFilterStatus= new StatusInfo(); 176 177 if (ENABLED.equals(fWorkingValues.get(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT))) { 179 fWorkingValues.put(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, ENABLED); 180 } 181 fRememberedUserCompliance= new String [] { 182 (String ) fWorkingValues.get(PREF_PB_ASSERT_AS_IDENTIFIER), 183 (String ) fWorkingValues.get(PREF_SOURCE_COMPATIBILITY), 184 (String ) fWorkingValues.get(PREF_CODEGEN_TARGET_PLATFORM), 185 (String ) fWorkingValues.get(PREF_COMPLIANCE), 186 }; 187 } 188 189 private static String [] getKeys() { 190 String [] keys= new String [] { 191 PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL, 192 PREF_CODEGEN_INLINE_JSR_BYTECODE, 193 PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, 194 PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, PREF_PB_DEPRECATION, PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL, 195 PREF_PB_UNUSED_PARAMETER, PREF_PB_SYNTHETIC_ACCESS_EMULATION, PREF_PB_NON_EXTERNALIZED_STRINGS, 196 PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_UNUSED_IMPORT, PREF_PB_MAX_PER_UNIT, PREF_SOURCE_COMPATIBILITY, PREF_COMPLIANCE, 197 PREF_PB_STATIC_ACCESS_RECEIVER, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, 198 PREF_PB_NO_EFFECT_ASSIGNMENT, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD, 199 PREF_PB_UNUSED_PRIVATE, PREF_PB_CHAR_ARRAY_IN_CONCAT, PREF_PB_UNNECESSARY_ELSE, 200 PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, PREF_PB_LOCAL_VARIABLE_HIDING, PREF_PB_FIELD_HIDING, 201 PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, PREF_PB_INDIRECT_STATIC_ACCESS, 202 PREF_PB_EMPTY_STATEMENT, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, 203 PREF_PB_UNNECESSARY_TYPE_CHECK, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, PREF_PB_UNQUALIFIED_FIELD_ACCESS, 204 PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, PREF_PB_DEPRECATION_WHEN_OVERRIDING, 205 PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING, 206 PREF_JAVADOC_SUPPORT, 207 PREF_PB_INVALID_JAVADOC, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, 208 PREF_PB_MISSING_JAVADOC_TAGS, PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING, 209 PREF_PB_MISSING_JAVADOC_COMMENTS, PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING, 210 211 PREF_RESOURCE_FILTER, PREF_BUILD_INVALID_CLASSPATH, PREF_PB_INCOMPLETE_BUILDPATH, PREF_PB_CIRCULAR_BUILDPATH, 212 PREF_BUILD_CLEAN_OUTPUT_FOLDER, PREF_PB_DUPLICATE_RESOURCE, 213 PREF_PB_INCOMPATIBLE_JDK_LEVEL, PREF_ENABLE_EXCLUSION_PATTERNS, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS 214 }; 215 if (JavaModelUtil.isJDTCore_1_5()) { 216 String [] newKeys= new String [] { 217 PREF_15_PB_UNSAVE_TYPE_OPERATION, PREF_15_PB_FINAL_PARAM_BOUND 218 }; 219 String [] merged= new String [keys.length + newKeys.length]; 220 System.arraycopy(keys, 0, merged, 0, keys.length); 221 System.arraycopy(newKeys, 0, merged, keys.length, newKeys.length); 222 keys= merged; 223 } 224 return keys; 225 } 226 227 protected final Map getOptions(boolean inheritJavaCoreOptions) { 228 Map map= super.getOptions(inheritJavaCoreOptions); 229 map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map)); 230 return map; 231 } 232 233 protected final Map getDefaultOptions() { 234 Map map= super.getDefaultOptions(); 235 map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map)); 236 return map; 237 } 238 239 240 243 protected Control createContents(Composite parent) { 244 fPixelConverter= new PixelConverter(parent); 245 setShell(parent.getShell()); 246 247 TabFolder folder= new TabFolder(parent, SWT.NONE); 248 folder.setLayout(new TabFolderLayout()); 249 folder.setLayoutData(new GridData(GridData.FILL_BOTH)); 250 251 Composite commonComposite= createStyleTabContent(folder); 252 Composite unusedComposite= createUnusedCodeTabContent(folder); 253 Composite advancedComposite= createAdvancedTabContent(folder); 254 255 Composite javadocComposite= createJavadocTabContent(folder); 256 Composite complianceComposite= createComplianceTabContent(folder); 257 Composite othersComposite= createBuildPathTabContent(folder); 258 259 TabItem item= new TabItem(folder, SWT.NONE); 260 item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.tabtitle")); item.setControl(commonComposite); 262 263 item= new TabItem(folder, SWT.NONE); 264 item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.tabtitle")); item.setControl(advancedComposite); 266 267 item= new TabItem(folder, SWT.NONE); 268 item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.tabtitle")); item.setControl(unusedComposite); 270 271 item= new TabItem(folder, SWT.NONE); 272 item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.tabtitle")); item.setControl(javadocComposite); 274 275 item= new TabItem(folder, SWT.NONE); 276 item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.tabtitle")); item.setControl(complianceComposite); 278 279 item= new TabItem(folder, SWT.NONE); 280 item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.others.tabtitle")); item.setControl(othersComposite); 282 283 if (JavaModelUtil.isJDTCore_1_5()) { 284 Composite extraComposite= create15TabContent(folder); 285 286 item= new TabItem(folder, SWT.NONE); 287 item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.15.tabtitle")); item.setControl(extraComposite); 289 } 290 291 validateSettings(null, null); 292 293 return folder; 294 } 295 296 private Composite createStyleTabContent(Composite folder) { 297 String [] errorWarningIgnore= new String [] { ERROR, WARNING, IGNORE }; 298 299 String [] errorWarningIgnoreLabels= new String [] { 300 PreferencesMessages.getString("CompilerConfigurationBlock.error"), PreferencesMessages.getString("CompilerConfigurationBlock.warning"), PreferencesMessages.getString("CompilerConfigurationBlock.ignore") }; 304 305 int nColumns= 3; 306 307 GridLayout layout= new GridLayout(); 308 layout.numColumns= nColumns; 309 310 Composite composite= new Composite(folder, SWT.NULL); 311 composite.setLayout(layout); 312 313 Label description= new Label(composite, SWT.WRAP); 314 description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.description")); GridData gd= new GridData(); 316 gd.horizontalSpan= nColumns; 317 description.setLayoutData(gd); 319 320 String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_overriding_pkg_dflt.label"); addComboBox(composite, label, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0); 322 323 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_method_naming.label"); addComboBox(composite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels, 0); 325 326 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_static_access_receiver.label"); addComboBox(composite, label, PREF_PB_STATIC_ACCESS_RECEIVER, errorWarningIgnore, errorWarningIgnoreLabels, 0); 328 329 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_indirect_access_to_static.label"); addComboBox(composite, label, PREF_PB_INDIRECT_STATIC_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0); 331 332 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_no_effect_assignment.label"); addComboBox(composite, label, PREF_PB_NO_EFFECT_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0); 334 335 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_accidential_assignement.label"); addComboBox(composite, label, PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0); 337 338 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unqualified_field_access.label"); addComboBox(composite, label, PREF_PB_UNQUALIFIED_FIELD_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0); 340 341 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_finally_block_not_completing.label"); addComboBox(composite, label, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, errorWarningIgnore, errorWarningIgnoreLabels, 0); 343 344 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_empty_statement.label"); addComboBox(composite, label, PREF_PB_EMPTY_STATEMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0); 346 347 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_undocumented_empty_block.label"); addComboBox(composite, label, PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0); 349 350 351 return composite; 352 } 353 354 private Composite createAdvancedTabContent(TabFolder folder) { 355 String [] errorWarningIgnore= new String [] { ERROR, WARNING, IGNORE }; 356 357 String [] errorWarningIgnoreLabels= new String [] { 358 PreferencesMessages.getString("CompilerConfigurationBlock.error"), PreferencesMessages.getString("CompilerConfigurationBlock.warning"), PreferencesMessages.getString("CompilerConfigurationBlock.ignore") }; 362 363 String [] enabledDisabled= new String [] { ENABLED, DISABLED }; 364 365 int nColumns= 3; 366 367 GridLayout layout= new GridLayout(); 368 layout.numColumns= nColumns; 369 370 Composite composite= new Composite(folder, SWT.NULL); 371 composite.setLayout(layout); 372 373 Label description= new Label(composite, SWT.WRAP); 374 description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.description")); GridData gd= new GridData(); 376 gd.horizontalSpan= nColumns; 377 description.setLayoutData(gd); 379 380 String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_synth_access_emul.label"); addComboBox(composite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels, 0); 382 383 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_local_variable_hiding.label"); addComboBox(composite, label, PREF_PB_LOCAL_VARIABLE_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0); 385 386 int indent= fPixelConverter.convertWidthInCharsToPixels(2); 387 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_special_param_hiding.label"); addCheckBox(composite, label, PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, enabledDisabled, indent); 389 390 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_field_hiding.label"); addComboBox(composite, label, PREF_PB_FIELD_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0); 392 393 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incompatible_interface_method.label"); addComboBox(composite, label, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0); 395 396 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_char_array_in_concat.label"); addComboBox(composite, label, PREF_PB_CHAR_ARRAY_IN_CONCAT, errorWarningIgnore, errorWarningIgnoreLabels, 0); 398 399 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation.label"); addComboBox(composite, label, PREF_PB_DEPRECATION, errorWarningIgnore, errorWarningIgnoreLabels, 0); 401 402 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation_in_deprecation.label"); addCheckBox(composite, label, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, enabledDisabled, indent); 404 405 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation_when_overriding.label"); addCheckBox(composite, label, PREF_PB_DEPRECATION_WHEN_OVERRIDING, enabledDisabled, indent); 407 408 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_non_externalized_strings.label"); addComboBox(composite, label, PREF_PB_NON_EXTERNALIZED_STRINGS, errorWarningIgnore, errorWarningIgnoreLabels, 0); 410 411 412 gd= new GridData(); 413 gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(6); 414 415 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_max_per_unit.label"); Text text= addTextField(composite, label, PREF_PB_MAX_PER_UNIT, 0, 0); 417 text.setTextLimit(6); 418 text.setLayoutData(gd); 419 420 return composite; 421 } 422 423 private Composite createUnusedCodeTabContent(TabFolder folder) { 424 String [] errorWarningIgnore= new String [] { ERROR, WARNING, IGNORE }; 425 426 String [] errorWarningIgnoreLabels= new String [] { 427 PreferencesMessages.getString("CompilerConfigurationBlock.error"), PreferencesMessages.getString("CompilerConfigurationBlock.warning"), PreferencesMessages.getString("CompilerConfigurationBlock.ignore") }; 431 432 String [] enabledDisabled= new String [] { ENABLED, DISABLED }; 433 434 int nColumns= 3; 435 436 GridLayout layout= new GridLayout(); 437 layout.numColumns= nColumns; 438 439 Composite composite= new Composite(folder, SWT.NULL); 440 composite.setLayout(layout); 441 442 Label description= new Label(composite, SWT.WRAP); 443 description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.description")); GridData gd= new GridData(); 445 gd.horizontalSpan= nColumns; 446 description.setLayoutData(gd); 448 449 String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_local.label"); addComboBox(composite, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels, 0); 451 452 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_parameter.label"); addComboBox(composite, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels, 0); 454 455 int indent= fPixelConverter.convertWidthInCharsToPixels(2); 456 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_signal_param_in_overriding.label"); addCheckBox(composite, label, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, enabledDisabled, indent); 458 459 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_imports.label"); addComboBox(composite, label, PREF_PB_UNUSED_IMPORT, errorWarningIgnore, errorWarningIgnoreLabels, 0); 461 462 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_private.label"); addComboBox(composite, label, PREF_PB_UNUSED_PRIVATE, errorWarningIgnore, errorWarningIgnoreLabels, 0); 464 465 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unnecessary_else.label"); addComboBox(composite, label, PREF_PB_UNNECESSARY_ELSE, errorWarningIgnore, errorWarningIgnoreLabels, 0); 467 468 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unnecessary_type_check.label"); addComboBox(composite, label, PREF_PB_UNNECESSARY_TYPE_CHECK, errorWarningIgnore, errorWarningIgnoreLabels, 0); 470 471 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_hidden_catchblock.label"); addComboBox(composite, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0); 473 474 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_throwing_exception.label"); addComboBox(composite, label, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, errorWarningIgnore, errorWarningIgnoreLabels, 0); 476 477 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_throwing_exception_when_overriding.label"); addCheckBox(composite, label, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING, enabledDisabled, indent); 479 480 return composite; 481 } 482 483 private Composite createJavadocTabContent(TabFolder folder) { 484 String [] errorWarningIgnore= new String [] { ERROR, WARNING, IGNORE }; 485 486 String [] errorWarningIgnoreLabels= new String [] { 487 PreferencesMessages.getString("CompilerConfigurationBlock.error"), PreferencesMessages.getString("CompilerConfigurationBlock.warning"), PreferencesMessages.getString("CompilerConfigurationBlock.ignore") }; 491 492 String [] enabledDisabled= new String [] { ENABLED, DISABLED }; 493 494 String [] visibilities= new String [] { PUBLIC, PROTECTED, DEFAULT, PRIVATE }; 495 496 String [] visibilitiesLabels= new String [] { 497 PreferencesMessages.getString("CompilerConfigurationBlock.public"), PreferencesMessages.getString("CompilerConfigurationBlock.protected"), PreferencesMessages.getString("CompilerConfigurationBlock.default"), PreferencesMessages.getString("CompilerConfigurationBlock.private") }; 502 int nColumns= 3; 503 504 GridLayout layout = new GridLayout(); 505 layout.numColumns= nColumns; 506 507 Composite outer= new Composite(folder, SWT.NULL); 508 outer.setLayout(layout); 509 510 String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_javadoc_support.label"); addCheckBox(outer, label, PREF_JAVADOC_SUPPORT, enabledDisabled, 0); 512 513 layout = new GridLayout(); 514 layout.numColumns= nColumns; 515 layout.marginHeight= 0; 516 518 Composite composite= new Composite(outer, SWT.NULL); 519 composite.setLayout(layout); 520 composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 521 fJavadocComposite= composite; 522 523 Label description= new Label(composite, SWT.WRAP); 524 description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.description")); GridData gd= new GridData(); 526 gd.horizontalSpan= nColumns; 527 description.setLayoutData(gd); 529 530 int indent= fPixelConverter.convertWidthInCharsToPixels(2); 531 532 label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc.label"); addComboBox(composite, label, PREF_PB_INVALID_JAVADOC, errorWarningIgnore, errorWarningIgnoreLabels, 0); 534 535 label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc_tags_visibility.label"); addComboBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent); 537 538 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc_tags.label"); addCheckBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS, enabledDisabled, indent); 540 541 Label separator= new Label(composite, SWT.HORIZONTAL); 542 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 543 gd.horizontalSpan= nColumns; 544 separator.setLayoutData(gd); 545 546 label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc.label"); addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS, errorWarningIgnore, errorWarningIgnoreLabels, 0); 548 549 label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc_tags_visibility.label"); addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent); 551 552 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc_tags_overriding.label"); addCheckBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING, enabledDisabled, indent); 554 555 separator= new Label(composite, SWT.HORIZONTAL); 556 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 557 gd.horizontalSpan= nColumns; 558 separator.setLayoutData(gd); 559 560 label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments.label"); addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS, errorWarningIgnore, errorWarningIgnoreLabels, 0); 562 563 label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments_visibility.label"); addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, visibilities, visibilitiesLabels, indent); 565 566 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments_overriding.label"); addCheckBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING, enabledDisabled, indent); 568 569 return outer; 570 } 571 572 573 574 private Composite createBuildPathTabContent(TabFolder folder) { 575 String [] abortIgnoreValues= new String [] { ABORT, IGNORE }; 576 String [] cleanIgnoreValues= new String [] { CLEAN, IGNORE }; 577 String [] enableDisableValues= new String [] { ENABLED, DISABLED }; 578 579 String [] errorWarning= new String [] { ERROR, WARNING }; 580 581 String [] errorWarningLabels= new String [] { 582 PreferencesMessages.getString("CompilerConfigurationBlock.error"), PreferencesMessages.getString("CompilerConfigurationBlock.warning") }; 585 586 int nColumns= 3; 587 588 GridLayout layout= new GridLayout(); 589 layout.numColumns= nColumns; 590 591 Composite othersComposite= new Composite(folder, SWT.NULL); 592 othersComposite.setLayout(layout); 593 594 Label description= new Label(othersComposite, SWT.WRAP); 595 description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.build_warnings.description")); GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); 597 gd.horizontalSpan= nColumns; 598 description.setLayoutData(gd); 599 600 String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incomplete_build_path.label"); addComboBox(othersComposite, label, PREF_PB_INCOMPLETE_BUILDPATH, errorWarning, errorWarningLabels, 0); 602 603 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_build_path_cycles.label"); addComboBox(othersComposite, label, PREF_PB_CIRCULAR_BUILDPATH, errorWarning, errorWarningLabels, 0); 605 606 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_duplicate_resources.label"); addComboBox(othersComposite, label, PREF_PB_DUPLICATE_RESOURCE, errorWarning, errorWarningLabels, 0); 608 609 String [] errorWarningIgnore= new String [] { ERROR, WARNING, IGNORE }; 610 611 String [] errorWarningIgnoreLabels= new String [] { 612 PreferencesMessages.getString("CompilerConfigurationBlock.error"), PreferencesMessages.getString("CompilerConfigurationBlock.warning"), PreferencesMessages.getString("CompilerConfigurationBlock.ignore") }; 616 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_check_prereq_binary_level.label"); addComboBox(othersComposite, label, PREF_PB_INCOMPATIBLE_JDK_LEVEL, errorWarningIgnore, errorWarningIgnoreLabels, 0); 618 619 label= PreferencesMessages.getString("CompilerConfigurationBlock.build_invalid_classpath.label"); addCheckBox(othersComposite, label, PREF_BUILD_INVALID_CLASSPATH, abortIgnoreValues, 0); 621 622 label= PreferencesMessages.getString("CompilerConfigurationBlock.build_clean_outputfolder.label"); addCheckBox(othersComposite, label, PREF_BUILD_CLEAN_OUTPUT_FOLDER, cleanIgnoreValues, 0); 624 625 label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_exclusion_patterns.label"); addCheckBox(othersComposite, label, PREF_ENABLE_EXCLUSION_PATTERNS, enableDisableValues, 0); 627 628 label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_multiple_outputlocations.label"); addCheckBox(othersComposite, label, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS, enableDisableValues, 0); 630 631 label= PreferencesMessages.getString("CompilerConfigurationBlock.resource_filter.label"); Text text= addTextField(othersComposite, label, PREF_RESOURCE_FILTER, 0, 0); 633 gd= (GridData) text.getLayoutData(); 634 gd.grabExcessHorizontalSpace= true; 635 gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(10); 636 637 description= new Label(othersComposite, SWT.WRAP); 638 description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.resource_filter.description")); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); 640 gd.horizontalSpan= nColumns; 641 gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60); 642 description.setLayoutData(gd); 643 644 645 return othersComposite; 646 } 647 648 private Composite createComplianceTabContent(Composite folder) { 649 GridLayout layout= new GridLayout(); 650 layout.numColumns= 1; 651 652 String [] values34, values34Labels; 653 if (JavaModelUtil.isJDTCore_1_5()) { 654 values34= new String [] { VERSION_1_3, VERSION_1_4, VERSION_1_5 }; 655 values34Labels= new String [] { 656 PreferencesMessages.getString("CompilerConfigurationBlock.version13"), PreferencesMessages.getString("CompilerConfigurationBlock.version14"), PreferencesMessages.getString("CompilerConfigurationBlock.version15") }; 660 } else { 661 values34= new String [] { VERSION_1_3, VERSION_1_4 }; 662 values34Labels= new String [] { 663 PreferencesMessages.getString("CompilerConfigurationBlock.version13"), PreferencesMessages.getString("CompilerConfigurationBlock.version14") }; 666 } 667 668 Composite compComposite= new Composite(folder, SWT.NULL); 669 compComposite.setLayout(layout); 670 671 int nColumns= 3; 672 673 layout= new GridLayout(); 674 layout.numColumns= nColumns; 675 676 Group group= new Group(compComposite, SWT.NONE); 677 group.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.group.label")); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 679 group.setLayout(layout); 680 681 String label= PreferencesMessages.getString("CompilerConfigurationBlock.compiler_compliance.label"); addComboBox(group, label, PREF_COMPLIANCE, values34, values34Labels, 0); 683 684 label= PreferencesMessages.getString("CompilerConfigurationBlock.default_settings.label"); addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, new String [] { DEFAULT_CONF, USER_CONF }, 0); 686 687 int indent= fPixelConverter.convertWidthInCharsToPixels(2); 688 Control[] otherChildren= group.getChildren(); 689 690 String [] values14, values14Labels; 691 if (JavaModelUtil.isJDTCore_1_5()) { 692 values14= new String [] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5 }; 693 values14Labels= new String [] { 694 PreferencesMessages.getString("CompilerConfigurationBlock.version11"), PreferencesMessages.getString("CompilerConfigurationBlock.version12"), PreferencesMessages.getString("CompilerConfigurationBlock.version13"), PreferencesMessages.getString("CompilerConfigurationBlock.version14"), PreferencesMessages.getString("CompilerConfigurationBlock.version15") }; 700 } else { 701 values14= new String [] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4 }; 702 values14Labels= new String [] { 703 PreferencesMessages.getString("CompilerConfigurationBlock.version11"), PreferencesMessages.getString("CompilerConfigurationBlock.version12"), PreferencesMessages.getString("CompilerConfigurationBlock.version13"), PreferencesMessages.getString("CompilerConfigurationBlock.version14") }; 708 } 709 710 label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_targetplatform.label"); addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, values14, values14Labels, indent); 712 713 label= PreferencesMessages.getString("CompilerConfigurationBlock.source_compatibility.label"); addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values34, values34Labels, indent); 715 716 String [] errorWarningIgnore= new String [] { ERROR, WARNING, IGNORE }; 717 718 String [] errorWarningIgnoreLabels= new String [] { 719 PreferencesMessages.getString("CompilerConfigurationBlock.error"), PreferencesMessages.getString("CompilerConfigurationBlock.warning"), PreferencesMessages.getString("CompilerConfigurationBlock.ignore") }; 723 724 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_assert_as_identifier.label"); addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent); 726 727 Control[] allChildren= group.getChildren(); 728 fComplianceControls.addAll(Arrays.asList(allChildren)); 729 fComplianceControls.removeAll(Arrays.asList(otherChildren)); 730 731 layout= new GridLayout(); 732 layout.numColumns= nColumns; 733 734 group= new Group(compComposite, SWT.NONE); 735 group.setText(PreferencesMessages.getString("CompilerConfigurationBlock.classfiles.group.label")); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 737 group.setLayout(layout); 738 739 String [] generateValues= new String [] { GENERATE, DO_NOT_GENERATE }; 740 String [] enableDisableValues= new String [] { ENABLED, DISABLED }; 741 742 label= PreferencesMessages.getString("CompilerConfigurationBlock.variable_attr.label"); addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0); 744 745 label= PreferencesMessages.getString("CompilerConfigurationBlock.line_number_attr.label"); addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0); 747 748 label= PreferencesMessages.getString("CompilerConfigurationBlock.source_file_attr.label"); addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0); 750 751 label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_unused_local.label"); addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String [] { PRESERVE, OPTIMIZE_OUT }, 0); 753 754 label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_inline_jsr_bytecode.label"); addCheckBox(group, label, PREF_CODEGEN_INLINE_JSR_BYTECODE, enableDisableValues, 0); 756 757 return compComposite; 758 } 759 760 761 private Composite create15TabContent(TabFolder folder) { 762 String [] errorWarningIgnore= new String [] { ERROR, WARNING, IGNORE }; 763 764 String [] errorWarningIgnoreLabels= new String [] { 765 PreferencesMessages.getString("CompilerConfigurationBlock.error"), PreferencesMessages.getString("CompilerConfigurationBlock.warning"), PreferencesMessages.getString("CompilerConfigurationBlock.ignore") }; 769 770 int nColumns= 3; 771 772 GridLayout layout= new GridLayout(); 773 layout.numColumns= nColumns; 774 775 Composite composite= new Composite(folder, SWT.NULL); 776 composite.setLayout(layout); 777 778 Label description= new Label(composite, SWT.WRAP); 779 description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.15.description")); GridData gd= new GridData(); 781 gd.horizontalSpan= nColumns; 782 description.setLayoutData(gd); 783 784 String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unsafe_type_op.label"); addComboBox(composite, label, PREF_15_PB_UNSAVE_TYPE_OPERATION, errorWarningIgnore, errorWarningIgnoreLabels, 0); 786 787 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_final_param_bound.label"); addComboBox(composite, label, PREF_15_PB_FINAL_PARAM_BOUND, errorWarningIgnore, errorWarningIgnoreLabels, 0); 789 790 return composite; 791 } 792 793 794 795 796 800 protected void validateSettings(String changedKey, String newValue) { 801 802 if (changedKey != null) { 803 if (INTR_DEFAULT_COMPLIANCE.equals(changedKey)) { 804 updateComplianceEnableState(); 805 updateComplianceDefaultSettings(true); 806 fComplianceStatus= validateCompliance(); 807 } else if (PREF_COMPLIANCE.equals(changedKey)) { 808 if (checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF)) { 809 updateComplianceDefaultSettings(false); 810 } 811 fComplianceStatus= validateCompliance(); 812 } else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey)) { 813 updateAssertAsIdentifierEnableState(); 814 fComplianceStatus= validateCompliance(); 815 } else if (PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey) || 816 PREF_PB_ASSERT_AS_IDENTIFIER.equals(changedKey)) { 817 fComplianceStatus= validateCompliance(); 818 } else if (PREF_PB_MAX_PER_UNIT.equals(changedKey)) { 819 fMaxNumberProblemsStatus= validateMaxNumberProblems(); 820 } else if (PREF_RESOURCE_FILTER.equals(changedKey)) { 821 fResourceFilterStatus= validateResourceFilters(); 822 } else if (PREF_PB_UNUSED_PARAMETER.equals(changedKey) || 823 PREF_PB_DEPRECATION.equals(changedKey) || 824 PREF_PB_INVALID_JAVADOC.equals(changedKey) || 825 PREF_PB_MISSING_JAVADOC_TAGS.equals(changedKey) || 826 PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) || 827 PREF_PB_LOCAL_VARIABLE_HIDING.equals(changedKey) || 828 PREF_JAVADOC_SUPPORT.equals(changedKey) || 829 PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION.equals(changedKey)) { 830 updateEnableStates(); 831 } else if (PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING.equals(changedKey)) { 832 fWorkingValues.put(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, newValue); 834 } else { 835 return; 836 } 837 } else { 838 updateEnableStates(); 839 updateComplianceEnableState(); 840 updateAssertAsIdentifierEnableState(); 841 fComplianceStatus= validateCompliance(); 842 fMaxNumberProblemsStatus= validateMaxNumberProblems(); 843 fResourceFilterStatus= validateResourceFilters(); 844 } 845 IStatus status= StatusUtil.getMostSevere(new IStatus[] { fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus }); 846 fContext.statusChanged(status); 847 } 848 849 private void updateEnableStates() { 850 boolean enableUnusedParams= !checkValue(PREF_PB_UNUSED_PARAMETER, IGNORE); 851 getCheckBox(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING).setEnabled(enableUnusedParams); 852 853 boolean enableDeprecation= !checkValue(PREF_PB_DEPRECATION, IGNORE); 854 getCheckBox(PREF_PB_DEPRECATION_IN_DEPRECATED_CODE).setEnabled(enableDeprecation); 855 getCheckBox(PREF_PB_DEPRECATION_WHEN_OVERRIDING).setEnabled(enableDeprecation); 856 857 boolean enableThrownExceptions= !checkValue(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, IGNORE); 858 getCheckBox(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING).setEnabled(enableThrownExceptions); 859 860 boolean enableHiding= !checkValue(PREF_PB_LOCAL_VARIABLE_HIDING, IGNORE); 861 getCheckBox(PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD).setEnabled(enableHiding); 862 863 boolean enableJavadoc= checkValue(PREF_JAVADOC_SUPPORT, ENABLED); 864 fJavadocComposite.setVisible(enableJavadoc); 865 866 boolean enableInvalidTagsErrors= !checkValue(PREF_PB_INVALID_JAVADOC, IGNORE); 867 getCheckBox(PREF_PB_INVALID_JAVADOC_TAGS).setEnabled(enableInvalidTagsErrors); 868 setComboEnabled(PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, enableInvalidTagsErrors); 869 870 boolean enableMissingTagsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_TAGS, IGNORE); 871 getCheckBox(PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING).setEnabled(enableMissingTagsErrors); 872 setComboEnabled(PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, enableMissingTagsErrors); 873 874 boolean enableMissingCommentsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_COMMENTS, IGNORE); 875 getCheckBox(PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING).setEnabled(enableMissingCommentsErrors); 876 setComboEnabled(PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, enableMissingCommentsErrors); 877 } 878 879 private IStatus validateCompliance() { 880 StatusInfo status= new StatusInfo(); 881 String compliance= (String ) fWorkingValues.get(PREF_COMPLIANCE); 882 String source= (String ) fWorkingValues.get(PREF_SOURCE_COMPATIBILITY); 883 String target= (String ) fWorkingValues.get(PREF_CODEGEN_TARGET_PLATFORM); 884 885 if (VERSION_1_3.equals(compliance)) { 886 if (VERSION_1_4.equals(source) || VERSION_1_5.equals(source)) { 887 status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13src145.error")); return status; 889 } 890 if (VERSION_1_4.equals(target) || VERSION_1_5.equals(target)) { 891 status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13trg145.error")); return status; 893 } 894 } else if (VERSION_1_4.equals(compliance)) { 895 if (VERSION_1_5.equals(source)) { 896 status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl14src15.error")); return status; 898 } 899 if (VERSION_1_5.equals(target)) { 900 status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl14trg15.error")); return status; 902 } 903 } 904 if (VERSION_1_4.equals(source)) { 905 if (!VERSION_1_4.equals(target)) { 906 status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14tgt14.error")); return status; 908 } 909 } 910 return status; 911 } 912 913 private IStatus validateMaxNumberProblems() { 914 String number= (String ) fWorkingValues.get(PREF_PB_MAX_PER_UNIT); 915 StatusInfo status= new StatusInfo(); 916 if (number.length() == 0) { 917 status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.empty_input")); } else { 919 try { 920 int value= Integer.parseInt(number); 921 if (value <= 0) { 922 status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); } 924 } catch (NumberFormatException e) { 925 status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); } 927 } 928 return status; 929 } 930 931 private IStatus validateResourceFilters() { 932 String text= (String ) fWorkingValues.get(PREF_RESOURCE_FILTER); 933 934 IWorkspace workspace= ResourcesPlugin.getWorkspace(); 935 936 String [] filters= getTokens(text, ","); for (int i= 0; i < filters.length; i++) { 938 String fileName= filters[i].replace('*', 'x'); 939 int resourceType= IResource.FILE; 940 int lastCharacter= fileName.length() - 1; 941 if (lastCharacter >= 0 && fileName.charAt(lastCharacter) == '/') { 942 fileName= fileName.substring(0, lastCharacter); 943 resourceType= IResource.FOLDER; 944 } 945 IStatus status= workspace.validateName(fileName, resourceType); 946 if (status.matches(IStatus.ERROR)) { 947 String message= PreferencesMessages.getFormattedString("CompilerConfigurationBlock.filter.invalidsegment.error", status.getMessage()); return new StatusInfo(IStatus.ERROR, message); 949 } 950 } 951 return new StatusInfo(); 952 } 953 954 957 private void updateComplianceEnableState() { 958 boolean enabled= checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF); 959 for (int i= fComplianceControls.size() - 1; i >= 0; i--) { 960 Control curr= (Control) fComplianceControls.get(i); 961 curr.setEnabled(enabled); 962 } 963 } 964 965 private void updateAssertAsIdentifierEnableState() { 966 if (checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF)) { 967 boolean enabled= checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_3); 968 Combo combo= getComboBox(PREF_PB_ASSERT_AS_IDENTIFIER); 969 combo.setEnabled(enabled); 970 971 if (!enabled) { 972 String val= (String ) fWorkingValues.get(PREF_PB_ASSERT_AS_IDENTIFIER); 973 if (!ERROR.equals(val)) { 974 fWorkingValues.put(PREF_PB_ASSERT_AS_IDENTIFIER, ERROR); 975 updateCombo(combo); 976 fRememberedUserCompliance[0]= val; 977 } 978 } else { 979 String val= fRememberedUserCompliance[0]; 980 if (!ERROR.equals(val)) { 981 fWorkingValues.put(PREF_PB_ASSERT_AS_IDENTIFIER, val); 982 updateCombo(combo); 983 } 984 } 985 } 986 } 987 988 991 private void updateComplianceDefaultSettings(boolean rememberOld) { 992 String assertAsId, source, target; 993 String complianceLevel= (String ) fWorkingValues.get(PREF_COMPLIANCE); 994 boolean isDefault= checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF); 995 996 if (isDefault) { 997 if (rememberOld) { 998 fRememberedUserCompliance[0]= (String ) fWorkingValues.get(PREF_PB_ASSERT_AS_IDENTIFIER); 999 fRememberedUserCompliance[1]= (String ) fWorkingValues.get(PREF_SOURCE_COMPATIBILITY); 1000 fRememberedUserCompliance[2]= (String ) fWorkingValues.get(PREF_CODEGEN_TARGET_PLATFORM); 1001 fRememberedUserCompliance[3]= complianceLevel; 1002 } 1003 1004 if (VERSION_1_4.equals(complianceLevel)) { 1005 assertAsId= WARNING; 1006 source= VERSION_1_3; 1007 target= VERSION_1_2; 1008 } else if (VERSION_1_5.equals(complianceLevel)) { 1009 assertAsId= ERROR; 1010 source= VERSION_1_5; 1011 target= VERSION_1_5; 1012 } else { 1013 assertAsId= IGNORE; 1014 source= VERSION_1_3; 1015 target= VERSION_1_1; 1016 } 1017 } else { 1018 if (rememberOld && complianceLevel.equals(fRememberedUserCompliance[3])) { 1019 assertAsId= fRememberedUserCompliance[0]; 1020 source= fRememberedUserCompliance[1]; 1021 target= fRememberedUserCompliance[2]; 1022 } else { 1023 return; 1024 } 1025 } 1026 fWorkingValues.put(PREF_PB_ASSERT_AS_IDENTIFIER, assertAsId); 1027 fWorkingValues.put(PREF_SOURCE_COMPATIBILITY, source); 1028 fWorkingValues.put(PREF_CODEGEN_TARGET_PLATFORM, target); 1029 updateControls(); 1030 } 1031 1032 1035 private static String getCurrentCompliance(Map map) { 1036 Object complianceLevel= map.get(PREF_COMPLIANCE); 1037 if ((VERSION_1_3.equals(complianceLevel) 1038 && IGNORE.equals(map.get(PREF_PB_ASSERT_AS_IDENTIFIER)) 1039 && VERSION_1_3.equals(map.get(PREF_SOURCE_COMPATIBILITY)) 1040 && VERSION_1_1.equals(map.get(PREF_CODEGEN_TARGET_PLATFORM))) 1041 || (VERSION_1_4.equals(complianceLevel) 1042 && WARNING.equals(map.get(PREF_PB_ASSERT_AS_IDENTIFIER)) 1043 && VERSION_1_3.equals(map.get(PREF_SOURCE_COMPATIBILITY)) 1044 && VERSION_1_2.equals(map.get(PREF_CODEGEN_TARGET_PLATFORM)))) { 1045 return DEFAULT_CONF; 1046 } 1047 return USER_CONF; 1048 } 1049 1050 1051 protected String [] getFullBuildDialogStrings(boolean workspaceSettings) { 1052 String title= PreferencesMessages.getString("CompilerConfigurationBlock.needsbuild.title"); String message; 1054 if (workspaceSettings) { 1055 message= PreferencesMessages.getString("CompilerConfigurationBlock.needsfullbuild.message"); } else { 1057 message= PreferencesMessages.getString("CompilerConfigurationBlock.needsprojectbuild.message"); } 1059 return new String [] { title, message }; 1060 } 1061 1062} 1063 | Popular Tags |