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;
40 import net.sourceforge.phpeclipse.ui.WebUI;
42 import org.eclipse.core.runtime.IStatus;
43 import org.eclipse.core.runtime.Preferences;
44 import org.eclipse.jface.action.Action;
45 import org.eclipse.jface.dialogs.Dialog;
46 import org.eclipse.jface.preference.IPreferenceStore;
47 import org.eclipse.jface.preference.PreferenceConverter;
48 import org.eclipse.jface.preference.PreferencePage;
49 import org.eclipse.jface.resource.JFaceResources;
50 import org.eclipse.jface.text.Document;
51 import org.eclipse.jface.text.IDocument;
52 import org.eclipse.jface.text.source.SourceViewer;
53 import org.eclipse.swt.SWT;
54 import org.eclipse.swt.events.KeyEvent;
55 import org.eclipse.swt.events.KeyListener;
56 import org.eclipse.swt.events.ModifyEvent;
57 import org.eclipse.swt.events.ModifyListener;
58 import org.eclipse.swt.events.SelectionEvent;
59 import org.eclipse.swt.events.SelectionListener;
60 import org.eclipse.swt.graphics.Color;
61 import org.eclipse.swt.graphics.Font;
62 import org.eclipse.swt.graphics.Point;
63 import org.eclipse.swt.graphics.RGB;
64 import org.eclipse.swt.layout.GridData;
65 import org.eclipse.swt.layout.GridLayout;
66 import org.eclipse.swt.layout.RowLayout;
67 import org.eclipse.swt.widgets.Button;
68 import org.eclipse.swt.widgets.Combo;
69 import org.eclipse.swt.widgets.Composite;
70 import org.eclipse.swt.widgets.Control;
71 import org.eclipse.swt.widgets.Event;
72 import org.eclipse.swt.widgets.Group;
73 import org.eclipse.swt.widgets.Label;
74 import org.eclipse.swt.widgets.Link;
75 import org.eclipse.swt.widgets.List;
76 import org.eclipse.swt.widgets.Listener;
77 import org.eclipse.swt.widgets.TabFolder;
78 import org.eclipse.swt.widgets.TabItem;
79 import org.eclipse.swt.widgets.Text;
80 import org.eclipse.ui.IWorkbench;
81 import org.eclipse.ui.IWorkbenchPreferencePage;
82 import org.eclipse.ui.PlatformUI;
83 import org.eclipse.ui.dialogs.PreferencesUtil;
84 import org.eclipse.ui.editors.text.EditorsUI;
85 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
86 import org.eclipse.ui.texteditor.AnnotationPreference;
87 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
88 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
92 * The page for setting the editor options.
94 public class JavaEditorPreferencePage extends PreferencePage implements
95 IWorkbenchPreferencePage {
96 private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
98 private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
100 private static final String DELIMITER = PreferencesMessages
101 .getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
103 /** The keys of the overlay store. */
104 public final OverlayPreferenceStore.OverlayKey[] fKeys;
106 private final String[][] fSyntaxColorListModel = new String[][] {
109 .getString("JavaEditorPreferencePage.multiLineComment"),
110 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
114 .getString("JavaEditorPreferencePage.singleLineComment"),
115 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
117 { PreferencesMessages.getString("JavaEditorPreferencePage.tags"),
118 PreferenceConstants.EDITOR_PHP_TAG_COLOR },
122 .getString("JavaEditorPreferencePage.keywords"),
123 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
126 .getString("JavaEditorPreferencePage.functionNames"),
127 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
131 .getString("JavaEditorPreferencePage.variables"),
132 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
136 .getString("JavaEditorPreferencePage.variables_dollar"),
137 PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR },
141 .getString("JavaEditorPreferencePage.constants"),
142 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
144 { PreferencesMessages.getString("JavaEditorPreferencePage.types"),
145 PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
149 .getString("JavaEditorPreferencePage.strings_dq"),
150 PreferenceConstants.EDITOR_STRING_COLOR_DQ },
153 .getString("JavaEditorPreferencePage.strings_sq"),
154 PreferenceConstants.EDITOR_STRING_COLOR_SQ },
158 .getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
161 .getString("JavaEditorPreferencePage.operators"),
162 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
166 .getString("JavaEditorPreferencePage.returnKeyword"),
167 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
168 { PreferencesMessages.getString("JavaEditorPreferencePage.braces"),
169 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR },
173 .getString("JavaEditorPreferencePage.phpDocKeywords"),
174 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
178 .getString("JavaEditorPreferencePage.phpDocHtmlTags"),
179 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
183 .getString("JavaEditorPreferencePage.phpDocLinks"),
184 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
188 .getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
191 private final String[][] fAppearanceColorListModel = new String[][] {
194 .getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
195 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
199 .getString("JavaEditorPreferencePage.currentLineHighlighColor"),
200 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
204 .getString("JavaEditorPreferencePage.printMarginColor2"),
205 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
209 .getString("JavaEditorPreferencePage.findScopeColor2"),
210 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
214 .getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
217 // private final String[][] fAnnotationColorListModel;
219 // private final String[][] fAnnotationDecorationListModel = new String[][]{
221 // PreferencesMessages
222 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
223 // AnnotationPreference.STYLE_NONE},
226 // PreferencesMessages
227 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
228 // AnnotationPreference.STYLE_SQUIGGLIES},
231 // PreferencesMessages
232 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
233 // AnnotationPreference.STYLE_UNDERLINE},
236 // PreferencesMessages
237 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
238 // AnnotationPreference.STYLE_BOX},
241 // PreferencesMessages
242 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
243 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
245 private OverlayPreferenceStore fOverlayStore;
247 private JavaTextTools fJavaTextTools;
249 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
251 private FoldingConfigurationBlock fFoldingConfigurationBlock;
253 private Map fColorButtons = new HashMap();
255 private Map fCheckBoxes = new HashMap();
257 private SelectionListener fCheckBoxListener = new SelectionListener() {
258 public void widgetDefaultSelected(SelectionEvent e) {
261 public void widgetSelected(SelectionEvent e) {
262 Button button = (Button) e.widget;
263 fOverlayStore.setValue((String) fCheckBoxes.get(button), button
268 private Map fTextFields = new HashMap();
270 private ModifyListener fTextFieldListener = new ModifyListener() {
271 public void modifyText(ModifyEvent e) {
272 Text text = (Text) e.widget;
273 fOverlayStore.setValue((String) fTextFields.get(text), text
278 private ArrayList fNumberFields = new ArrayList();
280 private ModifyListener fNumberFieldListener = new ModifyListener() {
281 public void modifyText(ModifyEvent e) {
282 numberFieldChanged((Text) e.widget);
286 private List fSyntaxColorList;
288 private List fAppearanceColorList;
290 // private List fContentAssistColorList;
291 private List fAnnotationList;
293 private ColorEditor fSyntaxForegroundColorEditor;
295 private ColorEditor fAppearanceColorEditor;
297 private ColorEditor fAnnotationForegroundColorEditor;
299 private ColorEditor fContentAssistColorEditor;
301 private ColorEditor fBackgroundColorEditor;
303 private Button fBackgroundDefaultRadioButton;
305 private Button fBackgroundCustomRadioButton;
307 private Button fBackgroundColorButton;
309 private Button fBoldCheckBox;
311 // private Button fAddJavaDocTagsButton;
313 private Button fEscapeStringsButtonDQ;
315 private Button fEscapeStringsButtonSQ;
317 // private Button fGuessMethodArgumentsButton;
318 private SourceViewer fPreviewViewer;
320 private Color fBackgroundColor;
322 private Control fAutoInsertDelayText;
324 private Control fAutoInsertJavaTriggerText;
326 private Control fAutoInsertJavaDocTriggerText;
328 private Label fAutoInsertDelayLabel;
330 private Label fAutoInsertJavaTriggerLabel;
332 private Label fAutoInsertJavaDocTriggerLabel;
334 private Button fShowInTextCheckBox;
336 private Combo fDecorationStyleCombo;
338 private Button fHighlightInTextCheckBox;
340 private Button fShowInOverviewRulerCheckBox;
342 private Button fShowInVerticalRulerCheckBox;
344 private Text fBrowserLikeLinksKeyModifierText;
346 private Button fBrowserLikeLinksCheckBox;
348 private StatusInfo fBrowserLikeLinksKeyModifierStatus;
350 // private Button fCompletionInsertsRadioButton;
351 // private Button fCompletionOverwritesRadioButton;
352 // private Button fStickyOccurrencesButton;
354 * Creates a new preference page.
356 public JavaEditorPreferencePage() {
357 setDescription(PreferencesMessages
358 .getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
359 setPreferenceStore(WebUI.getDefault().getPreferenceStore());
360 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
361 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
362 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
363 // fAnnotationColorListModel =
364 // createAnnotationTypeListModel(markerAnnotationPreferences);
367 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(
368 MarkerAnnotationPreferences preferences) {
369 ArrayList overlayKeys = new ArrayList();
370 Iterator e = preferences.getAnnotationPreferences().iterator();
371 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
372 OverlayPreferenceStore.STRING,
373 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
374 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
375 OverlayPreferenceStore.BOOLEAN,
376 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
377 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
378 OverlayPreferenceStore.STRING,
379 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
380 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
381 OverlayPreferenceStore.BOOLEAN,
382 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
383 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
384 OverlayPreferenceStore.INT,
385 PreferenceConstants.EDITOR_TAB_WIDTH));
386 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
387 OverlayPreferenceStore.STRING,
388 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
389 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
390 OverlayPreferenceStore.BOOLEAN,
391 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
392 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
393 OverlayPreferenceStore.STRING,
394 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
395 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
396 OverlayPreferenceStore.BOOLEAN,
397 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
398 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
399 OverlayPreferenceStore.STRING,
400 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
401 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
402 OverlayPreferenceStore.BOOLEAN,
403 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
405 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
406 OverlayPreferenceStore.STRING,
407 PreferenceConstants.EDITOR_PHP_TAG_COLOR));
408 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
409 OverlayPreferenceStore.BOOLEAN,
410 PreferenceConstants.EDITOR_PHP_TAG_BOLD));
411 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
412 OverlayPreferenceStore.STRING,
413 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
414 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
415 OverlayPreferenceStore.BOOLEAN,
416 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
417 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
418 OverlayPreferenceStore.STRING,
419 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
420 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
421 OverlayPreferenceStore.BOOLEAN,
422 PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
423 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
424 OverlayPreferenceStore.STRING,
425 PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR));
426 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
427 OverlayPreferenceStore.BOOLEAN,
428 PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_BOLD));
429 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
430 OverlayPreferenceStore.STRING,
431 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
432 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
433 OverlayPreferenceStore.BOOLEAN,
434 PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
435 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
436 OverlayPreferenceStore.STRING,
437 PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
438 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
439 OverlayPreferenceStore.BOOLEAN,
440 PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
442 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
443 OverlayPreferenceStore.STRING,
444 PreferenceConstants.EDITOR_STRING_COLOR_DQ));
445 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
446 OverlayPreferenceStore.BOOLEAN,
447 PreferenceConstants.EDITOR_STRING_BOLD_DQ));
448 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
449 OverlayPreferenceStore.STRING,
450 PreferenceConstants.EDITOR_STRING_COLOR_SQ));
451 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
452 OverlayPreferenceStore.BOOLEAN,
453 PreferenceConstants.EDITOR_STRING_BOLD_SQ));
454 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
455 OverlayPreferenceStore.STRING,
456 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
457 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
458 OverlayPreferenceStore.BOOLEAN,
459 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
460 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
461 OverlayPreferenceStore.STRING,
462 PreferenceConstants.EDITOR_TASK_TAG_COLOR));
463 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
464 OverlayPreferenceStore.BOOLEAN,
465 PreferenceConstants.EDITOR_TASK_TAG_BOLD));
466 // overlayKeys.add(new
467 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING_DQ,
468 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
469 // overlayKeys.add(new
470 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
471 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
472 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
473 OverlayPreferenceStore.STRING,
474 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
475 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
476 OverlayPreferenceStore.BOOLEAN,
477 PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
478 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
479 OverlayPreferenceStore.STRING,
480 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
481 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
482 OverlayPreferenceStore.BOOLEAN,
483 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
484 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
485 OverlayPreferenceStore.STRING,
486 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR));
487 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
488 OverlayPreferenceStore.BOOLEAN,
489 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_BOLD));
490 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
491 OverlayPreferenceStore.STRING,
492 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
493 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
494 OverlayPreferenceStore.BOOLEAN,
495 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
496 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
497 OverlayPreferenceStore.STRING,
498 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
499 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
500 OverlayPreferenceStore.BOOLEAN,
501 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
502 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
503 OverlayPreferenceStore.STRING,
504 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
505 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
506 OverlayPreferenceStore.BOOLEAN,
507 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
508 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
509 OverlayPreferenceStore.STRING,
510 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
511 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
512 OverlayPreferenceStore.BOOLEAN,
513 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
514 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
515 OverlayPreferenceStore.STRING,
516 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
517 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
518 OverlayPreferenceStore.BOOLEAN,
519 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
521 .add(new OverlayPreferenceStore.OverlayKey(
522 OverlayPreferenceStore.STRING,
523 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
525 .add(new OverlayPreferenceStore.OverlayKey(
526 OverlayPreferenceStore.BOOLEAN,
527 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
529 .add(new OverlayPreferenceStore.OverlayKey(
530 OverlayPreferenceStore.STRING,
531 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
533 .add(new OverlayPreferenceStore.OverlayKey(
534 OverlayPreferenceStore.INT,
535 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
537 .add(new OverlayPreferenceStore.OverlayKey(
538 OverlayPreferenceStore.BOOLEAN,
539 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
540 // overlayKeys.add(new
541 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
542 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
543 // overlayKeys.add(new
544 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
545 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
546 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
547 OverlayPreferenceStore.STRING,
548 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
549 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
550 OverlayPreferenceStore.STRING,
551 PreferenceConstants.EDITOR_LINK_COLOR));
552 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
553 OverlayPreferenceStore.BOOLEAN,
554 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
555 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
556 OverlayPreferenceStore.BOOLEAN,
557 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
559 .add(new OverlayPreferenceStore.OverlayKey(
560 OverlayPreferenceStore.BOOLEAN,
561 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
562 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
563 OverlayPreferenceStore.BOOLEAN,
564 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
565 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
566 OverlayPreferenceStore.BOOLEAN,
567 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
568 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
569 OverlayPreferenceStore.INT,
570 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
571 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
572 OverlayPreferenceStore.BOOLEAN,
573 PreferenceConstants.CODEASSIST_AUTOINSERT));
574 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
575 OverlayPreferenceStore.STRING,
576 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
577 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
578 OverlayPreferenceStore.STRING,
579 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
580 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
581 OverlayPreferenceStore.STRING,
582 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
583 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
584 OverlayPreferenceStore.STRING,
585 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
586 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
587 OverlayPreferenceStore.STRING,
588 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
589 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
590 OverlayPreferenceStore.STRING,
591 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
592 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
593 OverlayPreferenceStore.STRING,
594 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
596 .add(new OverlayPreferenceStore.OverlayKey(
597 OverlayPreferenceStore.STRING,
598 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
599 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
600 OverlayPreferenceStore.BOOLEAN,
601 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
602 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
603 OverlayPreferenceStore.BOOLEAN,
604 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
605 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
606 OverlayPreferenceStore.BOOLEAN,
607 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
608 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
609 OverlayPreferenceStore.BOOLEAN,
610 PreferenceConstants.CODEASSIST_ADDIMPORT));
611 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
612 OverlayPreferenceStore.BOOLEAN,
613 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
614 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
615 OverlayPreferenceStore.BOOLEAN,
616 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
617 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
618 OverlayPreferenceStore.BOOLEAN,
619 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
620 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
621 OverlayPreferenceStore.BOOLEAN,
622 PreferenceConstants.EDITOR_SMART_PASTE));
623 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
624 OverlayPreferenceStore.BOOLEAN,
625 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
626 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
627 OverlayPreferenceStore.BOOLEAN,
628 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
629 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
630 OverlayPreferenceStore.BOOLEAN,
631 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
633 // .add(new OverlayPreferenceStore.OverlayKey(
634 // OverlayPreferenceStore.BOOLEAN,
635 // PreferenceConstants.EDITOR_CLOSE_BRACES));
636 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
637 OverlayPreferenceStore.BOOLEAN,
638 PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
639 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
640 OverlayPreferenceStore.BOOLEAN,
641 PreferenceConstants.EDITOR_WRAP_WORDS));
642 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
643 OverlayPreferenceStore.BOOLEAN,
644 PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
645 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
646 OverlayPreferenceStore.BOOLEAN,
647 PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
648 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
649 OverlayPreferenceStore.BOOLEAN,
650 PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
651 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
652 OverlayPreferenceStore.BOOLEAN,
653 PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
655 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
656 OverlayPreferenceStore.BOOLEAN,
657 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
658 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
659 OverlayPreferenceStore.BOOLEAN,
660 PreferenceConstants.EDITOR_FORMAT_JAVADOCS));
662 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
663 OverlayPreferenceStore.BOOLEAN,
664 PreferenceConstants.EDITOR_SMART_HOME_END));
665 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
666 OverlayPreferenceStore.BOOLEAN,
667 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
668 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
669 OverlayPreferenceStore.BOOLEAN,
670 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
671 // overlayKeys.add(new
672 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
673 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
674 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
675 OverlayPreferenceStore.STRING,
676 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
677 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
678 OverlayPreferenceStore.STRING,
679 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
680 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
681 OverlayPreferenceStore.BOOLEAN,
682 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
683 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
684 OverlayPreferenceStore.STRING,
685 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
687 .add(new OverlayPreferenceStore.OverlayKey(
688 OverlayPreferenceStore.STRING,
689 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
690 while (e.hasNext()) {
691 AnnotationPreference info = (AnnotationPreference) e.next();
693 .add(new OverlayPreferenceStore.OverlayKey(
694 OverlayPreferenceStore.STRING, info
695 .getColorPreferenceKey()));
697 .add(new OverlayPreferenceStore.OverlayKey(
698 OverlayPreferenceStore.BOOLEAN, info
699 .getTextPreferenceKey()));
700 if (info.getHighlightPreferenceKey() != null)
701 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
702 OverlayPreferenceStore.BOOLEAN, info
703 .getHighlightPreferenceKey()));
704 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
705 OverlayPreferenceStore.BOOLEAN, info
706 .getOverviewRulerPreferenceKey()));
707 if (info.getVerticalRulerPreferenceKey() != null)
708 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
709 OverlayPreferenceStore.BOOLEAN, info
710 .getVerticalRulerPreferenceKey()));
711 if (info.getTextStylePreferenceKey() != null)
712 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
713 OverlayPreferenceStore.STRING, info
714 .getTextStylePreferenceKey()));
716 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
718 overlayKeys.toArray(keys);
721 * @see IWorkbenchPreferencePage#init()
724 public void init(IWorkbench workbench) {
728 * @see PreferencePage#createControl(Composite)
730 public void createControl(Composite parent) {
731 super.createControl(parent);
732 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
733 IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
736 private void handleSyntaxColorListSelection() {
737 int i = fSyntaxColorList.getSelectionIndex();
738 String key = fSyntaxColorListModel[i][1];
739 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
740 fSyntaxForegroundColorEditor.setColorValue(rgb);
741 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
744 private void handleAppearanceColorListSelection() {
745 int i = fAppearanceColorList.getSelectionIndex();
746 String key = fAppearanceColorListModel[i][1];
747 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
748 fAppearanceColorEditor.setColorValue(rgb);
751 // private void handleAnnotationListSelection() {
752 // int i = fAnnotationList.getSelectionIndex();
753 // String key = fAnnotationColorListModel[i][1];
754 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
755 // fAnnotationForegroundColorEditor.setColorValue(rgb);
756 // key = fAnnotationColorListModel[i][2];
757 // boolean showInText = fOverlayStore.getBoolean(key);
758 // fShowInTextCheckBox.setSelection(showInText);
759 // key = fAnnotationColorListModel[i][6];
760 // if (key != null) {
761 // fDecorationStyleCombo.setEnabled(showInText);
762 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
763 // String value = fOverlayStore.getString(key);
764 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
765 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
770 // fDecorationStyleCombo.setEnabled(false);
771 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); //
785 // key = fAnnotationColorListModel[i][3];
786 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
787 // key = fAnnotationColorListModel[i][4];
788 // if (key != null) {
789 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
790 // fHighlightInTextCheckBox.setEnabled(true);
792 // fHighlightInTextCheckBox.setEnabled(false);
793 // key = fAnnotationColorListModel[i][5];
794 // if (key != null) {
795 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
796 // fShowInVerticalRulerCheckBox.setEnabled(true);
798 // fShowInVerticalRulerCheckBox.setSelection(true);
799 // fShowInVerticalRulerCheckBox.setEnabled(false);
802 private Control createSyntaxPage(Composite parent) {
803 Composite colorComposite = new Composite(parent, SWT.NULL);
804 colorComposite.setLayout(new GridLayout());
805 Group backgroundComposite = new Group(colorComposite,
806 SWT.SHADOW_ETCHED_IN);
807 backgroundComposite.setLayout(new RowLayout());
808 backgroundComposite.setText(PreferencesMessages
809 .getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
810 SelectionListener backgroundSelectionListener = new SelectionListener() {
811 public void widgetSelected(SelectionEvent e) {
812 boolean custom = fBackgroundCustomRadioButton.getSelection();
813 fBackgroundColorButton.setEnabled(custom);
814 fOverlayStore.setValue(
815 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR,
819 public void widgetDefaultSelected(SelectionEvent e) {
822 fBackgroundDefaultRadioButton = new Button(backgroundComposite,
823 SWT.RADIO | SWT.LEFT);
824 fBackgroundDefaultRadioButton.setText(PreferencesMessages
825 .getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
826 fBackgroundDefaultRadioButton
827 .addSelectionListener(backgroundSelectionListener);
828 fBackgroundCustomRadioButton = new Button(backgroundComposite,
829 SWT.RADIO | SWT.LEFT);
830 fBackgroundCustomRadioButton.setText(PreferencesMessages
831 .getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
832 fBackgroundCustomRadioButton
833 .addSelectionListener(backgroundSelectionListener);
834 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
835 fBackgroundColorButton = fBackgroundColorEditor.getButton();
836 Label label = new Label(colorComposite, SWT.LEFT);
837 label.setText(PreferencesMessages
838 .getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
839 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
840 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
841 GridLayout layout = new GridLayout();
842 layout.numColumns = 2;
843 layout.marginHeight = 0;
844 layout.marginWidth = 0;
845 editorComposite.setLayout(layout);
846 GridData gd = new GridData(GridData.FILL_BOTH);
847 editorComposite.setLayoutData(gd);
848 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
850 gd = new GridData(GridData.FILL_BOTH);
851 gd.heightHint = convertHeightInCharsToPixels(5);
852 fSyntaxColorList.setLayoutData(gd);
853 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
854 layout = new GridLayout();
855 layout.marginHeight = 0;
856 layout.marginWidth = 0;
857 layout.numColumns = 2;
858 stylesComposite.setLayout(layout);
859 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
860 label = new Label(stylesComposite, SWT.LEFT);
861 label.setText(PreferencesMessages
862 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
864 gd.horizontalAlignment = GridData.BEGINNING;
865 label.setLayoutData(gd);
866 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
867 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
868 gd = new GridData(GridData.FILL_HORIZONTAL);
869 gd.horizontalAlignment = GridData.BEGINNING;
870 foregroundColorButton.setLayoutData(gd);
871 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
872 fBoldCheckBox.setText(PreferencesMessages
873 .getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
874 gd = new GridData(GridData.FILL_HORIZONTAL);
875 gd.horizontalAlignment = GridData.BEGINNING;
876 gd.horizontalSpan = 2;
877 fBoldCheckBox.setLayoutData(gd);
878 label = new Label(colorComposite, SWT.LEFT);
879 label.setText(PreferencesMessages
880 .getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
881 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
882 Control previewer = createPreviewer(colorComposite);
883 gd = new GridData(GridData.FILL_BOTH);
884 gd.widthHint = convertWidthInCharsToPixels(20);
885 gd.heightHint = convertHeightInCharsToPixels(5);
886 previewer.setLayoutData(gd);
887 fSyntaxColorList.addSelectionListener(new SelectionListener() {
888 public void widgetDefaultSelected(SelectionEvent e) {
892 public void widgetSelected(SelectionEvent e) {
893 handleSyntaxColorListSelection();
896 foregroundColorButton.addSelectionListener(new SelectionListener() {
897 public void widgetDefaultSelected(SelectionEvent e) {
901 public void widgetSelected(SelectionEvent e) {
902 int i = fSyntaxColorList.getSelectionIndex();
903 String key = fSyntaxColorListModel[i][1];
904 PreferenceConverter.setValue(fOverlayStore, key,
905 fSyntaxForegroundColorEditor.getColorValue());
908 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
909 public void widgetDefaultSelected(SelectionEvent e) {
913 public void widgetSelected(SelectionEvent e) {
914 PreferenceConverter.setValue(fOverlayStore,
915 PreferenceConstants.EDITOR_BACKGROUND_COLOR,
916 fBackgroundColorEditor.getColorValue());
919 fBoldCheckBox.addSelectionListener(new SelectionListener() {
920 public void widgetDefaultSelected(SelectionEvent e) {
924 public void widgetSelected(SelectionEvent e) {
925 int i = fSyntaxColorList.getSelectionIndex();
926 String key = fSyntaxColorListModel[i][1];
928 .setValue(key + BOLD, fBoldCheckBox.getSelection());
931 return colorComposite;
934 private Control createPreviewer(Composite parent) {
935 Preferences coreStore = createTemporaryCorePreferenceStore();
936 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
937 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
938 IPreferenceStore store = new ChainedPreferenceStore(
939 new IPreferenceStore[] {
941 new PreferencesAdapter(
942 createTemporaryCorePreferenceStore()),
945 fPreviewViewer = new JavaSourceViewer(parent, null, null, false,
946 SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
947 JavaTextTools tools = WebUI.getDefault().getJavaTextTools();
948 PHPSourceViewerConfiguration configuration = new PHPSourceViewerConfiguration(
949 tools.getColorManager(), store, null,
950 IPHPPartitions.PHP_PARTITIONING);
951 // PHPSourceViewerConfiguration configuration =new
952 // PHPSourceViewerConfiguration(fJavaTextTools, null,
953 // IPHPPartitions.PHP_PARTITIONING);
954 fPreviewViewer.configure(configuration);
956 Font font = JFaceResources
957 .getFont(PreferenceConstants.EDITOR_TEXT_FONT);
958 fPreviewViewer.getTextWidget().setFont(font);
959 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
960 fPreviewViewer.setEditable(false);
961 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
962 IDocument document = new Document(content);
963 fJavaTextTools.setupJavaDocumentPartitioner(document,
964 IPHPPartitions.PHP_PARTITIONING);
965 fPreviewViewer.setDocument(document);
966 return fPreviewViewer.getControl();
969 private Preferences createTemporaryCorePreferenceStore() {
970 Preferences result = new Preferences();
971 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
975 private Control createAppearancePage(Composite parent) {
976 Composite appearanceComposite = new Composite(parent, SWT.NONE);
977 GridLayout layout = new GridLayout();
978 layout.numColumns = 2;
979 appearanceComposite.setLayout(layout);
981 // Inserts a hyper-link to the General Editor preferences page
982 // TODO Can probably be removed post 1.5.0?
983 String label = PreferencesMessages
984 .getString("JavaEditorPreferencePage.appearanceTabLink");
985 Link link = new Link(appearanceComposite, SWT.NONE);
986 GridData gridPosition = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
987 gridPosition.horizontalSpan = 2;
988 link.setLayoutData(gridPosition);
991 link.addListener(SWT.Selection, new Listener () {
992 public void handleEvent(Event event) {
993 String u = event.text;
994 PreferencesUtil.createPreferenceDialogOn(getShell(), u, null, null);
997 String tooltip = PreferencesMessages
998 .getString("JavaEditorPreferencePage.appearanceTabTooltip");
999 link.setToolTipText(tooltip);
1001 label = PreferencesMessages
1002 .getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
1003 addTextField(appearanceComposite, label,
1004 PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
1005 label = PreferencesMessages
1006 .getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
1008 appearanceComposite,
1010 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN,
1012 label = PreferencesMessages
1013 .getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
1015 appearanceComposite,
1017 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER,
1019 label = PreferencesMessages
1020 .getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
1021 addCheckBox(appearanceComposite, label,
1022 PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
1023 label = PreferencesMessages
1024 .getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
1026 appearanceComposite,
1028 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
1030 label = PreferencesMessages
1031 .getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
1033 appearanceComposite,
1035 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
1037 label = PreferencesMessages
1038 .getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
1039 // Button master= addCheckBox(appearanceComposite, label,
1040 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
1041 label = PreferencesMessages
1042 .getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
1043 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
1044 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
1045 // createDependency(master, fStickyOccurrencesButton);
1046 Label l = new Label(appearanceComposite, SWT.LEFT);
1047 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1048 gd.horizontalSpan = 2;
1049 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1050 l.setLayoutData(gd);
1051 l = new Label(appearanceComposite, SWT.LEFT);
1052 l.setText(PreferencesMessages
1053 .getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
1054 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1055 gd.horizontalSpan = 2;
1056 l.setLayoutData(gd);
1057 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
1058 layout = new GridLayout();
1059 layout.numColumns = 2;
1060 layout.marginHeight = 0;
1061 layout.marginWidth = 0;
1062 editorComposite.setLayout(layout);
1063 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
1064 | GridData.FILL_VERTICAL);
1065 gd.horizontalSpan = 2;
1066 editorComposite.setLayoutData(gd);
1067 fAppearanceColorList = new List(editorComposite, SWT.SINGLE
1068 | SWT.V_SCROLL | SWT.BORDER);
1069 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1070 | GridData.FILL_HORIZONTAL);
1071 gd.heightHint = convertHeightInCharsToPixels(8);
1072 fAppearanceColorList.setLayoutData(gd);
1073 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
1074 layout = new GridLayout();
1075 layout.marginHeight = 0;
1076 layout.marginWidth = 0;
1077 layout.numColumns = 2;
1078 stylesComposite.setLayout(layout);
1079 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1080 l = new Label(stylesComposite, SWT.LEFT);
1081 l.setText(PreferencesMessages
1082 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
1083 gd = new GridData();
1084 gd.horizontalAlignment = GridData.BEGINNING;
1085 l.setLayoutData(gd);
1086 fAppearanceColorEditor = new ColorEditor(stylesComposite);
1087 Button foregroundColorButton = fAppearanceColorEditor.getButton();
1088 gd = new GridData(GridData.FILL_HORIZONTAL);
1089 gd.horizontalAlignment = GridData.BEGINNING;
1090 foregroundColorButton.setLayoutData(gd);
1091 fAppearanceColorList.addSelectionListener(new SelectionListener() {
1092 public void widgetDefaultSelected(SelectionEvent e) {
1096 public void widgetSelected(SelectionEvent e) {
1097 handleAppearanceColorListSelection();
1100 foregroundColorButton.addSelectionListener(new SelectionListener() {
1101 public void widgetDefaultSelected(SelectionEvent e) {
1105 public void widgetSelected(SelectionEvent e) {
1106 int i = fAppearanceColorList.getSelectionIndex();
1107 String key = fAppearanceColorListModel[i][1];
1108 PreferenceConverter.setValue(fOverlayStore, key,
1109 fAppearanceColorEditor.getColorValue());
1112 return appearanceComposite;
1115 // private Control createAnnotationsPage(Composite parent) {
1116 // Composite composite = new Composite(parent, SWT.NULL);
1117 // GridLayout layout = new GridLayout();
1118 // layout.numColumns = 2;
1119 // composite.setLayout(layout);
1120 // String text = PreferencesMessages
1121 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
1123 // addCheckBox(composite, text,
1124 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
1125 // text = PreferencesMessages
1126 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
1127 // addCheckBox(composite, text,
1128 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
1129 // addFiller(composite);
1130 // Label label = new Label(composite, SWT.LEFT);
1131 // label.setText(PreferencesMessages
1132 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
1134 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1135 // gd.horizontalSpan = 2;
1136 // label.setLayoutData(gd);
1137 // Composite editorComposite = new Composite(composite, SWT.NONE);
1138 // layout = new GridLayout();
1139 // layout.numColumns = 2;
1140 // layout.marginHeight = 0;
1141 // layout.marginWidth = 0;
1142 // editorComposite.setLayout(layout);
1143 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
1144 // GridData.FILL_VERTICAL);
1145 // gd.horizontalSpan = 2;
1146 // editorComposite.setLayoutData(gd);
1147 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
1149 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1150 // | GridData.FILL_HORIZONTAL);
1151 // gd.heightHint = convertHeightInCharsToPixels(10);
1152 // fAnnotationList.setLayoutData(gd);
1153 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
1154 // layout = new GridLayout();
1155 // layout.marginHeight = 0;
1156 // layout.marginWidth = 0;
1157 // layout.numColumns = 2;
1158 // optionsComposite.setLayout(layout);
1159 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1160 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1161 // fShowInTextCheckBox.setText(PreferencesMessages
1162 // .getString("JavaEditorPreferencePage.annotations.showInText"));
1164 // gd = new GridData(GridData.FILL_HORIZONTAL);
1165 // gd.horizontalAlignment = GridData.BEGINNING;
1166 // gd.horizontalSpan = 2;
1167 // fShowInTextCheckBox.setLayoutData(gd);
1168 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
1169 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
1170 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
1171 // gd = new GridData(GridData.FILL_HORIZONTAL);
1172 // gd.horizontalAlignment = GridData.BEGINNING;
1173 // gd.horizontalSpan = 2;
1174 // gd.horizontalIndent = 20;
1175 // fDecorationStyleCombo.setLayoutData(gd);
1176 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1177 // fHighlightInTextCheckBox.setText(PreferencesMessages
1178 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
1180 // gd = new GridData(GridData.FILL_HORIZONTAL);
1181 // gd.horizontalAlignment = GridData.BEGINNING;
1182 // gd.horizontalSpan = 2;
1183 // fHighlightInTextCheckBox.setLayoutData(gd);
1184 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1185 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
1186 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
1188 // gd = new GridData(GridData.FILL_HORIZONTAL);
1189 // gd.horizontalAlignment = GridData.BEGINNING;
1190 // gd.horizontalSpan = 2;
1191 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
1192 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1193 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
1194 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
1196 // gd = new GridData(GridData.FILL_HORIZONTAL);
1197 // gd.horizontalAlignment = GridData.BEGINNING;
1198 // gd.horizontalSpan = 2;
1199 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
1200 // label = new Label(optionsComposite, SWT.LEFT);
1201 // label.setText(PreferencesMessages
1202 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
1203 // gd = new GridData();
1204 // gd.horizontalAlignment = GridData.BEGINNING;
1205 // label.setLayoutData(gd);
1206 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
1207 // Button foregroundColorButton =
1208 // fAnnotationForegroundColorEditor.getButton();
1209 // gd = new GridData(GridData.FILL_HORIZONTAL);
1210 // gd.horizontalAlignment = GridData.BEGINNING;
1211 // foregroundColorButton.setLayoutData(gd);
1212 // fAnnotationList.addSelectionListener(new SelectionListener() {
1213 // public void widgetDefaultSelected(SelectionEvent e) {
1216 // public void widgetSelected(SelectionEvent e) {
1217 // handleAnnotationListSelection();
1220 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
1221 // public void widgetDefaultSelected(SelectionEvent e) {
1224 // public void widgetSelected(SelectionEvent e) {
1225 // int i = fAnnotationList.getSelectionIndex();
1226 // String key = fAnnotationColorListModel[i][2];
1227 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
1228 // String decorationKey = fAnnotationColorListModel[i][6];
1229 // fDecorationStyleCombo.setEnabled(decorationKey != null
1230 // && fShowInTextCheckBox.getSelection());
1233 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
1234 // public void widgetDefaultSelected(SelectionEvent e) {
1237 // public void widgetSelected(SelectionEvent e) {
1238 // int i = fAnnotationList.getSelectionIndex();
1239 // String key = fAnnotationColorListModel[i][4];
1240 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
1243 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener()
1245 // public void widgetDefaultSelected(SelectionEvent e) {
1248 // public void widgetSelected(SelectionEvent e) {
1249 // int i = fAnnotationList.getSelectionIndex();
1250 // String key = fAnnotationColorListModel[i][3];
1252 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
1255 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener()
1257 // public void widgetDefaultSelected(SelectionEvent e) {
1260 // public void widgetSelected(SelectionEvent e) {
1261 // int i = fAnnotationList.getSelectionIndex();
1262 // String key = fAnnotationColorListModel[i][5];
1264 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
1267 // foregroundColorButton.addSelectionListener(new SelectionListener() {
1268 // public void widgetDefaultSelected(SelectionEvent e) {
1271 // public void widgetSelected(SelectionEvent e) {
1272 // int i = fAnnotationList.getSelectionIndex();
1273 // String key = fAnnotationColorListModel[i][1];
1274 // PreferenceConverter.setValue(fOverlayStore, key,
1275 // fAnnotationForegroundColorEditor.getColorValue());
1278 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
1282 // public void widgetDefaultSelected(SelectionEvent e) {
1288 // public void widgetSelected(SelectionEvent e) {
1289 // int i = fAnnotationList.getSelectionIndex();
1290 // String key = fAnnotationColorListModel[i][6];
1291 // if (key != null) {
1292 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1293 // if (fAnnotationDecorationListModel[j][0]
1294 // .equals(fDecorationStyleCombo.getText())) {
1295 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1302 // return composite;
1304 private String[][] createAnnotationTypeListModel(
1305 MarkerAnnotationPreferences preferences) {
1306 ArrayList listModelItems = new ArrayList();
1307 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1309 * @see java.util.Comparator#compare(java.lang.Object,
1312 public int compare(Object o1, Object o2) {
1313 if (!(o2 instanceof AnnotationPreference))
1315 if (!(o1 instanceof AnnotationPreference))
1317 AnnotationPreference a1 = (AnnotationPreference) o1;
1318 AnnotationPreference a2 = (AnnotationPreference) o2;
1319 return Collator.getInstance().compare(a1.getPreferenceLabel(),
1320 a2.getPreferenceLabel());
1323 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1324 Iterator e = sortedPreferences.iterator();
1325 while (e.hasNext()) {
1326 AnnotationPreference info = (AnnotationPreference) e.next();
1327 listModelItems.add(new String[] { info.getPreferenceLabel(),
1328 info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1329 info.getOverviewRulerPreferenceKey(),
1330 info.getHighlightPreferenceKey(),
1331 info.getVerticalRulerPreferenceKey(),
1332 info.getTextStylePreferenceKey() });
1334 String[][] items = new String[listModelItems.size()][];
1335 listModelItems.toArray(items);
1339 private Control createTypingPage(Composite parent) {
1340 Composite composite = new Composite(parent, SWT.NONE);
1341 GridLayout layout = new GridLayout();
1342 layout.numColumns = 1;
1343 composite.setLayout(layout);
1345 // label = PreferencesMessages
1346 // .getString("JavaEditorPreferencePage.overwriteMode");
1348 // addCheckBox(composite, label,
1349 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1350 // addFiller(composite);
1352 // label = PreferencesMessages
1353 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1355 // addCheckBox(composite, label,
1356 // PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1358 // label = PreferencesMessages
1359 // .getString("JavaEditorPreferencePage.subWordNavigation");
1361 // addCheckBox(composite, label,
1362 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1363 // addFiller(composite);
1364 Group group = new Group(composite, SWT.NONE);
1365 layout = new GridLayout();
1366 layout.numColumns = 2;
1367 group.setLayout(layout);
1368 group.setText(PreferencesMessages
1369 .getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1371 label = PreferencesMessages
1372 .getString("JavaEditorPreferencePage.wrapWords");//$NON-NLS-1$
1373 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_WORDS, 1);
1375 label = PreferencesMessages
1376 .getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1377 Button button = addCheckBox(group, label,
1378 PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1380 label = PreferencesMessages
1381 .getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1382 fEscapeStringsButtonDQ = addCheckBox(group, label,
1383 PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1384 createDependency(button, fEscapeStringsButtonDQ);
1386 label = PreferencesMessages
1387 .getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1388 button = addCheckBox(group, label,
1389 PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1391 label = PreferencesMessages
1392 .getString("JavaEditorPreferencePage.escapeStringsSQ");
1394 fEscapeStringsButtonSQ = addCheckBox(group, label,
1395 PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1396 createDependency(button, fEscapeStringsButtonSQ);
1398 label = PreferencesMessages
1399 .getString("JavaEditorPreferencePage.smartPaste");
1401 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1403 label = PreferencesMessages
1404 .getString("JavaEditorPreferencePage.insertSpaceForTabs");
1406 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1408 label = PreferencesMessages
1409 .getString("JavaEditorPreferencePage.closeStringsDQ");
1411 addCheckBox(group, label,
1412 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1413 label = PreferencesMessages
1414 .getString("JavaEditorPreferencePage.closeStringsSQ");
1416 addCheckBox(group, label,
1417 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1419 label = PreferencesMessages
1420 .getString("JavaEditorPreferencePage.closeBrackets");
1422 addCheckBox(group, label,
1423 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1425 // label = PreferencesMessages
1426 // .getString("JavaEditorPreferencePage.closeBraces");
1428 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES,
1431 label = PreferencesMessages
1432 .getString("JavaEditorPreferencePage.closeJavaDocs");
1434 button = addCheckBox(group, label,
1435 PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1436 label = PreferencesMessages
1437 .getString("JavaEditorPreferencePage.formatJavaDocs");
1439 button = addCheckBox(group, label,
1440 PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
1443 // label = PreferencesMessages
1444 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1446 // fAddJavaDocTagsButton = addCheckBox(group, label,
1447 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1448 // createDependency(button, fAddJavaDocTagsButton);
1452 private void addFiller(Composite composite) {
1453 Label filler = new Label(composite, SWT.LEFT);
1454 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1455 gd.horizontalSpan = 2;
1456 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1457 filler.setLayoutData(gd);
1460 private static void indent(Control control) {
1461 GridData gridData = new GridData();
1462 gridData.horizontalIndent = 20;
1463 control.setLayoutData(gridData);
1466 private static void createDependency(final Button master,
1467 final Control slave) {
1469 master.addSelectionListener(new SelectionListener() {
1470 public void widgetSelected(SelectionEvent e) {
1471 slave.setEnabled(master.getSelection());
1474 public void widgetDefaultSelected(SelectionEvent e) {
1479 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1480 Composite completionComposite = new Composite(contentAssistComposite,
1482 GridData ccgd = new GridData();
1483 ccgd.horizontalSpan = 2;
1484 completionComposite.setLayoutData(ccgd);
1485 GridLayout ccgl = new GridLayout();
1486 ccgl.marginWidth = 0;
1487 ccgl.numColumns = 2;
1488 completionComposite.setLayout(ccgl);
1489 // SelectionListener completionSelectionListener= new SelectionAdapter()
1491 // public void widgetSelected(SelectionEvent e) {
1492 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1493 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1498 // fCompletionInsertsRadioButton= new Button(completionComposite,
1501 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1503 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1504 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1506 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1507 // SWT.RADIO | SWT.LEFT);
1508 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1510 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1511 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1514 private Control createNavigationPage(Composite parent) {
1515 Composite composite = new Composite(parent, SWT.NULL);
1516 GridLayout layout = new GridLayout();
1517 layout.numColumns = 2;
1518 composite.setLayout(layout);
1519 String text = PreferencesMessages
1520 .getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1522 fBrowserLikeLinksCheckBox = addCheckBox(composite, text,
1523 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1524 fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1525 public void widgetSelected(SelectionEvent e) {
1526 boolean state = fBrowserLikeLinksCheckBox.getSelection();
1527 fBrowserLikeLinksKeyModifierText.setEnabled(state);
1528 handleBrowserLikeLinksKeyModifierModified();
1531 public void widgetDefaultSelected(SelectionEvent e) {
1534 // Text field for modifier string
1535 text = PreferencesMessages
1536 .getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1538 fBrowserLikeLinksKeyModifierText = addTextField(composite, text,
1539 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20,
1541 fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1543 if (computeStateMask(fOverlayStore
1544 .getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) == -1) {
1545 // Fix possible illegal modifier string
1546 int stateMask = fOverlayStore
1547 .getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1548 if (stateMask == -1)
1549 fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1551 fBrowserLikeLinksKeyModifierText.setText(EditorUtility
1552 .getModifierString(stateMask));
1554 fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1555 private boolean isModifierCandidate;
1557 public void keyPressed(KeyEvent e) {
1558 isModifierCandidate = e.keyCode > 0 && e.character == 0
1559 && e.stateMask == 0;
1562 public void keyReleased(KeyEvent e) {
1563 if (isModifierCandidate && e.stateMask > 0
1564 && e.stateMask == e.stateMask && e.character == 0) {// &&
1570 String modifierString = fBrowserLikeLinksKeyModifierText
1572 Point selection = fBrowserLikeLinksKeyModifierText
1574 int i = selection.x - 1;
1576 && Character.isWhitespace(modifierString.charAt(i))) {
1579 boolean needsPrefixDelimiter = i > -1
1580 && !String.valueOf(modifierString.charAt(i))
1584 while (i < modifierString.length()
1585 && Character.isWhitespace(modifierString.charAt(i))) {
1588 boolean needsPostfixDelimiter = i < modifierString.length()
1589 && !String.valueOf(modifierString.charAt(i))
1592 String insertString;
1594 if (needsPrefixDelimiter && needsPostfixDelimiter)
1595 insertString = PreferencesMessages
1596 .getFormattedString(
1597 "JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1598 new String[] { Action
1599 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1600 else if (needsPrefixDelimiter)
1601 insertString = PreferencesMessages
1602 .getFormattedString(
1603 "JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1604 new String[] { Action
1605 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1606 else if (needsPostfixDelimiter)
1607 insertString = PreferencesMessages
1608 .getFormattedString(
1609 "JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1610 new String[] { Action
1611 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1613 insertString = Action.findModifierString(e.stateMask);
1615 fBrowserLikeLinksKeyModifierText.insert(insertString);
1620 fBrowserLikeLinksKeyModifierText
1621 .addModifyListener(new ModifyListener() {
1622 public void modifyText(ModifyEvent e) {
1623 handleBrowserLikeLinksKeyModifierModified();
1629 private void handleBrowserLikeLinksKeyModifierModified() {
1630 String modifiers = fBrowserLikeLinksKeyModifierText.getText();
1631 int stateMask = computeStateMask(modifiers);
1632 if (fBrowserLikeLinksCheckBox.getSelection()
1633 && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) {
1634 if (stateMask == -1)
1635 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(
1638 .getFormattedString(
1639 "JavaEditorPreferencePage.navigation.modifierIsNotValid", modifiers)); //$NON-NLS-1$
1641 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(
1644 .getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1647 StatusUtil.applyToStatusLine(this,
1648 fBrowserLikeLinksKeyModifierStatus);
1650 fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1651 updateStatus(fBrowserLikeLinksKeyModifierStatus);
1655 private IStatus getBrowserLikeLinksKeyModifierStatus() {
1656 if (fBrowserLikeLinksKeyModifierStatus == null)
1657 fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1658 return fBrowserLikeLinksKeyModifierStatus;
1662 * Computes the state mask for the given modifier string.
1665 * the string with the modifiers, separated by '+', '-', ';', ','
1667 * @return the state mask or -1 if the input is invalid
1669 private int computeStateMask(String modifiers) {
1670 if (modifiers == null)
1672 if (modifiers.length() == 0)
1675 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers,
1676 ",;.:+-* "); //$NON-NLS-1$
1677 while (modifierTokenizer.hasMoreTokens()) {
1678 int modifier = EditorUtility
1679 .findLocalizedModifier(modifierTokenizer.nextToken());
1680 if (modifier == 0 || (stateMask & modifier) == modifier)
1682 stateMask = stateMask | modifier;
1688 * @see PreferencePage#createContents(Composite)
1690 protected Control createContents(Composite parent) {
1691 initializeDefaultColors();
1692 fFoldingConfigurationBlock = new FoldingConfigurationBlock(
1694 fOverlayStore.load();
1695 fOverlayStore.start();
1696 TabFolder folder = new TabFolder(parent, SWT.NONE);
1697 folder.setLayout(new TabFolderLayout());
1698 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1699 TabItem item = new TabItem(folder, SWT.NONE);
1700 item.setText(PreferencesMessages
1701 .getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1702 item.setControl(createAppearancePage(folder));
1703 item = new TabItem(folder, SWT.NONE);
1704 item.setText(PreferencesMessages
1705 .getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1706 item.setControl(createSyntaxPage(folder));
1708 // item = new TabItem(folder, SWT.NONE);
1709 // item.setText(PreferencesMessages
1710 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1712 // item.setControl(createAnnotationsPage(folder));
1713 item = new TabItem(folder, SWT.NONE);
1714 item.setText(PreferencesMessages
1715 .getString("JavaEditorPreferencePage.typing.tabTitle"));
1717 item.setControl(createTypingPage(folder));
1719 item = new TabItem(folder, SWT.NONE);
1720 item.setText(PreferencesMessages
1721 .getString("JavaEditorPreferencePage.hoverTab.title"));
1723 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(
1724 this, fOverlayStore);
1725 item.setControl(fJavaEditorHoverConfigurationBlock
1726 .createControl(folder));
1727 item = new TabItem(folder, SWT.NONE);
1728 item.setText(PreferencesMessages
1729 .getString("JavaEditorPreferencePage.navigationTab.title"));
1731 item.setControl(createNavigationPage(folder));
1732 item = new TabItem(folder, SWT.NONE);
1733 item.setText(PreferencesMessages
1734 .getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1735 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1738 Dialog.applyDialogFont(folder);
1742 private void initialize() {
1744 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1745 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1746 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1748 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1749 fSyntaxColorList.select(0);
1750 handleSyntaxColorListSelection();
1754 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1755 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1756 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1758 if (fAppearanceColorList != null
1759 && !fAppearanceColorList.isDisposed()) {
1760 fAppearanceColorList.select(0);
1761 handleAppearanceColorListSelection();
1765 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1766 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1767 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1768 // public void run() {
1769 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1770 // fAnnotationList.select(0);
1771 // handleAnnotationListSelection();
1775 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1776 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1777 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1778 // public void run() {
1779 // if (fContentAssistColorList != null &&
1780 // !fContentAssistColorList.isDisposed()) {
1781 // fContentAssistColorList.select(0);
1782 // handleContentAssistColorListSelection();
1786 fFoldingConfigurationBlock.initialize();
1789 private void initializeFields() {
1790 Iterator e = fColorButtons.keySet().iterator();
1791 while (e.hasNext()) {
1792 ColorEditor c = (ColorEditor) e.next();
1793 String key = (String) fColorButtons.get(c);
1794 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1795 c.setColorValue(rgb);
1797 e = fCheckBoxes.keySet().iterator();
1798 while (e.hasNext()) {
1799 Button b = (Button) e.next();
1800 String key = (String) fCheckBoxes.get(b);
1801 b.setSelection(fOverlayStore.getBoolean(key));
1803 e = fTextFields.keySet().iterator();
1804 while (e.hasNext()) {
1805 Text t = (Text) e.next();
1806 String key = (String) fTextFields.get(t);
1807 t.setText(fOverlayStore.getString(key));
1809 RGB rgb = PreferenceConverter.getColor(fOverlayStore,
1810 PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1811 fBackgroundColorEditor.setColorValue(rgb);
1812 boolean default_ = fOverlayStore
1813 .getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1814 fBackgroundDefaultRadioButton.setSelection(default_);
1815 fBackgroundCustomRadioButton.setSelection(!default_);
1816 fBackgroundColorButton.setEnabled(!default_);
1817 boolean closeJavaDocs = fOverlayStore
1818 .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1819 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1820 fEscapeStringsButtonDQ.setEnabled(fOverlayStore
1821 .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1822 fEscapeStringsButtonSQ.setEnabled(fOverlayStore
1823 .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1824 // boolean fillMethodArguments=
1825 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1826 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1827 // boolean completionInserts=
1828 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1829 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1830 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1832 fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox
1834 // boolean markOccurrences=
1835 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1836 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1837 updateAutoactivationControls();
1840 private void initializeDefaultColors() {
1841 if (!getPreferenceStore().contains(
1842 PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1843 RGB rgb = getControl().getDisplay().getSystemColor(
1844 SWT.COLOR_LIST_BACKGROUND).getRGB();
1845 PreferenceConverter.setDefault(fOverlayStore,
1846 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1847 PreferenceConverter.setDefault(getPreferenceStore(),
1848 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1850 if (!getPreferenceStore().contains(
1851 PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1852 RGB rgb = getControl().getDisplay().getSystemColor(
1853 SWT.COLOR_LIST_FOREGROUND).getRGB();
1854 PreferenceConverter.setDefault(fOverlayStore,
1855 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1856 PreferenceConverter.setDefault(getPreferenceStore(),
1857 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1861 private void updateAutoactivationControls() {
1862 // boolean autoactivation=
1863 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1864 // fAutoInsertDelayText.setEnabled(autoactivation);
1865 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1866 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1867 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1869 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1870 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1874 * @see PreferencePage#performOk()
1876 public boolean performOk() {
1877 // fJavaEditorHoverConfigurationBlock.performOk();
1878 fFoldingConfigurationBlock.performOk();
1881 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1882 computeStateMask(fBrowserLikeLinksKeyModifierText
1884 fOverlayStore.propagate();
1885 WebUI.getDefault().savePluginPreferences();
1890 * @see PreferencePage#performDefaults()
1892 protected void performDefaults() {
1893 fOverlayStore.loadDefaults();
1895 handleSyntaxColorListSelection();
1896 handleAppearanceColorListSelection();
1897 // handleAnnotationListSelection();
1898 // handleContentAssistColorListSelection();
1899 // fJavaEditorHoverConfigurationBlock.performDefaults();
1900 fFoldingConfigurationBlock.performDefaults();
1901 super.performDefaults();
1902 fPreviewViewer.invalidateTextPresentation();
1906 * @see DialogPage#dispose()
1908 public void dispose() {
1909 fFoldingConfigurationBlock.dispose();
1911 if (fJavaTextTools != null) {
1912 fJavaTextTools.dispose();
1913 fJavaTextTools = null;
1915 if (fOverlayStore != null) {
1916 fOverlayStore.stop();
1917 fOverlayStore = null;
1919 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1920 fBackgroundColor.dispose();
1924 private Button addCheckBox(Composite parent, String label, String key,
1926 Button checkBox = new Button(parent, SWT.CHECK);
1927 checkBox.setText(label);
1928 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1929 gd.horizontalIndent = indentation;
1930 gd.horizontalSpan = 2;
1931 checkBox.setLayoutData(gd);
1932 checkBox.addSelectionListener(fCheckBoxListener);
1933 fCheckBoxes.put(checkBox, key);
1937 private Text addTextField(Composite composite, String label, String key,
1938 int textLimit, int indentation, boolean isNumber) {
1939 return getTextControl(addLabelledTextField(composite, label, key,
1940 textLimit, indentation, isNumber));
1943 private static Label getLabelControl(Control[] labelledTextField) {
1944 return (Label) labelledTextField[0];
1947 private static Text getTextControl(Control[] labelledTextField) {
1948 return (Text) labelledTextField[1];
1952 * Returns an array of size 2: - first element is of type <code>Label</code>-
1953 * second element is of type <code>Text</code> Use
1954 * <code>getLabelControl</code> and <code>getTextControl</code> to get
1957 private Control[] addLabelledTextField(Composite composite, String label,
1958 String key, int textLimit, int indentation, boolean isNumber) {
1959 Label labelControl = new Label(composite, SWT.NONE);
1960 labelControl.setText(label);
1961 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1962 gd.horizontalIndent = indentation;
1963 labelControl.setLayoutData(gd);
1964 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1965 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1966 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1967 textControl.setLayoutData(gd);
1968 textControl.setTextLimit(textLimit);
1969 fTextFields.put(textControl, key);
1971 fNumberFields.add(textControl);
1972 textControl.setText("0");
1973 textControl.addModifyListener(fNumberFieldListener);
1975 textControl.addModifyListener(fTextFieldListener);
1977 return new Control[] { labelControl, textControl };
1980 private String loadPreviewContentFromFile(String filename) {
1982 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1983 StringBuffer buffer = new StringBuffer(512);
1984 BufferedReader reader = null;
1986 reader = new BufferedReader(new InputStreamReader(getClass()
1987 .getResourceAsStream(filename)));
1988 while ((line = reader.readLine()) != null) {
1989 buffer.append(line);
1990 buffer.append(separator);
1992 } catch (IOException io) {
1995 if (reader != null) {
1998 } catch (IOException e) {
2002 return buffer.toString();
2005 private void numberFieldChanged(Text textControl) {
2006 String number = textControl.getText();
2007 IStatus status = validatePositiveNumber(number);
2008 if (!status.matches(IStatus.ERROR))
2009 fOverlayStore.setValue((String) fTextFields.get(textControl),
2011 updateStatus(status);
2014 private IStatus validatePositiveNumber(String number) {
2015 StatusInfo status = new StatusInfo();
2016 if (number.length() == 0) {
2017 status.setError(PreferencesMessages
2018 .getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
2021 int value = Integer.parseInt(number);
2023 status.setError(PreferencesMessages.getFormattedString(
2024 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
2025 } catch (NumberFormatException e) {
2026 status.setError(PreferencesMessages.getFormattedString(
2027 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
2033 void updateStatus(IStatus status) {
2034 if (!status.matches(IStatus.ERROR)) {
2035 for (int i = 0; i < fNumberFields.size(); i++) {
2036 Text text = (Text) fNumberFields.get(i);
2037 IStatus s = validatePositiveNumber(text.getText());
2038 status = StatusUtil.getMoreSevere(s, status);
2042 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
2045 // StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
2047 setValid(!status.matches(IStatus.ERROR));
2048 StatusUtil.applyToStatusLine(this, status);