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