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;
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;
22 import java.util.SortedSet;
23 import java.util.StringTokenizer;
24 import java.util.TreeSet;
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.PreferencesAdapter;
31 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
32 import net.sourceforge.phpdt.ui.PreferenceConstants;
33 import net.sourceforge.phpdt.ui.text.JavaTextTools;
34 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
35 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
36 import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer;
37 import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration;
38 import net.sourceforge.phpeclipse.preferences.ColorEditor;
40 import org.eclipse.core.runtime.IStatus;
41 import org.eclipse.core.runtime.Preferences;
42 import net.sourceforge.phpdt.internal.ui.preferences.FoldingConfigurationBlock;
43 import net.sourceforge.phpdt.internal.ui.preferences.PreferencesMessages;
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.ModifyEvent;
54 import org.eclipse.swt.events.ModifyListener;
55 import org.eclipse.swt.events.SelectionAdapter;
56 import org.eclipse.swt.events.SelectionEvent;
57 import org.eclipse.swt.events.SelectionListener;
58 import org.eclipse.swt.graphics.Color;
59 import org.eclipse.swt.graphics.RGB;
60 import org.eclipse.swt.layout.GridData;
61 import org.eclipse.swt.layout.GridLayout;
62 import org.eclipse.swt.layout.RowLayout;
63 import org.eclipse.swt.widgets.Button;
64 import org.eclipse.swt.widgets.Combo;
65 import org.eclipse.swt.widgets.Composite;
66 import org.eclipse.swt.widgets.Control;
67 import org.eclipse.swt.widgets.Group;
68 import org.eclipse.swt.widgets.Label;
69 import org.eclipse.swt.widgets.List;
70 import org.eclipse.swt.widgets.TabFolder;
71 import org.eclipse.swt.widgets.TabItem;
72 import org.eclipse.swt.widgets.Text;
73 import org.eclipse.ui.IWorkbench;
74 import org.eclipse.ui.IWorkbenchPreferencePage;
75 import org.eclipse.ui.editors.text.EditorsUI;
76 import org.eclipse.ui.help.WorkbenchHelp;
77 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
78 import org.eclipse.ui.texteditor.AnnotationPreference;
79 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
80 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
83 * The page for setting the editor options.
85 public class JavaEditorPreferencePage extends PreferencePage implements
86 IWorkbenchPreferencePage {
87 private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
89 private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
91 private static final String DELIMITER = PreferencesMessages
92 .getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
94 /** The keys of the overlay store. */
95 public final OverlayPreferenceStore.OverlayKey[] fKeys;
97 private final String[][] fSyntaxColorListModel = new String[][] {
99 // PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
100 // PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$
102 // PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
103 // PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$
104 // { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"),
105 // PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$
106 // { PreferencesMessages.getString("JavaEditorPreferencePage.strings"),
107 // PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$
109 // PreferencesMessages.getString("JavaEditorPreferencePage.methodNames"),
110 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR }, //$NON-NLS-1$
111 // { PreferencesMessages.getString("JavaEditorPreferencePage.operators"),
112 // PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR }, //$NON-NLS-1$
113 // { PreferencesMessages.getString("JavaEditorPreferencePage.others"),
114 // PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
116 // PreferencesMessages.getString("JavaEditorPreferencePage.javaCommentTaskTags"),
117 // PreferenceConstants.EDITOR_TASK_TAG_COLOR }, //$NON-NLS-1$
119 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocKeywords"),
120 // PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$
122 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocHtmlTags"),
123 // PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR }, //$NON-NLS-1$
125 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocLinks"),
126 // PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$
128 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocOthers"),
129 // PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
132 .getString("PHPEditorPreferencePage.multiLineComment"),
133 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
137 .getString("PHPEditorPreferencePage.singleLineComment"),
138 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
140 { PreferencesMessages.getString("PHPEditorPreferencePage.tags"),
141 PreferenceConstants.EDITOR_PHP_TAG_COLOR },
143 { PreferencesMessages.getString("PHPEditorPreferencePage.keywords"),
144 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
145 { PreferencesMessages.getString("PHPEditorPreferencePage.functionNames"),
146 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
148 { PreferencesMessages.getString("PHPEditorPreferencePage.variables"),
149 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
151 { PreferencesMessages.getString("PHPEditorPreferencePage.constants"),
152 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
154 { PreferencesMessages.getString("PHPEditorPreferencePage.types"),
155 PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
157 { PreferencesMessages.getString("PHPEditorPreferencePage.strings"),
158 PreferenceConstants.EDITOR_STRING_COLOR },
160 { PreferencesMessages.getString("PHPEditorPreferencePage.others"),
161 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
162 { PreferencesMessages.getString("JavaEditorPreferencePage.operators"),
163 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
167 .getString("JavaEditorPreferencePage.returnKeyword"),
168 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
172 .getString("PHPEditorPreferencePage.phpDocKeywords"),
173 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
177 .getString("PHPEditorPreferencePage.phpDocHtmlTags"),
178 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
180 { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocLinks"),
181 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
183 { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocOthers"),
184 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
187 private final String[][] fAppearanceColorListModel = new String[][] {
190 .getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
191 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR },
195 .getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
196 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
200 .getString("JavaEditorPreferencePage.currentLineHighlighColor"),
201 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
205 .getString("JavaEditorPreferencePage.printMarginColor2"),
206 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
210 .getString("JavaEditorPreferencePage.findScopeColor2"),
211 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
213 { PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"),
214 PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
217 // private final String[][] fAnnotationColorListModel;
219 // private final String[][] fAnnotationDecorationListModel = new String[][]{
221 // PreferencesMessages
222 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
223 // AnnotationPreference.STYLE_NONE},
226 // PreferencesMessages
227 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
228 // AnnotationPreference.STYLE_SQUIGGLIES},
231 // PreferencesMessages
232 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
233 // AnnotationPreference.STYLE_UNDERLINE},
236 // PreferencesMessages
237 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
238 // AnnotationPreference.STYLE_BOX},
241 // PreferencesMessages
242 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
243 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
245 private OverlayPreferenceStore fOverlayStore;
247 private JavaTextTools fJavaTextTools;
249 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
251 private FoldingConfigurationBlock fFoldingConfigurationBlock;
253 private Map fColorButtons = new HashMap();
255 private Map fCheckBoxes = new HashMap();
257 private SelectionListener fCheckBoxListener = new SelectionListener() {
258 public void widgetDefaultSelected(SelectionEvent e) {
261 public void widgetSelected(SelectionEvent e) {
262 Button button = (Button) e.widget;
263 fOverlayStore.setValue((String) fCheckBoxes.get(button), button
268 private Map fTextFields = new HashMap();
270 private ModifyListener fTextFieldListener = new ModifyListener() {
271 public void modifyText(ModifyEvent e) {
272 Text text = (Text) e.widget;
273 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
277 private ArrayList fNumberFields = new ArrayList();
279 private ModifyListener fNumberFieldListener = new ModifyListener() {
280 public void modifyText(ModifyEvent e) {
281 numberFieldChanged((Text) e.widget);
285 private List fSyntaxColorList;
287 private List fAppearanceColorList;
289 // private List fContentAssistColorList;
290 private List fAnnotationList;
292 private ColorEditor fSyntaxForegroundColorEditor;
294 private ColorEditor fAppearanceColorEditor;
296 private ColorEditor fAnnotationForegroundColorEditor;
298 private ColorEditor fContentAssistColorEditor;
300 private ColorEditor fBackgroundColorEditor;
302 private Button fBackgroundDefaultRadioButton;
304 private Button fBackgroundCustomRadioButton;
306 private Button fBackgroundColorButton;
308 private Button fBoldCheckBox;
310 // private Button fAddJavaDocTagsButton;
312 // private Button fEscapeStringsButton;
314 // private Button fGuessMethodArgumentsButton;
315 private SourceViewer fPreviewViewer;
317 private Color fBackgroundColor;
319 private Control fAutoInsertDelayText;
321 private Control fAutoInsertJavaTriggerText;
323 private Control fAutoInsertJavaDocTriggerText;
325 private Label fAutoInsertDelayLabel;
327 private Label fAutoInsertJavaTriggerLabel;
329 private Label fAutoInsertJavaDocTriggerLabel;
331 private Button fShowInTextCheckBox;
333 private Combo fDecorationStyleCombo;
335 private Button fHighlightInTextCheckBox;
337 private Button fShowInOverviewRulerCheckBox;
339 private Button fShowInVerticalRulerCheckBox;
341 // private Text fBrowserLikeLinksKeyModifierText;
342 // private Button fBrowserLikeLinksCheckBox;
343 // private StatusInfo fBrowserLikeLinksKeyModifierStatus;
344 // private Button fCompletionInsertsRadioButton;
345 // private Button fCompletionOverwritesRadioButton;
346 // private Button fStickyOccurrencesButton;
348 * Creates a new preference page.
350 public JavaEditorPreferencePage() {
351 setDescription(PreferencesMessages
352 .getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
353 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
354 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
355 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
356 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
357 // fAnnotationColorListModel =
358 // createAnnotationTypeListModel(markerAnnotationPreferences);
361 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(
362 MarkerAnnotationPreferences preferences) {
363 ArrayList overlayKeys = new ArrayList();
364 Iterator e = preferences.getAnnotationPreferences().iterator();
365 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
366 OverlayPreferenceStore.STRING,
367 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
368 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
369 OverlayPreferenceStore.BOOLEAN,
370 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
371 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
372 OverlayPreferenceStore.STRING,
373 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
374 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
375 OverlayPreferenceStore.BOOLEAN,
376 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
377 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
378 OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
379 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
380 OverlayPreferenceStore.STRING,
381 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
382 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
383 OverlayPreferenceStore.BOOLEAN,
384 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
385 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
386 OverlayPreferenceStore.STRING,
387 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
388 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
389 OverlayPreferenceStore.BOOLEAN,
390 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
391 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
392 OverlayPreferenceStore.STRING,
393 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
394 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
395 OverlayPreferenceStore.BOOLEAN,
396 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
399 .add(new OverlayPreferenceStore.OverlayKey(
400 OverlayPreferenceStore.STRING,
401 PreferenceConstants.EDITOR_PHP_TAG_COLOR));
403 .add(new OverlayPreferenceStore.OverlayKey(
404 OverlayPreferenceStore.BOOLEAN,
405 PreferenceConstants.EDITOR_PHP_TAG_BOLD));
406 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
407 OverlayPreferenceStore.STRING,
408 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
409 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
410 OverlayPreferenceStore.BOOLEAN,
411 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
412 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
413 OverlayPreferenceStore.STRING,
414 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
415 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
416 OverlayPreferenceStore.BOOLEAN,
417 PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
418 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
419 OverlayPreferenceStore.STRING,
420 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
421 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
422 OverlayPreferenceStore.BOOLEAN,
423 PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
424 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
425 OverlayPreferenceStore.STRING,
426 PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
427 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
428 OverlayPreferenceStore.BOOLEAN,
429 PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
432 .add(new OverlayPreferenceStore.OverlayKey(
433 OverlayPreferenceStore.STRING,
434 PreferenceConstants.EDITOR_STRING_COLOR));
436 .add(new OverlayPreferenceStore.OverlayKey(
437 OverlayPreferenceStore.BOOLEAN,
438 PreferenceConstants.EDITOR_STRING_BOLD));
439 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
440 OverlayPreferenceStore.STRING,
441 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
442 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
443 OverlayPreferenceStore.BOOLEAN,
444 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
445 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
446 OverlayPreferenceStore.STRING,
447 PreferenceConstants.EDITOR_TASK_TAG_COLOR));
448 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
449 OverlayPreferenceStore.BOOLEAN,
450 PreferenceConstants.EDITOR_TASK_TAG_BOLD));
451 // overlayKeys.add(new
452 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
453 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
454 // overlayKeys.add(new
455 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
456 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
457 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
458 OverlayPreferenceStore.STRING,
459 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
460 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
461 OverlayPreferenceStore.BOOLEAN,
462 PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
463 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
464 OverlayPreferenceStore.STRING,
465 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
466 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
467 OverlayPreferenceStore.BOOLEAN,
468 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
469 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
470 OverlayPreferenceStore.STRING,
471 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
472 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
473 OverlayPreferenceStore.BOOLEAN,
474 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
475 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
476 OverlayPreferenceStore.STRING,
477 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
478 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
479 OverlayPreferenceStore.BOOLEAN,
480 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
481 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
482 OverlayPreferenceStore.STRING,
483 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
484 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
485 OverlayPreferenceStore.BOOLEAN,
486 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
487 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
488 OverlayPreferenceStore.STRING,
489 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
490 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
491 OverlayPreferenceStore.BOOLEAN,
492 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
493 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
494 OverlayPreferenceStore.STRING,
495 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
496 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
497 OverlayPreferenceStore.BOOLEAN,
498 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
500 .add(new OverlayPreferenceStore.OverlayKey(
501 OverlayPreferenceStore.STRING,
502 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
503 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
504 OverlayPreferenceStore.BOOLEAN,
505 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
507 .add(new OverlayPreferenceStore.OverlayKey(
508 OverlayPreferenceStore.STRING,
509 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
511 .add(new OverlayPreferenceStore.OverlayKey(
512 OverlayPreferenceStore.INT,
513 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
514 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
515 OverlayPreferenceStore.BOOLEAN,
516 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
517 // overlayKeys.add(new
518 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
519 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
520 // overlayKeys.add(new
521 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
522 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
523 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
524 OverlayPreferenceStore.STRING,
525 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
526 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
527 OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
528 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
529 OverlayPreferenceStore.BOOLEAN,
530 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
531 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
532 OverlayPreferenceStore.BOOLEAN,
533 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
534 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
535 OverlayPreferenceStore.BOOLEAN,
536 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
538 .add(new OverlayPreferenceStore.OverlayKey(
539 OverlayPreferenceStore.STRING,
540 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
542 .add(new OverlayPreferenceStore.OverlayKey(
543 OverlayPreferenceStore.BOOLEAN,
544 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
545 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
546 OverlayPreferenceStore.BOOLEAN,
547 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
548 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
549 OverlayPreferenceStore.BOOLEAN,
550 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
551 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
552 OverlayPreferenceStore.INT,
553 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
554 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
555 OverlayPreferenceStore.BOOLEAN,
556 PreferenceConstants.CODEASSIST_AUTOINSERT));
557 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
558 OverlayPreferenceStore.STRING,
559 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
560 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
561 OverlayPreferenceStore.STRING,
562 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
563 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
564 OverlayPreferenceStore.STRING,
565 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
566 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
567 OverlayPreferenceStore.STRING,
568 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
569 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
570 OverlayPreferenceStore.STRING,
571 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
572 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
573 OverlayPreferenceStore.STRING,
574 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
575 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
576 OverlayPreferenceStore.STRING,
577 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
578 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
579 OverlayPreferenceStore.STRING,
580 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
581 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
582 OverlayPreferenceStore.BOOLEAN,
583 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
584 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
585 OverlayPreferenceStore.BOOLEAN,
586 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
587 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
588 OverlayPreferenceStore.BOOLEAN,
589 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
590 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
591 OverlayPreferenceStore.BOOLEAN,
592 PreferenceConstants.CODEASSIST_ADDIMPORT));
593 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
594 OverlayPreferenceStore.BOOLEAN,
595 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
596 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
597 OverlayPreferenceStore.BOOLEAN,
598 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
599 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
600 OverlayPreferenceStore.BOOLEAN,
601 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
603 .add(new OverlayPreferenceStore.OverlayKey(
604 OverlayPreferenceStore.BOOLEAN,
605 PreferenceConstants.EDITOR_SMART_PASTE));
606 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
607 OverlayPreferenceStore.BOOLEAN,
608 PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP));
609 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
610 OverlayPreferenceStore.BOOLEAN,
611 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
613 .add(new OverlayPreferenceStore.OverlayKey(
614 OverlayPreferenceStore.BOOLEAN,
615 PreferenceConstants.EDITOR_CLOSE_BRACES));
616 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
617 OverlayPreferenceStore.BOOLEAN,
618 PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
620 .add(new OverlayPreferenceStore.OverlayKey(
621 OverlayPreferenceStore.BOOLEAN,
622 PreferenceConstants.EDITOR_WRAP_STRINGS));
623 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
624 OverlayPreferenceStore.BOOLEAN,
625 PreferenceConstants.EDITOR_ESCAPE_STRINGS));
626 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
627 OverlayPreferenceStore.BOOLEAN,
628 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
629 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
630 OverlayPreferenceStore.BOOLEAN,
631 PreferenceConstants.EDITOR_SMART_HOME_END));
632 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
633 OverlayPreferenceStore.BOOLEAN,
634 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
635 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
636 OverlayPreferenceStore.BOOLEAN,
637 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
638 // overlayKeys.add(new
639 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
640 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
641 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
642 OverlayPreferenceStore.STRING,
643 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
644 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
645 OverlayPreferenceStore.STRING,
646 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
647 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
648 OverlayPreferenceStore.BOOLEAN,
649 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
650 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
651 OverlayPreferenceStore.STRING,
652 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
653 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
654 OverlayPreferenceStore.STRING,
655 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
656 while (e.hasNext()) {
657 AnnotationPreference info = (AnnotationPreference) e.next();
658 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
659 OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
660 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
661 OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
662 if (info.getHighlightPreferenceKey() != null)
663 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
664 OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
666 .add(new OverlayPreferenceStore.OverlayKey(
667 OverlayPreferenceStore.BOOLEAN, info
668 .getOverviewRulerPreferenceKey()));
669 if (info.getVerticalRulerPreferenceKey() != null)
670 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
671 OverlayPreferenceStore.BOOLEAN, info
672 .getVerticalRulerPreferenceKey()));
673 if (info.getTextStylePreferenceKey() != null)
674 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
675 OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
677 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
679 overlayKeys.toArray(keys);
682 * @see IWorkbenchPreferencePage#init()
685 public void init(IWorkbench workbench) {
689 * @see PreferencePage#createControl(Composite)
691 public void createControl(Composite parent) {
692 super.createControl(parent);
693 WorkbenchHelp.setHelp(getControl(),
694 IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
697 private void handleSyntaxColorListSelection() {
698 int i = fSyntaxColorList.getSelectionIndex();
699 String key = fSyntaxColorListModel[i][1];
700 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
701 fSyntaxForegroundColorEditor.setColorValue(rgb);
702 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
705 private void handleAppearanceColorListSelection() {
706 int i = fAppearanceColorList.getSelectionIndex();
707 String key = fAppearanceColorListModel[i][1];
708 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
709 fAppearanceColorEditor.setColorValue(rgb);
712 // private void handleAnnotationListSelection() {
713 // int i = fAnnotationList.getSelectionIndex();
714 // String key = fAnnotationColorListModel[i][1];
715 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
716 // fAnnotationForegroundColorEditor.setColorValue(rgb);
717 // key = fAnnotationColorListModel[i][2];
718 // boolean showInText = fOverlayStore.getBoolean(key);
719 // fShowInTextCheckBox.setSelection(showInText);
720 // key = fAnnotationColorListModel[i][6];
721 // if (key != null) {
722 // fDecorationStyleCombo.setEnabled(showInText);
723 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
724 // String value = fOverlayStore.getString(key);
725 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
726 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
731 // fDecorationStyleCombo.setEnabled(false);
732 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
745 // key = fAnnotationColorListModel[i][3];
746 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
747 // key = fAnnotationColorListModel[i][4];
748 // if (key != null) {
749 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
750 // fHighlightInTextCheckBox.setEnabled(true);
752 // fHighlightInTextCheckBox.setEnabled(false);
753 // key = fAnnotationColorListModel[i][5];
754 // if (key != null) {
755 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
756 // fShowInVerticalRulerCheckBox.setEnabled(true);
758 // fShowInVerticalRulerCheckBox.setSelection(true);
759 // fShowInVerticalRulerCheckBox.setEnabled(false);
762 private Control createSyntaxPage(Composite parent) {
763 Composite colorComposite = new Composite(parent, SWT.NULL);
764 colorComposite.setLayout(new GridLayout());
765 Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
766 backgroundComposite.setLayout(new RowLayout());
767 backgroundComposite.setText(PreferencesMessages
768 .getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
769 SelectionListener backgroundSelectionListener = new SelectionListener() {
770 public void widgetSelected(SelectionEvent e) {
771 boolean custom = fBackgroundCustomRadioButton.getSelection();
772 fBackgroundColorButton.setEnabled(custom);
773 fOverlayStore.setValue(
774 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
777 public void widgetDefaultSelected(SelectionEvent e) {
780 fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO
782 fBackgroundDefaultRadioButton.setText(PreferencesMessages
783 .getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
784 fBackgroundDefaultRadioButton
785 .addSelectionListener(backgroundSelectionListener);
786 fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO
788 fBackgroundCustomRadioButton.setText(PreferencesMessages
789 .getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
790 fBackgroundCustomRadioButton
791 .addSelectionListener(backgroundSelectionListener);
792 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
793 fBackgroundColorButton = fBackgroundColorEditor.getButton();
794 Label label = new Label(colorComposite, SWT.LEFT);
795 label.setText(PreferencesMessages
796 .getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
797 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
798 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
799 GridLayout layout = new GridLayout();
800 layout.numColumns = 2;
801 layout.marginHeight = 0;
802 layout.marginWidth = 0;
803 editorComposite.setLayout(layout);
804 GridData gd = new GridData(GridData.FILL_BOTH);
805 editorComposite.setLayoutData(gd);
806 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
808 gd = new GridData(GridData.FILL_BOTH);
809 gd.heightHint = convertHeightInCharsToPixels(5);
810 fSyntaxColorList.setLayoutData(gd);
811 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
812 layout = new GridLayout();
813 layout.marginHeight = 0;
814 layout.marginWidth = 0;
815 layout.numColumns = 2;
816 stylesComposite.setLayout(layout);
817 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
818 label = new Label(stylesComposite, SWT.LEFT);
819 label.setText(PreferencesMessages
820 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
822 gd.horizontalAlignment = GridData.BEGINNING;
823 label.setLayoutData(gd);
824 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
825 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
826 gd = new GridData(GridData.FILL_HORIZONTAL);
827 gd.horizontalAlignment = GridData.BEGINNING;
828 foregroundColorButton.setLayoutData(gd);
829 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
830 fBoldCheckBox.setText(PreferencesMessages
831 .getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
832 gd = new GridData(GridData.FILL_HORIZONTAL);
833 gd.horizontalAlignment = GridData.BEGINNING;
834 gd.horizontalSpan = 2;
835 fBoldCheckBox.setLayoutData(gd);
836 label = new Label(colorComposite, SWT.LEFT);
837 label.setText(PreferencesMessages
838 .getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
839 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
840 Control previewer = createPreviewer(colorComposite);
841 gd = new GridData(GridData.FILL_BOTH);
842 gd.widthHint = convertWidthInCharsToPixels(20);
843 gd.heightHint = convertHeightInCharsToPixels(5);
844 previewer.setLayoutData(gd);
845 fSyntaxColorList.addSelectionListener(new SelectionListener() {
846 public void widgetDefaultSelected(SelectionEvent e) {
850 public void widgetSelected(SelectionEvent e) {
851 handleSyntaxColorListSelection();
854 foregroundColorButton.addSelectionListener(new SelectionListener() {
855 public void widgetDefaultSelected(SelectionEvent e) {
859 public void widgetSelected(SelectionEvent e) {
860 int i = fSyntaxColorList.getSelectionIndex();
861 String key = fSyntaxColorListModel[i][1];
862 PreferenceConverter.setValue(fOverlayStore, key,
863 fSyntaxForegroundColorEditor.getColorValue());
866 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
867 public void widgetDefaultSelected(SelectionEvent e) {
871 public void widgetSelected(SelectionEvent e) {
872 PreferenceConverter.setValue(fOverlayStore,
873 PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
877 fBoldCheckBox.addSelectionListener(new SelectionListener() {
878 public void widgetDefaultSelected(SelectionEvent e) {
882 public void widgetSelected(SelectionEvent e) {
883 int i = fSyntaxColorList.getSelectionIndex();
884 String key = fSyntaxColorListModel[i][1];
885 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
888 return colorComposite;
891 private Control createPreviewer(Composite parent) {
892 Preferences coreStore = createTemporaryCorePreferenceStore();
893 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
894 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
895 IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] {
897 new PreferencesAdapter(createTemporaryCorePreferenceStore()),
900 fPreviewViewer = new JavaSourceViewer(parent, null, null, false,
901 SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
903 fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools,
905 // Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
906 // fPreviewViewer.getTextWidget().setFont(font);
907 fPreviewViewer.getTextWidget().setFont(
908 JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
909 // new JavaSourcePreviewerUpdater(fPreviewViewer, fJavaTextTools);
910 fPreviewViewer.setEditable(false);
911 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
912 IDocument document = new Document(content);
913 fJavaTextTools.setupJavaDocumentPartitioner(document, ".php", null); //IJavaPartitions.JAVA_PARTITIONING);
914 fPreviewViewer.setDocument(document);
915 return fPreviewViewer.getControl();
918 private Preferences createTemporaryCorePreferenceStore() {
919 Preferences result = new Preferences();
920 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
924 private Control createAppearancePage(Composite parent) {
925 Composite appearanceComposite = new Composite(parent, SWT.NONE);
926 GridLayout layout = new GridLayout();
927 layout.numColumns = 2;
928 appearanceComposite.setLayout(layout);
929 String label = PreferencesMessages
930 .getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
931 addTextField(appearanceComposite, label,
932 PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
933 label = PreferencesMessages
934 .getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
938 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN,
940 label = PreferencesMessages
941 .getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
942 addCheckBox(appearanceComposite, label,
943 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
944 label = PreferencesMessages
945 .getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
949 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER,
951 label = PreferencesMessages
952 .getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
953 addCheckBox(appearanceComposite, label,
954 PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
955 label = PreferencesMessages
956 .getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
957 addCheckBox(appearanceComposite, label,
958 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
959 label = PreferencesMessages
960 .getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
961 addCheckBox(appearanceComposite, label,
962 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
963 label = PreferencesMessages
964 .getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
965 // Button master= addCheckBox(appearanceComposite, label,
966 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
967 label = PreferencesMessages
968 .getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
969 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
970 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
971 // createDependency(master, fStickyOccurrencesButton);
972 Label l = new Label(appearanceComposite, SWT.LEFT);
973 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
974 gd.horizontalSpan = 2;
975 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
977 l = new Label(appearanceComposite, SWT.LEFT);
978 l.setText(PreferencesMessages
979 .getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
980 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
981 gd.horizontalSpan = 2;
983 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
984 layout = new GridLayout();
985 layout.numColumns = 2;
986 layout.marginHeight = 0;
987 layout.marginWidth = 0;
988 editorComposite.setLayout(layout);
989 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
990 gd.horizontalSpan = 2;
991 editorComposite.setLayoutData(gd);
992 fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
994 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
995 | GridData.FILL_HORIZONTAL);
996 gd.heightHint = convertHeightInCharsToPixels(8);
997 fAppearanceColorList.setLayoutData(gd);
998 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
999 layout = new GridLayout();
1000 layout.marginHeight = 0;
1001 layout.marginWidth = 0;
1002 layout.numColumns = 2;
1003 stylesComposite.setLayout(layout);
1004 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1005 l = new Label(stylesComposite, SWT.LEFT);
1006 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
1007 gd = new GridData();
1008 gd.horizontalAlignment = GridData.BEGINNING;
1009 l.setLayoutData(gd);
1010 fAppearanceColorEditor = new ColorEditor(stylesComposite);
1011 Button foregroundColorButton = fAppearanceColorEditor.getButton();
1012 gd = new GridData(GridData.FILL_HORIZONTAL);
1013 gd.horizontalAlignment = GridData.BEGINNING;
1014 foregroundColorButton.setLayoutData(gd);
1015 fAppearanceColorList.addSelectionListener(new SelectionListener() {
1016 public void widgetDefaultSelected(SelectionEvent e) {
1020 public void widgetSelected(SelectionEvent e) {
1021 handleAppearanceColorListSelection();
1024 foregroundColorButton.addSelectionListener(new SelectionListener() {
1025 public void widgetDefaultSelected(SelectionEvent e) {
1029 public void widgetSelected(SelectionEvent e) {
1030 int i = fAppearanceColorList.getSelectionIndex();
1031 String key = fAppearanceColorListModel[i][1];
1032 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor
1036 return appearanceComposite;
1039 // private Control createAnnotationsPage(Composite parent) {
1040 // Composite composite = new Composite(parent, SWT.NULL);
1041 // GridLayout layout = new GridLayout();
1042 // layout.numColumns = 2;
1043 // composite.setLayout(layout);
1044 // String text = PreferencesMessages
1045 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
1047 // addCheckBox(composite, text,
1048 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
1049 // text = PreferencesMessages
1050 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
1051 // addCheckBox(composite, text,
1052 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
1053 // addFiller(composite);
1054 // Label label = new Label(composite, SWT.LEFT);
1055 // label.setText(PreferencesMessages
1056 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
1058 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1059 // gd.horizontalSpan = 2;
1060 // label.setLayoutData(gd);
1061 // Composite editorComposite = new Composite(composite, SWT.NONE);
1062 // layout = new GridLayout();
1063 // layout.numColumns = 2;
1064 // layout.marginHeight = 0;
1065 // layout.marginWidth = 0;
1066 // editorComposite.setLayout(layout);
1067 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
1068 // gd.horizontalSpan = 2;
1069 // editorComposite.setLayoutData(gd);
1070 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
1072 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1073 // | GridData.FILL_HORIZONTAL);
1074 // gd.heightHint = convertHeightInCharsToPixels(10);
1075 // fAnnotationList.setLayoutData(gd);
1076 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
1077 // layout = new GridLayout();
1078 // layout.marginHeight = 0;
1079 // layout.marginWidth = 0;
1080 // layout.numColumns = 2;
1081 // optionsComposite.setLayout(layout);
1082 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1083 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1084 // fShowInTextCheckBox.setText(PreferencesMessages
1085 // .getString("JavaEditorPreferencePage.annotations.showInText"));
1087 // gd = new GridData(GridData.FILL_HORIZONTAL);
1088 // gd.horizontalAlignment = GridData.BEGINNING;
1089 // gd.horizontalSpan = 2;
1090 // fShowInTextCheckBox.setLayoutData(gd);
1091 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
1092 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
1093 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
1094 // gd = new GridData(GridData.FILL_HORIZONTAL);
1095 // gd.horizontalAlignment = GridData.BEGINNING;
1096 // gd.horizontalSpan = 2;
1097 // gd.horizontalIndent = 20;
1098 // fDecorationStyleCombo.setLayoutData(gd);
1099 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1100 // fHighlightInTextCheckBox.setText(PreferencesMessages
1101 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
1103 // gd = new GridData(GridData.FILL_HORIZONTAL);
1104 // gd.horizontalAlignment = GridData.BEGINNING;
1105 // gd.horizontalSpan = 2;
1106 // fHighlightInTextCheckBox.setLayoutData(gd);
1107 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1108 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
1109 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
1111 // gd = new GridData(GridData.FILL_HORIZONTAL);
1112 // gd.horizontalAlignment = GridData.BEGINNING;
1113 // gd.horizontalSpan = 2;
1114 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
1115 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1116 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
1117 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
1119 // gd = new GridData(GridData.FILL_HORIZONTAL);
1120 // gd.horizontalAlignment = GridData.BEGINNING;
1121 // gd.horizontalSpan = 2;
1122 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
1123 // label = new Label(optionsComposite, SWT.LEFT);
1124 // label.setText(PreferencesMessages
1125 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
1126 // gd = new GridData();
1127 // gd.horizontalAlignment = GridData.BEGINNING;
1128 // label.setLayoutData(gd);
1129 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
1130 // Button foregroundColorButton =
1131 // fAnnotationForegroundColorEditor.getButton();
1132 // gd = new GridData(GridData.FILL_HORIZONTAL);
1133 // gd.horizontalAlignment = GridData.BEGINNING;
1134 // foregroundColorButton.setLayoutData(gd);
1135 // fAnnotationList.addSelectionListener(new SelectionListener() {
1136 // public void widgetDefaultSelected(SelectionEvent e) {
1139 // public void widgetSelected(SelectionEvent e) {
1140 // handleAnnotationListSelection();
1143 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
1144 // public void widgetDefaultSelected(SelectionEvent e) {
1147 // public void widgetSelected(SelectionEvent e) {
1148 // int i = fAnnotationList.getSelectionIndex();
1149 // String key = fAnnotationColorListModel[i][2];
1150 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
1151 // String decorationKey = fAnnotationColorListModel[i][6];
1152 // fDecorationStyleCombo.setEnabled(decorationKey != null
1153 // && fShowInTextCheckBox.getSelection());
1156 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
1157 // public void widgetDefaultSelected(SelectionEvent e) {
1160 // public void widgetSelected(SelectionEvent e) {
1161 // int i = fAnnotationList.getSelectionIndex();
1162 // String key = fAnnotationColorListModel[i][4];
1163 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
1166 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
1167 // public void widgetDefaultSelected(SelectionEvent e) {
1170 // public void widgetSelected(SelectionEvent e) {
1171 // int i = fAnnotationList.getSelectionIndex();
1172 // String key = fAnnotationColorListModel[i][3];
1174 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
1177 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
1178 // public void widgetDefaultSelected(SelectionEvent e) {
1181 // public void widgetSelected(SelectionEvent e) {
1182 // int i = fAnnotationList.getSelectionIndex();
1183 // String key = fAnnotationColorListModel[i][5];
1185 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
1188 // foregroundColorButton.addSelectionListener(new SelectionListener() {
1189 // public void widgetDefaultSelected(SelectionEvent e) {
1192 // public void widgetSelected(SelectionEvent e) {
1193 // int i = fAnnotationList.getSelectionIndex();
1194 // String key = fAnnotationColorListModel[i][1];
1195 // PreferenceConverter.setValue(fOverlayStore, key,
1196 // fAnnotationForegroundColorEditor.getColorValue());
1199 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
1203 // public void widgetDefaultSelected(SelectionEvent e) {
1209 // public void widgetSelected(SelectionEvent e) {
1210 // int i = fAnnotationList.getSelectionIndex();
1211 // String key = fAnnotationColorListModel[i][6];
1212 // if (key != null) {
1213 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1214 // if (fAnnotationDecorationListModel[j][0]
1215 // .equals(fDecorationStyleCombo.getText())) {
1216 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1223 // return composite;
1225 private String[][] createAnnotationTypeListModel(
1226 MarkerAnnotationPreferences preferences) {
1227 ArrayList listModelItems = new ArrayList();
1228 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1230 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1232 public int compare(Object o1, Object o2) {
1233 if (!(o2 instanceof AnnotationPreference))
1235 if (!(o1 instanceof AnnotationPreference))
1237 AnnotationPreference a1 = (AnnotationPreference) o1;
1238 AnnotationPreference a2 = (AnnotationPreference) o2;
1239 return Collator.getInstance().compare(a1.getPreferenceLabel(),
1240 a2.getPreferenceLabel());
1243 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1244 Iterator e = sortedPreferences.iterator();
1245 while (e.hasNext()) {
1246 AnnotationPreference info = (AnnotationPreference) e.next();
1247 listModelItems.add(new String[] { info.getPreferenceLabel(),
1248 info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1249 info.getOverviewRulerPreferenceKey(),
1250 info.getHighlightPreferenceKey(),
1251 info.getVerticalRulerPreferenceKey(),
1252 info.getTextStylePreferenceKey() });
1254 String[][] items = new String[listModelItems.size()][];
1255 listModelItems.toArray(items);
1259 private Control createTypingPage(Composite parent) {
1260 Composite composite = new Composite(parent, SWT.NONE);
1261 GridLayout layout = new GridLayout();
1262 layout.numColumns = 1;
1263 composite.setLayout(layout);
1265 // label = PreferencesMessages
1266 // .getString("JavaEditorPreferencePage.overwriteMode");
1268 // addCheckBox(composite, label,
1269 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1270 // addFiller(composite);
1272 // label = PreferencesMessages
1273 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1275 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1277 // label = PreferencesMessages
1278 // .getString("JavaEditorPreferencePage.subWordNavigation");
1280 // addCheckBox(composite, label,
1281 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1282 // addFiller(composite);
1283 Group group = new Group(composite, SWT.NONE);
1284 layout = new GridLayout();
1285 layout.numColumns = 2;
1286 group.setLayout(layout);
1287 group.setText(PreferencesMessages
1288 .getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1290 // label = PreferencesMessages
1291 // .getString("JavaEditorPreferencePage.wrapStrings");
1293 // Button button = addCheckBox(group, label,
1294 // PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
1296 // label = PreferencesMessages
1297 // .getString("JavaEditorPreferencePage.escapeStrings");
1299 // fEscapeStringsButton = addCheckBox(group, label,
1300 // PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1);
1301 // createDependency(button, fEscapeStringsButton);
1303 // label = PreferencesMessages
1304 // .getString("JavaEditorPreferencePage.smartPaste");
1306 // addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1308 label = PreferencesMessages
1309 .getString("JavaEditorPreferencePage.insertSpaceForTabs");
1311 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1313 label = PreferencesMessages
1314 .getString("JavaEditorPreferencePage.closeStrings");
1316 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP, 1);
1318 label = PreferencesMessages
1319 .getString("JavaEditorPreferencePage.closeBrackets");
1321 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1323 // label = PreferencesMessages
1324 // .getString("JavaEditorPreferencePage.closeBraces");
1326 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1328 // label = PreferencesMessages
1329 // .getString("JavaEditorPreferencePage.closeJavaDocs");
1331 // button = addCheckBox(group, label,
1332 // PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1334 // label = PreferencesMessages
1335 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1337 // fAddJavaDocTagsButton = addCheckBox(group, label,
1338 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1339 // createDependency(button, fAddJavaDocTagsButton);
1343 private void addFiller(Composite composite) {
1344 Label filler = new Label(composite, SWT.LEFT);
1345 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1346 gd.horizontalSpan = 2;
1347 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1348 filler.setLayoutData(gd);
1351 private static void indent(Control control) {
1352 GridData gridData = new GridData();
1353 gridData.horizontalIndent = 20;
1354 control.setLayoutData(gridData);
1357 private static void createDependency(final Button master, final Control slave) {
1359 master.addSelectionListener(new SelectionListener() {
1360 public void widgetSelected(SelectionEvent e) {
1361 slave.setEnabled(master.getSelection());
1364 public void widgetDefaultSelected(SelectionEvent e) {
1369 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1370 Composite completionComposite = new Composite(contentAssistComposite,
1372 GridData ccgd = new GridData();
1373 ccgd.horizontalSpan = 2;
1374 completionComposite.setLayoutData(ccgd);
1375 GridLayout ccgl = new GridLayout();
1376 ccgl.marginWidth = 0;
1377 ccgl.numColumns = 2;
1378 completionComposite.setLayout(ccgl);
1379 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1380 // public void widgetSelected(SelectionEvent e) {
1381 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1382 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1387 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1389 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1391 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1392 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1394 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1395 // SWT.RADIO | SWT.LEFT);
1396 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1398 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1399 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1402 private Control createNavigationPage(Composite parent) {
1403 Composite composite = new Composite(parent, SWT.NULL);
1404 GridLayout layout = new GridLayout();
1405 layout.numColumns = 2;
1406 composite.setLayout(layout);
1408 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1410 // fBrowserLikeLinksCheckBox= addCheckBox(composite, text,
1411 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1412 // fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1413 // public void widgetSelected(SelectionEvent e) {
1414 // boolean state= fBrowserLikeLinksCheckBox.getSelection();
1415 // fBrowserLikeLinksKeyModifierText.setEnabled(state);
1416 // handleBrowserLikeLinksKeyModifierModified();
1418 // public void widgetDefaultSelected(SelectionEvent e) {
1421 // Text field for modifier string
1423 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1425 // fBrowserLikeLinksKeyModifierText= addTextField(composite, text,
1426 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0,
1428 // fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1431 // (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER))
1433 // // Fix possible illegal modifier string
1435 // fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1436 // if (stateMask == -1)
1437 // fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1439 // fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1441 // fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1442 // private boolean isModifierCandidate;
1443 // public void keyPressed(KeyEvent e) {
1444 // isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask ==
1448 // public void keyReleased(KeyEvent e) {
1449 // if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask
1450 // && e.character == 0) {// && e.time -time < 1000) {
1451 // String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1452 // Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1453 // int i= selection.x - 1;
1454 // while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1457 // boolean needsPrefixDelimiter= i > -1 &&
1458 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1461 // while (i < modifierString.length() &&
1462 // Character.isWhitespace(modifierString.charAt(i))) {
1465 // boolean needsPostfixDelimiter= i < modifierString.length() &&
1466 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1468 // String insertString;
1470 // if (needsPrefixDelimiter && needsPostfixDelimiter)
1472 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1473 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1474 // else if (needsPrefixDelimiter)
1476 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1477 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1478 // else if (needsPostfixDelimiter)
1480 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1481 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1483 // insertString= Action.findModifierString(e.stateMask);
1485 // fBrowserLikeLinksKeyModifierText.insert(insertString);
1490 // fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener()
1492 // public void modifyText(ModifyEvent e) {
1493 // handleBrowserLikeLinksKeyModifierModified();
1499 private void handleBrowserLikeLinksKeyModifierModified() {
1500 // String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1501 // int stateMask= computeStateMask(modifiers);
1502 // if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 ||
1503 // (stateMask & SWT.SHIFT) != 0)) {
1504 // if (stateMask == -1)
1505 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1506 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid",
1507 // modifiers)); //$NON-NLS-1$
1509 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1510 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1513 // StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1515 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1516 // updateStatus(fBrowserLikeLinksKeyModifierStatus);
1520 // private IStatus getBrowserLikeLinksKeyModifierStatus() {
1521 // if (fBrowserLikeLinksKeyModifierStatus == null)
1522 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1523 // return fBrowserLikeLinksKeyModifierStatus;
1526 * Computes the state mask for the given modifier string.
1529 * the string with the modifiers, separated by '+', '-', ';', ',' or
1531 * @return the state mask or -1 if the input is invalid
1533 private int computeStateMask(String modifiers) {
1534 if (modifiers == null)
1536 if (modifiers.length() == 0)
1539 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers,
1540 ",;.:+-* "); //$NON-NLS-1$
1541 while (modifierTokenizer.hasMoreTokens()) {
1542 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer
1544 if (modifier == 0 || (stateMask & modifier) == modifier)
1546 stateMask = stateMask | modifier;
1552 * @see PreferencePage#createContents(Composite)
1554 protected Control createContents(Composite parent) {
1555 initializeDefaultColors();
1556 fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore);
1557 fOverlayStore.load();
1558 fOverlayStore.start();
1559 TabFolder folder = new TabFolder(parent, SWT.NONE);
1560 folder.setLayout(new TabFolderLayout());
1561 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1562 TabItem item = new TabItem(folder, SWT.NONE);
1563 item.setText(PreferencesMessages
1564 .getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1565 item.setControl(createAppearancePage(folder));
1566 item = new TabItem(folder, SWT.NONE);
1567 item.setText(PreferencesMessages
1568 .getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1569 item.setControl(createSyntaxPage(folder));
1571 // item = new TabItem(folder, SWT.NONE);
1572 // item.setText(PreferencesMessages
1573 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1575 // item.setControl(createAnnotationsPage(folder));
1576 item = new TabItem(folder, SWT.NONE);
1577 item.setText(PreferencesMessages
1578 .getString("JavaEditorPreferencePage.typing.tabTitle"));
1580 item.setControl(createTypingPage(folder));
1582 item = new TabItem(folder, SWT.NONE);
1583 item.setText(PreferencesMessages
1584 .getString("JavaEditorPreferencePage.hoverTab.title"));
1586 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(
1587 this, fOverlayStore);
1588 item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1589 // item= new TabItem(folder, SWT.NONE);
1590 // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1592 // item.setControl(createNavigationPage(folder));
1593 item = new TabItem(folder, SWT.NONE);
1594 item.setText(PreferencesMessages
1595 .getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1596 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1599 Dialog.applyDialogFont(folder);
1603 private void initialize() {
1605 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1606 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1607 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1609 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1610 fSyntaxColorList.select(0);
1611 handleSyntaxColorListSelection();
1615 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1616 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1617 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1619 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1620 fAppearanceColorList.select(0);
1621 handleAppearanceColorListSelection();
1625 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1626 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1627 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1628 // public void run() {
1629 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1630 // fAnnotationList.select(0);
1631 // handleAnnotationListSelection();
1635 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1636 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1637 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1638 // public void run() {
1639 // if (fContentAssistColorList != null &&
1640 // !fContentAssistColorList.isDisposed()) {
1641 // fContentAssistColorList.select(0);
1642 // handleContentAssistColorListSelection();
1646 fFoldingConfigurationBlock.initialize();
1649 private void initializeFields() {
1650 Iterator e = fColorButtons.keySet().iterator();
1651 while (e.hasNext()) {
1652 ColorEditor c = (ColorEditor) e.next();
1653 String key = (String) fColorButtons.get(c);
1654 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1655 c.setColorValue(rgb);
1657 e = fCheckBoxes.keySet().iterator();
1658 while (e.hasNext()) {
1659 Button b = (Button) e.next();
1660 String key = (String) fCheckBoxes.get(b);
1661 b.setSelection(fOverlayStore.getBoolean(key));
1663 e = fTextFields.keySet().iterator();
1664 while (e.hasNext()) {
1665 Text t = (Text) e.next();
1666 String key = (String) fTextFields.get(t);
1667 t.setText(fOverlayStore.getString(key));
1669 RGB rgb = PreferenceConverter.getColor(fOverlayStore,
1670 PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1671 fBackgroundColorEditor.setColorValue(rgb);
1672 boolean default_ = fOverlayStore
1673 .getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1674 fBackgroundDefaultRadioButton.setSelection(default_);
1675 fBackgroundCustomRadioButton.setSelection(!default_);
1676 fBackgroundColorButton.setEnabled(!default_);
1677 // boolean closeJavaDocs = fOverlayStore
1678 // .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1679 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1680 // fEscapeStringsButton.setEnabled(fOverlayStore
1681 // .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS));
1682 // boolean fillMethodArguments=
1683 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1684 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1685 // boolean completionInserts=
1686 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1687 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1688 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1690 // fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1691 // boolean markOccurrences=
1692 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1693 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1694 updateAutoactivationControls();
1697 private void initializeDefaultColors() {
1698 if (!getPreferenceStore().contains(
1699 PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1700 RGB rgb = getControl().getDisplay().getSystemColor(
1701 SWT.COLOR_LIST_BACKGROUND).getRGB();
1702 PreferenceConverter.setDefault(fOverlayStore,
1703 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1704 PreferenceConverter.setDefault(getPreferenceStore(),
1705 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1707 if (!getPreferenceStore().contains(
1708 PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1709 RGB rgb = getControl().getDisplay().getSystemColor(
1710 SWT.COLOR_LIST_FOREGROUND).getRGB();
1711 PreferenceConverter.setDefault(fOverlayStore,
1712 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1713 PreferenceConverter.setDefault(getPreferenceStore(),
1714 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1718 private void updateAutoactivationControls() {
1719 // boolean autoactivation=
1720 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1721 // fAutoInsertDelayText.setEnabled(autoactivation);
1722 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1723 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1724 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1726 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1727 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1731 * @see PreferencePage#performOk()
1733 public boolean performOk() {
1734 // fJavaEditorHoverConfigurationBlock.performOk();
1735 fFoldingConfigurationBlock.performOk();
1736 // fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1737 // computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1738 fOverlayStore.propagate();
1739 PHPeclipsePlugin.getDefault().savePluginPreferences();
1744 * @see PreferencePage#performDefaults()
1746 protected void performDefaults() {
1747 fOverlayStore.loadDefaults();
1749 handleSyntaxColorListSelection();
1750 handleAppearanceColorListSelection();
1751 // handleAnnotationListSelection();
1752 // handleContentAssistColorListSelection();
1753 // fJavaEditorHoverConfigurationBlock.performDefaults();
1754 fFoldingConfigurationBlock.performDefaults();
1755 super.performDefaults();
1756 fPreviewViewer.invalidateTextPresentation();
1760 * @see DialogPage#dispose()
1762 public void dispose() {
1763 fFoldingConfigurationBlock.dispose();
1765 if (fJavaTextTools != null) {
1766 fJavaTextTools.dispose();
1767 fJavaTextTools = null;
1769 if (fOverlayStore != null) {
1770 fOverlayStore.stop();
1771 fOverlayStore = null;
1773 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1774 fBackgroundColor.dispose();
1778 private Button addCheckBox(Composite parent, String label, String key,
1780 Button checkBox = new Button(parent, SWT.CHECK);
1781 checkBox.setText(label);
1782 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1783 gd.horizontalIndent = indentation;
1784 gd.horizontalSpan = 2;
1785 checkBox.setLayoutData(gd);
1786 checkBox.addSelectionListener(fCheckBoxListener);
1787 fCheckBoxes.put(checkBox, key);
1791 private Text addTextField(Composite composite, String label, String key,
1792 int textLimit, int indentation, boolean isNumber) {
1793 return getTextControl(addLabelledTextField(composite, label, key,
1794 textLimit, indentation, isNumber));
1797 private static Label getLabelControl(Control[] labelledTextField) {
1798 return (Label) labelledTextField[0];
1801 private static Text getTextControl(Control[] labelledTextField) {
1802 return (Text) labelledTextField[1];
1806 * Returns an array of size 2: - first element is of type <code>Label</code>-
1807 * second element is of type <code>Text</code> Use
1808 * <code>getLabelControl</code> and <code>getTextControl</code> to get the
1811 private Control[] addLabelledTextField(Composite composite, String label,
1812 String key, int textLimit, int indentation, boolean isNumber) {
1813 Label labelControl = new Label(composite, SWT.NONE);
1814 labelControl.setText(label);
1815 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1816 gd.horizontalIndent = indentation;
1817 labelControl.setLayoutData(gd);
1818 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1819 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1820 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1821 textControl.setLayoutData(gd);
1822 textControl.setTextLimit(textLimit);
1823 fTextFields.put(textControl, key);
1825 fNumberFields.add(textControl);
1826 textControl.addModifyListener(fNumberFieldListener);
1828 textControl.addModifyListener(fTextFieldListener);
1830 return new Control[] { labelControl, textControl };
1833 private String loadPreviewContentFromFile(String filename) {
1835 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1836 StringBuffer buffer = new StringBuffer(512);
1837 BufferedReader reader = null;
1839 reader = new BufferedReader(new InputStreamReader(getClass()
1840 .getResourceAsStream(filename)));
1841 while ((line = reader.readLine()) != null) {
1842 buffer.append(line);
1843 buffer.append(separator);
1845 } catch (IOException io) {
1846 PHPeclipsePlugin.log(io);
1848 if (reader != null) {
1851 } catch (IOException e) {
1855 return buffer.toString();
1858 private void numberFieldChanged(Text textControl) {
1859 String number = textControl.getText();
1860 IStatus status = validatePositiveNumber(number);
1861 if (!status.matches(IStatus.ERROR))
1862 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1863 updateStatus(status);
1866 private IStatus validatePositiveNumber(String number) {
1867 StatusInfo status = new StatusInfo();
1868 if (number.length() == 0) {
1869 status.setError(PreferencesMessages
1870 .getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1873 int value = Integer.parseInt(number);
1875 status.setError(PreferencesMessages.getFormattedString(
1876 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1877 } catch (NumberFormatException e) {
1878 status.setError(PreferencesMessages.getFormattedString(
1879 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1885 void updateStatus(IStatus status) {
1886 if (!status.matches(IStatus.ERROR)) {
1887 for (int i = 0; i < fNumberFields.size(); i++) {
1888 Text text = (Text) fNumberFields.get(i);
1889 IStatus s = validatePositiveNumber(text.getText());
1890 status = StatusUtil.getMoreSevere(s, status);
1894 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1896 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1898 setValid(!status.matches(IStatus.ERROR));
1899 StatusUtil.applyToStatusLine(this, status);