KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > preferences > CompilerConfigurationBlock


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.preferences;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Arrays JavaDoc;
15 import java.util.Map JavaDoc;
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 /**
45   */

46 public class CompilerConfigurationBlock extends OptionsConfigurationBlock {
47
48     // Preference store keys, see JavaCore.getOptions
49
private static final String JavaDoc PREF_LOCAL_VARIABLE_ATTR= JavaCore.COMPILER_LOCAL_VARIABLE_ATTR;
50     private static final String JavaDoc PREF_LINE_NUMBER_ATTR= JavaCore.COMPILER_LINE_NUMBER_ATTR;
51     private static final String JavaDoc PREF_SOURCE_FILE_ATTR= JavaCore.COMPILER_SOURCE_FILE_ATTR;
52     private static final String JavaDoc PREF_CODEGEN_UNUSED_LOCAL= JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL;
53     private static final String JavaDoc PREF_CODEGEN_TARGET_PLATFORM= JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM;
54     private static final String JavaDoc PREF_CODEGEN_INLINE_JSR_BYTECODE= JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE;
55     
56     //private static final String PREF_PB_UNREACHABLE_CODE= JavaCore.COMPILER_PB_UNREACHABLE_CODE;
57
//private static final String PREF_PB_INVALID_IMPORT= JavaCore.COMPILER_PB_INVALID_IMPORT;
58
private static final String JavaDoc PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD= JavaCore.COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD;
59     private static final String JavaDoc PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME;
60     private static final String JavaDoc PREF_PB_DEPRECATION= JavaCore.COMPILER_PB_DEPRECATION;
61     private static final String JavaDoc PREF_PB_DEPRECATION_WHEN_OVERRIDING= JavaCore.COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD;
62     
63     private static final String JavaDoc PREF_PB_HIDDEN_CATCH_BLOCK= JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK;
64     private static final String JavaDoc PREF_PB_UNUSED_LOCAL= JavaCore.COMPILER_PB_UNUSED_LOCAL;
65     private static final String JavaDoc PREF_PB_UNUSED_PARAMETER= JavaCore.COMPILER_PB_UNUSED_PARAMETER;
66     private static final String JavaDoc PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE;
67     private static final String JavaDoc PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT;
68     private static final String JavaDoc PREF_PB_SYNTHETIC_ACCESS_EMULATION= JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION;
69     private static final String JavaDoc PREF_PB_NON_EXTERNALIZED_STRINGS= JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL;
70     private static final String JavaDoc PREF_PB_ASSERT_AS_IDENTIFIER= JavaCore.COMPILER_PB_ASSERT_IDENTIFIER;
71     private static final String JavaDoc PREF_PB_MAX_PER_UNIT= JavaCore.COMPILER_PB_MAX_PER_UNIT;
72     private static final String JavaDoc PREF_PB_UNUSED_IMPORT= JavaCore.COMPILER_PB_UNUSED_IMPORT;
73     private static final String JavaDoc PREF_PB_UNUSED_PRIVATE= JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER;
74     private static final String JavaDoc PREF_PB_STATIC_ACCESS_RECEIVER= JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER;
75     private static final String JavaDoc PREF_PB_NO_EFFECT_ASSIGNMENT= JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT;
76     private static final String JavaDoc PREF_PB_CHAR_ARRAY_IN_CONCAT= JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION;
77     private static final String JavaDoc PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT= JavaCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT;
78     private static final String JavaDoc PREF_PB_LOCAL_VARIABLE_HIDING= JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING;
79     private static final String JavaDoc PREF_PB_FIELD_HIDING= JavaCore.COMPILER_PB_FIELD_HIDING;
80     private static final String JavaDoc PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD= JavaCore.COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD;
81     private static final String JavaDoc PREF_PB_INDIRECT_STATIC_ACCESS= JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS;
82     private static final String JavaDoc PREF_PB_EMPTY_STATEMENT= JavaCore.COMPILER_PB_EMPTY_STATEMENT;
83     private static final String JavaDoc PREF_PB_UNNECESSARY_ELSE= JavaCore.COMPILER_PB_UNNECESSARY_ELSE;
84     private static final String JavaDoc PREF_PB_UNNECESSARY_TYPE_CHECK= JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK;
85     
86     private static final String JavaDoc PREF_JAVADOC_SUPPORT= JavaCore.COMPILER_DOC_COMMENT_SUPPORT;
87
88     private static final String JavaDoc PREF_PB_INVALID_JAVADOC= JavaCore.COMPILER_PB_INVALID_JAVADOC;
89     private static final String JavaDoc PREF_PB_INVALID_JAVADOC_TAGS= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS;
90     private static final String JavaDoc PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY;
91
92     private static final String JavaDoc PREF_PB_MISSING_JAVADOC_TAGS= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS;
93     private static final String JavaDoc PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY;
94     private static final String JavaDoc PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING;
95
96     private static final String JavaDoc PREF_PB_MISSING_JAVADOC_COMMENTS= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS;
97     private static final String JavaDoc PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY;
98     private static final String JavaDoc PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING;
99     
100     private static final String JavaDoc PREF_SOURCE_COMPATIBILITY= JavaCore.COMPILER_SOURCE;
101     private static final String JavaDoc PREF_COMPLIANCE= JavaCore.COMPILER_COMPLIANCE;
102
103     private static final String JavaDoc PREF_RESOURCE_FILTER= JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER;
104     private static final String JavaDoc PREF_BUILD_INVALID_CLASSPATH= JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH;
105     private static final String JavaDoc PREF_BUILD_CLEAN_OUTPUT_FOLDER= JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER;
106     private static final String JavaDoc PREF_ENABLE_EXCLUSION_PATTERNS= JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS;
107     private static final String JavaDoc PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS= JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS;
108
109     private static final String JavaDoc PREF_PB_INCOMPLETE_BUILDPATH= JavaCore.CORE_INCOMPLETE_CLASSPATH;
110     private static final String JavaDoc PREF_PB_CIRCULAR_BUILDPATH= JavaCore.CORE_CIRCULAR_CLASSPATH;
111     private static final String JavaDoc PREF_PB_INCOMPATIBLE_JDK_LEVEL= JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL;
112     private static final String JavaDoc PREF_PB_DUPLICATE_RESOURCE= JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE;
113
114     private static final String JavaDoc PREF_PB_DEPRECATION_IN_DEPRECATED_CODE= JavaCore.COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE;
115     private static final String JavaDoc PREF_PB_INCOMPATIBLE_INTERFACE_METHOD= JavaCore.COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD;
116
117     private static final String JavaDoc PREF_PB_UNDOCUMENTED_EMPTY_BLOCK= JavaCore.COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK;
118     private static final String JavaDoc PREF_PB_FINALLY_BLOCK_NOT_COMPLETING= JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING;
119     private static final String JavaDoc PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION= JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION;
120     private static final String JavaDoc PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING;
121     private static final String JavaDoc PREF_PB_UNQUALIFIED_FIELD_ACCESS= JavaCore.COMPILER_PB_UNQUALIFIED_FIELD_ACCESS;
122
123     private static final String JavaDoc PREF_15_PB_UNSAVE_TYPE_OPERATION= "org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation"; //$NON-NLS-1$
124
private static final String JavaDoc PREF_15_PB_FINAL_PARAM_BOUND= "org.eclipse.jdt.core.compiler.problem.finalParameterBound"; //$NON-NLS-1$
125

126     
127     private static final String JavaDoc INTR_DEFAULT_COMPLIANCE= "internal.default.compliance"; //$NON-NLS-1$
128

129     // values
130
private static final String JavaDoc GENERATE= JavaCore.GENERATE;
131     private static final String JavaDoc DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE;
132     
133     private static final String JavaDoc PRESERVE= JavaCore.PRESERVE;
134     private static final String JavaDoc OPTIMIZE_OUT= JavaCore.OPTIMIZE_OUT;
135     
136     private static final String JavaDoc VERSION_1_1= JavaCore.VERSION_1_1;
137     private static final String JavaDoc VERSION_1_2= JavaCore.VERSION_1_2;
138     private static final String JavaDoc VERSION_1_3= JavaCore.VERSION_1_3;
139     private static final String JavaDoc VERSION_1_4= JavaCore.VERSION_1_4;
140     private static final String JavaDoc VERSION_1_5= JavaCore.VERSION_1_5;
141     
142     private static final String JavaDoc ERROR= JavaCore.ERROR;
143     private static final String JavaDoc WARNING= JavaCore.WARNING;
144     private static final String JavaDoc IGNORE= JavaCore.IGNORE;
145
146     private static final String JavaDoc ABORT= JavaCore.ABORT;
147     private static final String JavaDoc CLEAN= JavaCore.CLEAN;
148
149     private static final String JavaDoc ENABLED= JavaCore.ENABLED;
150     private static final String JavaDoc DISABLED= JavaCore.DISABLED;
151     
152     private static final String JavaDoc PUBLIC= JavaCore.PUBLIC;
153     private static final String JavaDoc PROTECTED= JavaCore.PROTECTED;
154     private static final String JavaDoc DEFAULT= JavaCore.DEFAULT;
155     private static final String JavaDoc PRIVATE= JavaCore.PRIVATE;
156     
157     private static final String JavaDoc DEFAULT_CONF= "default"; //$NON-NLS-1$
158
private static final String JavaDoc USER_CONF= "user"; //$NON-NLS-1$
159

160     private ArrayList JavaDoc fComplianceControls;
161     private PixelConverter fPixelConverter;
162     private Composite fJavadocComposite;
163     
164     private String JavaDoc[] 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 JavaDoc();
172             
173         fComplianceStatus= new StatusInfo();
174         fMaxNumberProblemsStatus= new StatusInfo();
175         fResourceFilterStatus= new StatusInfo();
176         
177         // compatibilty code for the merge of the two option PB_SIGNAL_PARAMETER:
178
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 JavaDoc[] {
182             (String JavaDoc) fWorkingValues.get(PREF_PB_ASSERT_AS_IDENTIFIER),
183             (String JavaDoc) fWorkingValues.get(PREF_SOURCE_COMPATIBILITY),
184             (String JavaDoc) fWorkingValues.get(PREF_CODEGEN_TARGET_PLATFORM),
185             (String JavaDoc) fWorkingValues.get(PREF_COMPLIANCE),
186         };
187     }
188     
189     private static String JavaDoc[] getKeys() {
190         String JavaDoc[] keys= new String JavaDoc[] {
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 JavaDoc[] newKeys= new String JavaDoc[] {
217                     PREF_15_PB_UNSAVE_TYPE_OPERATION, PREF_15_PB_FINAL_PARAM_BOUND
218             };
219             String JavaDoc[] merged= new String JavaDoc[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 JavaDoc getOptions(boolean inheritJavaCoreOptions) {
228         Map JavaDoc map= super.getOptions(inheritJavaCoreOptions);
229         map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
230         return map;
231     }
232     
233     protected final Map JavaDoc getDefaultOptions() {
234         Map JavaDoc map= super.getDefaultOptions();
235         map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
236         return map;
237     }
238     
239     
240     /*
241      * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
242      */

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")); //$NON-NLS-1$
261
item.setControl(commonComposite);
262
263         item= new TabItem(folder, SWT.NONE);
264         item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.tabtitle")); //$NON-NLS-1$
265
item.setControl(advancedComposite);
266
267         item= new TabItem(folder, SWT.NONE);
268         item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.tabtitle")); //$NON-NLS-1$
269
item.setControl(unusedComposite);
270         
271         item= new TabItem(folder, SWT.NONE);
272         item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.tabtitle")); //$NON-NLS-1$
273
item.setControl(javadocComposite);
274     
275         item= new TabItem(folder, SWT.NONE);
276         item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.tabtitle")); //$NON-NLS-1$
277
item.setControl(complianceComposite);
278         
279         item= new TabItem(folder, SWT.NONE);
280         item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.others.tabtitle")); //$NON-NLS-1$
281
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")); //$NON-NLS-1$
288
item.setControl(extraComposite);
289         }
290         
291         validateSettings(null, null);
292     
293         return folder;
294     }
295
296     private Composite createStyleTabContent(Composite folder) {
297         String JavaDoc[] errorWarningIgnore= new String JavaDoc[] { ERROR, WARNING, IGNORE };
298         
299         String JavaDoc[] errorWarningIgnoreLabels= new String JavaDoc[] {
300             PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
301
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
302
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
303
};
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")); //$NON-NLS-1$
315
GridData gd= new GridData();
316         gd.horizontalSpan= nColumns;
317         //gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60);
318
description.setLayoutData(gd);
319
320         String JavaDoc label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_overriding_pkg_dflt.label"); //$NON-NLS-1$
321
addComboBox(composite, label, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0);
322
323         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_method_naming.label"); //$NON-NLS-1$
324
addComboBox(composite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels, 0);
325         
326         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_static_access_receiver.label"); //$NON-NLS-1$
327
addComboBox(composite, label, PREF_PB_STATIC_ACCESS_RECEIVER, errorWarningIgnore, errorWarningIgnoreLabels, 0);
328
329         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_indirect_access_to_static.label"); //$NON-NLS-1$
330
addComboBox(composite, label, PREF_PB_INDIRECT_STATIC_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
331         
332         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_no_effect_assignment.label"); //$NON-NLS-1$
333
addComboBox(composite, label, PREF_PB_NO_EFFECT_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
334
335         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_accidential_assignement.label"); //$NON-NLS-1$
336
addComboBox(composite, label, PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
337
338         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unqualified_field_access.label"); //$NON-NLS-1$
339
addComboBox(composite, label, PREF_PB_UNQUALIFIED_FIELD_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
340         
341         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_finally_block_not_completing.label"); //$NON-NLS-1$
342
addComboBox(composite, label, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
343
344         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_empty_statement.label"); //$NON-NLS-1$
345
addComboBox(composite, label, PREF_PB_EMPTY_STATEMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
346
347         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_undocumented_empty_block.label"); //$NON-NLS-1$
348
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 JavaDoc[] errorWarningIgnore= new String JavaDoc[] { ERROR, WARNING, IGNORE };
356         
357         String JavaDoc[] errorWarningIgnoreLabels= new String JavaDoc[] {
358             PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
359
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
360
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
361
};
362         
363         String JavaDoc[] enabledDisabled= new String JavaDoc[] { 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")); //$NON-NLS-1$
375
GridData gd= new GridData();
376         gd.horizontalSpan= nColumns;
377         //gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60);
378
description.setLayoutData(gd);
379             
380         String JavaDoc label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_synth_access_emul.label"); //$NON-NLS-1$
381
addComboBox(composite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
382
383         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_local_variable_hiding.label"); //$NON-NLS-1$
384
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"); //$NON-NLS-1$
388
addCheckBox(composite, label, PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, enabledDisabled, indent);
389
390         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_field_hiding.label"); //$NON-NLS-1$
391
addComboBox(composite, label, PREF_PB_FIELD_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
392
393         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incompatible_interface_method.label"); //$NON-NLS-1$
394
addComboBox(composite, label, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0);
395
396         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_char_array_in_concat.label"); //$NON-NLS-1$
397
addComboBox(composite, label, PREF_PB_CHAR_ARRAY_IN_CONCAT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
398         
399         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation.label"); //$NON-NLS-1$
400
addComboBox(composite, label, PREF_PB_DEPRECATION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
401
402         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation_in_deprecation.label"); //$NON-NLS-1$
403
addCheckBox(composite, label, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, enabledDisabled, indent);
404     
405         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation_when_overriding.label"); //$NON-NLS-1$
406
addCheckBox(composite, label, PREF_PB_DEPRECATION_WHEN_OVERRIDING, enabledDisabled, indent);
407         
408         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_non_externalized_strings.label"); //$NON-NLS-1$
409
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"); //$NON-NLS-1$
416
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 JavaDoc[] errorWarningIgnore= new String JavaDoc[] { ERROR, WARNING, IGNORE };
425         
426         String JavaDoc[] errorWarningIgnoreLabels= new String JavaDoc[] {
427             PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
428
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
429
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
430
};
431         
432         String JavaDoc[] enabledDisabled= new String JavaDoc[] { 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")); //$NON-NLS-1$
444
GridData gd= new GridData();
445         gd.horizontalSpan= nColumns;
446         //gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60);
447
description.setLayoutData(gd);
448         
449         String JavaDoc label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_local.label"); //$NON-NLS-1$
450
addComboBox(composite, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels, 0);
451
452         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_parameter.label"); //$NON-NLS-1$
453
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"); //$NON-NLS-1$
457
addCheckBox(composite, label, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, enabledDisabled, indent);
458         
459         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_imports.label"); //$NON-NLS-1$
460
addComboBox(composite, label, PREF_PB_UNUSED_IMPORT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
461
462         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_private.label"); //$NON-NLS-1$
463
addComboBox(composite, label, PREF_PB_UNUSED_PRIVATE, errorWarningIgnore, errorWarningIgnoreLabels, 0);
464         
465         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unnecessary_else.label"); //$NON-NLS-1$
466
addComboBox(composite, label, PREF_PB_UNNECESSARY_ELSE, errorWarningIgnore, errorWarningIgnoreLabels, 0);
467         
468         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unnecessary_type_check.label"); //$NON-NLS-1$
469
addComboBox(composite, label, PREF_PB_UNNECESSARY_TYPE_CHECK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
470
471         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_hidden_catchblock.label"); //$NON-NLS-1$
472
addComboBox(composite, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
473         
474         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_throwing_exception.label"); //$NON-NLS-1$
475
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"); //$NON-NLS-1$
478
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 JavaDoc[] errorWarningIgnore= new String JavaDoc[] { ERROR, WARNING, IGNORE };
485         
486         String JavaDoc[] errorWarningIgnoreLabels= new String JavaDoc[] {
487                 PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
488
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
489
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
490
};
491         
492         String JavaDoc[] enabledDisabled= new String JavaDoc[] { ENABLED, DISABLED };
493         
494         String JavaDoc[] visibilities= new String JavaDoc[] { PUBLIC, PROTECTED, DEFAULT, PRIVATE };
495         
496         String JavaDoc[] visibilitiesLabels= new String JavaDoc[] {
497                 PreferencesMessages.getString("CompilerConfigurationBlock.public"), //$NON-NLS-1$
498
PreferencesMessages.getString("CompilerConfigurationBlock.protected"), //$NON-NLS-1$
499
PreferencesMessages.getString("CompilerConfigurationBlock.default"), //$NON-NLS-1$
500
PreferencesMessages.getString("CompilerConfigurationBlock.private") //$NON-NLS-1$
501
};
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 JavaDoc label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_javadoc_support.label"); //$NON-NLS-1$
511
addCheckBox(outer, label, PREF_JAVADOC_SUPPORT, enabledDisabled, 0);
512         
513         layout = new GridLayout();
514         layout.numColumns= nColumns;
515         layout.marginHeight= 0;
516         //layout.marginWidth= 0;
517

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")); //$NON-NLS-1$
525
GridData gd= new GridData();
526         gd.horizontalSpan= nColumns;
527         //gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60);
528
description.setLayoutData(gd);
529             
530         int indent= fPixelConverter.convertWidthInCharsToPixels(2);
531         
532         label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc.label"); //$NON-NLS-1$
533
addComboBox(composite, label, PREF_PB_INVALID_JAVADOC, errorWarningIgnore, errorWarningIgnoreLabels, 0);
534         
535         label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc_tags_visibility.label"); //$NON-NLS-1$
536
addComboBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent);
537
538         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc_tags.label"); //$NON-NLS-1$
539
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"); //$NON-NLS-1$
547
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
548
549         label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc_tags_visibility.label"); //$NON-NLS-1$
550
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent);
551         
552         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc_tags_overriding.label"); //$NON-NLS-1$
553
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"); //$NON-NLS-1$
561
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
562
563         label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments_visibility.label"); //$NON-NLS-1$
564
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, visibilities, visibilitiesLabels, indent);
565         
566         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments_overriding.label"); //$NON-NLS-1$
567
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 JavaDoc[] abortIgnoreValues= new String JavaDoc[] { ABORT, IGNORE };
576         String JavaDoc[] cleanIgnoreValues= new String JavaDoc[] { CLEAN, IGNORE };
577         String JavaDoc[] enableDisableValues= new String JavaDoc[] { ENABLED, DISABLED };
578         
579         String JavaDoc[] errorWarning= new String JavaDoc[] { ERROR, WARNING };
580         
581         String JavaDoc[] errorWarningLabels= new String JavaDoc[] {
582             PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
583
PreferencesMessages.getString("CompilerConfigurationBlock.warning") //$NON-NLS-1$
584
};
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")); //$NON-NLS-1$
596
GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
597         gd.horizontalSpan= nColumns;
598         description.setLayoutData(gd);
599                 
600         String JavaDoc label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incomplete_build_path.label"); //$NON-NLS-1$
601
addComboBox(othersComposite, label, PREF_PB_INCOMPLETE_BUILDPATH, errorWarning, errorWarningLabels, 0);
602         
603         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_build_path_cycles.label"); //$NON-NLS-1$
604
addComboBox(othersComposite, label, PREF_PB_CIRCULAR_BUILDPATH, errorWarning, errorWarningLabels, 0);
605
606         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_duplicate_resources.label"); //$NON-NLS-1$
607
addComboBox(othersComposite, label, PREF_PB_DUPLICATE_RESOURCE, errorWarning, errorWarningLabels, 0);
608
609         String JavaDoc[] errorWarningIgnore= new String JavaDoc[] { ERROR, WARNING, IGNORE };
610         
611         String JavaDoc[] errorWarningIgnoreLabels= new String JavaDoc[] {
612             PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
613
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
614
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
615
};
616         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_check_prereq_binary_level.label"); //$NON-NLS-1$
617
addComboBox(othersComposite, label, PREF_PB_INCOMPATIBLE_JDK_LEVEL, errorWarningIgnore, errorWarningIgnoreLabels, 0);
618
619         label= PreferencesMessages.getString("CompilerConfigurationBlock.build_invalid_classpath.label"); //$NON-NLS-1$
620
addCheckBox(othersComposite, label, PREF_BUILD_INVALID_CLASSPATH, abortIgnoreValues, 0);
621
622         label= PreferencesMessages.getString("CompilerConfigurationBlock.build_clean_outputfolder.label"); //$NON-NLS-1$
623
addCheckBox(othersComposite, label, PREF_BUILD_CLEAN_OUTPUT_FOLDER, cleanIgnoreValues, 0);
624
625         label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_exclusion_patterns.label"); //$NON-NLS-1$
626
addCheckBox(othersComposite, label, PREF_ENABLE_EXCLUSION_PATTERNS, enableDisableValues, 0);
627
628         label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_multiple_outputlocations.label"); //$NON-NLS-1$
629
addCheckBox(othersComposite, label, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS, enableDisableValues, 0);
630                 
631         label= PreferencesMessages.getString("CompilerConfigurationBlock.resource_filter.label"); //$NON-NLS-1$
632
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")); //$NON-NLS-1$
639
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 JavaDoc[] values34, values34Labels;
653         if (JavaModelUtil.isJDTCore_1_5()) {
654             values34= new String JavaDoc[] { VERSION_1_3, VERSION_1_4, VERSION_1_5 };
655             values34Labels= new String JavaDoc[] {
656                 PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$
657
PreferencesMessages.getString("CompilerConfigurationBlock.version14"), //$NON-NLS-1$
658
PreferencesMessages.getString("CompilerConfigurationBlock.version15") //$NON-NLS-1$
659
};
660         } else {
661             values34= new String JavaDoc[] { VERSION_1_3, VERSION_1_4 };
662             values34Labels= new String JavaDoc[] {
663                 PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$
664
PreferencesMessages.getString("CompilerConfigurationBlock.version14") //$NON-NLS-1$
665
};
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")); //$NON-NLS-1$
678
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
679         group.setLayout(layout);
680     
681         String JavaDoc label= PreferencesMessages.getString("CompilerConfigurationBlock.compiler_compliance.label"); //$NON-NLS-1$
682
addComboBox(group, label, PREF_COMPLIANCE, values34, values34Labels, 0);
683
684         label= PreferencesMessages.getString("CompilerConfigurationBlock.default_settings.label"); //$NON-NLS-1$
685
addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, new String JavaDoc[] { DEFAULT_CONF, USER_CONF }, 0);
686
687         int indent= fPixelConverter.convertWidthInCharsToPixels(2);
688         Control[] otherChildren= group.getChildren();
689                 
690         String JavaDoc[] values14, values14Labels;
691         if (JavaModelUtil.isJDTCore_1_5()) {
692             values14= new String JavaDoc[] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5 };
693             values14Labels= new String JavaDoc[] {
694                 PreferencesMessages.getString("CompilerConfigurationBlock.version11"), //$NON-NLS-1$
695
PreferencesMessages.getString("CompilerConfigurationBlock.version12"), //$NON-NLS-1$
696
PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$
697
PreferencesMessages.getString("CompilerConfigurationBlock.version14"), //$NON-NLS-1$
698
PreferencesMessages.getString("CompilerConfigurationBlock.version15") //$NON-NLS-1$
699
};
700         } else {
701             values14= new String JavaDoc[] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4 };
702             values14Labels= new String JavaDoc[] {
703                 PreferencesMessages.getString("CompilerConfigurationBlock.version11"), //$NON-NLS-1$
704
PreferencesMessages.getString("CompilerConfigurationBlock.version12"), //$NON-NLS-1$
705
PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$
706
PreferencesMessages.getString("CompilerConfigurationBlock.version14") //$NON-NLS-1$
707
};
708         }
709         
710         label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_targetplatform.label"); //$NON-NLS-1$
711
addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, values14, values14Labels, indent);
712
713         label= PreferencesMessages.getString("CompilerConfigurationBlock.source_compatibility.label"); //$NON-NLS-1$
714
addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values34, values34Labels, indent);
715
716         String JavaDoc[] errorWarningIgnore= new String JavaDoc[] { ERROR, WARNING, IGNORE };
717         
718         String JavaDoc[] errorWarningIgnoreLabels= new String JavaDoc[] {
719             PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
720
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
721
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
722
};
723
724         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_assert_as_identifier.label"); //$NON-NLS-1$
725
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")); //$NON-NLS-1$
736
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
737         group.setLayout(layout);
738
739         String JavaDoc[] generateValues= new String JavaDoc[] { GENERATE, DO_NOT_GENERATE };
740         String JavaDoc[] enableDisableValues= new String JavaDoc[] { ENABLED, DISABLED };
741
742         label= PreferencesMessages.getString("CompilerConfigurationBlock.variable_attr.label"); //$NON-NLS-1$
743
addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0);
744         
745         label= PreferencesMessages.getString("CompilerConfigurationBlock.line_number_attr.label"); //$NON-NLS-1$
746
addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0);
747
748         label= PreferencesMessages.getString("CompilerConfigurationBlock.source_file_attr.label"); //$NON-NLS-1$
749
addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0);
750
751         label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_unused_local.label"); //$NON-NLS-1$
752
addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String JavaDoc[] { PRESERVE, OPTIMIZE_OUT }, 0);
753
754         label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_inline_jsr_bytecode.label"); //$NON-NLS-1$
755
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 JavaDoc[] errorWarningIgnore= new String JavaDoc[] { ERROR, WARNING, IGNORE };
763         
764         String JavaDoc[] errorWarningIgnoreLabels= new String JavaDoc[] {
765             PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
766
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
767
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
768
};
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")); //$NON-NLS-1$
780
GridData gd= new GridData();
781         gd.horizontalSpan= nColumns;
782         description.setLayoutData(gd);
783         
784         String JavaDoc label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unsafe_type_op.label"); //$NON-NLS-1$
785
addComboBox(composite, label, PREF_15_PB_UNSAVE_TYPE_OPERATION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
786
787         label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_final_param_bound.label"); //$NON-NLS-1$
788
addComboBox(composite, label, PREF_15_PB_FINAL_PARAM_BOUND, errorWarningIgnore, errorWarningIgnoreLabels, 0);
789
790         return composite;
791     }
792     
793     
794         
795     
796     /* (non-javadoc)
797      * Update fields and validate.
798      * @param changedKey Key that changed, or null, if all changed.
799      */

800     protected void validateSettings(String JavaDoc changedKey, String JavaDoc 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                 // merging the two options
833
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 JavaDoc compliance= (String JavaDoc) fWorkingValues.get(PREF_COMPLIANCE);
882         String JavaDoc source= (String JavaDoc) fWorkingValues.get(PREF_SOURCE_COMPATIBILITY);
883         String JavaDoc target= (String JavaDoc) 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")); //$NON-NLS-1$
888
return status;
889             }
890             if (VERSION_1_4.equals(target) || VERSION_1_5.equals(target)) {
891                 status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13trg145.error")); //$NON-NLS-1$
892
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")); //$NON-NLS-1$
897
return status;
898             }
899             if (VERSION_1_5.equals(target)) {
900                 status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl14trg15.error")); //$NON-NLS-1$
901
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")); //$NON-NLS-1$
907
return status;
908             }
909         }
910         return status;
911     }
912     
913     private IStatus validateMaxNumberProblems() {
914         String JavaDoc number= (String JavaDoc) 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")); //$NON-NLS-1$
918
} else {
919             try {
920                 int value= Integer.parseInt(number);
921                 if (value <= 0) {
922                     status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
923
}
924             } catch (NumberFormatException JavaDoc e) {
925                 status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
926
}
927         }
928         return status;
929     }
930     
931     private IStatus validateResourceFilters() {
932         String JavaDoc text= (String JavaDoc) fWorkingValues.get(PREF_RESOURCE_FILTER);
933         
934         IWorkspace workspace= ResourcesPlugin.getWorkspace();
935
936         String JavaDoc[] filters= getTokens(text, ","); //$NON-NLS-1$
937
for (int i= 0; i < filters.length; i++) {
938             String JavaDoc 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 JavaDoc message= PreferencesMessages.getFormattedString("CompilerConfigurationBlock.filter.invalidsegment.error", status.getMessage()); //$NON-NLS-1$
948
return new StatusInfo(IStatus.ERROR, message);
949             }
950         }
951         return new StatusInfo();
952     }
953         
954     /*
955      * Update the compliance controls' enable state
956      */

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 JavaDoc val= (String JavaDoc) 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 JavaDoc 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     /*
989      * Set the default compliance values derived from the chosen level
990      */

991     private void updateComplianceDefaultSettings(boolean rememberOld) {
992         String JavaDoc assertAsId, source, target;
993         String JavaDoc complianceLevel= (String JavaDoc) fWorkingValues.get(PREF_COMPLIANCE);
994         boolean isDefault= checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF);
995         
996         if (isDefault) {
997             if (rememberOld) {
998                 fRememberedUserCompliance[0]= (String JavaDoc) fWorkingValues.get(PREF_PB_ASSERT_AS_IDENTIFIER);
999                 fRememberedUserCompliance[1]= (String JavaDoc) fWorkingValues.get(PREF_SOURCE_COMPATIBILITY);
1000                fRememberedUserCompliance[2]= (String JavaDoc) 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    /*
1033     * Evaluate if the current compliance setting correspond to a default setting
1034     */

1035    private static String JavaDoc getCurrentCompliance(Map JavaDoc map) {
1036        Object JavaDoc 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 JavaDoc[] getFullBuildDialogStrings(boolean workspaceSettings) {
1052        String JavaDoc title= PreferencesMessages.getString("CompilerConfigurationBlock.needsbuild.title"); //$NON-NLS-1$
1053
String JavaDoc message;
1054        if (workspaceSettings) {
1055            message= PreferencesMessages.getString("CompilerConfigurationBlock.needsfullbuild.message"); //$NON-NLS-1$
1056
} else {
1057            message= PreferencesMessages.getString("CompilerConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$
1058
}
1059        return new String JavaDoc[] { title, message };
1060    }
1061    
1062}
1063
Popular Tags