misc preferences improvements
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / preferences / CompilerConfigurationBlock.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.preferences;
12
13 import java.util.ArrayList;
14 import java.util.Map;
15
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;
23
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;
34
35 /**
36   */
37 public class CompilerConfigurationBlock extends OptionsConfigurationBlock {
38
39         // Preference store keys, see JavaCore.getOptions
40     private static final String PREF_PB_PHP_VAR_DEPRECATED= JavaCore.COMPILER_PB_PHP_VAR_DEPRECATED;
41         
42 //      private static final String PREF_LOCAL_VARIABLE_ATTR=  JavaCore.COMPILER_LOCAL_VARIABLE_ATTR;
43 //      private static final String PREF_LINE_NUMBER_ATTR= JavaCore.COMPILER_LINE_NUMBER_ATTR;
44 //      private static final String PREF_SOURCE_FILE_ATTR= JavaCore.COMPILER_SOURCE_FILE_ATTR;
45 //      private static final String PREF_CODEGEN_UNUSED_LOCAL= JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL;
46 //      private static final String PREF_CODEGEN_TARGET_PLATFORM= JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM;
47         //private static final String PREF_PB_UNREACHABLE_CODE= JavaCore.COMPILER_PB_UNREACHABLE_CODE;
48         //private static final String PREF_PB_INVALID_IMPORT= JavaCore.COMPILER_PB_INVALID_IMPORT;
49 //      private static final String PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD= JavaCore.COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD;
50 //      private static final String PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME;
51 //      private static final String PREF_PB_DEPRECATION= JavaCore.COMPILER_PB_DEPRECATION;
52 //      private static final String PREF_PB_DEPRECATION_WHEN_OVERRIDING= JavaCore.COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD;
53         
54 //      private static final String PREF_PB_HIDDEN_CATCH_BLOCK= JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK;
55 //      private static final String PREF_PB_UNUSED_LOCAL= JavaCore.COMPILER_PB_UNUSED_LOCAL;
56 //      private static final String PREF_PB_UNUSED_PARAMETER= JavaCore.COMPILER_PB_UNUSED_PARAMETER;
57 //      private static final String PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE;
58 //      private static final String PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT;
59 //      private static final String PREF_PB_SYNTHETIC_ACCESS_EMULATION= JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION;
60 //      private static final String PREF_PB_NON_EXTERNALIZED_STRINGS= JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL;
61 //      private static final String PREF_PB_ASSERT_AS_IDENTIFIER= JavaCore.COMPILER_PB_ASSERT_IDENTIFIER;
62         private static final String PREF_PB_MAX_PER_UNIT= JavaCore.COMPILER_PB_MAX_PER_UNIT;
63 //      private static final String PREF_PB_UNUSED_IMPORT= JavaCore.COMPILER_PB_UNUSED_IMPORT;
64 //      private static final String PREF_PB_UNUSED_PRIVATE= JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER;
65 //      private static final String PREF_PB_STATIC_ACCESS_RECEIVER= JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER;
66 //      private static final String PREF_PB_NO_EFFECT_ASSIGNMENT= JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT;
67 //      private static final String PREF_PB_CHAR_ARRAY_IN_CONCAT= JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION;
68 //      private static final String PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT= JavaCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT;
69 //      private static final String PREF_PB_LOCAL_VARIABLE_HIDING= JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING;
70 //      private static final String PREF_PB_FIELD_HIDING= JavaCore.COMPILER_PB_FIELD_HIDING;
71 //      private static final String PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD= JavaCore.COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD;
72 //      private static final String PREF_PB_INDIRECT_STATIC_ACCESS= JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS;
73 //      private static final String PREF_PB_SUPERFLUOUS_SEMICOLON= JavaCore.COMPILER_PB_SUPERFLUOUS_SEMICOLON;
74 //      private static final String PREF_PB_UNNECESSARY_TYPE_CHECK= JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK;
75         
76 //      private static final String PREF_PB_INVALID_JAVADOC= JavaCore.COMPILER_PB_INVALID_JAVADOC;
77 //      private static final String PREF_PB_INVALID_JAVADOC_TAGS= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS;
78 //      private static final String PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY;
79 //
80 //      private static final String PREF_PB_MISSING_JAVADOC_TAGS= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS;
81 //      private static final String PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY;
82 //      private static final String PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING;
83 //
84 //      private static final String PREF_PB_MISSING_JAVADOC_COMMENTS= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS;
85 //      private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY;
86 //      private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING;
87 //      
88 //      private static final String PREF_SOURCE_COMPATIBILITY= JavaCore.COMPILER_SOURCE;
89 //      private static final String PREF_COMPLIANCE= JavaCore.COMPILER_COMPLIANCE;
90 //
91 //      private static final String PREF_RESOURCE_FILTER= JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER;
92 //      private static final String PREF_BUILD_INVALID_CLASSPATH= JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH;
93 //      private static final String PREF_BUILD_CLEAN_OUTPUT_FOLDER= JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER;
94 //      private static final String PREF_ENABLE_EXCLUSION_PATTERNS= JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS;
95 //      private static final String PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS= JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS;
96 //
97 //      private static final String PREF_PB_INCOMPLETE_BUILDPATH= JavaCore.CORE_INCOMPLETE_CLASSPATH;
98 //      private static final String PREF_PB_CIRCULAR_BUILDPATH= JavaCore.CORE_CIRCULAR_CLASSPATH;
99 ////    private static final String PREF_PB_INCOMPATIBLE_JDK_LEVEL= JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL;
100 //      private static final String PREF_PB_DEPRECATION_IN_DEPRECATED_CODE= JavaCore.COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE;
101 //      private static final String PREF_PB_DUPLICATE_RESOURCE= JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE;
102 //      private static final String PREF_PB_INCOMPATIBLE_INTERFACE_METHOD= JavaCore.COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD;
103
104 //      private static final String PREF_PB_UNDOCUMENTED_EMPTY_BLOCK= JavaCore.COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK;
105 //      private static final String PREF_PB_FINALLY_BLOCK_NOT_COMPLETING= JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING;
106 //      private static final String PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION= JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION;
107 //      private static final String PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING;
108 //      private static final String PREF_PB_UNQUALIFIED_FIELD_ACCESS= JavaCore.COMPILER_PB_UNQUALIFIED_FIELD_ACCESS;
109         
110 //      private static final String INTR_DEFAULT_COMPLIANCE= "internal.default.compliance"; //$NON-NLS-1$
111
112         // values
113         private static final String GENERATE= JavaCore.GENERATE;
114         private static final String DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE;
115         
116         private static final String PRESERVE= JavaCore.PRESERVE;
117         private static final String OPTIMIZE_OUT= JavaCore.OPTIMIZE_OUT;
118         
119         private static final String VERSION_1_1= JavaCore.VERSION_1_1;
120         private static final String VERSION_1_2= JavaCore.VERSION_1_2;
121         private static final String VERSION_1_3= JavaCore.VERSION_1_3;
122         private static final String VERSION_1_4= JavaCore.VERSION_1_4;
123         
124         private static final String ERROR= JavaCore.ERROR;
125         private static final String WARNING= JavaCore.WARNING;
126         private static final String IGNORE= JavaCore.IGNORE;
127         private static final String ABORT= JavaCore.ABORT;
128         
129         private static final String CLEAN= JavaCore.CLEAN;
130
131         private static final String ENABLED= JavaCore.ENABLED;
132         private static final String DISABLED= JavaCore.DISABLED;
133         
134 //      private static final String PUBLIC= JavaCore.PUBLIC;
135 //      private static final String PROTECTED= JavaCore.PROTECTED;
136 //      private static final String DEFAULT= JavaCore.DEFAULT;
137 //      private static final String PRIVATE= JavaCore.PRIVATE;
138         
139         private static final String DEFAULT_CONF= "default"; //$NON-NLS-1$
140         private static final String USER_CONF= "user";   //$NON-NLS-1$
141
142         private ArrayList fComplianceControls;
143         private PixelConverter fPixelConverter;
144
145         private IStatus fMaxNumberProblemsStatus;
146 //      private IStatus fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus;
147
148         public CompilerConfigurationBlock(IStatusChangeListener context, IJavaProject project) {
149                 super(context, project, getKeys());
150                 
151                 fComplianceControls= new ArrayList();
152                         
153 //              fComplianceStatus= new StatusInfo();
154                 fMaxNumberProblemsStatus= new StatusInfo();
155 //              fResourceFilterStatus= new StatusInfo();
156                 
157                 // compatibilty code for the merge of the two option PB_SIGNAL_PARAMETER: 
158 //              if (ENABLED.equals(fWorkingValues.get(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT))) {
159 //                      fWorkingValues.put(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, ENABLED);
160 //              }
161                 
162         }
163         
164         private final static String[] KEYS= new String[] {
165             PREF_PB_PHP_VAR_DEPRECATED,
166 //              PREF_LOCAL_VARIABLE_ATTR, 
167 //              PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL,
168 //              PREF_CODEGEN_TARGET_PLATFORM, 
169 //              PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, 
170 //              PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, 
171 //              PREF_PB_DEPRECATION, 
172 //              PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL,
173 //              PREF_PB_UNUSED_PARAMETER, 
174 //              PREF_PB_SYNTHETIC_ACCESS_EMULATION, PREF_PB_NON_EXTERNALIZED_STRINGS,
175 //              PREF_PB_ASSERT_AS_IDENTIFIER, 
176 //              PREF_PB_UNUSED_IMPORT, 
177                 PREF_PB_MAX_PER_UNIT, 
178 //              PREF_SOURCE_COMPATIBILITY, 
179 //              PREF_COMPLIANCE, 
180 //              PREF_RESOURCE_FILTER, PREF_BUILD_INVALID_CLASSPATH, PREF_PB_STATIC_ACCESS_RECEIVER, PREF_PB_INCOMPLETE_BUILDPATH,
181 //              PREF_PB_CIRCULAR_BUILDPATH, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, PREF_BUILD_CLEAN_OUTPUT_FOLDER,
182 //              PREF_PB_DUPLICATE_RESOURCE, PREF_PB_NO_EFFECT_ASSIGNMENT, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD,
183 //              PREF_PB_UNUSED_PRIVATE, PREF_PB_CHAR_ARRAY_IN_CONCAT, PREF_ENABLE_EXCLUSION_PATTERNS, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS,
184 //              PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, 
185 //              PREF_PB_LOCAL_VARIABLE_HIDING, 
186 //              PREF_PB_FIELD_HIDING,
187 //              PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, 
188 //              PREF_PB_INCOMPATIBLE_JDK_LEVEL, 
189 //              PREF_PB_INDIRECT_STATIC_ACCESS,
190 //              PREF_PB_SUPERFLUOUS_SEMICOLON, 
191 //              PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, 
192 //              PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT,
193 //              PREF_PB_UNNECESSARY_TYPE_CHECK, 
194 //              PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, 
195 //              PREF_PB_UNQUALIFIED_FIELD_ACCESS,
196 //              PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, 
197 //              PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, 
198 //              PREF_PB_DEPRECATION_WHEN_OVERRIDING,
199 //              PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING,
200
201 //              PREF_PB_INVALID_JAVADOC, 
202 //              PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, 
203 //              PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY,
204 //              PREF_PB_MISSING_JAVADOC_TAGS, 
205 //              PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, 
206 //              PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING,
207 //              PREF_PB_MISSING_JAVADOC_COMMENTS, 
208 //              PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, 
209 //              PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING
210         };      
211         
212         private static  String[] getKeys() {
213                 return KEYS;    
214         }
215         
216         protected final Map getOptions(boolean inheritJavaCoreOptions) {
217                 Map map= super.getOptions(inheritJavaCoreOptions);
218         //      map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
219                 return map;
220         }
221         
222         protected final Map getDefaultOptions() {
223                 Map map= super.getDefaultOptions();
224         //      map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
225                 return map;
226         }       
227         
228         
229         /*
230          * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
231          */
232         protected Control createContents(Composite parent) {
233                 fPixelConverter= new PixelConverter(parent);
234                 setShell(parent.getShell());
235                 
236                 TabFolder folder= new TabFolder(parent, SWT.NONE);
237                 folder.setLayout(new TabFolderLayout());        
238                 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
239                 
240                 Composite commonComposite= createStyleTabContent(folder);
241 //              Composite unusedComposite= createUnusedCodeTabContent(folder);
242                 Composite advancedComposite= createAdvancedTabContent(folder);
243 //              Composite javadocComposite= createJavadocTabContent(folder);
244 //              Composite complianceComposite= createComplianceTabContent(folder);
245 //              Composite othersComposite= createBuildPathTabContent(folder);
246
247                 TabItem item= new TabItem(folder, SWT.NONE);
248                 item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.tabtitle")); //$NON-NLS-1$
249                 item.setControl(commonComposite);
250
251                 item= new TabItem(folder, SWT.NONE);
252                 item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.tabtitle")); //$NON-NLS-1$
253                 item.setControl(advancedComposite);
254
255 //              item= new TabItem(folder, SWT.NONE);
256 //              item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.tabtitle")); //$NON-NLS-1$
257 //              item.setControl(unusedComposite);
258                 
259 //              item= new TabItem(folder, SWT.NONE);
260 //              item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.tabtitle")); //$NON-NLS-1$
261 //              item.setControl(javadocComposite);
262         
263 //              item= new TabItem(folder, SWT.NONE);
264 //              item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.tabtitle")); //$NON-NLS-1$
265 //              item.setControl(complianceComposite);
266                 
267 //              item= new TabItem(folder, SWT.NONE);
268 //              item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.others.tabtitle")); //$NON-NLS-1$
269 //              item.setControl(othersComposite);               
270                 
271                 validateSettings(null, null);
272         
273                 return folder;
274         }
275
276         private Composite createStyleTabContent(Composite folder) {
277                 String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
278                 
279                 String[] errorWarningIgnoreLabels= new String[] {
280                         PreferencesMessages.getString("CompilerConfigurationBlock.error"),  //$NON-NLS-1$
281                         PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
282                         PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
283                 };
284                 
285                 int nColumns= 3;
286                 
287                 GridLayout layout= new GridLayout();
288                 layout.numColumns= nColumns;
289
290                 Composite composite= new Composite(folder, SWT.NULL);
291                 composite.setLayout(layout);
292                 
293                 Label description= new Label(composite, SWT.WRAP);
294                 description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.description")); //$NON-NLS-1$
295                 GridData gd= new GridData();
296                 gd.horizontalSpan= nColumns;
297                 gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
298                 description.setLayoutData(gd);          
299
300                 String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_var_deprecated.label"); //$NON-NLS-1$
301                 addComboBox(composite, label, PREF_PB_PHP_VAR_DEPRECATED, errorWarningIgnore, errorWarningIgnoreLabels, 0);                     
302
303                 label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_overriding_pkg_dflt.label"); //$NON-NLS-1$
304 //              addComboBox(composite, label, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0);                      
305
306 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_method_naming.label"); //$NON-NLS-1$
307 //              addComboBox(composite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels, 0);                   
308 //
309 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_hidden_catchblock.label"); //$NON-NLS-1$
310 //              addComboBox(composite, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
311 //              
312 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_static_access_receiver.label"); //$NON-NLS-1$
313 //              addComboBox(composite, label, PREF_PB_STATIC_ACCESS_RECEIVER, errorWarningIgnore, errorWarningIgnoreLabels, 0);
314 //              
315 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_no_effect_assignment.label"); //$NON-NLS-1$
316 //              addComboBox(composite, label, PREF_PB_NO_EFFECT_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
317
318 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_indirect_access_to_static.label"); //$NON-NLS-1$
319 //              addComboBox(composite, label, PREF_PB_INDIRECT_STATIC_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0); 
320 //
321 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_accidential_assignement.label"); //$NON-NLS-1$
322 //              addComboBox(composite, label, PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
323 //
324 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_finally_block_not_completing.label"); //$NON-NLS-1$
325 //              addComboBox(composite, label, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
326 //
327 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_undocumented_empty_block.label"); //$NON-NLS-1$
328 //              addComboBox(composite, label, PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
329
330                 
331                 return composite;
332         }
333
334         private Composite createAdvancedTabContent(TabFolder folder) {
335                 String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
336                 
337                 String[] errorWarningIgnoreLabels= new String[] {
338                         PreferencesMessages.getString("CompilerConfigurationBlock.error"),  //$NON-NLS-1$
339                         PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
340                         PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
341                 };
342                 
343                 String[] enabledDisabled= new String[] { ENABLED, DISABLED };
344                 
345                 int nColumns= 3;
346                 
347                 GridLayout layout= new GridLayout();
348                 layout.numColumns= nColumns;
349                                         
350                 Composite composite= new Composite(folder, SWT.NULL);
351                 composite.setLayout(layout);
352
353                 Label description= new Label(composite, SWT.WRAP);
354                 description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.description")); //$NON-NLS-1$
355                 GridData gd= new GridData();
356                 gd.horizontalSpan= nColumns;
357                 gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
358                 description.setLayoutData(gd);
359                         
360 //              String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_synth_access_emul.label"); //$NON-NLS-1$
361 //              addComboBox(composite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
362
363 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_local_variable_hiding.label"); //$NON-NLS-1$
364 //              addComboBox(composite, label, PREF_PB_LOCAL_VARIABLE_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
365
366 //              int indent= fPixelConverter.convertWidthInCharsToPixels(2);
367 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_special_param_hiding.label"); //$NON-NLS-1$
368 //              addCheckBox(composite, label, PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, enabledDisabled, indent);
369
370 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_field_hiding.label"); //$NON-NLS-1$
371 //              addComboBox(composite, label, PREF_PB_FIELD_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
372
373 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_non_externalized_strings.label"); //$NON-NLS-1$
374 //              addComboBox(composite, label, PREF_PB_NON_EXTERNALIZED_STRINGS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
375 //
376 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incompatible_interface_method.label"); //$NON-NLS-1$
377 //              addComboBox(composite, label, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0);
378 //
379 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_char_array_in_concat.label"); //$NON-NLS-1$
380 //              addComboBox(composite, label, PREF_PB_CHAR_ARRAY_IN_CONCAT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
381
382 //              label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unqualified_field_access.label"); //$NON-NLS-1$
383 //              addComboBox(composite, label, PREF_PB_UNQUALIFIED_FIELD_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
384                 
385                 gd= new GridData();
386                 gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(6);
387                 
388                 String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_max_per_unit.label"); //$NON-NLS-1$
389                 Text text= addTextField(composite, label, PREF_PB_MAX_PER_UNIT, 0, 0);
390                 text.setTextLimit(6);
391                 text.setLayoutData(gd);
392
393                 return composite;
394         }
395
396         
397         
398                 
399         
400         /* (non-javadoc)
401          * Update fields and validate.
402          * @param changedKey Key that changed, or null, if all changed.
403          */     
404         protected void validateSettings(String changedKey, String newValue) {
405                 
406                 if (changedKey != null) {
407 //                      if (INTR_DEFAULT_COMPLIANCE.equals(changedKey)) {
408 //                              updateComplianceEnableState();
409 //                              if (DEFAULT_CONF.equals(newValue)) {
410 //                                      updateComplianceDefaultSettings();
411 //                              }
412 //                              fComplianceStatus= validateCompliance();
413 //                      } else if (PREF_COMPLIANCE.equals(changedKey)) {
414 //                              if (checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF)) {
415 //                                      updateComplianceDefaultSettings();
416 //                              }
417 //                              fComplianceStatus= validateCompliance();
418 //                      } else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey) ||
419 //                                      PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey) ||
420 //                                      PREF_PB_ASSERT_AS_IDENTIFIER.equals(changedKey)) {
421 //                              fComplianceStatus= validateCompliance();
422 //                      } else 
423                           if (PREF_PB_MAX_PER_UNIT.equals(changedKey)) {
424                                 fMaxNumberProblemsStatus= validateMaxNumberProblems();
425 //                      } else if (PREF_RESOURCE_FILTER.equals(changedKey)) {
426 //                              fResourceFilterStatus= validateResourceFilters();
427 //                      } else if (S.equals(changedKey) ||
428 //                                      PREF_PB_DEPRECATION.equals(changedKey) ) { // ||
429 ////                                    PREF_PB_INVALID_JAVADOC.equals(changedKey) ||
430 ////                                    PREF_PB_MISSING_JAVADOC_TAGS.equals(changedKey) ||
431 ////                                    PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) ||
432 ////                                    PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) ||
433 ////                                    PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION.equals(changedKey)) {                          
434 //                              updateEnableStates();
435 //                      } else if (PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING.equals(changedKey)) {
436 //                              // merging the two options
437 //                              fWorkingValues.put(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, newValue);
438                         } else {
439                                 return;
440                         }
441                 } else {
442 //                      updateEnableStates();
443 //                      updateComplianceEnableState();
444 //                      fComplianceStatus= validateCompliance();
445                         fMaxNumberProblemsStatus= validateMaxNumberProblems();
446 //                      fResourceFilterStatus= validateResourceFilters();
447                 }               
448 //              IStatus status= StatusUtil.getMostSevere(new IStatus[] { fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus });
449                 IStatus status= StatusUtil.getMostSevere(new IStatus[] { fMaxNumberProblemsStatus });
450                 fContext.statusChanged(status);
451         }
452         
453 //      private void updateEnableStates() {
454 //              boolean enableUnusedParams= !checkValue(PREF_PB_UNUSED_PARAMETER, IGNORE);
455 //              getCheckBox(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING).setEnabled(enableUnusedParams);
456                 
457 //              boolean enableDeprecation= !checkValue(PREF_PB_DEPRECATION, IGNORE);
458 //              getCheckBox(PREF_PB_DEPRECATION_IN_DEPRECATED_CODE).setEnabled(enableDeprecation);
459 //              getCheckBox(PREF_PB_DEPRECATION_WHEN_OVERRIDING).setEnabled(enableDeprecation);
460 //              
461 //              boolean enableThrownExceptions= !checkValue(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, IGNORE);
462 //              getCheckBox(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING).setEnabled(enableThrownExceptions);
463 //
464 //              boolean enableHiding= !checkValue(PREF_PB_LOCAL_VARIABLE_HIDING, IGNORE);
465 //              getCheckBox(PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD).setEnabled(enableHiding);
466 //
467 //              boolean enableInvalidTagsErrors= !checkValue(PREF_PB_INVALID_JAVADOC, IGNORE);
468 //              getCheckBox(PREF_PB_INVALID_JAVADOC_TAGS).setEnabled(enableInvalidTagsErrors);
469 //              setComboEnabled(PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, enableInvalidTagsErrors);
470 //              
471 //              boolean enableMissingTagsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_TAGS, IGNORE);
472 //              getCheckBox(PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING).setEnabled(enableMissingTagsErrors);
473 //              setComboEnabled(PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, enableMissingTagsErrors);
474 //              
475 //              boolean enableMissingCommentsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_COMMENTS, IGNORE);
476 //              getCheckBox(PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING).setEnabled(enableMissingCommentsErrors);
477 //              setComboEnabled(PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, enableMissingCommentsErrors);
478 //      }
479
480 //      private IStatus validateCompliance() {
481 //              StatusInfo status= new StatusInfo();
482 //              if (checkValue(PREF_COMPLIANCE, VERSION_1_3)) {
483 //                      if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
484 //                              status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13src14.error")); //$NON-NLS-1$
485 //                              return status;
486 //                      } else if (checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) {
487 //                              status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13trg14.error")); //$NON-NLS-1$
488 //                              return status;
489 //                      }
490 //              }
491 //              if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
492 //                      if (!checkValue(PREF_PB_ASSERT_AS_IDENTIFIER, ERROR)) {
493 //                              status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14asrterr.error")); //$NON-NLS-1$
494 //                              return status;
495 //                      }
496 //              }
497 //              if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
498 //                      if (!checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) {
499 //                              status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14tgt14.error")); //$NON-NLS-1$
500 //                              return status;
501 //                      }
502 //              }
503 //              return status;
504 //      }
505         
506         private IStatus validateMaxNumberProblems() {
507                 String number= (String) fWorkingValues.get(PREF_PB_MAX_PER_UNIT);
508                 StatusInfo status= new StatusInfo();
509                 if (number.length() == 0) {
510                         status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.empty_input")); //$NON-NLS-1$
511                 } else {
512                         try {
513                                 int value= Integer.parseInt(number);
514                                 if (value <= 0) {
515                                         status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
516                                 }
517                         } catch (NumberFormatException e) {
518                                 status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
519                         }
520                 }
521                 return status;
522         }
523         
524 //      private IStatus validateResourceFilters() {
525 //              String text= (String) fWorkingValues.get(PREF_RESOURCE_FILTER);
526 //              
527 //              IWorkspace workspace= ResourcesPlugin.getWorkspace();
528 //
529 //              String[] filters= getTokens(text, ","); //$NON-NLS-1$
530 //              for (int i= 0; i < filters.length; i++) {
531 //                      String fileName= filters[i].replace('*', 'x');
532 //                      int resourceType= IResource.FILE;
533 //                      int lastCharacter= fileName.length() - 1;
534 //                      if (lastCharacter >= 0 && fileName.charAt(lastCharacter) == '/') {
535 //                              fileName= fileName.substring(0, lastCharacter);
536 //                              resourceType= IResource.FOLDER;
537 //                      }
538 //                      IStatus status= workspace.validateName(fileName, resourceType);
539 //                      if (status.matches(IStatus.ERROR)) {
540 //                              String message= PreferencesMessages.getFormattedString("CompilerConfigurationBlock.filter.invalidsegment.error", status.getMessage()); //$NON-NLS-1$
541 //                              return new StatusInfo(IStatus.ERROR, message);
542 //                      }
543 //              }
544 //              return new StatusInfo();
545 //      }
546         
547         protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
548                 String title= PreferencesMessages.getString("CompilerConfigurationBlock.needsbuild.title"); //$NON-NLS-1$
549                 String message;
550                 if (workspaceSettings) {
551                         message= PreferencesMessages.getString("CompilerConfigurationBlock.needsfullbuild.message"); //$NON-NLS-1$
552                 } else {
553                         message= PreferencesMessages.getString("CompilerConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$
554                 }
555                 return new String[] { title, message };
556         }       
557                         
558 }