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