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