added syntax color for {} operators
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / preferences / JavaEditorPreferencePage.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.io.BufferedReader;
14 import java.io.IOException;
15 import java.io.InputStreamReader;
16 import java.text.Collator;
17 import java.util.ArrayList;
18 import java.util.Comparator;
19 import java.util.HashMap;
20 import java.util.Iterator;
21 import java.util.Map;
22 import java.util.SortedSet;
23 import java.util.StringTokenizer;
24 import java.util.TreeSet;
25
26 import net.sourceforge.phpdt.core.JavaCore;
27 import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
28 import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
29 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
30 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
31 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
32 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
33 import net.sourceforge.phpdt.ui.PreferenceConstants;
34 import net.sourceforge.phpdt.ui.text.JavaTextTools;
35 import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
36 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
37 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
38 import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer;
39 import net.sourceforge.phpeclipse.preferences.ColorEditor;
40
41 import org.eclipse.core.runtime.IStatus;
42 import org.eclipse.core.runtime.Preferences;
43 import org.eclipse.jface.dialogs.Dialog;
44 import org.eclipse.jface.preference.IPreferenceStore;
45 import org.eclipse.jface.preference.PreferenceConverter;
46 import org.eclipse.jface.preference.PreferencePage;
47 import org.eclipse.jface.resource.JFaceResources;
48 import org.eclipse.jface.text.Document;
49 import org.eclipse.jface.text.IDocument;
50 import org.eclipse.jface.text.source.SourceViewer;
51 import org.eclipse.swt.SWT;
52 import org.eclipse.swt.events.ModifyEvent;
53 import org.eclipse.swt.events.ModifyListener;
54 import org.eclipse.swt.events.SelectionEvent;
55 import org.eclipse.swt.events.SelectionListener;
56 import org.eclipse.swt.graphics.Color;
57 import org.eclipse.swt.graphics.Font;
58 import org.eclipse.swt.graphics.RGB;
59 import org.eclipse.swt.layout.GridData;
60 import org.eclipse.swt.layout.GridLayout;
61 import org.eclipse.swt.layout.RowLayout;
62 import org.eclipse.swt.widgets.Button;
63 import org.eclipse.swt.widgets.Combo;
64 import org.eclipse.swt.widgets.Composite;
65 import org.eclipse.swt.widgets.Control;
66 import org.eclipse.swt.widgets.Group;
67 import org.eclipse.swt.widgets.Label;
68 import org.eclipse.swt.widgets.List;
69 import org.eclipse.swt.widgets.TabFolder;
70 import org.eclipse.swt.widgets.TabItem;
71 import org.eclipse.swt.widgets.Text;
72 import org.eclipse.ui.IWorkbench;
73 import org.eclipse.ui.IWorkbenchPreferencePage;
74 import org.eclipse.ui.editors.text.EditorsUI;
75 import org.eclipse.ui.help.WorkbenchHelp;
76 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
77 import org.eclipse.ui.texteditor.AnnotationPreference;
78 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
79 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
80
81 /**
82  * The page for setting the editor options.
83  */
84 public class JavaEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
85   private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
86
87   private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
88
89   private static final String DELIMITER = PreferencesMessages.getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
90
91   /** The keys of the overlay store. */
92   public final OverlayPreferenceStore.OverlayKey[] fKeys;
93
94   private final String[][] fSyntaxColorListModel = new String[][] {
95       { PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
96           PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
97       //$NON-NLS-1$
98       { PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
99           PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
100       //$NON-NLS-1$
101       { PreferencesMessages.getString("JavaEditorPreferencePage.tags"), PreferenceConstants.EDITOR_PHP_TAG_COLOR },
102       //$NON-NLS-1$
103       { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
104       { PreferencesMessages.getString("JavaEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
105       //$NON-NLS-1$
106       { PreferencesMessages.getString("JavaEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
107       //$NON-NLS-1$
108       { PreferencesMessages.getString("JavaEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
109       //$NON-NLS-1$
110       { PreferencesMessages.getString("JavaEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
111       //$NON-NLS-1$
112       { PreferencesMessages.getString("JavaEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR },
113       //$NON-NLS-1$
114       { PreferencesMessages.getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
115       { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
116       //$NON-NLS-1$
117       { PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"),
118           PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR }, 
119       { PreferencesMessages.getString("JavaEditorPreferencePage.braces"),
120           PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR },
121       //$NON-NLS-1$
122       { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
123       //$NON-NLS-1$
124       { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
125       //$NON-NLS-1$
126       { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
127       //$NON-NLS-1$
128       { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
129   };
130
131   private final String[][] fAppearanceColorListModel = new String[][] {
132       { PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
133           AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR },
134       //$NON-NLS-1$
135       { PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
136           PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
137       //$NON-NLS-1$
138       { PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"),
139           AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
140       //$NON-NLS-1$
141       { PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"),
142           AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
143       //$NON-NLS-1$
144       { PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
145       //$NON-NLS-1$
146       { PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
147   };
148
149   //  private final String[][] fAnnotationColorListModel;
150
151   //  private final String[][] fAnnotationDecorationListModel = new String[][]{
152   //      {
153   //          PreferencesMessages
154   //              .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
155   //          AnnotationPreference.STYLE_NONE},
156   //      //$NON-NLS-1$
157   //      {
158   //          PreferencesMessages
159   //              .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
160   //          AnnotationPreference.STYLE_SQUIGGLIES},
161   //      //$NON-NLS-1$
162   //      {
163   //          PreferencesMessages
164   //              .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
165   //          AnnotationPreference.STYLE_UNDERLINE},
166   //      //$NON-NLS-1$
167   //      {
168   //          PreferencesMessages
169   //              .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
170   //          AnnotationPreference.STYLE_BOX},
171   //      //$NON-NLS-1$
172   //      {
173   //          PreferencesMessages
174   //              .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
175   //          AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
176   //  };
177   private OverlayPreferenceStore fOverlayStore;
178
179   private JavaTextTools fJavaTextTools;
180
181   private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
182
183   private FoldingConfigurationBlock fFoldingConfigurationBlock;
184
185   private Map fColorButtons = new HashMap();
186
187   private Map fCheckBoxes = new HashMap();
188
189   private SelectionListener fCheckBoxListener = new SelectionListener() {
190     public void widgetDefaultSelected(SelectionEvent e) {
191     }
192
193     public void widgetSelected(SelectionEvent e) {
194       Button button = (Button) e.widget;
195       fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
196     }
197   };
198
199   private Map fTextFields = new HashMap();
200
201   private ModifyListener fTextFieldListener = new ModifyListener() {
202     public void modifyText(ModifyEvent e) {
203       Text text = (Text) e.widget;
204       fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
205     }
206   };
207
208   private ArrayList fNumberFields = new ArrayList();
209
210   private ModifyListener fNumberFieldListener = new ModifyListener() {
211     public void modifyText(ModifyEvent e) {
212       numberFieldChanged((Text) e.widget);
213     }
214   };
215
216   private List fSyntaxColorList;
217
218   private List fAppearanceColorList;
219
220   //  private List fContentAssistColorList;
221   private List fAnnotationList;
222
223   private ColorEditor fSyntaxForegroundColorEditor;
224
225   private ColorEditor fAppearanceColorEditor;
226
227   private ColorEditor fAnnotationForegroundColorEditor;
228
229   private ColorEditor fContentAssistColorEditor;
230
231   private ColorEditor fBackgroundColorEditor;
232
233   private Button fBackgroundDefaultRadioButton;
234
235   private Button fBackgroundCustomRadioButton;
236
237   private Button fBackgroundColorButton;
238
239   private Button fBoldCheckBox;
240
241   //  private Button fAddJavaDocTagsButton;
242
243   private Button fEscapeStringsButtonDQ;
244   
245   private Button fEscapeStringsButtonSQ;
246
247   //    private Button fGuessMethodArgumentsButton;
248   private SourceViewer fPreviewViewer;
249
250   private Color fBackgroundColor;
251
252   private Control fAutoInsertDelayText;
253
254   private Control fAutoInsertJavaTriggerText;
255
256   private Control fAutoInsertJavaDocTriggerText;
257
258   private Label fAutoInsertDelayLabel;
259
260   private Label fAutoInsertJavaTriggerLabel;
261
262   private Label fAutoInsertJavaDocTriggerLabel;
263
264   private Button fShowInTextCheckBox;
265
266   private Combo fDecorationStyleCombo;
267
268   private Button fHighlightInTextCheckBox;
269
270   private Button fShowInOverviewRulerCheckBox;
271
272   private Button fShowInVerticalRulerCheckBox;
273
274   //    private Text fBrowserLikeLinksKeyModifierText;
275   //    private Button fBrowserLikeLinksCheckBox;
276   //    private StatusInfo fBrowserLikeLinksKeyModifierStatus;
277   //    private Button fCompletionInsertsRadioButton;
278   //    private Button fCompletionOverwritesRadioButton;
279   //    private Button fStickyOccurrencesButton;
280   /**
281    * Creates a new preference page.
282    */
283   public JavaEditorPreferencePage() {
284     setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
285     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
286     MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
287     fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
288     fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
289     //    fAnnotationColorListModel =
290     // createAnnotationTypeListModel(markerAnnotationPreferences);
291   }
292
293   private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
294     ArrayList overlayKeys = new ArrayList();
295     Iterator e = preferences.getAnnotationPreferences().iterator();
296     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
297         PreferenceConstants.EDITOR_FOREGROUND_COLOR));
298     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
299         PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
300     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
301         PreferenceConstants.EDITOR_BACKGROUND_COLOR));
302     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
303         PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
304     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
305     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
306         PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
307     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
308         PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
309     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
310         PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
311     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
312         PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
313     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
314         PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
315     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
316         PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
317
318     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TAG_COLOR));
319     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TAG_BOLD));
320     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
321         PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
322     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
323         PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
324     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
325         PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
326     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
327         PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
328     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
329         PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
330     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
331         PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
332     overlayKeys
333         .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
334     overlayKeys
335         .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
336
337     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR));
338     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD));
339     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
340         PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
341     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
342         PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
343     overlayKeys
344         .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
345     overlayKeys
346         .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
347     //          overlayKeys.add(new
348     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
349     // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
350     //          overlayKeys.add(new
351     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
352     // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
353     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
354         PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
355     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
356         PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
357     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
358         PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
359     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
360         PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
361     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
362         PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR));
363     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
364         PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_BOLD));
365     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
366         PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
367     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
368         PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
369     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
370         PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
371     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
372         PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
373     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
374         PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
375     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
376         PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
377     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
378         PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
379     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
380         PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
381     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
382         PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
383     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
384         PreferenceConstants.EDITOR_MATCHING_BRACKETS));
385     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
386         AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
387     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
388         AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
389     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
390         AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
391     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
392         AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
393     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
394         AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
395     //          overlayKeys.add(new
396     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
397     // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
398     //          overlayKeys.add(new
399     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
400     // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
401     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
402         PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
403     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
404     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
405         PreferenceConstants.EDITOR_CORRECTION_INDICATION));
406     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
407         PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
408     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
409         AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
410     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
411         AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
412     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
413         AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
414     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
415         PreferenceConstants.EDITOR_SPACES_FOR_TABS));
416     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
417         PreferenceConstants.CODEASSIST_AUTOACTIVATION));
418     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
419         PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
420     overlayKeys
421         .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT));
422     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
423         PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
424     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
425         PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
426     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
427         PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
428     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
429         PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
430     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
431         PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
432     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
433         PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
434     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
435         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
436     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
437         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
438     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
439         PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
440     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
441         PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
442     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
443         PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
444     overlayKeys
445         .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT));
446     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
447         PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
448     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
449         PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
450     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
451         PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
452     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE));
453     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
454         PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
455     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
456         PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
457     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
458         PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
459     //    overlayKeys
460     //        .add(new OverlayPreferenceStore.OverlayKey(
461     //            OverlayPreferenceStore.BOOLEAN,
462     //            PreferenceConstants.EDITOR_CLOSE_BRACES));
463     //    overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
464     //        OverlayPreferenceStore.BOOLEAN,
465     //        PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
466     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
467     overlayKeys
468         .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
469     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
470     overlayKeys
471         .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
472     
473     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
474         PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
475     overlayKeys
476         .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
477     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
478         PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
479     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
480         PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
481     //          overlayKeys.add(new
482     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
483     // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
484     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
485         PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
486     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
487         PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
488     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
489         PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
490     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
491         PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
492     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
493         PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
494     while (e.hasNext()) {
495       AnnotationPreference info = (AnnotationPreference) e.next();
496       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
497       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
498       if (info.getHighlightPreferenceKey() != null)
499         overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
500       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
501       if (info.getVerticalRulerPreferenceKey() != null)
502         overlayKeys
503             .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
504       if (info.getTextStylePreferenceKey() != null)
505         overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
506     }
507     OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
508     overlayKeys.toArray(keys);
509     return keys;
510   } /*
511      * @see IWorkbenchPreferencePage#init()
512      */
513
514   public void init(IWorkbench workbench) {
515   }
516
517   /*
518    * @see PreferencePage#createControl(Composite)
519    */
520   public void createControl(Composite parent) {
521     super.createControl(parent);
522     WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
523   }
524
525   private void handleSyntaxColorListSelection() {
526     int i = fSyntaxColorList.getSelectionIndex();
527     String key = fSyntaxColorListModel[i][1];
528     RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
529     fSyntaxForegroundColorEditor.setColorValue(rgb);
530     fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
531   }
532
533   private void handleAppearanceColorListSelection() {
534     int i = fAppearanceColorList.getSelectionIndex();
535     String key = fAppearanceColorListModel[i][1];
536     RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
537     fAppearanceColorEditor.setColorValue(rgb);
538   }
539
540   //  private void handleAnnotationListSelection() {
541   //    int i = fAnnotationList.getSelectionIndex();
542   //    String key = fAnnotationColorListModel[i][1];
543   //    RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
544   //    fAnnotationForegroundColorEditor.setColorValue(rgb);
545   //    key = fAnnotationColorListModel[i][2];
546   //    boolean showInText = fOverlayStore.getBoolean(key);
547   //    fShowInTextCheckBox.setSelection(showInText);
548   //    key = fAnnotationColorListModel[i][6];
549   //    if (key != null) {
550   //      fDecorationStyleCombo.setEnabled(showInText);
551   //      for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
552   //        String value = fOverlayStore.getString(key);
553   //        if (fAnnotationDecorationListModel[j][1].equals(value)) {
554   //          fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
555   //          break;
556   //        }
557   //      }
558   //    } else {
559   //      fDecorationStyleCombo.setEnabled(false);
560   //      fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
561   //                                                                           // selection
562   //                                                                           // to
563   //                                                                           // squigglies
564   //                                                                           // if
565   //                                                                           // the
566   //                                                                           // key
567   //                                                                           // is
568   //                                                                           // not
569   //                                                                           // there
570   //                                                                           // (legacy
571   //                                                                           // support)
572   //    }
573   //    key = fAnnotationColorListModel[i][3];
574   //    fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
575   //    key = fAnnotationColorListModel[i][4];
576   //    if (key != null) {
577   //      fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
578   //      fHighlightInTextCheckBox.setEnabled(true);
579   //    } else
580   //      fHighlightInTextCheckBox.setEnabled(false);
581   //    key = fAnnotationColorListModel[i][5];
582   //    if (key != null) {
583   //      fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
584   //      fShowInVerticalRulerCheckBox.setEnabled(true);
585   //    } else {
586   //      fShowInVerticalRulerCheckBox.setSelection(true);
587   //      fShowInVerticalRulerCheckBox.setEnabled(false);
588   //    }
589   //  }
590   private Control createSyntaxPage(Composite parent) {
591     Composite colorComposite = new Composite(parent, SWT.NULL);
592     colorComposite.setLayout(new GridLayout());
593     Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
594     backgroundComposite.setLayout(new RowLayout());
595     backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
596     SelectionListener backgroundSelectionListener = new SelectionListener() {
597       public void widgetSelected(SelectionEvent e) {
598         boolean custom = fBackgroundCustomRadioButton.getSelection();
599         fBackgroundColorButton.setEnabled(custom);
600         fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
601       }
602
603       public void widgetDefaultSelected(SelectionEvent e) {
604       }
605     };
606     fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
607     fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
608     fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
609     fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
610     fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
611     fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
612     fBackgroundColorEditor = new ColorEditor(backgroundComposite);
613     fBackgroundColorButton = fBackgroundColorEditor.getButton();
614     Label label = new Label(colorComposite, SWT.LEFT);
615     label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
616     label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
617     Composite editorComposite = new Composite(colorComposite, SWT.NONE);
618     GridLayout layout = new GridLayout();
619     layout.numColumns = 2;
620     layout.marginHeight = 0;
621     layout.marginWidth = 0;
622     editorComposite.setLayout(layout);
623     GridData gd = new GridData(GridData.FILL_BOTH);
624     editorComposite.setLayoutData(gd);
625     fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
626     gd = new GridData(GridData.FILL_BOTH);
627     gd.heightHint = convertHeightInCharsToPixels(5);
628     fSyntaxColorList.setLayoutData(gd);
629     Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
630     layout = new GridLayout();
631     layout.marginHeight = 0;
632     layout.marginWidth = 0;
633     layout.numColumns = 2;
634     stylesComposite.setLayout(layout);
635     stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
636     label = new Label(stylesComposite, SWT.LEFT);
637     label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
638     gd = new GridData();
639     gd.horizontalAlignment = GridData.BEGINNING;
640     label.setLayoutData(gd);
641     fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
642     Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
643     gd = new GridData(GridData.FILL_HORIZONTAL);
644     gd.horizontalAlignment = GridData.BEGINNING;
645     foregroundColorButton.setLayoutData(gd);
646     fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
647     fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
648     gd = new GridData(GridData.FILL_HORIZONTAL);
649     gd.horizontalAlignment = GridData.BEGINNING;
650     gd.horizontalSpan = 2;
651     fBoldCheckBox.setLayoutData(gd);
652     label = new Label(colorComposite, SWT.LEFT);
653     label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
654     label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
655     Control previewer = createPreviewer(colorComposite);
656     gd = new GridData(GridData.FILL_BOTH);
657     gd.widthHint = convertWidthInCharsToPixels(20);
658     gd.heightHint = convertHeightInCharsToPixels(5);
659     previewer.setLayoutData(gd);
660     fSyntaxColorList.addSelectionListener(new SelectionListener() {
661       public void widgetDefaultSelected(SelectionEvent e) {
662         // do nothing
663       }
664
665       public void widgetSelected(SelectionEvent e) {
666         handleSyntaxColorListSelection();
667       }
668     });
669     foregroundColorButton.addSelectionListener(new SelectionListener() {
670       public void widgetDefaultSelected(SelectionEvent e) {
671         // do nothing
672       }
673
674       public void widgetSelected(SelectionEvent e) {
675         int i = fSyntaxColorList.getSelectionIndex();
676         String key = fSyntaxColorListModel[i][1];
677         PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
678       }
679     });
680     fBackgroundColorButton.addSelectionListener(new SelectionListener() {
681       public void widgetDefaultSelected(SelectionEvent e) {
682         // do nothing
683       }
684
685       public void widgetSelected(SelectionEvent e) {
686         PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
687             .getColorValue());
688       }
689     });
690     fBoldCheckBox.addSelectionListener(new SelectionListener() {
691       public void widgetDefaultSelected(SelectionEvent e) {
692         // do nothing
693       }
694
695       public void widgetSelected(SelectionEvent e) {
696         int i = fSyntaxColorList.getSelectionIndex();
697         String key = fSyntaxColorListModel[i][1];
698         fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
699       }
700     });
701     return colorComposite;
702   }
703
704   private Control createPreviewer(Composite parent) {
705     Preferences coreStore = createTemporaryCorePreferenceStore();
706     fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
707     IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
708     IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
709         new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
710
711     fPreviewViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
712     JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
713         PHPSourceViewerConfiguration configuration= new PHPSourceViewerConfiguration(tools.getColorManager(), store, null, IPHPPartitions.PHP_PARTITIONING);
714 //    PHPSourceViewerConfiguration configuration =new PHPSourceViewerConfiguration(fJavaTextTools, null, IPHPPartitions.PHP_PARTITIONING);
715     fPreviewViewer.configure(configuration);
716      
717     Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
718         fPreviewViewer.getTextWidget().setFont(font);
719     new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
720         fPreviewViewer.setEditable(false);
721     String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
722     IDocument document = new Document(content);
723     fJavaTextTools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
724     fPreviewViewer.setDocument(document);
725     return fPreviewViewer.getControl();
726   }
727
728   private Preferences createTemporaryCorePreferenceStore() {
729     Preferences result = new Preferences();
730     result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
731     return result;
732   }
733
734   private Control createAppearancePage(Composite parent) {
735     Composite appearanceComposite = new Composite(parent, SWT.NONE);
736     GridLayout layout = new GridLayout();
737     layout.numColumns = 2;
738     appearanceComposite.setLayout(layout);
739     String label = PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
740     addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
741     label = PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
742     addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
743     label = PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
744     addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
745     label = PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
746     addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
747     label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
748     addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
749     label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
750     addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
751     label = PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
752     addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
753     label = PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
754     //          Button master= addCheckBox(appearanceComposite, label,
755     // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
756     label = PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
757     //          fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
758     // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
759     //          createDependency(master, fStickyOccurrencesButton);
760     Label l = new Label(appearanceComposite, SWT.LEFT);
761     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
762     gd.horizontalSpan = 2;
763     gd.heightHint = convertHeightInCharsToPixels(1) / 2;
764     l.setLayoutData(gd);
765     l = new Label(appearanceComposite, SWT.LEFT);
766     l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
767     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
768     gd.horizontalSpan = 2;
769     l.setLayoutData(gd);
770     Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
771     layout = new GridLayout();
772     layout.numColumns = 2;
773     layout.marginHeight = 0;
774     layout.marginWidth = 0;
775     editorComposite.setLayout(layout);
776     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
777     gd.horizontalSpan = 2;
778     editorComposite.setLayoutData(gd);
779     fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
780     gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
781     gd.heightHint = convertHeightInCharsToPixels(8);
782     fAppearanceColorList.setLayoutData(gd);
783     Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
784     layout = new GridLayout();
785     layout.marginHeight = 0;
786     layout.marginWidth = 0;
787     layout.numColumns = 2;
788     stylesComposite.setLayout(layout);
789     stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
790     l = new Label(stylesComposite, SWT.LEFT);
791     l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
792     gd = new GridData();
793     gd.horizontalAlignment = GridData.BEGINNING;
794     l.setLayoutData(gd);
795     fAppearanceColorEditor = new ColorEditor(stylesComposite);
796     Button foregroundColorButton = fAppearanceColorEditor.getButton();
797     gd = new GridData(GridData.FILL_HORIZONTAL);
798     gd.horizontalAlignment = GridData.BEGINNING;
799     foregroundColorButton.setLayoutData(gd);
800     fAppearanceColorList.addSelectionListener(new SelectionListener() {
801       public void widgetDefaultSelected(SelectionEvent e) {
802         // do nothing
803       }
804
805       public void widgetSelected(SelectionEvent e) {
806         handleAppearanceColorListSelection();
807       }
808     });
809     foregroundColorButton.addSelectionListener(new SelectionListener() {
810       public void widgetDefaultSelected(SelectionEvent e) {
811         // do nothing
812       }
813
814       public void widgetSelected(SelectionEvent e) {
815         int i = fAppearanceColorList.getSelectionIndex();
816         String key = fAppearanceColorListModel[i][1];
817         PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
818       }
819     });
820     return appearanceComposite;
821   }
822
823   //  private Control createAnnotationsPage(Composite parent) {
824   //    Composite composite = new Composite(parent, SWT.NULL);
825   //    GridLayout layout = new GridLayout();
826   //    layout.numColumns = 2;
827   //    composite.setLayout(layout);
828   //    String text = PreferencesMessages
829   //        .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
830   // //$NON-NLS-1$
831   //    addCheckBox(composite, text,
832   //        PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
833   //    text = PreferencesMessages
834   //        .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
835   //    addCheckBox(composite, text,
836   //        PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
837   //    addFiller(composite);
838   //    Label label = new Label(composite, SWT.LEFT);
839   //    label.setText(PreferencesMessages
840   //        .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
841   // //$NON-NLS-1$
842   //    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
843   //    gd.horizontalSpan = 2;
844   //    label.setLayoutData(gd);
845   //    Composite editorComposite = new Composite(composite, SWT.NONE);
846   //    layout = new GridLayout();
847   //    layout.numColumns = 2;
848   //    layout.marginHeight = 0;
849   //    layout.marginWidth = 0;
850   //    editorComposite.setLayout(layout);
851   //    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
852   //    gd.horizontalSpan = 2;
853   //    editorComposite.setLayoutData(gd);
854   //    fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
855   //        | SWT.BORDER);
856   //    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
857   //        | GridData.FILL_HORIZONTAL);
858   //    gd.heightHint = convertHeightInCharsToPixels(10);
859   //    fAnnotationList.setLayoutData(gd);
860   //    Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
861   //    layout = new GridLayout();
862   //    layout.marginHeight = 0;
863   //    layout.marginWidth = 0;
864   //    layout.numColumns = 2;
865   //    optionsComposite.setLayout(layout);
866   //    optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
867   //    fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
868   //    fShowInTextCheckBox.setText(PreferencesMessages
869   //        .getString("JavaEditorPreferencePage.annotations.showInText"));
870   // //$NON-NLS-1$
871   //    gd = new GridData(GridData.FILL_HORIZONTAL);
872   //    gd.horizontalAlignment = GridData.BEGINNING;
873   //    gd.horizontalSpan = 2;
874   //    fShowInTextCheckBox.setLayoutData(gd);
875   //    fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
876   //    for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
877   //      fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
878   //    gd = new GridData(GridData.FILL_HORIZONTAL);
879   //    gd.horizontalAlignment = GridData.BEGINNING;
880   //    gd.horizontalSpan = 2;
881   //    gd.horizontalIndent = 20;
882   //    fDecorationStyleCombo.setLayoutData(gd);
883   //    fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
884   //    fHighlightInTextCheckBox.setText(PreferencesMessages
885   //        .getString("TextEditorPreferencePage.annotations.highlightInText"));
886   // //$NON-NLS-1$
887   //    gd = new GridData(GridData.FILL_HORIZONTAL);
888   //    gd.horizontalAlignment = GridData.BEGINNING;
889   //    gd.horizontalSpan = 2;
890   //    fHighlightInTextCheckBox.setLayoutData(gd);
891   //    fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
892   //    fShowInOverviewRulerCheckBox.setText(PreferencesMessages
893   //        .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
894   // //$NON-NLS-1$
895   //    gd = new GridData(GridData.FILL_HORIZONTAL);
896   //    gd.horizontalAlignment = GridData.BEGINNING;
897   //    gd.horizontalSpan = 2;
898   //    fShowInOverviewRulerCheckBox.setLayoutData(gd);
899   //    fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
900   //    fShowInVerticalRulerCheckBox.setText(PreferencesMessages
901   //        .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
902   // //$NON-NLS-1$
903   //    gd = new GridData(GridData.FILL_HORIZONTAL);
904   //    gd.horizontalAlignment = GridData.BEGINNING;
905   //    gd.horizontalSpan = 2;
906   //    fShowInVerticalRulerCheckBox.setLayoutData(gd);
907   //    label = new Label(optionsComposite, SWT.LEFT);
908   //    label.setText(PreferencesMessages
909   //        .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
910   //    gd = new GridData();
911   //    gd.horizontalAlignment = GridData.BEGINNING;
912   //    label.setLayoutData(gd);
913   //    fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
914   //    Button foregroundColorButton =
915   // fAnnotationForegroundColorEditor.getButton();
916   //    gd = new GridData(GridData.FILL_HORIZONTAL);
917   //    gd.horizontalAlignment = GridData.BEGINNING;
918   //    foregroundColorButton.setLayoutData(gd);
919   //    fAnnotationList.addSelectionListener(new SelectionListener() {
920   //      public void widgetDefaultSelected(SelectionEvent e) {
921   //        // do nothing
922   //      }
923   //      public void widgetSelected(SelectionEvent e) {
924   //        handleAnnotationListSelection();
925   //      }
926   //    });
927   //    fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
928   //      public void widgetDefaultSelected(SelectionEvent e) {
929   //        // do nothing
930   //      }
931   //      public void widgetSelected(SelectionEvent e) {
932   //        int i = fAnnotationList.getSelectionIndex();
933   //        String key = fAnnotationColorListModel[i][2];
934   //        fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
935   //        String decorationKey = fAnnotationColorListModel[i][6];
936   //        fDecorationStyleCombo.setEnabled(decorationKey != null
937   //            && fShowInTextCheckBox.getSelection());
938   //      }
939   //    });
940   //    fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
941   //      public void widgetDefaultSelected(SelectionEvent e) {
942   //        // do nothing
943   //      }
944   //      public void widgetSelected(SelectionEvent e) {
945   //        int i = fAnnotationList.getSelectionIndex();
946   //        String key = fAnnotationColorListModel[i][4];
947   //        fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
948   //      }
949   //    });
950   //    fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
951   //      public void widgetDefaultSelected(SelectionEvent e) {
952   //        // do nothing
953   //      }
954   //      public void widgetSelected(SelectionEvent e) {
955   //        int i = fAnnotationList.getSelectionIndex();
956   //        String key = fAnnotationColorListModel[i][3];
957   //        fOverlayStore
958   //            .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
959   //      }
960   //    });
961   //    fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
962   //      public void widgetDefaultSelected(SelectionEvent e) {
963   //        // do nothing
964   //      }
965   //      public void widgetSelected(SelectionEvent e) {
966   //        int i = fAnnotationList.getSelectionIndex();
967   //        String key = fAnnotationColorListModel[i][5];
968   //        fOverlayStore
969   //            .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
970   //      }
971   //    });
972   //    foregroundColorButton.addSelectionListener(new SelectionListener() {
973   //      public void widgetDefaultSelected(SelectionEvent e) {
974   //        // do nothing
975   //      }
976   //      public void widgetSelected(SelectionEvent e) {
977   //        int i = fAnnotationList.getSelectionIndex();
978   //        String key = fAnnotationColorListModel[i][1];
979   //        PreferenceConverter.setValue(fOverlayStore, key,
980   //            fAnnotationForegroundColorEditor.getColorValue());
981   //      }
982   //    });
983   //    fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
984   //      /**
985   //       * {@inheritdoc}
986   //       */
987   //      public void widgetDefaultSelected(SelectionEvent e) {
988   //        // do nothing
989   //      }
990   //      /**
991   //       * {@inheritdoc}
992   //       */
993   //      public void widgetSelected(SelectionEvent e) {
994   //        int i = fAnnotationList.getSelectionIndex();
995   //        String key = fAnnotationColorListModel[i][6];
996   //        if (key != null) {
997   //          for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
998   //            if (fAnnotationDecorationListModel[j][0]
999   //                .equals(fDecorationStyleCombo.getText())) {
1000   //              fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1001   //              break;
1002   //            }
1003   //          }
1004   //        }
1005   //      }
1006   //    });
1007   //    return composite;
1008   //  }
1009   private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
1010     ArrayList listModelItems = new ArrayList();
1011     SortedSet sortedPreferences = new TreeSet(new Comparator() {
1012       /*
1013        * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1014        */
1015       public int compare(Object o1, Object o2) {
1016         if (!(o2 instanceof AnnotationPreference))
1017           return -1;
1018         if (!(o1 instanceof AnnotationPreference))
1019           return 1;
1020         AnnotationPreference a1 = (AnnotationPreference) o1;
1021         AnnotationPreference a2 = (AnnotationPreference) o2;
1022         return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
1023       }
1024     });
1025     sortedPreferences.addAll(preferences.getAnnotationPreferences());
1026     Iterator e = sortedPreferences.iterator();
1027     while (e.hasNext()) {
1028       AnnotationPreference info = (AnnotationPreference) e.next();
1029       listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1030           info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(),
1031           info.getTextStylePreferenceKey() });
1032     }
1033     String[][] items = new String[listModelItems.size()][];
1034     listModelItems.toArray(items);
1035     return items;
1036   }
1037
1038   private Control createTypingPage(Composite parent) {
1039     Composite composite = new Composite(parent, SWT.NONE);
1040     GridLayout layout = new GridLayout();
1041     layout.numColumns = 1;
1042     composite.setLayout(layout);
1043     String label;
1044     //    label = PreferencesMessages
1045     //        .getString("JavaEditorPreferencePage.overwriteMode");
1046     //    //$NON-NLS-1$
1047     //    addCheckBox(composite, label,
1048     //        PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1049     //    addFiller(composite);
1050     //
1051     //    label = PreferencesMessages
1052     //        .getString("JavaEditorPreferencePage.smartHomeEnd");
1053     //    //$NON-NLS-1$
1054     //    addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1055     //
1056     //    label = PreferencesMessages
1057     //        .getString("JavaEditorPreferencePage.subWordNavigation");
1058     //    //$NON-NLS-1$
1059     //    addCheckBox(composite, label,
1060     //        PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1061     //    addFiller(composite);
1062     Group group = new Group(composite, SWT.NONE);
1063     layout = new GridLayout();
1064     layout.numColumns = 2;
1065     group.setLayout(layout);
1066     group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1067
1068     label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1069     Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1070
1071     label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1072     fEscapeStringsButtonDQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1073     createDependency(button, fEscapeStringsButtonDQ);
1074
1075     label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1076     addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1077
1078     label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsSQ");
1079     //$NON-NLS-1$
1080     fEscapeStringsButtonSQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1081     createDependency(button, fEscapeStringsButtonSQ);
1082     
1083     label = PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
1084     //$NON-NLS-1$
1085     addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1086
1087     label = PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
1088     //$NON-NLS-1$
1089     addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1090
1091     label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsDQ");
1092     //$NON-NLS-1$
1093     addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1094     label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsSQ");
1095     //$NON-NLS-1$
1096     addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1097
1098     label = PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
1099     //$NON-NLS-1$
1100     addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1101
1102     //    label = PreferencesMessages
1103     //        .getString("JavaEditorPreferencePage.closeBraces");
1104     //    //$NON-NLS-1$
1105     //    addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1106
1107     //    label = PreferencesMessages
1108     //        .getString("JavaEditorPreferencePage.closeJavaDocs");
1109     //    //$NON-NLS-1$
1110     //    button = addCheckBox(group, label,
1111     //        PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1112     //
1113     //    label = PreferencesMessages
1114     //        .getString("JavaEditorPreferencePage.addJavaDocTags");
1115     //    //$NON-NLS-1$
1116     //    fAddJavaDocTagsButton = addCheckBox(group, label,
1117     //        PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1118     //    createDependency(button, fAddJavaDocTagsButton);
1119     return composite;
1120   }
1121
1122   private void addFiller(Composite composite) {
1123     Label filler = new Label(composite, SWT.LEFT);
1124     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1125     gd.horizontalSpan = 2;
1126     gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1127     filler.setLayoutData(gd);
1128   }
1129
1130   private static void indent(Control control) {
1131     GridData gridData = new GridData();
1132     gridData.horizontalIndent = 20;
1133     control.setLayoutData(gridData);
1134   }
1135
1136   private static void createDependency(final Button master, final Control slave) {
1137     indent(slave);
1138     master.addSelectionListener(new SelectionListener() {
1139       public void widgetSelected(SelectionEvent e) {
1140         slave.setEnabled(master.getSelection());
1141       }
1142
1143       public void widgetDefaultSelected(SelectionEvent e) {
1144       }
1145     });
1146   }
1147
1148   private void addCompletionRadioButtons(Composite contentAssistComposite) {
1149     Composite completionComposite = new Composite(contentAssistComposite, SWT.NONE);
1150     GridData ccgd = new GridData();
1151     ccgd.horizontalSpan = 2;
1152     completionComposite.setLayoutData(ccgd);
1153     GridLayout ccgl = new GridLayout();
1154     ccgl.marginWidth = 0;
1155     ccgl.numColumns = 2;
1156     completionComposite.setLayout(ccgl);
1157     //          SelectionListener completionSelectionListener= new SelectionAdapter() {
1158     //                  public void widgetSelected(SelectionEvent e) {
1159     //                          boolean insert= fCompletionInsertsRadioButton.getSelection();
1160     //                          fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1161     // insert);
1162     //                  }
1163     //          };
1164     //          
1165     //          fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1166     // | SWT.LEFT);
1167     //          fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1168     // //$NON-NLS-1$
1169     //          fCompletionInsertsRadioButton.setLayoutData(new GridData());
1170     //          fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1171     //          
1172     //          fCompletionOverwritesRadioButton= new Button(completionComposite,
1173     // SWT.RADIO | SWT.LEFT);
1174     //          fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1175     // //$NON-NLS-1$
1176     //          fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1177     //          fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1178   }
1179
1180   private Control createNavigationPage(Composite parent) {
1181     Composite composite = new Composite(parent, SWT.NULL);
1182     GridLayout layout = new GridLayout();
1183     layout.numColumns = 2;
1184     composite.setLayout(layout);
1185     //          String text=
1186     // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1187     // //$NON-NLS-1$
1188     //          fBrowserLikeLinksCheckBox= addCheckBox(composite, text,
1189     // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1190     //          fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1191     //                  public void widgetSelected(SelectionEvent e) {
1192     //                          boolean state= fBrowserLikeLinksCheckBox.getSelection();
1193     //                          fBrowserLikeLinksKeyModifierText.setEnabled(state);
1194     //                          handleBrowserLikeLinksKeyModifierModified();
1195     //                  }
1196     //                  public void widgetDefaultSelected(SelectionEvent e) {
1197     //                  }
1198     //          });
1199     // Text field for modifier string
1200     //          text=
1201     // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1202     // //$NON-NLS-1$
1203     //          fBrowserLikeLinksKeyModifierText= addTextField(composite, text,
1204     // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0,
1205     // false);
1206     //          fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1207     //          
1208     //          if
1209     // (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER))
1210     // == -1) {
1211     //                  // Fix possible illegal modifier string
1212     //                  int stateMask=
1213     // fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1214     //                  if (stateMask == -1)
1215     //                          fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1216     //                  else
1217     //                          fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1218     //          }
1219     //          fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1220     //                  private boolean isModifierCandidate;
1221     //                  public void keyPressed(KeyEvent e) {
1222     //                          isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask ==
1223     // 0;
1224     //                  }
1225     //          
1226     //                  public void keyReleased(KeyEvent e) {
1227     //                          if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask
1228     // && e.character == 0) {// && e.time -time < 1000) {
1229     //                                  String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1230     //                                  Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1231     //                                  int i= selection.x - 1;
1232     //                                  while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1233     //                                          i--;
1234     //                                  }
1235     //                                  boolean needsPrefixDelimiter= i > -1 &&
1236     // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1237     //
1238     //                                  i= selection.y;
1239     //                                  while (i < modifierString.length() &&
1240     // Character.isWhitespace(modifierString.charAt(i))) {
1241     //                                          i++;
1242     //                                  }
1243     //                                  boolean needsPostfixDelimiter= i < modifierString.length() &&
1244     // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1245     //
1246     //                                  String insertString;
1247     //
1248     //                                  if (needsPrefixDelimiter && needsPostfixDelimiter)
1249     //                                          insertString=
1250     // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1251     // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1252     //                                  else if (needsPrefixDelimiter)
1253     //                                          insertString=
1254     // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1255     // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1256     //                                  else if (needsPostfixDelimiter)
1257     //                                          insertString=
1258     // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1259     // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1260     //                                  else
1261     //                                          insertString= Action.findModifierString(e.stateMask);
1262     //
1263     //                                  fBrowserLikeLinksKeyModifierText.insert(insertString);
1264     //                          }
1265     //                  }
1266     //          });
1267     //
1268     //          fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener()
1269     // {
1270     //                  public void modifyText(ModifyEvent e) {
1271     //                          handleBrowserLikeLinksKeyModifierModified();
1272     //                  }
1273     //          });
1274     return composite;
1275   }
1276
1277   private void handleBrowserLikeLinksKeyModifierModified() {
1278     //          String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1279     //          int stateMask= computeStateMask(modifiers);
1280     //          if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 ||
1281     // (stateMask & SWT.SHIFT) != 0)) {
1282     //                  if (stateMask == -1)
1283     //                          fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1284     // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid",
1285     // modifiers)); //$NON-NLS-1$
1286     //                  else
1287     //                          fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1288     // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1289     // //$NON-NLS-1$
1290     //                  setValid(false);
1291     //                  StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1292     //          } else {
1293     //                  fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1294     //                  updateStatus(fBrowserLikeLinksKeyModifierStatus);
1295     //          }
1296   }
1297
1298   //    private IStatus getBrowserLikeLinksKeyModifierStatus() {
1299   //            if (fBrowserLikeLinksKeyModifierStatus == null)
1300   //            fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1301   //            return fBrowserLikeLinksKeyModifierStatus;
1302   //    }
1303   /**
1304    * Computes the state mask for the given modifier string.
1305    * 
1306    * @param modifiers
1307    *          the string with the modifiers, separated by '+', '-', ';', ',' or '.'
1308    * @return the state mask or -1 if the input is invalid
1309    */
1310   private int computeStateMask(String modifiers) {
1311     if (modifiers == null)
1312       return -1;
1313     if (modifiers.length() == 0)
1314       return SWT.NONE;
1315     int stateMask = 0;
1316     StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
1317     while (modifierTokenizer.hasMoreTokens()) {
1318       int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
1319       if (modifier == 0 || (stateMask & modifier) == modifier)
1320         return -1;
1321       stateMask = stateMask | modifier;
1322     }
1323     return stateMask;
1324   }
1325
1326   /*
1327    * @see PreferencePage#createContents(Composite)
1328    */
1329   protected Control createContents(Composite parent) {
1330     initializeDefaultColors();
1331     fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore);
1332     fOverlayStore.load();
1333     fOverlayStore.start();
1334     TabFolder folder = new TabFolder(parent, SWT.NONE);
1335     folder.setLayout(new TabFolderLayout());
1336     folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1337     TabItem item = new TabItem(folder, SWT.NONE);
1338     item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1339     item.setControl(createAppearancePage(folder));
1340     item = new TabItem(folder, SWT.NONE);
1341     item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1342     item.setControl(createSyntaxPage(folder));
1343
1344     //    item = new TabItem(folder, SWT.NONE);
1345     //    item.setText(PreferencesMessages
1346     //        .getString("JavaEditorPreferencePage.annotationsTab.title"));
1347     // //$NON-NLS-1$
1348     //    item.setControl(createAnnotationsPage(folder));
1349     item = new TabItem(folder, SWT.NONE);
1350     item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
1351     //$NON-NLS-1$
1352     item.setControl(createTypingPage(folder));
1353
1354     item = new TabItem(folder, SWT.NONE);
1355     item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
1356     //$NON-NLS-1$
1357     fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1358     item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1359     //                  item= new TabItem(folder, SWT.NONE);
1360     //                  item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1361     // //$NON-NLS-1$
1362     //                  item.setControl(createNavigationPage(folder));
1363     item = new TabItem(folder, SWT.NONE);
1364     item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1365     item.setControl(fFoldingConfigurationBlock.createControl(folder));
1366
1367     initialize();
1368     Dialog.applyDialogFont(folder);
1369     return folder;
1370   }
1371
1372   private void initialize() {
1373     initializeFields();
1374     for (int i = 0; i < fSyntaxColorListModel.length; i++)
1375       fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1376     fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1377       public void run() {
1378         if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1379           fSyntaxColorList.select(0);
1380           handleSyntaxColorListSelection();
1381         }
1382       }
1383     });
1384     for (int i = 0; i < fAppearanceColorListModel.length; i++)
1385       fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1386     fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1387       public void run() {
1388         if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1389           fAppearanceColorList.select(0);
1390           handleAppearanceColorListSelection();
1391         }
1392       }
1393     });
1394     //    for (int i = 0; i < fAnnotationColorListModel.length; i++)
1395     //      fAnnotationList.add(fAnnotationColorListModel[i][0]);
1396     //    fAnnotationList.getDisplay().asyncExec(new Runnable() {
1397     //      public void run() {
1398     //        if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1399     //          fAnnotationList.select(0);
1400     //          handleAnnotationListSelection();
1401     //        }
1402     //      }
1403     //    });
1404     //          for (int i= 0; i < fContentAssistColorListModel.length; i++)
1405     //                  fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1406     //          fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1407     //                  public void run() {
1408     //                          if (fContentAssistColorList != null &&
1409     // !fContentAssistColorList.isDisposed()) {
1410     //                                  fContentAssistColorList.select(0);
1411     //                                  handleContentAssistColorListSelection();
1412     //                          }
1413     //                  }
1414     //          });
1415     fFoldingConfigurationBlock.initialize();
1416   }
1417
1418   private void initializeFields() {
1419     Iterator e = fColorButtons.keySet().iterator();
1420     while (e.hasNext()) {
1421       ColorEditor c = (ColorEditor) e.next();
1422       String key = (String) fColorButtons.get(c);
1423       RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1424       c.setColorValue(rgb);
1425     }
1426     e = fCheckBoxes.keySet().iterator();
1427     while (e.hasNext()) {
1428       Button b = (Button) e.next();
1429       String key = (String) fCheckBoxes.get(b);
1430       b.setSelection(fOverlayStore.getBoolean(key));
1431     }
1432     e = fTextFields.keySet().iterator();
1433     while (e.hasNext()) {
1434       Text t = (Text) e.next();
1435       String key = (String) fTextFields.get(t);
1436       t.setText(fOverlayStore.getString(key));
1437     }
1438     RGB rgb = PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1439     fBackgroundColorEditor.setColorValue(rgb);
1440     boolean default_ = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1441     fBackgroundDefaultRadioButton.setSelection(default_);
1442     fBackgroundCustomRadioButton.setSelection(!default_);
1443     fBackgroundColorButton.setEnabled(!default_);
1444     //    boolean closeJavaDocs = fOverlayStore
1445     //        .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1446     //    fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1447     fEscapeStringsButtonDQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1448     fEscapeStringsButtonSQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1449     //          boolean fillMethodArguments=
1450     // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1451     //          fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1452     //          boolean completionInserts=
1453     // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1454     //          fCompletionInsertsRadioButton.setSelection(completionInserts);
1455     //          fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1456     //          
1457     //          fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1458     //          boolean markOccurrences=
1459     // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1460     //          fStickyOccurrencesButton.setEnabled(markOccurrences);
1461     updateAutoactivationControls();
1462   }
1463
1464   private void initializeDefaultColors() {
1465     if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1466       RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1467       PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1468       PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1469     }
1470     if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1471       RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1472       PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1473       PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1474     }
1475   }
1476
1477   private void updateAutoactivationControls() {
1478     //        boolean autoactivation=
1479     // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1480     //        fAutoInsertDelayText.setEnabled(autoactivation);
1481     //          fAutoInsertDelayLabel.setEnabled(autoactivation);
1482     //        fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1483     //          fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1484     //
1485     //        fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1486     //          fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1487   }
1488
1489   /*
1490    * @see PreferencePage#performOk()
1491    */
1492   public boolean performOk() {
1493     //          fJavaEditorHoverConfigurationBlock.performOk();
1494     fFoldingConfigurationBlock.performOk();
1495     //          fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1496     // computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1497     fOverlayStore.propagate();
1498     PHPeclipsePlugin.getDefault().savePluginPreferences();
1499     return true;
1500   }
1501
1502   /*
1503    * @see PreferencePage#performDefaults()
1504    */
1505   protected void performDefaults() {
1506     fOverlayStore.loadDefaults();
1507     initializeFields();
1508     handleSyntaxColorListSelection();
1509     handleAppearanceColorListSelection();
1510     //    handleAnnotationListSelection();
1511     //          handleContentAssistColorListSelection();
1512     //          fJavaEditorHoverConfigurationBlock.performDefaults();
1513     fFoldingConfigurationBlock.performDefaults();
1514     super.performDefaults();
1515     fPreviewViewer.invalidateTextPresentation();
1516   }
1517
1518   /*
1519    * @see DialogPage#dispose()
1520    */
1521   public void dispose() {
1522     fFoldingConfigurationBlock.dispose();
1523
1524     if (fJavaTextTools != null) {
1525       fJavaTextTools.dispose();
1526       fJavaTextTools = null;
1527     }
1528     if (fOverlayStore != null) {
1529       fOverlayStore.stop();
1530       fOverlayStore = null;
1531     }
1532     if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1533       fBackgroundColor.dispose();
1534     super.dispose();
1535   }
1536
1537   private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1538     Button checkBox = new Button(parent, SWT.CHECK);
1539     checkBox.setText(label);
1540     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1541     gd.horizontalIndent = indentation;
1542     gd.horizontalSpan = 2;
1543     checkBox.setLayoutData(gd);
1544     checkBox.addSelectionListener(fCheckBoxListener);
1545     fCheckBoxes.put(checkBox, key);
1546     return checkBox;
1547   }
1548
1549   private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1550     return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
1551   }
1552
1553   private static Label getLabelControl(Control[] labelledTextField) {
1554     return (Label) labelledTextField[0];
1555   }
1556
1557   private static Text getTextControl(Control[] labelledTextField) {
1558     return (Text) labelledTextField[1];
1559   }
1560
1561   /**
1562    * Returns an array of size 2: - first element is of type <code>Label</code>- second element is of type <code>Text</code> Use
1563    * <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
1564    */
1565   private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation,
1566       boolean isNumber) {
1567     Label labelControl = new Label(composite, SWT.NONE);
1568     labelControl.setText(label);
1569     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1570     gd.horizontalIndent = indentation;
1571     labelControl.setLayoutData(gd);
1572     Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1573     gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1574     gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1575     textControl.setLayoutData(gd);
1576     textControl.setTextLimit(textLimit);
1577     fTextFields.put(textControl, key);
1578     if (isNumber) {
1579       fNumberFields.add(textControl);
1580       textControl.addModifyListener(fNumberFieldListener);
1581     } else {
1582       textControl.addModifyListener(fTextFieldListener);
1583     }
1584     return new Control[] { labelControl, textControl };
1585   }
1586
1587   private String loadPreviewContentFromFile(String filename) {
1588     String line;
1589     String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1590     StringBuffer buffer = new StringBuffer(512);
1591     BufferedReader reader = null;
1592     try {
1593       reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1594       while ((line = reader.readLine()) != null) {
1595         buffer.append(line);
1596         buffer.append(separator);
1597       }
1598     } catch (IOException io) {
1599       PHPeclipsePlugin.log(io);
1600     } finally {
1601       if (reader != null) {
1602         try {
1603           reader.close();
1604         } catch (IOException e) {
1605         }
1606       }
1607     }
1608     return buffer.toString();
1609   }
1610
1611   private void numberFieldChanged(Text textControl) {
1612     String number = textControl.getText();
1613     IStatus status = validatePositiveNumber(number);
1614     if (!status.matches(IStatus.ERROR))
1615       fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1616     updateStatus(status);
1617   }
1618
1619   private IStatus validatePositiveNumber(String number) {
1620     StatusInfo status = new StatusInfo();
1621     if (number.length() == 0) {
1622       status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1623     } else {
1624       try {
1625         int value = Integer.parseInt(number);
1626         if (value < 0)
1627           status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1628       } catch (NumberFormatException e) {
1629         status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1630       }
1631     }
1632     return status;
1633   }
1634
1635   void updateStatus(IStatus status) {
1636     if (!status.matches(IStatus.ERROR)) {
1637       for (int i = 0; i < fNumberFields.size(); i++) {
1638         Text text = (Text) fNumberFields.get(i);
1639         IStatus s = validatePositiveNumber(text.getText());
1640         status = StatusUtil.getMoreSevere(s, status);
1641       }
1642     }
1643     //          status=
1644     // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1645     // status);
1646     //          status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1647     // status);
1648     setValid(!status.matches(IStatus.ERROR));
1649     StatusUtil.applyToStatusLine(this, status);
1650   }
1651 }