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