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