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