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.IPHPPartitions;
31 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
32 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
33 import net.sourceforge.phpdt.ui.PreferenceConstants;
34 import net.sourceforge.phpdt.ui.text.JavaTextTools;
35 import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
36 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
37 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
38 import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer;
39 import net.sourceforge.phpeclipse.preferences.ColorEditor;
41 import org.eclipse.core.runtime.IStatus;
42 import org.eclipse.core.runtime.Preferences;
43 import org.eclipse.jface.action.Action;
44 import org.eclipse.jface.dialogs.Dialog;
45 import org.eclipse.jface.preference.IPreferenceStore;
46 import org.eclipse.jface.preference.PreferenceConverter;
47 import org.eclipse.jface.preference.PreferencePage;
48 import org.eclipse.jface.resource.JFaceResources;
49 import org.eclipse.jface.text.Document;
50 import org.eclipse.jface.text.IDocument;
51 import org.eclipse.jface.text.source.SourceViewer;
52 import org.eclipse.swt.SWT;
53 import org.eclipse.swt.events.KeyEvent;
54 import org.eclipse.swt.events.KeyListener;
55 import org.eclipse.swt.events.ModifyEvent;
56 import org.eclipse.swt.events.ModifyListener;
57 import org.eclipse.swt.events.SelectionEvent;
58 import org.eclipse.swt.events.SelectionListener;
59 import org.eclipse.swt.graphics.Color;
60 import org.eclipse.swt.graphics.Font;
61 import org.eclipse.swt.graphics.Point;
62 import org.eclipse.swt.graphics.RGB;
63 import org.eclipse.swt.layout.GridData;
64 import org.eclipse.swt.layout.GridLayout;
65 import org.eclipse.swt.layout.RowLayout;
66 import org.eclipse.swt.widgets.Button;
67 import org.eclipse.swt.widgets.Combo;
68 import org.eclipse.swt.widgets.Composite;
69 import org.eclipse.swt.widgets.Control;
70 import org.eclipse.swt.widgets.Group;
71 import org.eclipse.swt.widgets.Label;
72 import org.eclipse.swt.widgets.List;
73 import org.eclipse.swt.widgets.TabFolder;
74 import org.eclipse.swt.widgets.TabItem;
75 import org.eclipse.swt.widgets.Text;
76 import org.eclipse.ui.IWorkbench;
77 import org.eclipse.ui.IWorkbenchPreferencePage;
78 import org.eclipse.ui.PlatformUI;
79 import org.eclipse.ui.editors.text.EditorsUI;
80 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
81 import org.eclipse.ui.texteditor.AnnotationPreference;
82 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
83 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
86 * The page for setting the editor options.
88 public class JavaEditorPreferencePage extends PreferencePage implements
89 IWorkbenchPreferencePage {
90 private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
92 private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
94 private static final String DELIMITER = PreferencesMessages
95 .getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
97 /** The keys of the overlay store. */
98 public final OverlayPreferenceStore.OverlayKey[] fKeys;
100 private final String[][] fSyntaxColorListModel = new String[][] {
103 .getString("JavaEditorPreferencePage.multiLineComment"),
104 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
108 .getString("JavaEditorPreferencePage.singleLineComment"),
109 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
111 { PreferencesMessages.getString("JavaEditorPreferencePage.tags"),
112 PreferenceConstants.EDITOR_PHP_TAG_COLOR },
116 .getString("JavaEditorPreferencePage.keywords"),
117 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
120 .getString("JavaEditorPreferencePage.functionNames"),
121 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
125 .getString("JavaEditorPreferencePage.variables"),
126 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
130 .getString("JavaEditorPreferencePage.variables_dollar"),
131 PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR },
135 .getString("JavaEditorPreferencePage.constants"),
136 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
138 { PreferencesMessages.getString("JavaEditorPreferencePage.types"),
139 PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
143 .getString("JavaEditorPreferencePage.strings_dq"),
144 PreferenceConstants.EDITOR_STRING_COLOR_DQ },
147 .getString("JavaEditorPreferencePage.strings_sq"),
148 PreferenceConstants.EDITOR_STRING_COLOR_SQ },
152 .getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
155 .getString("JavaEditorPreferencePage.operators"),
156 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
160 .getString("JavaEditorPreferencePage.returnKeyword"),
161 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
162 { PreferencesMessages.getString("JavaEditorPreferencePage.braces"),
163 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR },
167 .getString("JavaEditorPreferencePage.phpDocKeywords"),
168 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
172 .getString("JavaEditorPreferencePage.phpDocHtmlTags"),
173 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
177 .getString("JavaEditorPreferencePage.phpDocLinks"),
178 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
182 .getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
185 private final String[][] fAppearanceColorListModel = new String[][] {
188 .getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
189 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR },
193 .getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
194 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
198 .getString("JavaEditorPreferencePage.currentLineHighlighColor"),
199 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
203 .getString("JavaEditorPreferencePage.printMarginColor2"),
204 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
208 .getString("JavaEditorPreferencePage.findScopeColor2"),
209 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
213 .getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
216 // private final String[][] fAnnotationColorListModel;
218 // private final String[][] fAnnotationDecorationListModel = new String[][]{
220 // PreferencesMessages
221 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
222 // AnnotationPreference.STYLE_NONE},
225 // PreferencesMessages
226 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
227 // AnnotationPreference.STYLE_SQUIGGLIES},
230 // PreferencesMessages
231 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
232 // AnnotationPreference.STYLE_UNDERLINE},
235 // PreferencesMessages
236 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
237 // AnnotationPreference.STYLE_BOX},
240 // PreferencesMessages
241 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
242 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
244 private OverlayPreferenceStore fOverlayStore;
246 private JavaTextTools fJavaTextTools;
248 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
250 private FoldingConfigurationBlock fFoldingConfigurationBlock;
252 private Map fColorButtons = new HashMap();
254 private Map fCheckBoxes = new HashMap();
256 private SelectionListener fCheckBoxListener = new SelectionListener() {
257 public void widgetDefaultSelected(SelectionEvent e) {
260 public void widgetSelected(SelectionEvent e) {
261 Button button = (Button) e.widget;
262 fOverlayStore.setValue((String) fCheckBoxes.get(button), button
267 private Map fTextFields = new HashMap();
269 private ModifyListener fTextFieldListener = new ModifyListener() {
270 public void modifyText(ModifyEvent e) {
271 Text text = (Text) e.widget;
272 fOverlayStore.setValue((String) fTextFields.get(text), text
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 fEscapeStringsButtonDQ;
314 private Button fEscapeStringsButtonSQ;
316 // private Button fGuessMethodArgumentsButton;
317 private SourceViewer fPreviewViewer;
319 private Color fBackgroundColor;
321 private Control fAutoInsertDelayText;
323 private Control fAutoInsertJavaTriggerText;
325 private Control fAutoInsertJavaDocTriggerText;
327 private Label fAutoInsertDelayLabel;
329 private Label fAutoInsertJavaTriggerLabel;
331 private Label fAutoInsertJavaDocTriggerLabel;
333 private Button fShowInTextCheckBox;
335 private Combo fDecorationStyleCombo;
337 private Button fHighlightInTextCheckBox;
339 private Button fShowInOverviewRulerCheckBox;
341 private Button fShowInVerticalRulerCheckBox;
343 private Text fBrowserLikeLinksKeyModifierText;
345 private Button fBrowserLikeLinksCheckBox;
347 private StatusInfo fBrowserLikeLinksKeyModifierStatus;
349 // private Button fCompletionInsertsRadioButton;
350 // private Button fCompletionOverwritesRadioButton;
351 // private Button fStickyOccurrencesButton;
353 * Creates a new preference page.
355 public JavaEditorPreferencePage() {
356 setDescription(PreferencesMessages
357 .getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
358 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
359 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
360 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
361 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
362 // fAnnotationColorListModel =
363 // createAnnotationTypeListModel(markerAnnotationPreferences);
366 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(
367 MarkerAnnotationPreferences preferences) {
368 ArrayList overlayKeys = new ArrayList();
369 Iterator e = preferences.getAnnotationPreferences().iterator();
370 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
371 OverlayPreferenceStore.STRING,
372 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
373 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
374 OverlayPreferenceStore.BOOLEAN,
375 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
376 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
377 OverlayPreferenceStore.STRING,
378 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
379 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
380 OverlayPreferenceStore.BOOLEAN,
381 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
382 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
383 OverlayPreferenceStore.INT,
384 PreferenceConstants.EDITOR_TAB_WIDTH));
385 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
386 OverlayPreferenceStore.STRING,
387 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
388 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
389 OverlayPreferenceStore.BOOLEAN,
390 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
391 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
392 OverlayPreferenceStore.STRING,
393 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
394 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
395 OverlayPreferenceStore.BOOLEAN,
396 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
397 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
398 OverlayPreferenceStore.STRING,
399 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
400 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
401 OverlayPreferenceStore.BOOLEAN,
402 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
404 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
405 OverlayPreferenceStore.STRING,
406 PreferenceConstants.EDITOR_PHP_TAG_COLOR));
407 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
408 OverlayPreferenceStore.BOOLEAN,
409 PreferenceConstants.EDITOR_PHP_TAG_BOLD));
410 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
411 OverlayPreferenceStore.STRING,
412 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
413 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
414 OverlayPreferenceStore.BOOLEAN,
415 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
416 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
417 OverlayPreferenceStore.STRING,
418 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
419 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
420 OverlayPreferenceStore.BOOLEAN,
421 PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
422 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
423 OverlayPreferenceStore.STRING,
424 PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR));
425 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
426 OverlayPreferenceStore.BOOLEAN,
427 PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_BOLD));
428 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
429 OverlayPreferenceStore.STRING,
430 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
431 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
432 OverlayPreferenceStore.BOOLEAN,
433 PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
434 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
435 OverlayPreferenceStore.STRING,
436 PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
437 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
438 OverlayPreferenceStore.BOOLEAN,
439 PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
441 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
442 OverlayPreferenceStore.STRING,
443 PreferenceConstants.EDITOR_STRING_COLOR_DQ));
444 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
445 OverlayPreferenceStore.BOOLEAN,
446 PreferenceConstants.EDITOR_STRING_BOLD_DQ));
447 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
448 OverlayPreferenceStore.STRING,
449 PreferenceConstants.EDITOR_STRING_COLOR_SQ));
450 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
451 OverlayPreferenceStore.BOOLEAN,
452 PreferenceConstants.EDITOR_STRING_BOLD_SQ));
453 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
454 OverlayPreferenceStore.STRING,
455 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
456 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
457 OverlayPreferenceStore.BOOLEAN,
458 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
459 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
460 OverlayPreferenceStore.STRING,
461 PreferenceConstants.EDITOR_TASK_TAG_COLOR));
462 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
463 OverlayPreferenceStore.BOOLEAN,
464 PreferenceConstants.EDITOR_TASK_TAG_BOLD));
465 // overlayKeys.add(new
466 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING_DQ,
467 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
468 // overlayKeys.add(new
469 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
470 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
471 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
472 OverlayPreferenceStore.STRING,
473 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
474 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
475 OverlayPreferenceStore.BOOLEAN,
476 PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
477 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
478 OverlayPreferenceStore.STRING,
479 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
480 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
481 OverlayPreferenceStore.BOOLEAN,
482 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
483 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
484 OverlayPreferenceStore.STRING,
485 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR));
486 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
487 OverlayPreferenceStore.BOOLEAN,
488 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_BOLD));
489 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
490 OverlayPreferenceStore.STRING,
491 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
492 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
493 OverlayPreferenceStore.BOOLEAN,
494 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
495 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
496 OverlayPreferenceStore.STRING,
497 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
498 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
499 OverlayPreferenceStore.BOOLEAN,
500 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
501 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
502 OverlayPreferenceStore.STRING,
503 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
504 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
505 OverlayPreferenceStore.BOOLEAN,
506 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
507 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
508 OverlayPreferenceStore.STRING,
509 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
510 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
511 OverlayPreferenceStore.BOOLEAN,
512 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
513 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
514 OverlayPreferenceStore.STRING,
515 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
516 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
517 OverlayPreferenceStore.BOOLEAN,
518 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
520 .add(new OverlayPreferenceStore.OverlayKey(
521 OverlayPreferenceStore.STRING,
522 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
524 .add(new OverlayPreferenceStore.OverlayKey(
525 OverlayPreferenceStore.BOOLEAN,
526 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
528 .add(new OverlayPreferenceStore.OverlayKey(
529 OverlayPreferenceStore.STRING,
530 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
532 .add(new OverlayPreferenceStore.OverlayKey(
533 OverlayPreferenceStore.INT,
534 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
536 .add(new OverlayPreferenceStore.OverlayKey(
537 OverlayPreferenceStore.BOOLEAN,
538 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
539 // overlayKeys.add(new
540 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
541 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
542 // overlayKeys.add(new
543 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
544 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
545 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
546 OverlayPreferenceStore.STRING,
547 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
548 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
549 OverlayPreferenceStore.STRING,
550 PreferenceConstants.EDITOR_LINK_COLOR));
551 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
552 OverlayPreferenceStore.BOOLEAN,
553 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
554 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
555 OverlayPreferenceStore.BOOLEAN,
556 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
558 .add(new OverlayPreferenceStore.OverlayKey(
559 OverlayPreferenceStore.BOOLEAN,
560 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
562 .add(new OverlayPreferenceStore.OverlayKey(
563 OverlayPreferenceStore.STRING,
564 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
566 .add(new OverlayPreferenceStore.OverlayKey(
567 OverlayPreferenceStore.BOOLEAN,
568 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
569 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
570 OverlayPreferenceStore.BOOLEAN,
571 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
572 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
573 OverlayPreferenceStore.BOOLEAN,
574 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
575 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
576 OverlayPreferenceStore.INT,
577 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
578 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
579 OverlayPreferenceStore.BOOLEAN,
580 PreferenceConstants.CODEASSIST_AUTOINSERT));
581 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
582 OverlayPreferenceStore.STRING,
583 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
584 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
585 OverlayPreferenceStore.STRING,
586 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
587 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
588 OverlayPreferenceStore.STRING,
589 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
590 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
591 OverlayPreferenceStore.STRING,
592 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
593 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
594 OverlayPreferenceStore.STRING,
595 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
596 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
597 OverlayPreferenceStore.STRING,
598 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
599 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
600 OverlayPreferenceStore.STRING,
601 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
603 .add(new OverlayPreferenceStore.OverlayKey(
604 OverlayPreferenceStore.STRING,
605 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
606 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
607 OverlayPreferenceStore.BOOLEAN,
608 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
609 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
610 OverlayPreferenceStore.BOOLEAN,
611 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
612 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
613 OverlayPreferenceStore.BOOLEAN,
614 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
615 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
616 OverlayPreferenceStore.BOOLEAN,
617 PreferenceConstants.CODEASSIST_ADDIMPORT));
618 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
619 OverlayPreferenceStore.BOOLEAN,
620 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
621 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
622 OverlayPreferenceStore.BOOLEAN,
623 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
624 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
625 OverlayPreferenceStore.BOOLEAN,
626 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
627 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
628 OverlayPreferenceStore.BOOLEAN,
629 PreferenceConstants.EDITOR_SMART_PASTE));
630 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
631 OverlayPreferenceStore.BOOLEAN,
632 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
633 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
634 OverlayPreferenceStore.BOOLEAN,
635 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
636 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
637 OverlayPreferenceStore.BOOLEAN,
638 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
640 // .add(new OverlayPreferenceStore.OverlayKey(
641 // OverlayPreferenceStore.BOOLEAN,
642 // PreferenceConstants.EDITOR_CLOSE_BRACES));
643 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
644 OverlayPreferenceStore.BOOLEAN,
645 PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
646 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
647 OverlayPreferenceStore.BOOLEAN,
648 PreferenceConstants.EDITOR_WRAP_WORDS));
649 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
650 OverlayPreferenceStore.BOOLEAN,
651 PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
652 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
653 OverlayPreferenceStore.BOOLEAN,
654 PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
655 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
656 OverlayPreferenceStore.BOOLEAN,
657 PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
658 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
659 OverlayPreferenceStore.BOOLEAN,
660 PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
662 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
663 OverlayPreferenceStore.BOOLEAN,
664 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
665 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
666 OverlayPreferenceStore.BOOLEAN,
667 PreferenceConstants.EDITOR_FORMAT_JAVADOCS));
668 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
669 OverlayPreferenceStore.BOOLEAN,
670 PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE));
672 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
673 OverlayPreferenceStore.BOOLEAN,
674 PreferenceConstants.EDITOR_SMART_HOME_END));
675 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
676 OverlayPreferenceStore.BOOLEAN,
677 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
678 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
679 OverlayPreferenceStore.BOOLEAN,
680 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
681 // overlayKeys.add(new
682 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
683 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
684 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
685 OverlayPreferenceStore.STRING,
686 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
687 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
688 OverlayPreferenceStore.STRING,
689 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
690 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
691 OverlayPreferenceStore.BOOLEAN,
692 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
693 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
694 OverlayPreferenceStore.STRING,
695 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
697 .add(new OverlayPreferenceStore.OverlayKey(
698 OverlayPreferenceStore.STRING,
699 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
700 while (e.hasNext()) {
701 AnnotationPreference info = (AnnotationPreference) e.next();
703 .add(new OverlayPreferenceStore.OverlayKey(
704 OverlayPreferenceStore.STRING, info
705 .getColorPreferenceKey()));
707 .add(new OverlayPreferenceStore.OverlayKey(
708 OverlayPreferenceStore.BOOLEAN, info
709 .getTextPreferenceKey()));
710 if (info.getHighlightPreferenceKey() != null)
711 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
712 OverlayPreferenceStore.BOOLEAN, info
713 .getHighlightPreferenceKey()));
714 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
715 OverlayPreferenceStore.BOOLEAN, info
716 .getOverviewRulerPreferenceKey()));
717 if (info.getVerticalRulerPreferenceKey() != null)
718 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
719 OverlayPreferenceStore.BOOLEAN, info
720 .getVerticalRulerPreferenceKey()));
721 if (info.getTextStylePreferenceKey() != null)
722 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
723 OverlayPreferenceStore.STRING, info
724 .getTextStylePreferenceKey()));
726 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
728 overlayKeys.toArray(keys);
731 * @see IWorkbenchPreferencePage#init()
734 public void init(IWorkbench workbench) {
738 * @see PreferencePage#createControl(Composite)
740 public void createControl(Composite parent) {
741 super.createControl(parent);
742 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
743 IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
746 private void handleSyntaxColorListSelection() {
747 int i = fSyntaxColorList.getSelectionIndex();
748 String key = fSyntaxColorListModel[i][1];
749 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
750 fSyntaxForegroundColorEditor.setColorValue(rgb);
751 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
754 private void handleAppearanceColorListSelection() {
755 int i = fAppearanceColorList.getSelectionIndex();
756 String key = fAppearanceColorListModel[i][1];
757 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
758 fAppearanceColorEditor.setColorValue(rgb);
761 // private void handleAnnotationListSelection() {
762 // int i = fAnnotationList.getSelectionIndex();
763 // String key = fAnnotationColorListModel[i][1];
764 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
765 // fAnnotationForegroundColorEditor.setColorValue(rgb);
766 // key = fAnnotationColorListModel[i][2];
767 // boolean showInText = fOverlayStore.getBoolean(key);
768 // fShowInTextCheckBox.setSelection(showInText);
769 // key = fAnnotationColorListModel[i][6];
770 // if (key != null) {
771 // fDecorationStyleCombo.setEnabled(showInText);
772 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
773 // String value = fOverlayStore.getString(key);
774 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
775 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
780 // fDecorationStyleCombo.setEnabled(false);
781 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); //
795 // key = fAnnotationColorListModel[i][3];
796 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
797 // key = fAnnotationColorListModel[i][4];
798 // if (key != null) {
799 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
800 // fHighlightInTextCheckBox.setEnabled(true);
802 // fHighlightInTextCheckBox.setEnabled(false);
803 // key = fAnnotationColorListModel[i][5];
804 // if (key != null) {
805 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
806 // fShowInVerticalRulerCheckBox.setEnabled(true);
808 // fShowInVerticalRulerCheckBox.setSelection(true);
809 // fShowInVerticalRulerCheckBox.setEnabled(false);
812 private Control createSyntaxPage(Composite parent) {
813 Composite colorComposite = new Composite(parent, SWT.NULL);
814 colorComposite.setLayout(new GridLayout());
815 Group backgroundComposite = new Group(colorComposite,
816 SWT.SHADOW_ETCHED_IN);
817 backgroundComposite.setLayout(new RowLayout());
818 backgroundComposite.setText(PreferencesMessages
819 .getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
820 SelectionListener backgroundSelectionListener = new SelectionListener() {
821 public void widgetSelected(SelectionEvent e) {
822 boolean custom = fBackgroundCustomRadioButton.getSelection();
823 fBackgroundColorButton.setEnabled(custom);
824 fOverlayStore.setValue(
825 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR,
829 public void widgetDefaultSelected(SelectionEvent e) {
832 fBackgroundDefaultRadioButton = new Button(backgroundComposite,
833 SWT.RADIO | SWT.LEFT);
834 fBackgroundDefaultRadioButton.setText(PreferencesMessages
835 .getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
836 fBackgroundDefaultRadioButton
837 .addSelectionListener(backgroundSelectionListener);
838 fBackgroundCustomRadioButton = new Button(backgroundComposite,
839 SWT.RADIO | SWT.LEFT);
840 fBackgroundCustomRadioButton.setText(PreferencesMessages
841 .getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
842 fBackgroundCustomRadioButton
843 .addSelectionListener(backgroundSelectionListener);
844 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
845 fBackgroundColorButton = fBackgroundColorEditor.getButton();
846 Label label = new Label(colorComposite, SWT.LEFT);
847 label.setText(PreferencesMessages
848 .getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
849 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
850 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
851 GridLayout layout = new GridLayout();
852 layout.numColumns = 2;
853 layout.marginHeight = 0;
854 layout.marginWidth = 0;
855 editorComposite.setLayout(layout);
856 GridData gd = new GridData(GridData.FILL_BOTH);
857 editorComposite.setLayoutData(gd);
858 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
860 gd = new GridData(GridData.FILL_BOTH);
861 gd.heightHint = convertHeightInCharsToPixels(5);
862 fSyntaxColorList.setLayoutData(gd);
863 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
864 layout = new GridLayout();
865 layout.marginHeight = 0;
866 layout.marginWidth = 0;
867 layout.numColumns = 2;
868 stylesComposite.setLayout(layout);
869 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
870 label = new Label(stylesComposite, SWT.LEFT);
871 label.setText(PreferencesMessages
872 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
874 gd.horizontalAlignment = GridData.BEGINNING;
875 label.setLayoutData(gd);
876 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
877 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
878 gd = new GridData(GridData.FILL_HORIZONTAL);
879 gd.horizontalAlignment = GridData.BEGINNING;
880 foregroundColorButton.setLayoutData(gd);
881 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
882 fBoldCheckBox.setText(PreferencesMessages
883 .getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
884 gd = new GridData(GridData.FILL_HORIZONTAL);
885 gd.horizontalAlignment = GridData.BEGINNING;
886 gd.horizontalSpan = 2;
887 fBoldCheckBox.setLayoutData(gd);
888 label = new Label(colorComposite, SWT.LEFT);
889 label.setText(PreferencesMessages
890 .getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
891 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
892 Control previewer = createPreviewer(colorComposite);
893 gd = new GridData(GridData.FILL_BOTH);
894 gd.widthHint = convertWidthInCharsToPixels(20);
895 gd.heightHint = convertHeightInCharsToPixels(5);
896 previewer.setLayoutData(gd);
897 fSyntaxColorList.addSelectionListener(new SelectionListener() {
898 public void widgetDefaultSelected(SelectionEvent e) {
902 public void widgetSelected(SelectionEvent e) {
903 handleSyntaxColorListSelection();
906 foregroundColorButton.addSelectionListener(new SelectionListener() {
907 public void widgetDefaultSelected(SelectionEvent e) {
911 public void widgetSelected(SelectionEvent e) {
912 int i = fSyntaxColorList.getSelectionIndex();
913 String key = fSyntaxColorListModel[i][1];
914 PreferenceConverter.setValue(fOverlayStore, key,
915 fSyntaxForegroundColorEditor.getColorValue());
918 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
919 public void widgetDefaultSelected(SelectionEvent e) {
923 public void widgetSelected(SelectionEvent e) {
924 PreferenceConverter.setValue(fOverlayStore,
925 PreferenceConstants.EDITOR_BACKGROUND_COLOR,
926 fBackgroundColorEditor.getColorValue());
929 fBoldCheckBox.addSelectionListener(new SelectionListener() {
930 public void widgetDefaultSelected(SelectionEvent e) {
934 public void widgetSelected(SelectionEvent e) {
935 int i = fSyntaxColorList.getSelectionIndex();
936 String key = fSyntaxColorListModel[i][1];
938 .setValue(key + BOLD, fBoldCheckBox.getSelection());
941 return colorComposite;
944 private Control createPreviewer(Composite parent) {
945 Preferences coreStore = createTemporaryCorePreferenceStore();
946 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
947 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
948 IPreferenceStore store = new ChainedPreferenceStore(
949 new IPreferenceStore[] {
951 new PreferencesAdapter(
952 createTemporaryCorePreferenceStore()),
955 fPreviewViewer = new JavaSourceViewer(parent, null, null, false,
956 SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
957 JavaTextTools tools = PHPeclipsePlugin.getDefault().getJavaTextTools();
958 PHPSourceViewerConfiguration configuration = new PHPSourceViewerConfiguration(
959 tools.getColorManager(), store, null,
960 IPHPPartitions.PHP_PARTITIONING);
961 // PHPSourceViewerConfiguration configuration =new
962 // PHPSourceViewerConfiguration(fJavaTextTools, null,
963 // IPHPPartitions.PHP_PARTITIONING);
964 fPreviewViewer.configure(configuration);
966 Font font = JFaceResources
967 .getFont(PreferenceConstants.EDITOR_TEXT_FONT);
968 fPreviewViewer.getTextWidget().setFont(font);
969 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
970 fPreviewViewer.setEditable(false);
971 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
972 IDocument document = new Document(content);
973 fJavaTextTools.setupJavaDocumentPartitioner(document,
974 IPHPPartitions.PHP_PARTITIONING);
975 fPreviewViewer.setDocument(document);
976 return fPreviewViewer.getControl();
979 private Preferences createTemporaryCorePreferenceStore() {
980 Preferences result = new Preferences();
981 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
985 private Control createAppearancePage(Composite parent) {
986 Composite appearanceComposite = new Composite(parent, SWT.NONE);
987 GridLayout layout = new GridLayout();
988 layout.numColumns = 2;
989 appearanceComposite.setLayout(layout);
990 String label = PreferencesMessages
991 .getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
992 addTextField(appearanceComposite, label,
993 PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
994 label = PreferencesMessages
995 .getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
999 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN,
1001 label = PreferencesMessages
1002 .getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
1004 appearanceComposite,
1006 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER,
1008 label = PreferencesMessages
1009 .getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
1011 appearanceComposite,
1013 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER,
1015 label = PreferencesMessages
1016 .getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
1017 addCheckBox(appearanceComposite, label,
1018 PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
1019 label = PreferencesMessages
1020 .getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
1022 appearanceComposite,
1024 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
1026 label = PreferencesMessages
1027 .getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
1029 appearanceComposite,
1031 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
1033 label = PreferencesMessages
1034 .getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
1035 // Button master= addCheckBox(appearanceComposite, label,
1036 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
1037 label = PreferencesMessages
1038 .getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
1039 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
1040 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
1041 // createDependency(master, fStickyOccurrencesButton);
1042 Label l = new Label(appearanceComposite, SWT.LEFT);
1043 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1044 gd.horizontalSpan = 2;
1045 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1046 l.setLayoutData(gd);
1047 l = new Label(appearanceComposite, SWT.LEFT);
1048 l.setText(PreferencesMessages
1049 .getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
1050 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1051 gd.horizontalSpan = 2;
1052 l.setLayoutData(gd);
1053 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
1054 layout = new GridLayout();
1055 layout.numColumns = 2;
1056 layout.marginHeight = 0;
1057 layout.marginWidth = 0;
1058 editorComposite.setLayout(layout);
1059 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
1060 | GridData.FILL_VERTICAL);
1061 gd.horizontalSpan = 2;
1062 editorComposite.setLayoutData(gd);
1063 fAppearanceColorList = new List(editorComposite, SWT.SINGLE
1064 | SWT.V_SCROLL | SWT.BORDER);
1065 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1066 | GridData.FILL_HORIZONTAL);
1067 gd.heightHint = convertHeightInCharsToPixels(8);
1068 fAppearanceColorList.setLayoutData(gd);
1069 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
1070 layout = new GridLayout();
1071 layout.marginHeight = 0;
1072 layout.marginWidth = 0;
1073 layout.numColumns = 2;
1074 stylesComposite.setLayout(layout);
1075 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1076 l = new Label(stylesComposite, SWT.LEFT);
1077 l.setText(PreferencesMessages
1078 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
1079 gd = new GridData();
1080 gd.horizontalAlignment = GridData.BEGINNING;
1081 l.setLayoutData(gd);
1082 fAppearanceColorEditor = new ColorEditor(stylesComposite);
1083 Button foregroundColorButton = fAppearanceColorEditor.getButton();
1084 gd = new GridData(GridData.FILL_HORIZONTAL);
1085 gd.horizontalAlignment = GridData.BEGINNING;
1086 foregroundColorButton.setLayoutData(gd);
1087 fAppearanceColorList.addSelectionListener(new SelectionListener() {
1088 public void widgetDefaultSelected(SelectionEvent e) {
1092 public void widgetSelected(SelectionEvent e) {
1093 handleAppearanceColorListSelection();
1096 foregroundColorButton.addSelectionListener(new SelectionListener() {
1097 public void widgetDefaultSelected(SelectionEvent e) {
1101 public void widgetSelected(SelectionEvent e) {
1102 int i = fAppearanceColorList.getSelectionIndex();
1103 String key = fAppearanceColorListModel[i][1];
1104 PreferenceConverter.setValue(fOverlayStore, key,
1105 fAppearanceColorEditor.getColorValue());
1108 return appearanceComposite;
1111 // private Control createAnnotationsPage(Composite parent) {
1112 // Composite composite = new Composite(parent, SWT.NULL);
1113 // GridLayout layout = new GridLayout();
1114 // layout.numColumns = 2;
1115 // composite.setLayout(layout);
1116 // String text = PreferencesMessages
1117 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
1119 // addCheckBox(composite, text,
1120 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
1121 // text = PreferencesMessages
1122 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
1123 // addCheckBox(composite, text,
1124 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
1125 // addFiller(composite);
1126 // Label label = new Label(composite, SWT.LEFT);
1127 // label.setText(PreferencesMessages
1128 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
1130 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1131 // gd.horizontalSpan = 2;
1132 // label.setLayoutData(gd);
1133 // Composite editorComposite = new Composite(composite, SWT.NONE);
1134 // layout = new GridLayout();
1135 // layout.numColumns = 2;
1136 // layout.marginHeight = 0;
1137 // layout.marginWidth = 0;
1138 // editorComposite.setLayout(layout);
1139 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
1140 // GridData.FILL_VERTICAL);
1141 // gd.horizontalSpan = 2;
1142 // editorComposite.setLayoutData(gd);
1143 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
1145 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1146 // | GridData.FILL_HORIZONTAL);
1147 // gd.heightHint = convertHeightInCharsToPixels(10);
1148 // fAnnotationList.setLayoutData(gd);
1149 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
1150 // layout = new GridLayout();
1151 // layout.marginHeight = 0;
1152 // layout.marginWidth = 0;
1153 // layout.numColumns = 2;
1154 // optionsComposite.setLayout(layout);
1155 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1156 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1157 // fShowInTextCheckBox.setText(PreferencesMessages
1158 // .getString("JavaEditorPreferencePage.annotations.showInText"));
1160 // gd = new GridData(GridData.FILL_HORIZONTAL);
1161 // gd.horizontalAlignment = GridData.BEGINNING;
1162 // gd.horizontalSpan = 2;
1163 // fShowInTextCheckBox.setLayoutData(gd);
1164 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
1165 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
1166 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
1167 // gd = new GridData(GridData.FILL_HORIZONTAL);
1168 // gd.horizontalAlignment = GridData.BEGINNING;
1169 // gd.horizontalSpan = 2;
1170 // gd.horizontalIndent = 20;
1171 // fDecorationStyleCombo.setLayoutData(gd);
1172 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1173 // fHighlightInTextCheckBox.setText(PreferencesMessages
1174 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
1176 // gd = new GridData(GridData.FILL_HORIZONTAL);
1177 // gd.horizontalAlignment = GridData.BEGINNING;
1178 // gd.horizontalSpan = 2;
1179 // fHighlightInTextCheckBox.setLayoutData(gd);
1180 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1181 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
1182 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
1184 // gd = new GridData(GridData.FILL_HORIZONTAL);
1185 // gd.horizontalAlignment = GridData.BEGINNING;
1186 // gd.horizontalSpan = 2;
1187 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
1188 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1189 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
1190 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
1192 // gd = new GridData(GridData.FILL_HORIZONTAL);
1193 // gd.horizontalAlignment = GridData.BEGINNING;
1194 // gd.horizontalSpan = 2;
1195 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
1196 // label = new Label(optionsComposite, SWT.LEFT);
1197 // label.setText(PreferencesMessages
1198 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
1199 // gd = new GridData();
1200 // gd.horizontalAlignment = GridData.BEGINNING;
1201 // label.setLayoutData(gd);
1202 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
1203 // Button foregroundColorButton =
1204 // fAnnotationForegroundColorEditor.getButton();
1205 // gd = new GridData(GridData.FILL_HORIZONTAL);
1206 // gd.horizontalAlignment = GridData.BEGINNING;
1207 // foregroundColorButton.setLayoutData(gd);
1208 // fAnnotationList.addSelectionListener(new SelectionListener() {
1209 // public void widgetDefaultSelected(SelectionEvent e) {
1212 // public void widgetSelected(SelectionEvent e) {
1213 // handleAnnotationListSelection();
1216 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
1217 // public void widgetDefaultSelected(SelectionEvent e) {
1220 // public void widgetSelected(SelectionEvent e) {
1221 // int i = fAnnotationList.getSelectionIndex();
1222 // String key = fAnnotationColorListModel[i][2];
1223 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
1224 // String decorationKey = fAnnotationColorListModel[i][6];
1225 // fDecorationStyleCombo.setEnabled(decorationKey != null
1226 // && fShowInTextCheckBox.getSelection());
1229 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
1230 // public void widgetDefaultSelected(SelectionEvent e) {
1233 // public void widgetSelected(SelectionEvent e) {
1234 // int i = fAnnotationList.getSelectionIndex();
1235 // String key = fAnnotationColorListModel[i][4];
1236 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
1239 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener()
1241 // public void widgetDefaultSelected(SelectionEvent e) {
1244 // public void widgetSelected(SelectionEvent e) {
1245 // int i = fAnnotationList.getSelectionIndex();
1246 // String key = fAnnotationColorListModel[i][3];
1248 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
1251 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener()
1253 // public void widgetDefaultSelected(SelectionEvent e) {
1256 // public void widgetSelected(SelectionEvent e) {
1257 // int i = fAnnotationList.getSelectionIndex();
1258 // String key = fAnnotationColorListModel[i][5];
1260 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
1263 // foregroundColorButton.addSelectionListener(new SelectionListener() {
1264 // public void widgetDefaultSelected(SelectionEvent e) {
1267 // public void widgetSelected(SelectionEvent e) {
1268 // int i = fAnnotationList.getSelectionIndex();
1269 // String key = fAnnotationColorListModel[i][1];
1270 // PreferenceConverter.setValue(fOverlayStore, key,
1271 // fAnnotationForegroundColorEditor.getColorValue());
1274 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
1278 // public void widgetDefaultSelected(SelectionEvent e) {
1284 // public void widgetSelected(SelectionEvent e) {
1285 // int i = fAnnotationList.getSelectionIndex();
1286 // String key = fAnnotationColorListModel[i][6];
1287 // if (key != null) {
1288 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1289 // if (fAnnotationDecorationListModel[j][0]
1290 // .equals(fDecorationStyleCombo.getText())) {
1291 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1298 // return composite;
1300 private String[][] createAnnotationTypeListModel(
1301 MarkerAnnotationPreferences preferences) {
1302 ArrayList listModelItems = new ArrayList();
1303 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1305 * @see java.util.Comparator#compare(java.lang.Object,
1308 public int compare(Object o1, Object o2) {
1309 if (!(o2 instanceof AnnotationPreference))
1311 if (!(o1 instanceof AnnotationPreference))
1313 AnnotationPreference a1 = (AnnotationPreference) o1;
1314 AnnotationPreference a2 = (AnnotationPreference) o2;
1315 return Collator.getInstance().compare(a1.getPreferenceLabel(),
1316 a2.getPreferenceLabel());
1319 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1320 Iterator e = sortedPreferences.iterator();
1321 while (e.hasNext()) {
1322 AnnotationPreference info = (AnnotationPreference) e.next();
1323 listModelItems.add(new String[] { info.getPreferenceLabel(),
1324 info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1325 info.getOverviewRulerPreferenceKey(),
1326 info.getHighlightPreferenceKey(),
1327 info.getVerticalRulerPreferenceKey(),
1328 info.getTextStylePreferenceKey() });
1330 String[][] items = new String[listModelItems.size()][];
1331 listModelItems.toArray(items);
1335 private Control createTypingPage(Composite parent) {
1336 Composite composite = new Composite(parent, SWT.NONE);
1337 GridLayout layout = new GridLayout();
1338 layout.numColumns = 1;
1339 composite.setLayout(layout);
1341 // label = PreferencesMessages
1342 // .getString("JavaEditorPreferencePage.overwriteMode");
1344 // addCheckBox(composite, label,
1345 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1346 // addFiller(composite);
1348 // label = PreferencesMessages
1349 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1351 // addCheckBox(composite, label,
1352 // PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1354 // label = PreferencesMessages
1355 // .getString("JavaEditorPreferencePage.subWordNavigation");
1357 // addCheckBox(composite, label,
1358 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1359 // addFiller(composite);
1360 Group group = new Group(composite, SWT.NONE);
1361 layout = new GridLayout();
1362 layout.numColumns = 2;
1363 group.setLayout(layout);
1364 group.setText(PreferencesMessages
1365 .getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1367 label = PreferencesMessages
1368 .getString("JavaEditorPreferencePage.wrapWords");//$NON-NLS-1$
1369 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_WORDS, 1);
1371 label = PreferencesMessages
1372 .getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1373 Button button = addCheckBox(group, label,
1374 PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1376 label = PreferencesMessages
1377 .getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1378 fEscapeStringsButtonDQ = addCheckBox(group, label,
1379 PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1380 createDependency(button, fEscapeStringsButtonDQ);
1382 label = PreferencesMessages
1383 .getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1384 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1386 label = PreferencesMessages
1387 .getString("JavaEditorPreferencePage.escapeStringsSQ");
1389 fEscapeStringsButtonSQ = addCheckBox(group, label,
1390 PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1391 createDependency(button, fEscapeStringsButtonSQ);
1393 label = PreferencesMessages
1394 .getString("JavaEditorPreferencePage.smartPaste");
1396 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1398 label = PreferencesMessages
1399 .getString("JavaEditorPreferencePage.insertSpaceForTabs");
1401 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1403 label = PreferencesMessages
1404 .getString("JavaEditorPreferencePage.closeStringsDQ");
1406 addCheckBox(group, label,
1407 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1408 label = PreferencesMessages
1409 .getString("JavaEditorPreferencePage.closeStringsSQ");
1411 addCheckBox(group, label,
1412 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1414 label = PreferencesMessages
1415 .getString("JavaEditorPreferencePage.closeBrackets");
1417 addCheckBox(group, label,
1418 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1420 // label = PreferencesMessages
1421 // .getString("JavaEditorPreferencePage.closeBraces");
1423 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES,
1426 label = PreferencesMessages
1427 .getString("JavaEditorPreferencePage.closeJavaDocs");
1429 button = addCheckBox(group, label,
1430 PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1431 label = PreferencesMessages
1432 .getString("JavaEditorPreferencePage.formatJavaDocs");
1434 button = addCheckBox(group, label,
1435 PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
1437 label = PreferencesMessages
1438 .getString("JavaEditorPreferencePage.p_rtrim_on_save");
1439 addCheckBox(group, label, PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE, 1);
1441 // label = PreferencesMessages
1442 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1444 // fAddJavaDocTagsButton = addCheckBox(group, label,
1445 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1446 // createDependency(button, fAddJavaDocTagsButton);
1450 private void addFiller(Composite composite) {
1451 Label filler = new Label(composite, SWT.LEFT);
1452 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1453 gd.horizontalSpan = 2;
1454 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1455 filler.setLayoutData(gd);
1458 private static void indent(Control control) {
1459 GridData gridData = new GridData();
1460 gridData.horizontalIndent = 20;
1461 control.setLayoutData(gridData);
1464 private static void createDependency(final Button master,
1465 final Control slave) {
1467 master.addSelectionListener(new SelectionListener() {
1468 public void widgetSelected(SelectionEvent e) {
1469 slave.setEnabled(master.getSelection());
1472 public void widgetDefaultSelected(SelectionEvent e) {
1477 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1478 Composite completionComposite = new Composite(contentAssistComposite,
1480 GridData ccgd = new GridData();
1481 ccgd.horizontalSpan = 2;
1482 completionComposite.setLayoutData(ccgd);
1483 GridLayout ccgl = new GridLayout();
1484 ccgl.marginWidth = 0;
1485 ccgl.numColumns = 2;
1486 completionComposite.setLayout(ccgl);
1487 // SelectionListener completionSelectionListener= new SelectionAdapter()
1489 // public void widgetSelected(SelectionEvent e) {
1490 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1491 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1496 // fCompletionInsertsRadioButton= new Button(completionComposite,
1499 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1501 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1502 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1504 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1505 // SWT.RADIO | SWT.LEFT);
1506 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1508 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1509 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1512 private Control createNavigationPage(Composite parent) {
1513 Composite composite = new Composite(parent, SWT.NULL);
1514 GridLayout layout = new GridLayout();
1515 layout.numColumns = 2;
1516 composite.setLayout(layout);
1517 String text = PreferencesMessages
1518 .getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1520 fBrowserLikeLinksCheckBox = addCheckBox(composite, text,
1521 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1522 fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1523 public void widgetSelected(SelectionEvent e) {
1524 boolean state = fBrowserLikeLinksCheckBox.getSelection();
1525 fBrowserLikeLinksKeyModifierText.setEnabled(state);
1526 handleBrowserLikeLinksKeyModifierModified();
1529 public void widgetDefaultSelected(SelectionEvent e) {
1532 // Text field for modifier string
1533 text = PreferencesMessages
1534 .getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1536 fBrowserLikeLinksKeyModifierText = addTextField(composite, text,
1537 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20,
1539 fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1541 if (computeStateMask(fOverlayStore
1542 .getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) == -1) {
1543 // Fix possible illegal modifier string
1544 int stateMask = fOverlayStore
1545 .getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1546 if (stateMask == -1)
1547 fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1549 fBrowserLikeLinksKeyModifierText.setText(EditorUtility
1550 .getModifierString(stateMask));
1552 fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1553 private boolean isModifierCandidate;
1555 public void keyPressed(KeyEvent e) {
1556 isModifierCandidate = e.keyCode > 0 && e.character == 0
1557 && e.stateMask == 0;
1560 public void keyReleased(KeyEvent e) {
1561 if (isModifierCandidate && e.stateMask > 0
1562 && e.stateMask == e.stateMask && e.character == 0) {// &&
1568 String modifierString = fBrowserLikeLinksKeyModifierText
1570 Point selection = fBrowserLikeLinksKeyModifierText
1572 int i = selection.x - 1;
1574 && Character.isWhitespace(modifierString.charAt(i))) {
1577 boolean needsPrefixDelimiter = i > -1
1578 && !String.valueOf(modifierString.charAt(i))
1582 while (i < modifierString.length()
1583 && Character.isWhitespace(modifierString.charAt(i))) {
1586 boolean needsPostfixDelimiter = i < modifierString.length()
1587 && !String.valueOf(modifierString.charAt(i))
1590 String insertString;
1592 if (needsPrefixDelimiter && needsPostfixDelimiter)
1593 insertString = PreferencesMessages
1594 .getFormattedString(
1595 "JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1596 new String[] { Action
1597 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1598 else if (needsPrefixDelimiter)
1599 insertString = PreferencesMessages
1600 .getFormattedString(
1601 "JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1602 new String[] { Action
1603 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1604 else if (needsPostfixDelimiter)
1605 insertString = PreferencesMessages
1606 .getFormattedString(
1607 "JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1608 new String[] { Action
1609 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1611 insertString = Action.findModifierString(e.stateMask);
1613 fBrowserLikeLinksKeyModifierText.insert(insertString);
1618 fBrowserLikeLinksKeyModifierText
1619 .addModifyListener(new ModifyListener() {
1620 public void modifyText(ModifyEvent e) {
1621 handleBrowserLikeLinksKeyModifierModified();
1627 private void handleBrowserLikeLinksKeyModifierModified() {
1628 String modifiers = fBrowserLikeLinksKeyModifierText.getText();
1629 int stateMask = computeStateMask(modifiers);
1630 if (fBrowserLikeLinksCheckBox.getSelection()
1631 && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) {
1632 if (stateMask == -1)
1633 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(
1636 .getFormattedString(
1637 "JavaEditorPreferencePage.navigation.modifierIsNotValid", modifiers)); //$NON-NLS-1$
1639 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(
1642 .getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1645 StatusUtil.applyToStatusLine(this,
1646 fBrowserLikeLinksKeyModifierStatus);
1648 fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1649 updateStatus(fBrowserLikeLinksKeyModifierStatus);
1653 private IStatus getBrowserLikeLinksKeyModifierStatus() {
1654 if (fBrowserLikeLinksKeyModifierStatus == null)
1655 fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1656 return fBrowserLikeLinksKeyModifierStatus;
1660 * Computes the state mask for the given modifier string.
1663 * the string with the modifiers, separated by '+', '-', ';', ','
1665 * @return the state mask or -1 if the input is invalid
1667 private int computeStateMask(String modifiers) {
1668 if (modifiers == null)
1670 if (modifiers.length() == 0)
1673 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers,
1674 ",;.:+-* "); //$NON-NLS-1$
1675 while (modifierTokenizer.hasMoreTokens()) {
1676 int modifier = EditorUtility
1677 .findLocalizedModifier(modifierTokenizer.nextToken());
1678 if (modifier == 0 || (stateMask & modifier) == modifier)
1680 stateMask = stateMask | modifier;
1686 * @see PreferencePage#createContents(Composite)
1688 protected Control createContents(Composite parent) {
1689 initializeDefaultColors();
1690 fFoldingConfigurationBlock = new FoldingConfigurationBlock(
1692 fOverlayStore.load();
1693 fOverlayStore.start();
1694 TabFolder folder = new TabFolder(parent, SWT.NONE);
1695 folder.setLayout(new TabFolderLayout());
1696 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1697 TabItem item = new TabItem(folder, SWT.NONE);
1698 item.setText(PreferencesMessages
1699 .getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1700 item.setControl(createAppearancePage(folder));
1701 item = new TabItem(folder, SWT.NONE);
1702 item.setText(PreferencesMessages
1703 .getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1704 item.setControl(createSyntaxPage(folder));
1706 // item = new TabItem(folder, SWT.NONE);
1707 // item.setText(PreferencesMessages
1708 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1710 // item.setControl(createAnnotationsPage(folder));
1711 item = new TabItem(folder, SWT.NONE);
1712 item.setText(PreferencesMessages
1713 .getString("JavaEditorPreferencePage.typing.tabTitle"));
1715 item.setControl(createTypingPage(folder));
1717 item = new TabItem(folder, SWT.NONE);
1718 item.setText(PreferencesMessages
1719 .getString("JavaEditorPreferencePage.hoverTab.title"));
1721 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(
1722 this, fOverlayStore);
1723 item.setControl(fJavaEditorHoverConfigurationBlock
1724 .createControl(folder));
1725 item = new TabItem(folder, SWT.NONE);
1726 item.setText(PreferencesMessages
1727 .getString("JavaEditorPreferencePage.navigationTab.title"));
1729 item.setControl(createNavigationPage(folder));
1730 item = new TabItem(folder, SWT.NONE);
1731 item.setText(PreferencesMessages
1732 .getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1733 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1736 Dialog.applyDialogFont(folder);
1740 private void initialize() {
1742 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1743 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1744 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1746 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1747 fSyntaxColorList.select(0);
1748 handleSyntaxColorListSelection();
1752 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1753 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1754 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1756 if (fAppearanceColorList != null
1757 && !fAppearanceColorList.isDisposed()) {
1758 fAppearanceColorList.select(0);
1759 handleAppearanceColorListSelection();
1763 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1764 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1765 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1766 // public void run() {
1767 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1768 // fAnnotationList.select(0);
1769 // handleAnnotationListSelection();
1773 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1774 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1775 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1776 // public void run() {
1777 // if (fContentAssistColorList != null &&
1778 // !fContentAssistColorList.isDisposed()) {
1779 // fContentAssistColorList.select(0);
1780 // handleContentAssistColorListSelection();
1784 fFoldingConfigurationBlock.initialize();
1787 private void initializeFields() {
1788 Iterator e = fColorButtons.keySet().iterator();
1789 while (e.hasNext()) {
1790 ColorEditor c = (ColorEditor) e.next();
1791 String key = (String) fColorButtons.get(c);
1792 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1793 c.setColorValue(rgb);
1795 e = fCheckBoxes.keySet().iterator();
1796 while (e.hasNext()) {
1797 Button b = (Button) e.next();
1798 String key = (String) fCheckBoxes.get(b);
1799 b.setSelection(fOverlayStore.getBoolean(key));
1801 e = fTextFields.keySet().iterator();
1802 while (e.hasNext()) {
1803 Text t = (Text) e.next();
1804 String key = (String) fTextFields.get(t);
1805 t.setText(fOverlayStore.getString(key));
1807 RGB rgb = PreferenceConverter.getColor(fOverlayStore,
1808 PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1809 fBackgroundColorEditor.setColorValue(rgb);
1810 boolean default_ = fOverlayStore
1811 .getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1812 fBackgroundDefaultRadioButton.setSelection(default_);
1813 fBackgroundCustomRadioButton.setSelection(!default_);
1814 fBackgroundColorButton.setEnabled(!default_);
1815 boolean closeJavaDocs = fOverlayStore
1816 .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1817 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1818 fEscapeStringsButtonDQ.setEnabled(fOverlayStore
1819 .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1820 fEscapeStringsButtonSQ.setEnabled(fOverlayStore
1821 .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1822 // boolean fillMethodArguments=
1823 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1824 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1825 // boolean completionInserts=
1826 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1827 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1828 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1830 fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox
1832 // boolean markOccurrences=
1833 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1834 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1835 updateAutoactivationControls();
1838 private void initializeDefaultColors() {
1839 if (!getPreferenceStore().contains(
1840 PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1841 RGB rgb = getControl().getDisplay().getSystemColor(
1842 SWT.COLOR_LIST_BACKGROUND).getRGB();
1843 PreferenceConverter.setDefault(fOverlayStore,
1844 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1845 PreferenceConverter.setDefault(getPreferenceStore(),
1846 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1848 if (!getPreferenceStore().contains(
1849 PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1850 RGB rgb = getControl().getDisplay().getSystemColor(
1851 SWT.COLOR_LIST_FOREGROUND).getRGB();
1852 PreferenceConverter.setDefault(fOverlayStore,
1853 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1854 PreferenceConverter.setDefault(getPreferenceStore(),
1855 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1859 private void updateAutoactivationControls() {
1860 // boolean autoactivation=
1861 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1862 // fAutoInsertDelayText.setEnabled(autoactivation);
1863 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1864 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1865 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1867 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1868 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1872 * @see PreferencePage#performOk()
1874 public boolean performOk() {
1875 // fJavaEditorHoverConfigurationBlock.performOk();
1876 fFoldingConfigurationBlock.performOk();
1879 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1880 computeStateMask(fBrowserLikeLinksKeyModifierText
1882 fOverlayStore.propagate();
1883 PHPeclipsePlugin.getDefault().savePluginPreferences();
1888 * @see PreferencePage#performDefaults()
1890 protected void performDefaults() {
1891 fOverlayStore.loadDefaults();
1893 handleSyntaxColorListSelection();
1894 handleAppearanceColorListSelection();
1895 // handleAnnotationListSelection();
1896 // handleContentAssistColorListSelection();
1897 // fJavaEditorHoverConfigurationBlock.performDefaults();
1898 fFoldingConfigurationBlock.performDefaults();
1899 super.performDefaults();
1900 fPreviewViewer.invalidateTextPresentation();
1904 * @see DialogPage#dispose()
1906 public void dispose() {
1907 fFoldingConfigurationBlock.dispose();
1909 if (fJavaTextTools != null) {
1910 fJavaTextTools.dispose();
1911 fJavaTextTools = null;
1913 if (fOverlayStore != null) {
1914 fOverlayStore.stop();
1915 fOverlayStore = null;
1917 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1918 fBackgroundColor.dispose();
1922 private Button addCheckBox(Composite parent, String label, String key,
1924 Button checkBox = new Button(parent, SWT.CHECK);
1925 checkBox.setText(label);
1926 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1927 gd.horizontalIndent = indentation;
1928 gd.horizontalSpan = 2;
1929 checkBox.setLayoutData(gd);
1930 checkBox.addSelectionListener(fCheckBoxListener);
1931 fCheckBoxes.put(checkBox, key);
1935 private Text addTextField(Composite composite, String label, String key,
1936 int textLimit, int indentation, boolean isNumber) {
1937 return getTextControl(addLabelledTextField(composite, label, key,
1938 textLimit, indentation, isNumber));
1941 private static Label getLabelControl(Control[] labelledTextField) {
1942 return (Label) labelledTextField[0];
1945 private static Text getTextControl(Control[] labelledTextField) {
1946 return (Text) labelledTextField[1];
1950 * Returns an array of size 2: - first element is of type <code>Label</code>-
1951 * second element is of type <code>Text</code> Use
1952 * <code>getLabelControl</code> and <code>getTextControl</code> to get
1955 private Control[] addLabelledTextField(Composite composite, String label,
1956 String key, int textLimit, int indentation, boolean isNumber) {
1957 Label labelControl = new Label(composite, SWT.NONE);
1958 labelControl.setText(label);
1959 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1960 gd.horizontalIndent = indentation;
1961 labelControl.setLayoutData(gd);
1962 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1963 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1964 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1965 textControl.setLayoutData(gd);
1966 textControl.setTextLimit(textLimit);
1967 fTextFields.put(textControl, key);
1969 fNumberFields.add(textControl);
1970 textControl.addModifyListener(fNumberFieldListener);
1972 textControl.addModifyListener(fTextFieldListener);
1974 return new Control[] { labelControl, textControl };
1977 private String loadPreviewContentFromFile(String filename) {
1979 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1980 StringBuffer buffer = new StringBuffer(512);
1981 BufferedReader reader = null;
1983 reader = new BufferedReader(new InputStreamReader(getClass()
1984 .getResourceAsStream(filename)));
1985 while ((line = reader.readLine()) != null) {
1986 buffer.append(line);
1987 buffer.append(separator);
1989 } catch (IOException io) {
1990 PHPeclipsePlugin.log(io);
1992 if (reader != null) {
1995 } catch (IOException e) {
1999 return buffer.toString();
2002 private void numberFieldChanged(Text textControl) {
2003 String number = textControl.getText();
2004 IStatus status = validatePositiveNumber(number);
2005 if (!status.matches(IStatus.ERROR))
2006 fOverlayStore.setValue((String) fTextFields.get(textControl),
2008 updateStatus(status);
2011 private IStatus validatePositiveNumber(String number) {
2012 StatusInfo status = new StatusInfo();
2013 if (number.length() == 0) {
2014 status.setError(PreferencesMessages
2015 .getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
2018 int value = Integer.parseInt(number);
2020 status.setError(PreferencesMessages.getFormattedString(
2021 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
2022 } catch (NumberFormatException e) {
2023 status.setError(PreferencesMessages.getFormattedString(
2024 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
2030 void updateStatus(IStatus status) {
2031 if (!status.matches(IStatus.ERROR)) {
2032 for (int i = 0; i < fNumberFields.size(); i++) {
2033 Text text = (Text) fNumberFields.get(i);
2034 IStatus s = validatePositiveNumber(text.getText());
2035 status = StatusUtil.getMoreSevere(s, status);
2039 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
2042 // StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
2044 setValid(!status.matches(IStatus.ERROR));
2045 StatusUtil.applyToStatusLine(this, status);