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