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));
669 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
670 OverlayPreferenceStore.BOOLEAN,
671 PreferenceConstants.EDITOR_SMART_HOME_END));
672 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
673 OverlayPreferenceStore.BOOLEAN,
674 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
675 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
676 OverlayPreferenceStore.BOOLEAN,
677 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
678 // overlayKeys.add(new
679 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
680 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
681 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
682 OverlayPreferenceStore.STRING,
683 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
684 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
685 OverlayPreferenceStore.STRING,
686 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
687 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
688 OverlayPreferenceStore.BOOLEAN,
689 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
690 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
691 OverlayPreferenceStore.STRING,
692 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
694 .add(new OverlayPreferenceStore.OverlayKey(
695 OverlayPreferenceStore.STRING,
696 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
697 while (e.hasNext()) {
698 AnnotationPreference info = (AnnotationPreference) e.next();
700 .add(new OverlayPreferenceStore.OverlayKey(
701 OverlayPreferenceStore.STRING, info
702 .getColorPreferenceKey()));
704 .add(new OverlayPreferenceStore.OverlayKey(
705 OverlayPreferenceStore.BOOLEAN, info
706 .getTextPreferenceKey()));
707 if (info.getHighlightPreferenceKey() != null)
708 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
709 OverlayPreferenceStore.BOOLEAN, info
710 .getHighlightPreferenceKey()));
711 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
712 OverlayPreferenceStore.BOOLEAN, info
713 .getOverviewRulerPreferenceKey()));
714 if (info.getVerticalRulerPreferenceKey() != null)
715 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
716 OverlayPreferenceStore.BOOLEAN, info
717 .getVerticalRulerPreferenceKey()));
718 if (info.getTextStylePreferenceKey() != null)
719 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
720 OverlayPreferenceStore.STRING, info
721 .getTextStylePreferenceKey()));
723 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
725 overlayKeys.toArray(keys);
728 * @see IWorkbenchPreferencePage#init()
731 public void init(IWorkbench workbench) {
735 * @see PreferencePage#createControl(Composite)
737 public void createControl(Composite parent) {
738 super.createControl(parent);
739 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
740 IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
743 private void handleSyntaxColorListSelection() {
744 int i = fSyntaxColorList.getSelectionIndex();
745 String key = fSyntaxColorListModel[i][1];
746 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
747 fSyntaxForegroundColorEditor.setColorValue(rgb);
748 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
751 private void handleAppearanceColorListSelection() {
752 int i = fAppearanceColorList.getSelectionIndex();
753 String key = fAppearanceColorListModel[i][1];
754 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
755 fAppearanceColorEditor.setColorValue(rgb);
758 // private void handleAnnotationListSelection() {
759 // int i = fAnnotationList.getSelectionIndex();
760 // String key = fAnnotationColorListModel[i][1];
761 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
762 // fAnnotationForegroundColorEditor.setColorValue(rgb);
763 // key = fAnnotationColorListModel[i][2];
764 // boolean showInText = fOverlayStore.getBoolean(key);
765 // fShowInTextCheckBox.setSelection(showInText);
766 // key = fAnnotationColorListModel[i][6];
767 // if (key != null) {
768 // fDecorationStyleCombo.setEnabled(showInText);
769 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
770 // String value = fOverlayStore.getString(key);
771 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
772 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
777 // fDecorationStyleCombo.setEnabled(false);
778 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); //
792 // key = fAnnotationColorListModel[i][3];
793 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
794 // key = fAnnotationColorListModel[i][4];
795 // if (key != null) {
796 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
797 // fHighlightInTextCheckBox.setEnabled(true);
799 // fHighlightInTextCheckBox.setEnabled(false);
800 // key = fAnnotationColorListModel[i][5];
801 // if (key != null) {
802 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
803 // fShowInVerticalRulerCheckBox.setEnabled(true);
805 // fShowInVerticalRulerCheckBox.setSelection(true);
806 // fShowInVerticalRulerCheckBox.setEnabled(false);
809 private Control createSyntaxPage(Composite parent) {
810 Composite colorComposite = new Composite(parent, SWT.NULL);
811 colorComposite.setLayout(new GridLayout());
812 Group backgroundComposite = new Group(colorComposite,
813 SWT.SHADOW_ETCHED_IN);
814 backgroundComposite.setLayout(new RowLayout());
815 backgroundComposite.setText(PreferencesMessages
816 .getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
817 SelectionListener backgroundSelectionListener = new SelectionListener() {
818 public void widgetSelected(SelectionEvent e) {
819 boolean custom = fBackgroundCustomRadioButton.getSelection();
820 fBackgroundColorButton.setEnabled(custom);
821 fOverlayStore.setValue(
822 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR,
826 public void widgetDefaultSelected(SelectionEvent e) {
829 fBackgroundDefaultRadioButton = new Button(backgroundComposite,
830 SWT.RADIO | SWT.LEFT);
831 fBackgroundDefaultRadioButton.setText(PreferencesMessages
832 .getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
833 fBackgroundDefaultRadioButton
834 .addSelectionListener(backgroundSelectionListener);
835 fBackgroundCustomRadioButton = new Button(backgroundComposite,
836 SWT.RADIO | SWT.LEFT);
837 fBackgroundCustomRadioButton.setText(PreferencesMessages
838 .getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
839 fBackgroundCustomRadioButton
840 .addSelectionListener(backgroundSelectionListener);
841 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
842 fBackgroundColorButton = fBackgroundColorEditor.getButton();
843 Label label = new Label(colorComposite, SWT.LEFT);
844 label.setText(PreferencesMessages
845 .getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
846 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
847 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
848 GridLayout layout = new GridLayout();
849 layout.numColumns = 2;
850 layout.marginHeight = 0;
851 layout.marginWidth = 0;
852 editorComposite.setLayout(layout);
853 GridData gd = new GridData(GridData.FILL_BOTH);
854 editorComposite.setLayoutData(gd);
855 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
857 gd = new GridData(GridData.FILL_BOTH);
858 gd.heightHint = convertHeightInCharsToPixels(5);
859 fSyntaxColorList.setLayoutData(gd);
860 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
861 layout = new GridLayout();
862 layout.marginHeight = 0;
863 layout.marginWidth = 0;
864 layout.numColumns = 2;
865 stylesComposite.setLayout(layout);
866 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
867 label = new Label(stylesComposite, SWT.LEFT);
868 label.setText(PreferencesMessages
869 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
871 gd.horizontalAlignment = GridData.BEGINNING;
872 label.setLayoutData(gd);
873 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
874 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
875 gd = new GridData(GridData.FILL_HORIZONTAL);
876 gd.horizontalAlignment = GridData.BEGINNING;
877 foregroundColorButton.setLayoutData(gd);
878 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
879 fBoldCheckBox.setText(PreferencesMessages
880 .getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
881 gd = new GridData(GridData.FILL_HORIZONTAL);
882 gd.horizontalAlignment = GridData.BEGINNING;
883 gd.horizontalSpan = 2;
884 fBoldCheckBox.setLayoutData(gd);
885 label = new Label(colorComposite, SWT.LEFT);
886 label.setText(PreferencesMessages
887 .getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
888 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
889 Control previewer = createPreviewer(colorComposite);
890 gd = new GridData(GridData.FILL_BOTH);
891 gd.widthHint = convertWidthInCharsToPixels(20);
892 gd.heightHint = convertHeightInCharsToPixels(5);
893 previewer.setLayoutData(gd);
894 fSyntaxColorList.addSelectionListener(new SelectionListener() {
895 public void widgetDefaultSelected(SelectionEvent e) {
899 public void widgetSelected(SelectionEvent e) {
900 handleSyntaxColorListSelection();
903 foregroundColorButton.addSelectionListener(new SelectionListener() {
904 public void widgetDefaultSelected(SelectionEvent e) {
908 public void widgetSelected(SelectionEvent e) {
909 int i = fSyntaxColorList.getSelectionIndex();
910 String key = fSyntaxColorListModel[i][1];
911 PreferenceConverter.setValue(fOverlayStore, key,
912 fSyntaxForegroundColorEditor.getColorValue());
915 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
916 public void widgetDefaultSelected(SelectionEvent e) {
920 public void widgetSelected(SelectionEvent e) {
921 PreferenceConverter.setValue(fOverlayStore,
922 PreferenceConstants.EDITOR_BACKGROUND_COLOR,
923 fBackgroundColorEditor.getColorValue());
926 fBoldCheckBox.addSelectionListener(new SelectionListener() {
927 public void widgetDefaultSelected(SelectionEvent e) {
931 public void widgetSelected(SelectionEvent e) {
932 int i = fSyntaxColorList.getSelectionIndex();
933 String key = fSyntaxColorListModel[i][1];
935 .setValue(key + BOLD, fBoldCheckBox.getSelection());
938 return colorComposite;
941 private Control createPreviewer(Composite parent) {
942 Preferences coreStore = createTemporaryCorePreferenceStore();
943 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
944 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
945 IPreferenceStore store = new ChainedPreferenceStore(
946 new IPreferenceStore[] {
948 new PreferencesAdapter(
949 createTemporaryCorePreferenceStore()),
952 fPreviewViewer = new JavaSourceViewer(parent, null, null, false,
953 SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
954 JavaTextTools tools = PHPeclipsePlugin.getDefault().getJavaTextTools();
955 PHPSourceViewerConfiguration configuration = new PHPSourceViewerConfiguration(
956 tools.getColorManager(), store, null,
957 IPHPPartitions.PHP_PARTITIONING);
958 // PHPSourceViewerConfiguration configuration =new
959 // PHPSourceViewerConfiguration(fJavaTextTools, null,
960 // IPHPPartitions.PHP_PARTITIONING);
961 fPreviewViewer.configure(configuration);
963 Font font = JFaceResources
964 .getFont(PreferenceConstants.EDITOR_TEXT_FONT);
965 fPreviewViewer.getTextWidget().setFont(font);
966 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
967 fPreviewViewer.setEditable(false);
968 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
969 IDocument document = new Document(content);
970 fJavaTextTools.setupJavaDocumentPartitioner(document,
971 IPHPPartitions.PHP_PARTITIONING);
972 fPreviewViewer.setDocument(document);
973 return fPreviewViewer.getControl();
976 private Preferences createTemporaryCorePreferenceStore() {
977 Preferences result = new Preferences();
978 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
982 private Control createAppearancePage(Composite parent) {
983 Composite appearanceComposite = new Composite(parent, SWT.NONE);
984 GridLayout layout = new GridLayout();
985 layout.numColumns = 2;
986 appearanceComposite.setLayout(layout);
987 String label = PreferencesMessages
988 .getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
989 addTextField(appearanceComposite, label,
990 PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
991 label = PreferencesMessages
992 .getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
996 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN,
998 label = PreferencesMessages
999 .getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
1001 appearanceComposite,
1003 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER,
1005 label = PreferencesMessages
1006 .getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
1008 appearanceComposite,
1010 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER,
1012 label = PreferencesMessages
1013 .getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
1014 addCheckBox(appearanceComposite, label,
1015 PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
1016 label = PreferencesMessages
1017 .getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
1019 appearanceComposite,
1021 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
1023 label = PreferencesMessages
1024 .getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
1026 appearanceComposite,
1028 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
1030 label = PreferencesMessages
1031 .getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
1032 // Button master= addCheckBox(appearanceComposite, label,
1033 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
1034 label = PreferencesMessages
1035 .getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
1036 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
1037 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
1038 // createDependency(master, fStickyOccurrencesButton);
1039 Label l = new Label(appearanceComposite, SWT.LEFT);
1040 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1041 gd.horizontalSpan = 2;
1042 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1043 l.setLayoutData(gd);
1044 l = new Label(appearanceComposite, SWT.LEFT);
1045 l.setText(PreferencesMessages
1046 .getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
1047 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1048 gd.horizontalSpan = 2;
1049 l.setLayoutData(gd);
1050 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
1051 layout = new GridLayout();
1052 layout.numColumns = 2;
1053 layout.marginHeight = 0;
1054 layout.marginWidth = 0;
1055 editorComposite.setLayout(layout);
1056 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
1057 | GridData.FILL_VERTICAL);
1058 gd.horizontalSpan = 2;
1059 editorComposite.setLayoutData(gd);
1060 fAppearanceColorList = new List(editorComposite, SWT.SINGLE
1061 | SWT.V_SCROLL | SWT.BORDER);
1062 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1063 | GridData.FILL_HORIZONTAL);
1064 gd.heightHint = convertHeightInCharsToPixels(8);
1065 fAppearanceColorList.setLayoutData(gd);
1066 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
1067 layout = new GridLayout();
1068 layout.marginHeight = 0;
1069 layout.marginWidth = 0;
1070 layout.numColumns = 2;
1071 stylesComposite.setLayout(layout);
1072 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1073 l = new Label(stylesComposite, SWT.LEFT);
1074 l.setText(PreferencesMessages
1075 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
1076 gd = new GridData();
1077 gd.horizontalAlignment = GridData.BEGINNING;
1078 l.setLayoutData(gd);
1079 fAppearanceColorEditor = new ColorEditor(stylesComposite);
1080 Button foregroundColorButton = fAppearanceColorEditor.getButton();
1081 gd = new GridData(GridData.FILL_HORIZONTAL);
1082 gd.horizontalAlignment = GridData.BEGINNING;
1083 foregroundColorButton.setLayoutData(gd);
1084 fAppearanceColorList.addSelectionListener(new SelectionListener() {
1085 public void widgetDefaultSelected(SelectionEvent e) {
1089 public void widgetSelected(SelectionEvent e) {
1090 handleAppearanceColorListSelection();
1093 foregroundColorButton.addSelectionListener(new SelectionListener() {
1094 public void widgetDefaultSelected(SelectionEvent e) {
1098 public void widgetSelected(SelectionEvent e) {
1099 int i = fAppearanceColorList.getSelectionIndex();
1100 String key = fAppearanceColorListModel[i][1];
1101 PreferenceConverter.setValue(fOverlayStore, key,
1102 fAppearanceColorEditor.getColorValue());
1105 return appearanceComposite;
1108 // private Control createAnnotationsPage(Composite parent) {
1109 // Composite composite = new Composite(parent, SWT.NULL);
1110 // GridLayout layout = new GridLayout();
1111 // layout.numColumns = 2;
1112 // composite.setLayout(layout);
1113 // String text = PreferencesMessages
1114 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
1116 // addCheckBox(composite, text,
1117 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
1118 // text = PreferencesMessages
1119 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
1120 // addCheckBox(composite, text,
1121 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
1122 // addFiller(composite);
1123 // Label label = new Label(composite, SWT.LEFT);
1124 // label.setText(PreferencesMessages
1125 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
1127 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1128 // gd.horizontalSpan = 2;
1129 // label.setLayoutData(gd);
1130 // Composite editorComposite = new Composite(composite, SWT.NONE);
1131 // layout = new GridLayout();
1132 // layout.numColumns = 2;
1133 // layout.marginHeight = 0;
1134 // layout.marginWidth = 0;
1135 // editorComposite.setLayout(layout);
1136 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
1137 // GridData.FILL_VERTICAL);
1138 // gd.horizontalSpan = 2;
1139 // editorComposite.setLayoutData(gd);
1140 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
1142 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1143 // | GridData.FILL_HORIZONTAL);
1144 // gd.heightHint = convertHeightInCharsToPixels(10);
1145 // fAnnotationList.setLayoutData(gd);
1146 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
1147 // layout = new GridLayout();
1148 // layout.marginHeight = 0;
1149 // layout.marginWidth = 0;
1150 // layout.numColumns = 2;
1151 // optionsComposite.setLayout(layout);
1152 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1153 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1154 // fShowInTextCheckBox.setText(PreferencesMessages
1155 // .getString("JavaEditorPreferencePage.annotations.showInText"));
1157 // gd = new GridData(GridData.FILL_HORIZONTAL);
1158 // gd.horizontalAlignment = GridData.BEGINNING;
1159 // gd.horizontalSpan = 2;
1160 // fShowInTextCheckBox.setLayoutData(gd);
1161 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
1162 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
1163 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
1164 // gd = new GridData(GridData.FILL_HORIZONTAL);
1165 // gd.horizontalAlignment = GridData.BEGINNING;
1166 // gd.horizontalSpan = 2;
1167 // gd.horizontalIndent = 20;
1168 // fDecorationStyleCombo.setLayoutData(gd);
1169 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1170 // fHighlightInTextCheckBox.setText(PreferencesMessages
1171 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
1173 // gd = new GridData(GridData.FILL_HORIZONTAL);
1174 // gd.horizontalAlignment = GridData.BEGINNING;
1175 // gd.horizontalSpan = 2;
1176 // fHighlightInTextCheckBox.setLayoutData(gd);
1177 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1178 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
1179 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
1181 // gd = new GridData(GridData.FILL_HORIZONTAL);
1182 // gd.horizontalAlignment = GridData.BEGINNING;
1183 // gd.horizontalSpan = 2;
1184 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
1185 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1186 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
1187 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
1189 // gd = new GridData(GridData.FILL_HORIZONTAL);
1190 // gd.horizontalAlignment = GridData.BEGINNING;
1191 // gd.horizontalSpan = 2;
1192 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
1193 // label = new Label(optionsComposite, SWT.LEFT);
1194 // label.setText(PreferencesMessages
1195 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
1196 // gd = new GridData();
1197 // gd.horizontalAlignment = GridData.BEGINNING;
1198 // label.setLayoutData(gd);
1199 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
1200 // Button foregroundColorButton =
1201 // fAnnotationForegroundColorEditor.getButton();
1202 // gd = new GridData(GridData.FILL_HORIZONTAL);
1203 // gd.horizontalAlignment = GridData.BEGINNING;
1204 // foregroundColorButton.setLayoutData(gd);
1205 // fAnnotationList.addSelectionListener(new SelectionListener() {
1206 // public void widgetDefaultSelected(SelectionEvent e) {
1209 // public void widgetSelected(SelectionEvent e) {
1210 // handleAnnotationListSelection();
1213 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
1214 // public void widgetDefaultSelected(SelectionEvent e) {
1217 // public void widgetSelected(SelectionEvent e) {
1218 // int i = fAnnotationList.getSelectionIndex();
1219 // String key = fAnnotationColorListModel[i][2];
1220 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
1221 // String decorationKey = fAnnotationColorListModel[i][6];
1222 // fDecorationStyleCombo.setEnabled(decorationKey != null
1223 // && fShowInTextCheckBox.getSelection());
1226 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
1227 // public void widgetDefaultSelected(SelectionEvent e) {
1230 // public void widgetSelected(SelectionEvent e) {
1231 // int i = fAnnotationList.getSelectionIndex();
1232 // String key = fAnnotationColorListModel[i][4];
1233 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
1236 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener()
1238 // public void widgetDefaultSelected(SelectionEvent e) {
1241 // public void widgetSelected(SelectionEvent e) {
1242 // int i = fAnnotationList.getSelectionIndex();
1243 // String key = fAnnotationColorListModel[i][3];
1245 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
1248 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener()
1250 // public void widgetDefaultSelected(SelectionEvent e) {
1253 // public void widgetSelected(SelectionEvent e) {
1254 // int i = fAnnotationList.getSelectionIndex();
1255 // String key = fAnnotationColorListModel[i][5];
1257 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
1260 // foregroundColorButton.addSelectionListener(new SelectionListener() {
1261 // public void widgetDefaultSelected(SelectionEvent e) {
1264 // public void widgetSelected(SelectionEvent e) {
1265 // int i = fAnnotationList.getSelectionIndex();
1266 // String key = fAnnotationColorListModel[i][1];
1267 // PreferenceConverter.setValue(fOverlayStore, key,
1268 // fAnnotationForegroundColorEditor.getColorValue());
1271 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
1275 // public void widgetDefaultSelected(SelectionEvent e) {
1281 // public void widgetSelected(SelectionEvent e) {
1282 // int i = fAnnotationList.getSelectionIndex();
1283 // String key = fAnnotationColorListModel[i][6];
1284 // if (key != null) {
1285 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1286 // if (fAnnotationDecorationListModel[j][0]
1287 // .equals(fDecorationStyleCombo.getText())) {
1288 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1295 // return composite;
1297 private String[][] createAnnotationTypeListModel(
1298 MarkerAnnotationPreferences preferences) {
1299 ArrayList listModelItems = new ArrayList();
1300 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1302 * @see java.util.Comparator#compare(java.lang.Object,
1305 public int compare(Object o1, Object o2) {
1306 if (!(o2 instanceof AnnotationPreference))
1308 if (!(o1 instanceof AnnotationPreference))
1310 AnnotationPreference a1 = (AnnotationPreference) o1;
1311 AnnotationPreference a2 = (AnnotationPreference) o2;
1312 return Collator.getInstance().compare(a1.getPreferenceLabel(),
1313 a2.getPreferenceLabel());
1316 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1317 Iterator e = sortedPreferences.iterator();
1318 while (e.hasNext()) {
1319 AnnotationPreference info = (AnnotationPreference) e.next();
1320 listModelItems.add(new String[] { info.getPreferenceLabel(),
1321 info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1322 info.getOverviewRulerPreferenceKey(),
1323 info.getHighlightPreferenceKey(),
1324 info.getVerticalRulerPreferenceKey(),
1325 info.getTextStylePreferenceKey() });
1327 String[][] items = new String[listModelItems.size()][];
1328 listModelItems.toArray(items);
1332 private Control createTypingPage(Composite parent) {
1333 Composite composite = new Composite(parent, SWT.NONE);
1334 GridLayout layout = new GridLayout();
1335 layout.numColumns = 1;
1336 composite.setLayout(layout);
1338 // label = PreferencesMessages
1339 // .getString("JavaEditorPreferencePage.overwriteMode");
1341 // addCheckBox(composite, label,
1342 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1343 // addFiller(composite);
1345 // label = PreferencesMessages
1346 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1348 // addCheckBox(composite, label,
1349 // PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1351 // label = PreferencesMessages
1352 // .getString("JavaEditorPreferencePage.subWordNavigation");
1354 // addCheckBox(composite, label,
1355 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1356 // addFiller(composite);
1357 Group group = new Group(composite, SWT.NONE);
1358 layout = new GridLayout();
1359 layout.numColumns = 2;
1360 group.setLayout(layout);
1361 group.setText(PreferencesMessages
1362 .getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1364 label = PreferencesMessages
1365 .getString("JavaEditorPreferencePage.wrapWords");//$NON-NLS-1$
1366 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_WORDS, 1);
1368 label = PreferencesMessages
1369 .getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1370 Button button = addCheckBox(group, label,
1371 PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1373 label = PreferencesMessages
1374 .getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1375 fEscapeStringsButtonDQ = addCheckBox(group, label,
1376 PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1377 createDependency(button, fEscapeStringsButtonDQ);
1379 label = PreferencesMessages
1380 .getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1381 button = addCheckBox(group, label,
1382 PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1384 label = PreferencesMessages
1385 .getString("JavaEditorPreferencePage.escapeStringsSQ");
1387 fEscapeStringsButtonSQ = addCheckBox(group, label,
1388 PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1389 createDependency(button, fEscapeStringsButtonSQ);
1391 label = PreferencesMessages
1392 .getString("JavaEditorPreferencePage.smartPaste");
1394 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1396 label = PreferencesMessages
1397 .getString("JavaEditorPreferencePage.insertSpaceForTabs");
1399 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1401 label = PreferencesMessages
1402 .getString("JavaEditorPreferencePage.closeStringsDQ");
1404 addCheckBox(group, label,
1405 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1406 label = PreferencesMessages
1407 .getString("JavaEditorPreferencePage.closeStringsSQ");
1409 addCheckBox(group, label,
1410 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1412 label = PreferencesMessages
1413 .getString("JavaEditorPreferencePage.closeBrackets");
1415 addCheckBox(group, label,
1416 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1418 // label = PreferencesMessages
1419 // .getString("JavaEditorPreferencePage.closeBraces");
1421 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES,
1424 label = PreferencesMessages
1425 .getString("JavaEditorPreferencePage.closeJavaDocs");
1427 button = addCheckBox(group, label,
1428 PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1429 label = PreferencesMessages
1430 .getString("JavaEditorPreferencePage.formatJavaDocs");
1432 button = addCheckBox(group, label,
1433 PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
1436 // label = PreferencesMessages
1437 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1439 // fAddJavaDocTagsButton = addCheckBox(group, label,
1440 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1441 // createDependency(button, fAddJavaDocTagsButton);
1445 private void addFiller(Composite composite) {
1446 Label filler = new Label(composite, SWT.LEFT);
1447 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1448 gd.horizontalSpan = 2;
1449 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1450 filler.setLayoutData(gd);
1453 private static void indent(Control control) {
1454 GridData gridData = new GridData();
1455 gridData.horizontalIndent = 20;
1456 control.setLayoutData(gridData);
1459 private static void createDependency(final Button master,
1460 final Control slave) {
1462 master.addSelectionListener(new SelectionListener() {
1463 public void widgetSelected(SelectionEvent e) {
1464 slave.setEnabled(master.getSelection());
1467 public void widgetDefaultSelected(SelectionEvent e) {
1472 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1473 Composite completionComposite = new Composite(contentAssistComposite,
1475 GridData ccgd = new GridData();
1476 ccgd.horizontalSpan = 2;
1477 completionComposite.setLayoutData(ccgd);
1478 GridLayout ccgl = new GridLayout();
1479 ccgl.marginWidth = 0;
1480 ccgl.numColumns = 2;
1481 completionComposite.setLayout(ccgl);
1482 // SelectionListener completionSelectionListener= new SelectionAdapter()
1484 // public void widgetSelected(SelectionEvent e) {
1485 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1486 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1491 // fCompletionInsertsRadioButton= new Button(completionComposite,
1494 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1496 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1497 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1499 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1500 // SWT.RADIO | SWT.LEFT);
1501 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1503 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1504 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1507 private Control createNavigationPage(Composite parent) {
1508 Composite composite = new Composite(parent, SWT.NULL);
1509 GridLayout layout = new GridLayout();
1510 layout.numColumns = 2;
1511 composite.setLayout(layout);
1512 String text = PreferencesMessages
1513 .getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1515 fBrowserLikeLinksCheckBox = addCheckBox(composite, text,
1516 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1517 fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1518 public void widgetSelected(SelectionEvent e) {
1519 boolean state = fBrowserLikeLinksCheckBox.getSelection();
1520 fBrowserLikeLinksKeyModifierText.setEnabled(state);
1521 handleBrowserLikeLinksKeyModifierModified();
1524 public void widgetDefaultSelected(SelectionEvent e) {
1527 // Text field for modifier string
1528 text = PreferencesMessages
1529 .getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1531 fBrowserLikeLinksKeyModifierText = addTextField(composite, text,
1532 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20,
1534 fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1536 if (computeStateMask(fOverlayStore
1537 .getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) == -1) {
1538 // Fix possible illegal modifier string
1539 int stateMask = fOverlayStore
1540 .getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1541 if (stateMask == -1)
1542 fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1544 fBrowserLikeLinksKeyModifierText.setText(EditorUtility
1545 .getModifierString(stateMask));
1547 fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1548 private boolean isModifierCandidate;
1550 public void keyPressed(KeyEvent e) {
1551 isModifierCandidate = e.keyCode > 0 && e.character == 0
1552 && e.stateMask == 0;
1555 public void keyReleased(KeyEvent e) {
1556 if (isModifierCandidate && e.stateMask > 0
1557 && e.stateMask == e.stateMask && e.character == 0) {// &&
1563 String modifierString = fBrowserLikeLinksKeyModifierText
1565 Point selection = fBrowserLikeLinksKeyModifierText
1567 int i = selection.x - 1;
1569 && Character.isWhitespace(modifierString.charAt(i))) {
1572 boolean needsPrefixDelimiter = i > -1
1573 && !String.valueOf(modifierString.charAt(i))
1577 while (i < modifierString.length()
1578 && Character.isWhitespace(modifierString.charAt(i))) {
1581 boolean needsPostfixDelimiter = i < modifierString.length()
1582 && !String.valueOf(modifierString.charAt(i))
1585 String insertString;
1587 if (needsPrefixDelimiter && needsPostfixDelimiter)
1588 insertString = PreferencesMessages
1589 .getFormattedString(
1590 "JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1591 new String[] { Action
1592 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1593 else if (needsPrefixDelimiter)
1594 insertString = PreferencesMessages
1595 .getFormattedString(
1596 "JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1597 new String[] { Action
1598 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1599 else if (needsPostfixDelimiter)
1600 insertString = PreferencesMessages
1601 .getFormattedString(
1602 "JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1603 new String[] { Action
1604 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1606 insertString = Action.findModifierString(e.stateMask);
1608 fBrowserLikeLinksKeyModifierText.insert(insertString);
1613 fBrowserLikeLinksKeyModifierText
1614 .addModifyListener(new ModifyListener() {
1615 public void modifyText(ModifyEvent e) {
1616 handleBrowserLikeLinksKeyModifierModified();
1622 private void handleBrowserLikeLinksKeyModifierModified() {
1623 String modifiers = fBrowserLikeLinksKeyModifierText.getText();
1624 int stateMask = computeStateMask(modifiers);
1625 if (fBrowserLikeLinksCheckBox.getSelection()
1626 && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) {
1627 if (stateMask == -1)
1628 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(
1631 .getFormattedString(
1632 "JavaEditorPreferencePage.navigation.modifierIsNotValid", modifiers)); //$NON-NLS-1$
1634 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(
1637 .getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1640 StatusUtil.applyToStatusLine(this,
1641 fBrowserLikeLinksKeyModifierStatus);
1643 fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1644 updateStatus(fBrowserLikeLinksKeyModifierStatus);
1648 private IStatus getBrowserLikeLinksKeyModifierStatus() {
1649 if (fBrowserLikeLinksKeyModifierStatus == null)
1650 fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1651 return fBrowserLikeLinksKeyModifierStatus;
1655 * Computes the state mask for the given modifier string.
1658 * the string with the modifiers, separated by '+', '-', ';', ','
1660 * @return the state mask or -1 if the input is invalid
1662 private int computeStateMask(String modifiers) {
1663 if (modifiers == null)
1665 if (modifiers.length() == 0)
1668 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers,
1669 ",;.:+-* "); //$NON-NLS-1$
1670 while (modifierTokenizer.hasMoreTokens()) {
1671 int modifier = EditorUtility
1672 .findLocalizedModifier(modifierTokenizer.nextToken());
1673 if (modifier == 0 || (stateMask & modifier) == modifier)
1675 stateMask = stateMask | modifier;
1681 * @see PreferencePage#createContents(Composite)
1683 protected Control createContents(Composite parent) {
1684 initializeDefaultColors();
1685 fFoldingConfigurationBlock = new FoldingConfigurationBlock(
1687 fOverlayStore.load();
1688 fOverlayStore.start();
1689 TabFolder folder = new TabFolder(parent, SWT.NONE);
1690 folder.setLayout(new TabFolderLayout());
1691 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1692 TabItem item = new TabItem(folder, SWT.NONE);
1693 item.setText(PreferencesMessages
1694 .getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1695 item.setControl(createAppearancePage(folder));
1696 item = new TabItem(folder, SWT.NONE);
1697 item.setText(PreferencesMessages
1698 .getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1699 item.setControl(createSyntaxPage(folder));
1701 // item = new TabItem(folder, SWT.NONE);
1702 // item.setText(PreferencesMessages
1703 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1705 // item.setControl(createAnnotationsPage(folder));
1706 item = new TabItem(folder, SWT.NONE);
1707 item.setText(PreferencesMessages
1708 .getString("JavaEditorPreferencePage.typing.tabTitle"));
1710 item.setControl(createTypingPage(folder));
1712 item = new TabItem(folder, SWT.NONE);
1713 item.setText(PreferencesMessages
1714 .getString("JavaEditorPreferencePage.hoverTab.title"));
1716 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(
1717 this, fOverlayStore);
1718 item.setControl(fJavaEditorHoverConfigurationBlock
1719 .createControl(folder));
1720 item = new TabItem(folder, SWT.NONE);
1721 item.setText(PreferencesMessages
1722 .getString("JavaEditorPreferencePage.navigationTab.title"));
1724 item.setControl(createNavigationPage(folder));
1725 item = new TabItem(folder, SWT.NONE);
1726 item.setText(PreferencesMessages
1727 .getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1728 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1731 Dialog.applyDialogFont(folder);
1735 private void initialize() {
1737 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1738 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1739 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1741 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1742 fSyntaxColorList.select(0);
1743 handleSyntaxColorListSelection();
1747 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1748 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1749 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1751 if (fAppearanceColorList != null
1752 && !fAppearanceColorList.isDisposed()) {
1753 fAppearanceColorList.select(0);
1754 handleAppearanceColorListSelection();
1758 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1759 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1760 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1761 // public void run() {
1762 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1763 // fAnnotationList.select(0);
1764 // handleAnnotationListSelection();
1768 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1769 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1770 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1771 // public void run() {
1772 // if (fContentAssistColorList != null &&
1773 // !fContentAssistColorList.isDisposed()) {
1774 // fContentAssistColorList.select(0);
1775 // handleContentAssistColorListSelection();
1779 fFoldingConfigurationBlock.initialize();
1782 private void initializeFields() {
1783 Iterator e = fColorButtons.keySet().iterator();
1784 while (e.hasNext()) {
1785 ColorEditor c = (ColorEditor) e.next();
1786 String key = (String) fColorButtons.get(c);
1787 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1788 c.setColorValue(rgb);
1790 e = fCheckBoxes.keySet().iterator();
1791 while (e.hasNext()) {
1792 Button b = (Button) e.next();
1793 String key = (String) fCheckBoxes.get(b);
1794 b.setSelection(fOverlayStore.getBoolean(key));
1796 e = fTextFields.keySet().iterator();
1797 while (e.hasNext()) {
1798 Text t = (Text) e.next();
1799 String key = (String) fTextFields.get(t);
1800 t.setText(fOverlayStore.getString(key));
1802 RGB rgb = PreferenceConverter.getColor(fOverlayStore,
1803 PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1804 fBackgroundColorEditor.setColorValue(rgb);
1805 boolean default_ = fOverlayStore
1806 .getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1807 fBackgroundDefaultRadioButton.setSelection(default_);
1808 fBackgroundCustomRadioButton.setSelection(!default_);
1809 fBackgroundColorButton.setEnabled(!default_);
1810 boolean closeJavaDocs = fOverlayStore
1811 .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1812 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1813 fEscapeStringsButtonDQ.setEnabled(fOverlayStore
1814 .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1815 fEscapeStringsButtonSQ.setEnabled(fOverlayStore
1816 .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1817 // boolean fillMethodArguments=
1818 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1819 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1820 // boolean completionInserts=
1821 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1822 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1823 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1825 fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox
1827 // boolean markOccurrences=
1828 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1829 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1830 updateAutoactivationControls();
1833 private void initializeDefaultColors() {
1834 if (!getPreferenceStore().contains(
1835 PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1836 RGB rgb = getControl().getDisplay().getSystemColor(
1837 SWT.COLOR_LIST_BACKGROUND).getRGB();
1838 PreferenceConverter.setDefault(fOverlayStore,
1839 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1840 PreferenceConverter.setDefault(getPreferenceStore(),
1841 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1843 if (!getPreferenceStore().contains(
1844 PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1845 RGB rgb = getControl().getDisplay().getSystemColor(
1846 SWT.COLOR_LIST_FOREGROUND).getRGB();
1847 PreferenceConverter.setDefault(fOverlayStore,
1848 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1849 PreferenceConverter.setDefault(getPreferenceStore(),
1850 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1854 private void updateAutoactivationControls() {
1855 // boolean autoactivation=
1856 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1857 // fAutoInsertDelayText.setEnabled(autoactivation);
1858 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1859 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1860 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1862 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1863 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1867 * @see PreferencePage#performOk()
1869 public boolean performOk() {
1870 // fJavaEditorHoverConfigurationBlock.performOk();
1871 fFoldingConfigurationBlock.performOk();
1874 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1875 computeStateMask(fBrowserLikeLinksKeyModifierText
1877 fOverlayStore.propagate();
1878 PHPeclipsePlugin.getDefault().savePluginPreferences();
1883 * @see PreferencePage#performDefaults()
1885 protected void performDefaults() {
1886 fOverlayStore.loadDefaults();
1888 handleSyntaxColorListSelection();
1889 handleAppearanceColorListSelection();
1890 // handleAnnotationListSelection();
1891 // handleContentAssistColorListSelection();
1892 // fJavaEditorHoverConfigurationBlock.performDefaults();
1893 fFoldingConfigurationBlock.performDefaults();
1894 super.performDefaults();
1895 fPreviewViewer.invalidateTextPresentation();
1899 * @see DialogPage#dispose()
1901 public void dispose() {
1902 fFoldingConfigurationBlock.dispose();
1904 if (fJavaTextTools != null) {
1905 fJavaTextTools.dispose();
1906 fJavaTextTools = null;
1908 if (fOverlayStore != null) {
1909 fOverlayStore.stop();
1910 fOverlayStore = null;
1912 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1913 fBackgroundColor.dispose();
1917 private Button addCheckBox(Composite parent, String label, String key,
1919 Button checkBox = new Button(parent, SWT.CHECK);
1920 checkBox.setText(label);
1921 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1922 gd.horizontalIndent = indentation;
1923 gd.horizontalSpan = 2;
1924 checkBox.setLayoutData(gd);
1925 checkBox.addSelectionListener(fCheckBoxListener);
1926 fCheckBoxes.put(checkBox, key);
1930 private Text addTextField(Composite composite, String label, String key,
1931 int textLimit, int indentation, boolean isNumber) {
1932 return getTextControl(addLabelledTextField(composite, label, key,
1933 textLimit, indentation, isNumber));
1936 private static Label getLabelControl(Control[] labelledTextField) {
1937 return (Label) labelledTextField[0];
1940 private static Text getTextControl(Control[] labelledTextField) {
1941 return (Text) labelledTextField[1];
1945 * Returns an array of size 2: - first element is of type <code>Label</code>-
1946 * second element is of type <code>Text</code> Use
1947 * <code>getLabelControl</code> and <code>getTextControl</code> to get
1950 private Control[] addLabelledTextField(Composite composite, String label,
1951 String key, int textLimit, int indentation, boolean isNumber) {
1952 Label labelControl = new Label(composite, SWT.NONE);
1953 labelControl.setText(label);
1954 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1955 gd.horizontalIndent = indentation;
1956 labelControl.setLayoutData(gd);
1957 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1958 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1959 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1960 textControl.setLayoutData(gd);
1961 textControl.setTextLimit(textLimit);
1962 fTextFields.put(textControl, key);
1964 fNumberFields.add(textControl);
1965 textControl.setText("0");
1966 textControl.addModifyListener(fNumberFieldListener);
1968 textControl.addModifyListener(fTextFieldListener);
1970 return new Control[] { labelControl, textControl };
1973 private String loadPreviewContentFromFile(String filename) {
1975 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1976 StringBuffer buffer = new StringBuffer(512);
1977 BufferedReader reader = null;
1979 reader = new BufferedReader(new InputStreamReader(getClass()
1980 .getResourceAsStream(filename)));
1981 while ((line = reader.readLine()) != null) {
1982 buffer.append(line);
1983 buffer.append(separator);
1985 } catch (IOException io) {
1986 PHPeclipsePlugin.log(io);
1988 if (reader != null) {
1991 } catch (IOException e) {
1995 return buffer.toString();
1998 private void numberFieldChanged(Text textControl) {
1999 String number = textControl.getText();
2000 IStatus status = validatePositiveNumber(number);
2001 if (!status.matches(IStatus.ERROR))
2002 fOverlayStore.setValue((String) fTextFields.get(textControl),
2004 updateStatus(status);
2007 private IStatus validatePositiveNumber(String number) {
2008 StatusInfo status = new StatusInfo();
2009 if (number.length() == 0) {
2010 status.setError(PreferencesMessages
2011 .getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
2014 int value = Integer.parseInt(number);
2016 status.setError(PreferencesMessages.getFormattedString(
2017 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
2018 } catch (NumberFormatException e) {
2019 status.setError(PreferencesMessages.getFormattedString(
2020 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
2026 void updateStatus(IStatus status) {
2027 if (!status.matches(IStatus.ERROR)) {
2028 for (int i = 0; i < fNumberFields.size(); i++) {
2029 Text text = (Text) fNumberFields.get(i);
2030 IStatus s = validatePositiveNumber(text.getText());
2031 status = StatusUtil.getMoreSevere(s, status);
2035 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
2038 // StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
2040 setValid(!status.matches(IStatus.ERROR));
2041 StatusUtil.applyToStatusLine(this, status);