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