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