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