1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.preferences;
13 import java.util.ArrayList;
16 import net.sourceforge.phpdt.core.IJavaProject;
17 import net.sourceforge.phpdt.core.JavaCore;
18 import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
19 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
20 import net.sourceforge.phpdt.internal.ui.util.PixelConverter;
21 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
22 import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener;
24 import org.eclipse.core.runtime.IStatus;
25 import org.eclipse.swt.SWT;
26 import org.eclipse.swt.layout.GridData;
27 import org.eclipse.swt.layout.GridLayout;
28 import org.eclipse.swt.widgets.Composite;
29 import org.eclipse.swt.widgets.Control;
30 import org.eclipse.swt.widgets.Label;
31 import org.eclipse.swt.widgets.TabFolder;
32 import org.eclipse.swt.widgets.TabItem;
33 import org.eclipse.swt.widgets.Text;
37 public class CompilerConfigurationBlock extends OptionsConfigurationBlock {
39 // Preference store keys, see JavaCore.getOptions
40 private static final String PREF_PB_PHP_VAR_DEPRECATED = JavaCore.COMPILER_PB_PHP_VAR_DEPRECATED;
42 private static final String PREF_PB_PHP_KEYWORD = JavaCore.COMPILER_PB_PHP_KEYWORD;
44 private static final String PREF_PB_PHP_UPPERCASE_IDENTIFIER = JavaCore.COMPILER_PB_PHP_UPPERCASE_IDENTIFIER;
46 private static final String PREF_PB_PHP_FILE_NOT_EXIST = JavaCore.COMPILER_PB_PHP_FILE_NOT_EXIST;
48 private static final String PREF_PB_UNREACHABLE_CODE = JavaCore.COMPILER_PB_UNREACHABLE_CODE;
50 private static final String PREF_PB_UNINITIALIZED_LOCAL_VARIABLE = JavaCore.COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE;
52 // private static final String PREF_LOCAL_VARIABLE_ATTR=
53 // JavaCore.COMPILER_LOCAL_VARIABLE_ATTR;
54 // private static final String PREF_LINE_NUMBER_ATTR=
55 // JavaCore.COMPILER_LINE_NUMBER_ATTR;
56 // private static final String PREF_SOURCE_FILE_ATTR=
57 // JavaCore.COMPILER_SOURCE_FILE_ATTR;
58 // private static final String PREF_CODEGEN_UNUSED_LOCAL=
59 // JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL;
60 // private static final String PREF_CODEGEN_TARGET_PLATFORM=
61 // JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM;
62 // private static final String PREF_PB_UNREACHABLE_CODE=
63 // JavaCore.COMPILER_PB_UNREACHABLE_CODE;
64 // private static final String PREF_PB_INVALID_IMPORT=
65 // JavaCore.COMPILER_PB_INVALID_IMPORT;
66 // private static final String PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD=
67 // JavaCore.COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD;
68 // private static final String PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME=
69 // JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME;
70 // private static final String PREF_PB_DEPRECATION=
71 // JavaCore.COMPILER_PB_DEPRECATION;
72 // private static final String PREF_PB_DEPRECATION_WHEN_OVERRIDING=
73 // JavaCore.COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD;
75 // private static final String PREF_PB_HIDDEN_CATCH_BLOCK=
76 // JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK;
77 // private static final String PREF_PB_UNUSED_LOCAL=
78 // JavaCore.COMPILER_PB_UNUSED_LOCAL;
79 // private static final String PREF_PB_UNUSED_PARAMETER=
80 // JavaCore.COMPILER_PB_UNUSED_PARAMETER;
81 // private static final String PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING=
82 // JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE;
83 // private static final String PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT=
84 // JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT;
85 // private static final String PREF_PB_SYNTHETIC_ACCESS_EMULATION=
86 // JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION;
87 // private static final String PREF_PB_NON_EXTERNALIZED_STRINGS=
88 // JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL;
89 // private static final String PREF_PB_ASSERT_AS_IDENTIFIER=
90 // JavaCore.COMPILER_PB_ASSERT_IDENTIFIER;
91 private static final String PREF_PB_MAX_PER_UNIT = JavaCore.COMPILER_PB_MAX_PER_UNIT;
93 // private static final String PREF_PB_UNUSED_IMPORT=
94 // JavaCore.COMPILER_PB_UNUSED_IMPORT;
95 // private static final String PREF_PB_UNUSED_PRIVATE=
96 // JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER;
97 // private static final String PREF_PB_STATIC_ACCESS_RECEIVER=
98 // JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER;
99 // private static final String PREF_PB_NO_EFFECT_ASSIGNMENT=
100 // JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT;
101 // private static final String PREF_PB_CHAR_ARRAY_IN_CONCAT=
102 // JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION;
103 // private static final String
104 // PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT=
105 // JavaCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT;
106 // private static final String PREF_PB_LOCAL_VARIABLE_HIDING=
107 // JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING;
108 // private static final String PREF_PB_FIELD_HIDING=
109 // JavaCore.COMPILER_PB_FIELD_HIDING;
110 // private static final String PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD=
111 // JavaCore.COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD;
112 // private static final String PREF_PB_INDIRECT_STATIC_ACCESS=
113 // JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS;
114 // private static final String PREF_PB_SUPERFLUOUS_SEMICOLON=
115 // JavaCore.COMPILER_PB_SUPERFLUOUS_SEMICOLON;
116 // private static final String PREF_PB_UNNECESSARY_TYPE_CHECK=
117 // JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK;
119 // private static final String PREF_PB_INVALID_JAVADOC=
120 // JavaCore.COMPILER_PB_INVALID_JAVADOC;
121 // private static final String PREF_PB_INVALID_JAVADOC_TAGS=
122 // JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS;
123 // private static final String PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY=
124 // JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY;
126 // private static final String PREF_PB_MISSING_JAVADOC_TAGS=
127 // JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS;
128 // private static final String PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY=
129 // JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY;
130 // private static final String PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING=
131 // JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING;
133 // private static final String PREF_PB_MISSING_JAVADOC_COMMENTS=
134 // JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS;
135 // private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY=
136 // JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY;
137 // private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING=
138 // JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING;
140 // private static final String PREF_SOURCE_COMPATIBILITY=
141 // JavaCore.COMPILER_SOURCE;
142 // private static final String PREF_COMPLIANCE=
143 // JavaCore.COMPILER_COMPLIANCE;
145 // private static final String PREF_RESOURCE_FILTER=
146 // JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER;
147 // private static final String PREF_BUILD_INVALID_CLASSPATH=
148 // JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH;
149 // private static final String PREF_BUILD_CLEAN_OUTPUT_FOLDER=
150 // JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER;
151 // private static final String PREF_ENABLE_EXCLUSION_PATTERNS=
152 // JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS;
153 // private static final String PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS=
154 // JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS;
156 // private static final String PREF_PB_INCOMPLETE_BUILDPATH=
157 // JavaCore.CORE_INCOMPLETE_CLASSPATH;
158 // private static final String PREF_PB_CIRCULAR_BUILDPATH=
159 // JavaCore.CORE_CIRCULAR_CLASSPATH;
160 // // private static final String PREF_PB_INCOMPATIBLE_JDK_LEVEL=
161 // JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL;
162 // private static final String PREF_PB_DEPRECATION_IN_DEPRECATED_CODE=
163 // JavaCore.COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE;
164 // private static final String PREF_PB_DUPLICATE_RESOURCE=
165 // JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE;
166 // private static final String PREF_PB_INCOMPATIBLE_INTERFACE_METHOD=
167 // JavaCore.COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD;
169 // private static final String PREF_PB_UNDOCUMENTED_EMPTY_BLOCK=
170 // JavaCore.COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK;
171 // private static final String PREF_PB_FINALLY_BLOCK_NOT_COMPLETING=
172 // JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING;
173 // private static final String PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION=
174 // JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION;
175 // private static final String
176 // PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING=
177 // JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING;
178 // private static final String PREF_PB_UNQUALIFIED_FIELD_ACCESS=
179 // JavaCore.COMPILER_PB_UNQUALIFIED_FIELD_ACCESS;
181 // private static final String INTR_DEFAULT_COMPLIANCE=
182 // "internal.default.compliance"; //$NON-NLS-1$
185 private static final String GENERATE = JavaCore.GENERATE;
187 private static final String DO_NOT_GENERATE = JavaCore.DO_NOT_GENERATE;
189 private static final String PRESERVE = JavaCore.PRESERVE;
191 private static final String OPTIMIZE_OUT = JavaCore.OPTIMIZE_OUT;
193 private static final String VERSION_1_1 = JavaCore.VERSION_1_1;
195 private static final String VERSION_1_2 = JavaCore.VERSION_1_2;
197 private static final String VERSION_1_3 = JavaCore.VERSION_1_3;
199 private static final String VERSION_1_4 = JavaCore.VERSION_1_4;
201 private static final String ERROR = JavaCore.ERROR;
203 private static final String WARNING = JavaCore.WARNING;
205 private static final String IGNORE = JavaCore.IGNORE;
207 private static final String ABORT = JavaCore.ABORT;
209 private static final String CLEAN = JavaCore.CLEAN;
211 private static final String ENABLED = JavaCore.ENABLED;
213 private static final String DISABLED = JavaCore.DISABLED;
215 // private static final String PUBLIC= JavaCore.PUBLIC;
216 // private static final String PROTECTED= JavaCore.PROTECTED;
217 // private static final String DEFAULT= JavaCore.DEFAULT;
218 // private static final String PRIVATE= JavaCore.PRIVATE;
220 private static final String DEFAULT_CONF = "default"; //$NON-NLS-1$
222 private static final String USER_CONF = "user"; //$NON-NLS-1$
224 private ArrayList fComplianceControls;
226 private PixelConverter fPixelConverter;
228 private IStatus fMaxNumberProblemsStatus;
230 // private IStatus fComplianceStatus, fMaxNumberProblemsStatus,
231 // fResourceFilterStatus;
233 public CompilerConfigurationBlock(IStatusChangeListener context,
234 IJavaProject project) {
235 super(context, project, getKeys());
237 fComplianceControls = new ArrayList();
239 // fComplianceStatus= new StatusInfo();
240 fMaxNumberProblemsStatus = new StatusInfo();
241 // fResourceFilterStatus= new StatusInfo();
243 // compatibilty code for the merge of the two option
244 // PB_SIGNAL_PARAMETER:
246 // (ENABLED.equals(fWorkingValues.get(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT)))
248 // fWorkingValues.put(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, ENABLED);
253 private final static String[] KEYS = new String[] {
254 PREF_PB_PHP_FILE_NOT_EXIST, PREF_PB_PHP_VAR_DEPRECATED,
255 PREF_PB_PHP_KEYWORD, PREF_PB_PHP_UPPERCASE_IDENTIFIER,
256 PREF_PB_UNREACHABLE_CODE, PREF_PB_UNINITIALIZED_LOCAL_VARIABLE,
257 // PREF_LOCAL_VARIABLE_ATTR,
258 // PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR,
259 // PREF_CODEGEN_UNUSED_LOCAL,
260 // PREF_CODEGEN_TARGET_PLATFORM,
261 // PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
262 // PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME,
263 // PREF_PB_DEPRECATION,
264 // PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL,
265 // PREF_PB_UNUSED_PARAMETER,
266 // PREF_PB_SYNTHETIC_ACCESS_EMULATION,
267 // PREF_PB_NON_EXTERNALIZED_STRINGS,
268 // PREF_PB_ASSERT_AS_IDENTIFIER,
269 // PREF_PB_UNUSED_IMPORT,
270 PREF_PB_MAX_PER_UNIT,
271 // PREF_SOURCE_COMPATIBILITY,
273 // PREF_RESOURCE_FILTER, PREF_BUILD_INVALID_CLASSPATH,
274 // PREF_PB_STATIC_ACCESS_RECEIVER, PREF_PB_INCOMPLETE_BUILDPATH,
275 // PREF_PB_CIRCULAR_BUILDPATH, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE,
276 // PREF_BUILD_CLEAN_OUTPUT_FOLDER,
277 // PREF_PB_DUPLICATE_RESOURCE, PREF_PB_NO_EFFECT_ASSIGNMENT,
278 // PREF_PB_INCOMPATIBLE_INTERFACE_METHOD,
279 // PREF_PB_UNUSED_PRIVATE, PREF_PB_CHAR_ARRAY_IN_CONCAT,
280 // PREF_ENABLE_EXCLUSION_PATTERNS, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS,
281 // PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT,
282 // PREF_PB_LOCAL_VARIABLE_HIDING,
283 // PREF_PB_FIELD_HIDING,
284 // PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD,
285 // PREF_PB_INCOMPATIBLE_JDK_LEVEL,
286 // PREF_PB_INDIRECT_STATIC_ACCESS,
287 // PREF_PB_SUPERFLUOUS_SEMICOLON,
288 // PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING,
289 // PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT,
290 // PREF_PB_UNNECESSARY_TYPE_CHECK,
291 // PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION,
292 // PREF_PB_UNQUALIFIED_FIELD_ACCESS,
293 // PREF_PB_UNDOCUMENTED_EMPTY_BLOCK,
294 // PREF_PB_FINALLY_BLOCK_NOT_COMPLETING,
295 // PREF_PB_DEPRECATION_WHEN_OVERRIDING,
296 // PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING,
298 // PREF_PB_INVALID_JAVADOC,
299 // PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY,
300 // PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY,
301 // PREF_PB_MISSING_JAVADOC_TAGS,
302 // PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY,
303 // PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING,
304 // PREF_PB_MISSING_JAVADOC_COMMENTS,
305 // PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY,
306 // PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING
309 private static String[] getKeys() {
313 protected final Map getOptions(boolean inheritJavaCoreOptions) {
314 Map map = super.getOptions(inheritJavaCoreOptions);
315 // map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
319 protected final Map getDefaultOptions() {
320 Map map = super.getDefaultOptions();
321 // map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
326 * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
328 protected Control createContents(Composite parent) {
329 fPixelConverter = new PixelConverter(parent);
330 setShell(parent.getShell());
332 TabFolder folder = new TabFolder(parent, SWT.NONE);
333 folder.setLayout(new TabFolderLayout());
334 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
336 Composite commonComposite = createStyleTabContent(folder);
337 // Composite unusedComposite= createUnusedCodeTabContent(folder);
338 Composite advancedComposite = createAdvancedTabContent(folder);
339 // Composite javadocComposite= createJavadocTabContent(folder);
340 // Composite complianceComposite= createComplianceTabContent(folder);
341 // Composite othersComposite= createBuildPathTabContent(folder);
343 TabItem item = new TabItem(folder, SWT.NONE);
344 item.setText(PreferencesMessages
345 .getString("CompilerConfigurationBlock.common.tabtitle")); //$NON-NLS-1$
346 item.setControl(commonComposite);
348 item = new TabItem(folder, SWT.NONE);
349 item.setText(PreferencesMessages
350 .getString("CompilerConfigurationBlock.advanced.tabtitle")); //$NON-NLS-1$
351 item.setControl(advancedComposite);
353 // item= new TabItem(folder, SWT.NONE);
354 // item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.tabtitle"));
356 // item.setControl(unusedComposite);
358 // item= new TabItem(folder, SWT.NONE);
359 // item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.tabtitle"));
361 // item.setControl(javadocComposite);
363 // item= new TabItem(folder, SWT.NONE);
364 // item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.tabtitle"));
366 // item.setControl(complianceComposite);
368 // item= new TabItem(folder, SWT.NONE);
369 // item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.others.tabtitle"));
371 // item.setControl(othersComposite);
373 validateSettings(null, null);
378 private Composite createStyleTabContent(Composite folder) {
379 String[] errorWarningIgnore = new String[] { ERROR, WARNING, IGNORE };
381 String[] errorWarningIgnoreLabels = new String[] {
383 .getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
385 .getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
387 .getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
392 GridLayout layout = new GridLayout();
393 layout.numColumns = nColumns;
395 Composite composite = new Composite(folder, SWT.NULL);
396 composite.setLayout(layout);
398 Label description = new Label(composite, SWT.WRAP);
399 description.setText(PreferencesMessages
400 .getString("CompilerConfigurationBlock.common.description")); //$NON-NLS-1$
401 GridData gd = new GridData();
402 gd.horizontalSpan = nColumns;
403 gd.widthHint = fPixelConverter.convertWidthInCharsToPixels(50);
404 description.setLayoutData(gd);
406 String label = PreferencesMessages
407 .getString("CompilerConfigurationBlock.pb_file_not_exist.label"); //$NON-NLS-1$
408 addComboBox(composite, label, PREF_PB_PHP_FILE_NOT_EXIST,
409 errorWarningIgnore, errorWarningIgnoreLabels, 0);
411 label = PreferencesMessages
412 .getString("CompilerConfigurationBlock.pb_var_deprecated.label"); //$NON-NLS-1$
413 addComboBox(composite, label, PREF_PB_PHP_VAR_DEPRECATED,
414 errorWarningIgnore, errorWarningIgnoreLabels, 0);
416 label = PreferencesMessages
417 .getString("CompilerConfigurationBlock.pb_keyword.label"); //$NON-NLS-1$
418 addComboBox(composite, label, PREF_PB_PHP_KEYWORD, errorWarningIgnore,
419 errorWarningIgnoreLabels, 0);
421 label = PreferencesMessages
422 .getString("CompilerConfigurationBlock.pb_uppercase_identifier.label"); //$NON-NLS-1$
423 addComboBox(composite, label, PREF_PB_PHP_UPPERCASE_IDENTIFIER,
424 errorWarningIgnore, errorWarningIgnoreLabels, 0);
426 label = PreferencesMessages
427 .getString("CompilerConfigurationBlock.pb_unreachable_code.label"); //$NON-NLS-1$
428 addComboBox(composite, label, PREF_PB_UNREACHABLE_CODE,
429 errorWarningIgnore, errorWarningIgnoreLabels, 0);
431 label = PreferencesMessages
432 .getString("CompilerConfigurationBlock.pb_unitialized_local_variable.label"); //$NON-NLS-1$
433 addComboBox(composite, label, PREF_PB_UNINITIALIZED_LOCAL_VARIABLE,
434 errorWarningIgnore, errorWarningIgnoreLabels, 0);
436 label = PreferencesMessages
437 .getString("CompilerConfigurationBlock.pb_overriding_pkg_dflt.label"); //$NON-NLS-1$
438 // addComboBox(composite, label,
439 // PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore,
440 // errorWarningIgnoreLabels, 0);
443 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_method_naming.label");
445 // addComboBox(composite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME,
446 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
449 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_hidden_catchblock.label");
451 // addComboBox(composite, label, PREF_PB_HIDDEN_CATCH_BLOCK,
452 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
455 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_static_access_receiver.label");
457 // addComboBox(composite, label, PREF_PB_STATIC_ACCESS_RECEIVER,
458 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
461 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_no_effect_assignment.label");
463 // addComboBox(composite, label, PREF_PB_NO_EFFECT_ASSIGNMENT,
464 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
467 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_indirect_access_to_static.label");
469 // addComboBox(composite, label, PREF_PB_INDIRECT_STATIC_ACCESS,
470 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
473 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_accidential_assignement.label");
475 // addComboBox(composite, label,
476 // PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, errorWarningIgnore,
477 // errorWarningIgnoreLabels, 0);
480 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_finally_block_not_completing.label");
482 // addComboBox(composite, label, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING,
483 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
486 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_undocumented_empty_block.label");
488 // addComboBox(composite, label, PREF_PB_UNDOCUMENTED_EMPTY_BLOCK,
489 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
494 private Composite createAdvancedTabContent(TabFolder folder) {
495 String[] errorWarningIgnore = new String[] { ERROR, WARNING, IGNORE };
497 String[] errorWarningIgnoreLabels = new String[] {
499 .getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
501 .getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
503 .getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
506 String[] enabledDisabled = new String[] { ENABLED, DISABLED };
510 GridLayout layout = new GridLayout();
511 layout.numColumns = nColumns;
513 Composite composite = new Composite(folder, SWT.NULL);
514 composite.setLayout(layout);
516 Label description = new Label(composite, SWT.WRAP);
517 description.setText(PreferencesMessages
518 .getString("CompilerConfigurationBlock.advanced.description")); //$NON-NLS-1$
519 GridData gd = new GridData();
520 gd.horizontalSpan = nColumns;
521 gd.widthHint = fPixelConverter.convertWidthInCharsToPixels(50);
522 description.setLayoutData(gd);
525 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_synth_access_emul.label");
527 // addComboBox(composite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION,
528 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
531 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_local_variable_hiding.label");
533 // addComboBox(composite, label, PREF_PB_LOCAL_VARIABLE_HIDING,
534 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
536 // int indent= fPixelConverter.convertWidthInCharsToPixels(2);
538 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_special_param_hiding.label");
540 // addCheckBox(composite, label, PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD,
541 // enabledDisabled, indent);
544 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_field_hiding.label");
546 // addComboBox(composite, label, PREF_PB_FIELD_HIDING,
547 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
550 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_non_externalized_strings.label");
552 // addComboBox(composite, label, PREF_PB_NON_EXTERNALIZED_STRINGS,
553 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
556 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_incompatible_interface_method.label");
558 // addComboBox(composite, label, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD,
559 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
562 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_char_array_in_concat.label");
564 // addComboBox(composite, label, PREF_PB_CHAR_ARRAY_IN_CONCAT,
565 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
568 // PreferencesMessages.getString("CompilerConfigurationBlock.pb_unqualified_field_access.label");
570 // addComboBox(composite, label, PREF_PB_UNQUALIFIED_FIELD_ACCESS,
571 // errorWarningIgnore, errorWarningIgnoreLabels, 0);
574 gd.widthHint = fPixelConverter.convertWidthInCharsToPixels(6);
576 String label = PreferencesMessages
577 .getString("CompilerConfigurationBlock.pb_max_per_unit.label"); //$NON-NLS-1$
578 Text text = addTextField(composite, label, PREF_PB_MAX_PER_UNIT, 0, 0);
579 text.setTextLimit(6);
580 text.setLayoutData(gd);
586 * (non-javadoc) Update fields and validate. @param changedKey Key that
587 * changed, or null, if all changed.
589 protected void validateSettings(String changedKey, String newValue) {
591 if (changedKey != null) {
592 // if (INTR_DEFAULT_COMPLIANCE.equals(changedKey)) {
593 // updateComplianceEnableState();
594 // if (DEFAULT_CONF.equals(newValue)) {
595 // updateComplianceDefaultSettings();
597 // fComplianceStatus= validateCompliance();
598 // } else if (PREF_COMPLIANCE.equals(changedKey)) {
599 // if (checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF)) {
600 // updateComplianceDefaultSettings();
602 // fComplianceStatus= validateCompliance();
603 // } else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey) ||
604 // PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey) ||
605 // PREF_PB_ASSERT_AS_IDENTIFIER.equals(changedKey)) {
606 // fComplianceStatus= validateCompliance();
608 if (PREF_PB_MAX_PER_UNIT.equals(changedKey)) {
609 fMaxNumberProblemsStatus = validateMaxNumberProblems();
610 // } else if (PREF_RESOURCE_FILTER.equals(changedKey)) {
611 // fResourceFilterStatus= validateResourceFilters();
612 // } else if (S.equals(changedKey) ||
613 // PREF_PB_DEPRECATION.equals(changedKey) ) { // ||
614 // // PREF_PB_INVALID_JAVADOC.equals(changedKey) ||
615 // // PREF_PB_MISSING_JAVADOC_TAGS.equals(changedKey) ||
616 // // PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) ||
617 // // PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) ||
619 // PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION.equals(changedKey))
621 // updateEnableStates();
623 // (PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING.equals(changedKey)) {
624 // // merging the two options
625 // fWorkingValues.put(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT,
631 // updateEnableStates();
632 // updateComplianceEnableState();
633 // fComplianceStatus= validateCompliance();
634 fMaxNumberProblemsStatus = validateMaxNumberProblems();
635 // fResourceFilterStatus= validateResourceFilters();
637 // IStatus status= StatusUtil.getMostSevere(new IStatus[] {
638 // fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus
640 IStatus status = StatusUtil
641 .getMostSevere(new IStatus[] { fMaxNumberProblemsStatus });
642 fContext.statusChanged(status);
645 // private void updateEnableStates() {
646 // boolean enableUnusedParams= !checkValue(PREF_PB_UNUSED_PARAMETER,
648 // getCheckBox(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING).setEnabled(enableUnusedParams);
650 // boolean enableDeprecation= !checkValue(PREF_PB_DEPRECATION, IGNORE);
651 // getCheckBox(PREF_PB_DEPRECATION_IN_DEPRECATED_CODE).setEnabled(enableDeprecation);
652 // getCheckBox(PREF_PB_DEPRECATION_WHEN_OVERRIDING).setEnabled(enableDeprecation);
654 // boolean enableThrownExceptions=
655 // !checkValue(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, IGNORE);
656 // getCheckBox(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING).setEnabled(enableThrownExceptions);
658 // boolean enableHiding= !checkValue(PREF_PB_LOCAL_VARIABLE_HIDING, IGNORE);
659 // getCheckBox(PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD).setEnabled(enableHiding);
661 // boolean enableInvalidTagsErrors= !checkValue(PREF_PB_INVALID_JAVADOC,
663 // getCheckBox(PREF_PB_INVALID_JAVADOC_TAGS).setEnabled(enableInvalidTagsErrors);
664 // setComboEnabled(PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY,
665 // enableInvalidTagsErrors);
667 // boolean enableMissingTagsErrors=
668 // !checkValue(PREF_PB_MISSING_JAVADOC_TAGS, IGNORE);
669 // getCheckBox(PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING).setEnabled(enableMissingTagsErrors);
670 // setComboEnabled(PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY,
671 // enableMissingTagsErrors);
673 // boolean enableMissingCommentsErrors=
674 // !checkValue(PREF_PB_MISSING_JAVADOC_COMMENTS, IGNORE);
675 // getCheckBox(PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING).setEnabled(enableMissingCommentsErrors);
676 // setComboEnabled(PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY,
677 // enableMissingCommentsErrors);
680 // private IStatus validateCompliance() {
681 // StatusInfo status= new StatusInfo();
682 // if (checkValue(PREF_COMPLIANCE, VERSION_1_3)) {
683 // if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
684 // status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13src14.error"));
687 // } else if (checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) {
688 // status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13trg14.error"));
693 // if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
694 // if (!checkValue(PREF_PB_ASSERT_AS_IDENTIFIER, ERROR)) {
695 // status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14asrterr.error"));
700 // if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
701 // if (!checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) {
702 // status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14tgt14.error"));
710 private IStatus validateMaxNumberProblems() {
711 String number = (String) fWorkingValues.get(PREF_PB_MAX_PER_UNIT);
712 StatusInfo status = new StatusInfo();
713 if (number.length() == 0) {
714 status.setError(PreferencesMessages
715 .getString("CompilerConfigurationBlock.empty_input")); //$NON-NLS-1$
718 int value = Integer.parseInt(number);
721 .setError(PreferencesMessages
723 "CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
725 } catch (NumberFormatException e) {
726 status.setError(PreferencesMessages.getFormattedString(
727 "CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
733 // private IStatus validateResourceFilters() {
734 // String text= (String) fWorkingValues.get(PREF_RESOURCE_FILTER);
736 // IWorkspace workspace= ResourcesPlugin.getWorkspace();
738 // String[] filters= getTokens(text, ","); //$NON-NLS-1$
739 // for (int i= 0; i < filters.length; i++) {
740 // String fileName= filters[i].replace('*', 'x');
741 // int resourceType= IResource.FILE;
742 // int lastCharacter= fileName.length() - 1;
743 // if (lastCharacter >= 0 && fileName.charAt(lastCharacter) == '/') {
744 // fileName= fileName.substring(0, lastCharacter);
745 // resourceType= IResource.FOLDER;
747 // IStatus status= workspace.validateName(fileName, resourceType);
748 // if (status.matches(IStatus.ERROR)) {
750 // PreferencesMessages.getFormattedString("CompilerConfigurationBlock.filter.invalidsegment.error",
751 // status.getMessage()); //$NON-NLS-1$
752 // return new StatusInfo(IStatus.ERROR, message);
755 // return new StatusInfo();
758 protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
759 String title = PreferencesMessages
760 .getString("CompilerConfigurationBlock.needsbuild.title"); //$NON-NLS-1$
762 if (workspaceSettings) {
763 message = PreferencesMessages
764 .getString("CompilerConfigurationBlock.needsfullbuild.message"); //$NON-NLS-1$
766 message = PreferencesMessages
767 .getString("CompilerConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$
769 return new String[] { title, message };