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.Event;
71 import org.eclipse.swt.widgets.Group;
72 import org.eclipse.swt.widgets.Label;
73 import org.eclipse.swt.widgets.Link;
74 import org.eclipse.swt.widgets.List;
75 import org.eclipse.swt.widgets.Listener;
76 import org.eclipse.swt.widgets.TabFolder;
77 import org.eclipse.swt.widgets.TabItem;
78 import org.eclipse.swt.widgets.Text;
79 import org.eclipse.ui.IWorkbench;
80 import org.eclipse.ui.IWorkbenchPreferencePage;
81 import org.eclipse.ui.PlatformUI;
82 import org.eclipse.ui.dialogs.PreferencesUtil;
83 import org.eclipse.ui.editors.text.EditorsUI;
84 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
85 import org.eclipse.ui.texteditor.AnnotationPreference;
86 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
87 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
91 * The page for setting the editor options.
93 public class JavaEditorPreferencePage extends PreferencePage implements
94 IWorkbenchPreferencePage {
95 private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
97 private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
99 private static final String DELIMITER = PreferencesMessages
100 .getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
102 /** The keys of the overlay store. */
103 public final OverlayPreferenceStore.OverlayKey[] fKeys;
105 private final String[][] fSyntaxColorListModel = new String[][] {
108 .getString("JavaEditorPreferencePage.multiLineComment"),
109 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
113 .getString("JavaEditorPreferencePage.singleLineComment"),
114 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
116 { PreferencesMessages.getString("JavaEditorPreferencePage.tags"),
117 PreferenceConstants.EDITOR_PHP_TAG_COLOR },
121 .getString("JavaEditorPreferencePage.keywords"),
122 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
125 .getString("JavaEditorPreferencePage.functionNames"),
126 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
130 .getString("JavaEditorPreferencePage.variables"),
131 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
135 .getString("JavaEditorPreferencePage.variables_dollar"),
136 PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR },
140 .getString("JavaEditorPreferencePage.constants"),
141 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
143 { PreferencesMessages.getString("JavaEditorPreferencePage.types"),
144 PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
148 .getString("JavaEditorPreferencePage.strings_dq"),
149 PreferenceConstants.EDITOR_STRING_COLOR_DQ },
152 .getString("JavaEditorPreferencePage.strings_sq"),
153 PreferenceConstants.EDITOR_STRING_COLOR_SQ },
157 .getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
160 .getString("JavaEditorPreferencePage.operators"),
161 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
165 .getString("JavaEditorPreferencePage.returnKeyword"),
166 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
167 { PreferencesMessages.getString("JavaEditorPreferencePage.braces"),
168 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR },
172 .getString("JavaEditorPreferencePage.phpDocKeywords"),
173 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
177 .getString("JavaEditorPreferencePage.phpDocHtmlTags"),
178 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
182 .getString("JavaEditorPreferencePage.phpDocLinks"),
183 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
187 .getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
190 private final String[][] fAppearanceColorListModel = new String[][] {
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;
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));
561 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
562 OverlayPreferenceStore.BOOLEAN,
563 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
564 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
565 OverlayPreferenceStore.BOOLEAN,
566 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
567 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
568 OverlayPreferenceStore.INT,
569 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
570 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
571 OverlayPreferenceStore.BOOLEAN,
572 PreferenceConstants.CODEASSIST_AUTOINSERT));
573 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
574 OverlayPreferenceStore.STRING,
575 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
576 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
577 OverlayPreferenceStore.STRING,
578 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
579 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
580 OverlayPreferenceStore.STRING,
581 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
582 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
583 OverlayPreferenceStore.STRING,
584 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
585 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
586 OverlayPreferenceStore.STRING,
587 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
588 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
589 OverlayPreferenceStore.STRING,
590 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
591 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
592 OverlayPreferenceStore.STRING,
593 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
595 .add(new OverlayPreferenceStore.OverlayKey(
596 OverlayPreferenceStore.STRING,
597 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
598 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
599 OverlayPreferenceStore.BOOLEAN,
600 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
601 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
602 OverlayPreferenceStore.BOOLEAN,
603 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
604 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
605 OverlayPreferenceStore.BOOLEAN,
606 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
607 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
608 OverlayPreferenceStore.BOOLEAN,
609 PreferenceConstants.CODEASSIST_ADDIMPORT));
610 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
611 OverlayPreferenceStore.BOOLEAN,
612 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
613 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
614 OverlayPreferenceStore.BOOLEAN,
615 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
616 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
617 OverlayPreferenceStore.BOOLEAN,
618 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
619 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
620 OverlayPreferenceStore.BOOLEAN,
621 PreferenceConstants.EDITOR_SMART_PASTE));
622 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
623 OverlayPreferenceStore.BOOLEAN,
624 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
625 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
626 OverlayPreferenceStore.BOOLEAN,
627 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
628 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
629 OverlayPreferenceStore.BOOLEAN,
630 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
632 // .add(new OverlayPreferenceStore.OverlayKey(
633 // OverlayPreferenceStore.BOOLEAN,
634 // PreferenceConstants.EDITOR_CLOSE_BRACES));
635 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
636 OverlayPreferenceStore.BOOLEAN,
637 PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
638 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
639 OverlayPreferenceStore.BOOLEAN,
640 PreferenceConstants.EDITOR_WRAP_WORDS));
641 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
642 OverlayPreferenceStore.BOOLEAN,
643 PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
644 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
645 OverlayPreferenceStore.BOOLEAN,
646 PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
647 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
648 OverlayPreferenceStore.BOOLEAN,
649 PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
650 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
651 OverlayPreferenceStore.BOOLEAN,
652 PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
654 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
655 OverlayPreferenceStore.BOOLEAN,
656 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
657 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
658 OverlayPreferenceStore.BOOLEAN,
659 PreferenceConstants.EDITOR_FORMAT_JAVADOCS));
661 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
662 OverlayPreferenceStore.BOOLEAN,
663 PreferenceConstants.EDITOR_SMART_HOME_END));
664 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
665 OverlayPreferenceStore.BOOLEAN,
666 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
667 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
668 OverlayPreferenceStore.BOOLEAN,
669 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
670 // overlayKeys.add(new
671 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
672 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
673 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
674 OverlayPreferenceStore.STRING,
675 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
676 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
677 OverlayPreferenceStore.STRING,
678 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
679 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
680 OverlayPreferenceStore.BOOLEAN,
681 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
682 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
683 OverlayPreferenceStore.STRING,
684 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
686 .add(new OverlayPreferenceStore.OverlayKey(
687 OverlayPreferenceStore.STRING,
688 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
689 while (e.hasNext()) {
690 AnnotationPreference info = (AnnotationPreference) e.next();
692 .add(new OverlayPreferenceStore.OverlayKey(
693 OverlayPreferenceStore.STRING, info
694 .getColorPreferenceKey()));
696 .add(new OverlayPreferenceStore.OverlayKey(
697 OverlayPreferenceStore.BOOLEAN, info
698 .getTextPreferenceKey()));
699 if (info.getHighlightPreferenceKey() != null)
700 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
701 OverlayPreferenceStore.BOOLEAN, info
702 .getHighlightPreferenceKey()));
703 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
704 OverlayPreferenceStore.BOOLEAN, info
705 .getOverviewRulerPreferenceKey()));
706 if (info.getVerticalRulerPreferenceKey() != null)
707 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
708 OverlayPreferenceStore.BOOLEAN, info
709 .getVerticalRulerPreferenceKey()));
710 if (info.getTextStylePreferenceKey() != null)
711 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
712 OverlayPreferenceStore.STRING, info
713 .getTextStylePreferenceKey()));
715 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
717 overlayKeys.toArray(keys);
720 * @see IWorkbenchPreferencePage#init()
723 public void init(IWorkbench workbench) {
727 * @see PreferencePage#createControl(Composite)
729 public void createControl(Composite parent) {
730 super.createControl(parent);
731 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
732 IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
735 private void handleSyntaxColorListSelection() {
736 int i = fSyntaxColorList.getSelectionIndex();
737 String key = fSyntaxColorListModel[i][1];
738 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
739 fSyntaxForegroundColorEditor.setColorValue(rgb);
740 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
743 private void handleAppearanceColorListSelection() {
744 int i = fAppearanceColorList.getSelectionIndex();
745 String key = fAppearanceColorListModel[i][1];
746 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
747 fAppearanceColorEditor.setColorValue(rgb);
750 // private void handleAnnotationListSelection() {
751 // int i = fAnnotationList.getSelectionIndex();
752 // String key = fAnnotationColorListModel[i][1];
753 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
754 // fAnnotationForegroundColorEditor.setColorValue(rgb);
755 // key = fAnnotationColorListModel[i][2];
756 // boolean showInText = fOverlayStore.getBoolean(key);
757 // fShowInTextCheckBox.setSelection(showInText);
758 // key = fAnnotationColorListModel[i][6];
759 // if (key != null) {
760 // fDecorationStyleCombo.setEnabled(showInText);
761 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
762 // String value = fOverlayStore.getString(key);
763 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
764 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
769 // fDecorationStyleCombo.setEnabled(false);
770 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); //
784 // key = fAnnotationColorListModel[i][3];
785 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
786 // key = fAnnotationColorListModel[i][4];
787 // if (key != null) {
788 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
789 // fHighlightInTextCheckBox.setEnabled(true);
791 // fHighlightInTextCheckBox.setEnabled(false);
792 // key = fAnnotationColorListModel[i][5];
793 // if (key != null) {
794 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
795 // fShowInVerticalRulerCheckBox.setEnabled(true);
797 // fShowInVerticalRulerCheckBox.setSelection(true);
798 // fShowInVerticalRulerCheckBox.setEnabled(false);
801 private Control createSyntaxPage(Composite parent) {
802 Composite colorComposite = new Composite(parent, SWT.NULL);
803 colorComposite.setLayout(new GridLayout());
804 Group backgroundComposite = new Group(colorComposite,
805 SWT.SHADOW_ETCHED_IN);
806 backgroundComposite.setLayout(new RowLayout());
807 backgroundComposite.setText(PreferencesMessages
808 .getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
809 SelectionListener backgroundSelectionListener = new SelectionListener() {
810 public void widgetSelected(SelectionEvent e) {
811 boolean custom = fBackgroundCustomRadioButton.getSelection();
812 fBackgroundColorButton.setEnabled(custom);
813 fOverlayStore.setValue(
814 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR,
818 public void widgetDefaultSelected(SelectionEvent e) {
821 fBackgroundDefaultRadioButton = new Button(backgroundComposite,
822 SWT.RADIO | SWT.LEFT);
823 fBackgroundDefaultRadioButton.setText(PreferencesMessages
824 .getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
825 fBackgroundDefaultRadioButton
826 .addSelectionListener(backgroundSelectionListener);
827 fBackgroundCustomRadioButton = new Button(backgroundComposite,
828 SWT.RADIO | SWT.LEFT);
829 fBackgroundCustomRadioButton.setText(PreferencesMessages
830 .getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
831 fBackgroundCustomRadioButton
832 .addSelectionListener(backgroundSelectionListener);
833 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
834 fBackgroundColorButton = fBackgroundColorEditor.getButton();
835 Label label = new Label(colorComposite, SWT.LEFT);
836 label.setText(PreferencesMessages
837 .getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
838 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
839 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
840 GridLayout layout = new GridLayout();
841 layout.numColumns = 2;
842 layout.marginHeight = 0;
843 layout.marginWidth = 0;
844 editorComposite.setLayout(layout);
845 GridData gd = new GridData(GridData.FILL_BOTH);
846 editorComposite.setLayoutData(gd);
847 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
849 gd = new GridData(GridData.FILL_BOTH);
850 gd.heightHint = convertHeightInCharsToPixels(5);
851 fSyntaxColorList.setLayoutData(gd);
852 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
853 layout = new GridLayout();
854 layout.marginHeight = 0;
855 layout.marginWidth = 0;
856 layout.numColumns = 2;
857 stylesComposite.setLayout(layout);
858 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
859 label = new Label(stylesComposite, SWT.LEFT);
860 label.setText(PreferencesMessages
861 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
863 gd.horizontalAlignment = GridData.BEGINNING;
864 label.setLayoutData(gd);
865 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
866 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
867 gd = new GridData(GridData.FILL_HORIZONTAL);
868 gd.horizontalAlignment = GridData.BEGINNING;
869 foregroundColorButton.setLayoutData(gd);
870 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
871 fBoldCheckBox.setText(PreferencesMessages
872 .getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
873 gd = new GridData(GridData.FILL_HORIZONTAL);
874 gd.horizontalAlignment = GridData.BEGINNING;
875 gd.horizontalSpan = 2;
876 fBoldCheckBox.setLayoutData(gd);
877 label = new Label(colorComposite, SWT.LEFT);
878 label.setText(PreferencesMessages
879 .getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
880 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
881 Control previewer = createPreviewer(colorComposite);
882 gd = new GridData(GridData.FILL_BOTH);
883 gd.widthHint = convertWidthInCharsToPixels(20);
884 gd.heightHint = convertHeightInCharsToPixels(5);
885 previewer.setLayoutData(gd);
886 fSyntaxColorList.addSelectionListener(new SelectionListener() {
887 public void widgetDefaultSelected(SelectionEvent e) {
891 public void widgetSelected(SelectionEvent e) {
892 handleSyntaxColorListSelection();
895 foregroundColorButton.addSelectionListener(new SelectionListener() {
896 public void widgetDefaultSelected(SelectionEvent e) {
900 public void widgetSelected(SelectionEvent e) {
901 int i = fSyntaxColorList.getSelectionIndex();
902 String key = fSyntaxColorListModel[i][1];
903 PreferenceConverter.setValue(fOverlayStore, key,
904 fSyntaxForegroundColorEditor.getColorValue());
907 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
908 public void widgetDefaultSelected(SelectionEvent e) {
912 public void widgetSelected(SelectionEvent e) {
913 PreferenceConverter.setValue(fOverlayStore,
914 PreferenceConstants.EDITOR_BACKGROUND_COLOR,
915 fBackgroundColorEditor.getColorValue());
918 fBoldCheckBox.addSelectionListener(new SelectionListener() {
919 public void widgetDefaultSelected(SelectionEvent e) {
923 public void widgetSelected(SelectionEvent e) {
924 int i = fSyntaxColorList.getSelectionIndex();
925 String key = fSyntaxColorListModel[i][1];
927 .setValue(key + BOLD, fBoldCheckBox.getSelection());
930 return colorComposite;
933 private Control createPreviewer(Composite parent) {
934 Preferences coreStore = createTemporaryCorePreferenceStore();
935 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
936 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
937 IPreferenceStore store = new ChainedPreferenceStore(
938 new IPreferenceStore[] {
940 new PreferencesAdapter(
941 createTemporaryCorePreferenceStore()),
944 fPreviewViewer = new JavaSourceViewer(parent, null, null, false,
945 SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
946 JavaTextTools tools = PHPeclipsePlugin.getDefault().getJavaTextTools();
947 PHPSourceViewerConfiguration configuration = new PHPSourceViewerConfiguration(
948 tools.getColorManager(), store, null,
949 IPHPPartitions.PHP_PARTITIONING);
950 // PHPSourceViewerConfiguration configuration =new
951 // PHPSourceViewerConfiguration(fJavaTextTools, null,
952 // IPHPPartitions.PHP_PARTITIONING);
953 fPreviewViewer.configure(configuration);
955 Font font = JFaceResources
956 .getFont(PreferenceConstants.EDITOR_TEXT_FONT);
957 fPreviewViewer.getTextWidget().setFont(font);
958 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
959 fPreviewViewer.setEditable(false);
960 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
961 IDocument document = new Document(content);
962 fJavaTextTools.setupJavaDocumentPartitioner(document,
963 IPHPPartitions.PHP_PARTITIONING);
964 fPreviewViewer.setDocument(document);
965 return fPreviewViewer.getControl();
968 private Preferences createTemporaryCorePreferenceStore() {
969 Preferences result = new Preferences();
970 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
974 private Control createAppearancePage(Composite parent) {
975 Composite appearanceComposite = new Composite(parent, SWT.NONE);
976 GridLayout layout = new GridLayout();
977 layout.numColumns = 2;
978 appearanceComposite.setLayout(layout);
980 // Inserts a hyper-link to the General Editor preferences page
981 // TODO Can probably be removed post 1.5.0?
982 String label = PreferencesMessages
983 .getString("JavaEditorPreferencePage.appearanceTabLink");
984 Link link = new Link(appearanceComposite, SWT.NONE);
985 GridData gridPosition = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
986 gridPosition.horizontalSpan = 2;
987 link.setLayoutData(gridPosition);
990 link.addListener(SWT.Selection, new Listener () {
991 public void handleEvent(Event event) {
992 String u = event.text;
993 PreferencesUtil.createPreferenceDialogOn(getShell(), u, null, null);
996 String tooltip = PreferencesMessages
997 .getString("JavaEditorPreferencePage.appearanceTabTooltip");
998 link.setToolTipText(tooltip);
1000 label = PreferencesMessages
1001 .getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
1002 addTextField(appearanceComposite, label,
1003 PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
1004 label = PreferencesMessages
1005 .getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
1007 appearanceComposite,
1009 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN,
1011 label = PreferencesMessages
1012 .getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
1014 appearanceComposite,
1016 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER,
1018 label = PreferencesMessages
1019 .getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
1020 addCheckBox(appearanceComposite, label,
1021 PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
1022 label = PreferencesMessages
1023 .getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
1025 appearanceComposite,
1027 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
1029 label = PreferencesMessages
1030 .getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
1032 appearanceComposite,
1034 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
1036 label = PreferencesMessages
1037 .getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
1038 // Button master= addCheckBox(appearanceComposite, label,
1039 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
1040 label = PreferencesMessages
1041 .getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
1042 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
1043 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
1044 // createDependency(master, fStickyOccurrencesButton);
1045 Label l = new Label(appearanceComposite, SWT.LEFT);
1046 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1047 gd.horizontalSpan = 2;
1048 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1049 l.setLayoutData(gd);
1050 l = new Label(appearanceComposite, SWT.LEFT);
1051 l.setText(PreferencesMessages
1052 .getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
1053 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1054 gd.horizontalSpan = 2;
1055 l.setLayoutData(gd);
1056 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
1057 layout = new GridLayout();
1058 layout.numColumns = 2;
1059 layout.marginHeight = 0;
1060 layout.marginWidth = 0;
1061 editorComposite.setLayout(layout);
1062 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
1063 | GridData.FILL_VERTICAL);
1064 gd.horizontalSpan = 2;
1065 editorComposite.setLayoutData(gd);
1066 fAppearanceColorList = new List(editorComposite, SWT.SINGLE
1067 | SWT.V_SCROLL | SWT.BORDER);
1068 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1069 | GridData.FILL_HORIZONTAL);
1070 gd.heightHint = convertHeightInCharsToPixels(8);
1071 fAppearanceColorList.setLayoutData(gd);
1072 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
1073 layout = new GridLayout();
1074 layout.marginHeight = 0;
1075 layout.marginWidth = 0;
1076 layout.numColumns = 2;
1077 stylesComposite.setLayout(layout);
1078 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1079 l = new Label(stylesComposite, SWT.LEFT);
1080 l.setText(PreferencesMessages
1081 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
1082 gd = new GridData();
1083 gd.horizontalAlignment = GridData.BEGINNING;
1084 l.setLayoutData(gd);
1085 fAppearanceColorEditor = new ColorEditor(stylesComposite);
1086 Button foregroundColorButton = fAppearanceColorEditor.getButton();
1087 gd = new GridData(GridData.FILL_HORIZONTAL);
1088 gd.horizontalAlignment = GridData.BEGINNING;
1089 foregroundColorButton.setLayoutData(gd);
1090 fAppearanceColorList.addSelectionListener(new SelectionListener() {
1091 public void widgetDefaultSelected(SelectionEvent e) {
1095 public void widgetSelected(SelectionEvent e) {
1096 handleAppearanceColorListSelection();
1099 foregroundColorButton.addSelectionListener(new SelectionListener() {
1100 public void widgetDefaultSelected(SelectionEvent e) {
1104 public void widgetSelected(SelectionEvent e) {
1105 int i = fAppearanceColorList.getSelectionIndex();
1106 String key = fAppearanceColorListModel[i][1];
1107 PreferenceConverter.setValue(fOverlayStore, key,
1108 fAppearanceColorEditor.getColorValue());
1111 return appearanceComposite;
1114 // private Control createAnnotationsPage(Composite parent) {
1115 // Composite composite = new Composite(parent, SWT.NULL);
1116 // GridLayout layout = new GridLayout();
1117 // layout.numColumns = 2;
1118 // composite.setLayout(layout);
1119 // String text = PreferencesMessages
1120 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
1122 // addCheckBox(composite, text,
1123 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
1124 // text = PreferencesMessages
1125 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
1126 // addCheckBox(composite, text,
1127 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
1128 // addFiller(composite);
1129 // Label label = new Label(composite, SWT.LEFT);
1130 // label.setText(PreferencesMessages
1131 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
1133 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1134 // gd.horizontalSpan = 2;
1135 // label.setLayoutData(gd);
1136 // Composite editorComposite = new Composite(composite, SWT.NONE);
1137 // layout = new GridLayout();
1138 // layout.numColumns = 2;
1139 // layout.marginHeight = 0;
1140 // layout.marginWidth = 0;
1141 // editorComposite.setLayout(layout);
1142 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
1143 // GridData.FILL_VERTICAL);
1144 // gd.horizontalSpan = 2;
1145 // editorComposite.setLayoutData(gd);
1146 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
1148 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1149 // | GridData.FILL_HORIZONTAL);
1150 // gd.heightHint = convertHeightInCharsToPixels(10);
1151 // fAnnotationList.setLayoutData(gd);
1152 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
1153 // layout = new GridLayout();
1154 // layout.marginHeight = 0;
1155 // layout.marginWidth = 0;
1156 // layout.numColumns = 2;
1157 // optionsComposite.setLayout(layout);
1158 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1159 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1160 // fShowInTextCheckBox.setText(PreferencesMessages
1161 // .getString("JavaEditorPreferencePage.annotations.showInText"));
1163 // gd = new GridData(GridData.FILL_HORIZONTAL);
1164 // gd.horizontalAlignment = GridData.BEGINNING;
1165 // gd.horizontalSpan = 2;
1166 // fShowInTextCheckBox.setLayoutData(gd);
1167 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
1168 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
1169 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
1170 // gd = new GridData(GridData.FILL_HORIZONTAL);
1171 // gd.horizontalAlignment = GridData.BEGINNING;
1172 // gd.horizontalSpan = 2;
1173 // gd.horizontalIndent = 20;
1174 // fDecorationStyleCombo.setLayoutData(gd);
1175 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1176 // fHighlightInTextCheckBox.setText(PreferencesMessages
1177 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
1179 // gd = new GridData(GridData.FILL_HORIZONTAL);
1180 // gd.horizontalAlignment = GridData.BEGINNING;
1181 // gd.horizontalSpan = 2;
1182 // fHighlightInTextCheckBox.setLayoutData(gd);
1183 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1184 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
1185 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
1187 // gd = new GridData(GridData.FILL_HORIZONTAL);
1188 // gd.horizontalAlignment = GridData.BEGINNING;
1189 // gd.horizontalSpan = 2;
1190 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
1191 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1192 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
1193 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
1195 // gd = new GridData(GridData.FILL_HORIZONTAL);
1196 // gd.horizontalAlignment = GridData.BEGINNING;
1197 // gd.horizontalSpan = 2;
1198 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
1199 // label = new Label(optionsComposite, SWT.LEFT);
1200 // label.setText(PreferencesMessages
1201 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
1202 // gd = new GridData();
1203 // gd.horizontalAlignment = GridData.BEGINNING;
1204 // label.setLayoutData(gd);
1205 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
1206 // Button foregroundColorButton =
1207 // fAnnotationForegroundColorEditor.getButton();
1208 // gd = new GridData(GridData.FILL_HORIZONTAL);
1209 // gd.horizontalAlignment = GridData.BEGINNING;
1210 // foregroundColorButton.setLayoutData(gd);
1211 // fAnnotationList.addSelectionListener(new SelectionListener() {
1212 // public void widgetDefaultSelected(SelectionEvent e) {
1215 // public void widgetSelected(SelectionEvent e) {
1216 // handleAnnotationListSelection();
1219 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
1220 // public void widgetDefaultSelected(SelectionEvent e) {
1223 // public void widgetSelected(SelectionEvent e) {
1224 // int i = fAnnotationList.getSelectionIndex();
1225 // String key = fAnnotationColorListModel[i][2];
1226 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
1227 // String decorationKey = fAnnotationColorListModel[i][6];
1228 // fDecorationStyleCombo.setEnabled(decorationKey != null
1229 // && fShowInTextCheckBox.getSelection());
1232 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
1233 // public void widgetDefaultSelected(SelectionEvent e) {
1236 // public void widgetSelected(SelectionEvent e) {
1237 // int i = fAnnotationList.getSelectionIndex();
1238 // String key = fAnnotationColorListModel[i][4];
1239 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
1242 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener()
1244 // public void widgetDefaultSelected(SelectionEvent e) {
1247 // public void widgetSelected(SelectionEvent e) {
1248 // int i = fAnnotationList.getSelectionIndex();
1249 // String key = fAnnotationColorListModel[i][3];
1251 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
1254 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener()
1256 // public void widgetDefaultSelected(SelectionEvent e) {
1259 // public void widgetSelected(SelectionEvent e) {
1260 // int i = fAnnotationList.getSelectionIndex();
1261 // String key = fAnnotationColorListModel[i][5];
1263 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
1266 // foregroundColorButton.addSelectionListener(new SelectionListener() {
1267 // public void widgetDefaultSelected(SelectionEvent e) {
1270 // public void widgetSelected(SelectionEvent e) {
1271 // int i = fAnnotationList.getSelectionIndex();
1272 // String key = fAnnotationColorListModel[i][1];
1273 // PreferenceConverter.setValue(fOverlayStore, key,
1274 // fAnnotationForegroundColorEditor.getColorValue());
1277 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
1281 // public void widgetDefaultSelected(SelectionEvent e) {
1287 // public void widgetSelected(SelectionEvent e) {
1288 // int i = fAnnotationList.getSelectionIndex();
1289 // String key = fAnnotationColorListModel[i][6];
1290 // if (key != null) {
1291 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1292 // if (fAnnotationDecorationListModel[j][0]
1293 // .equals(fDecorationStyleCombo.getText())) {
1294 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1301 // return composite;
1303 // private String[][] createAnnotationTypeListModel(
1304 // MarkerAnnotationPreferences preferences) {
1305 // ArrayList listModelItems = new ArrayList();
1306 // SortedSet sortedPreferences = new TreeSet(new Comparator() {
1308 // * @see java.util.Comparator#compare(java.lang.Object,
1309 // * java.lang.Object)
1311 // public int compare(Object o1, Object o2) {
1312 // if (!(o2 instanceof AnnotationPreference))
1314 // if (!(o1 instanceof AnnotationPreference))
1316 // AnnotationPreference a1 = (AnnotationPreference) o1;
1317 // AnnotationPreference a2 = (AnnotationPreference) o2;
1318 // return Collator.getInstance().compare(a1.getPreferenceLabel(),
1319 // a2.getPreferenceLabel());
1322 // sortedPreferences.addAll(preferences.getAnnotationPreferences());
1323 // Iterator e = sortedPreferences.iterator();
1324 // while (e.hasNext()) {
1325 // AnnotationPreference info = (AnnotationPreference) e.next();
1326 // listModelItems.add(new String[] { info.getPreferenceLabel(),
1327 // info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1328 // info.getOverviewRulerPreferenceKey(),
1329 // info.getHighlightPreferenceKey(),
1330 // info.getVerticalRulerPreferenceKey(),
1331 // info.getTextStylePreferenceKey() });
1333 // String[][] items = new String[listModelItems.size()][];
1334 // listModelItems.toArray(items);
1338 private Control createTypingPage(Composite parent) {
1339 Composite composite = new Composite(parent, SWT.NONE);
1340 GridLayout layout = new GridLayout();
1341 layout.numColumns = 1;
1342 composite.setLayout(layout);
1344 // label = PreferencesMessages
1345 // .getString("JavaEditorPreferencePage.overwriteMode");
1347 // addCheckBox(composite, label,
1348 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1349 // addFiller(composite);
1351 // label = PreferencesMessages
1352 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1354 // addCheckBox(composite, label,
1355 // PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1357 // label = PreferencesMessages
1358 // .getString("JavaEditorPreferencePage.subWordNavigation");
1360 // addCheckBox(composite, label,
1361 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1362 // addFiller(composite);
1363 Group group = new Group(composite, SWT.NONE);
1364 layout = new GridLayout();
1365 layout.numColumns = 2;
1366 group.setLayout(layout);
1367 group.setText(PreferencesMessages
1368 .getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1370 label = PreferencesMessages
1371 .getString("JavaEditorPreferencePage.wrapWords");//$NON-NLS-1$
1372 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_WORDS, 1);
1374 label = PreferencesMessages
1375 .getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1376 Button button = addCheckBox(group, label,
1377 PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1379 label = PreferencesMessages
1380 .getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1381 fEscapeStringsButtonDQ = addCheckBox(group, label,
1382 PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1383 createDependency(button, fEscapeStringsButtonDQ);
1385 label = PreferencesMessages
1386 .getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1387 button = addCheckBox(group, label,
1388 PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1390 label = PreferencesMessages
1391 .getString("JavaEditorPreferencePage.escapeStringsSQ");
1393 fEscapeStringsButtonSQ = addCheckBox(group, label,
1394 PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1395 createDependency(button, fEscapeStringsButtonSQ);
1397 label = PreferencesMessages
1398 .getString("JavaEditorPreferencePage.smartPaste");
1400 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1402 label = PreferencesMessages
1403 .getString("JavaEditorPreferencePage.insertSpaceForTabs");
1405 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1407 label = PreferencesMessages
1408 .getString("JavaEditorPreferencePage.closeStringsDQ");
1410 addCheckBox(group, label,
1411 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1412 label = PreferencesMessages
1413 .getString("JavaEditorPreferencePage.closeStringsSQ");
1415 addCheckBox(group, label,
1416 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1418 label = PreferencesMessages
1419 .getString("JavaEditorPreferencePage.closeBrackets");
1421 addCheckBox(group, label,
1422 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1424 // label = PreferencesMessages
1425 // .getString("JavaEditorPreferencePage.closeBraces");
1427 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES,
1430 label = PreferencesMessages
1431 .getString("JavaEditorPreferencePage.closeJavaDocs");
1433 button = addCheckBox(group, label,
1434 PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1435 label = PreferencesMessages
1436 .getString("JavaEditorPreferencePage.formatJavaDocs");
1438 button = addCheckBox(group, label,
1439 PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
1442 // label = PreferencesMessages
1443 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1445 // fAddJavaDocTagsButton = addCheckBox(group, label,
1446 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1447 // createDependency(button, fAddJavaDocTagsButton);
1451 // private void addFiller(Composite composite) {
1452 // Label filler = new Label(composite, SWT.LEFT);
1453 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1454 // gd.horizontalSpan = 2;
1455 // gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1456 // filler.setLayoutData(gd);
1459 private static void indent(Control control) {
1460 GridData gridData = new GridData();
1461 gridData.horizontalIndent = 20;
1462 control.setLayoutData(gridData);
1465 private static void createDependency(final Button master,
1466 final Control slave) {
1468 master.addSelectionListener(new SelectionListener() {
1469 public void widgetSelected(SelectionEvent e) {
1470 slave.setEnabled(master.getSelection());
1473 public void widgetDefaultSelected(SelectionEvent e) {
1478 // private void addCompletionRadioButtons(Composite contentAssistComposite) {
1479 // Composite completionComposite = new Composite(contentAssistComposite,
1481 // GridData ccgd = new GridData();
1482 // ccgd.horizontalSpan = 2;
1483 // completionComposite.setLayoutData(ccgd);
1484 // GridLayout ccgl = new GridLayout();
1485 // ccgl.marginWidth = 0;
1486 // ccgl.numColumns = 2;
1487 // completionComposite.setLayout(ccgl);
1488 // // SelectionListener completionSelectionListener= new SelectionAdapter()
1490 // // public void widgetSelected(SelectionEvent e) {
1491 // // boolean insert= fCompletionInsertsRadioButton.getSelection();
1492 // // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1497 // // fCompletionInsertsRadioButton= new Button(completionComposite,
1500 // // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1502 // // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1503 // // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1505 // // fCompletionOverwritesRadioButton= new Button(completionComposite,
1506 // // SWT.RADIO | SWT.LEFT);
1507 // // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1509 // // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1510 // // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1513 private Control createNavigationPage(Composite parent) {
1514 Composite composite = new Composite(parent, SWT.NULL);
1515 GridLayout layout = new GridLayout();
1516 layout.numColumns = 2;
1517 composite.setLayout(layout);
1518 String text = PreferencesMessages
1519 .getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1521 fBrowserLikeLinksCheckBox = addCheckBox(composite, text,
1522 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1523 fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1524 public void widgetSelected(SelectionEvent e) {
1525 boolean state = fBrowserLikeLinksCheckBox.getSelection();
1526 fBrowserLikeLinksKeyModifierText.setEnabled(state);
1527 handleBrowserLikeLinksKeyModifierModified();
1530 public void widgetDefaultSelected(SelectionEvent e) {
1533 // Text field for modifier string
1534 text = PreferencesMessages
1535 .getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1537 fBrowserLikeLinksKeyModifierText = addTextField(composite, text,
1538 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20,
1540 fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1542 if (computeStateMask(fOverlayStore
1543 .getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) == -1) {
1544 // Fix possible illegal modifier string
1545 int stateMask = fOverlayStore
1546 .getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1547 if (stateMask == -1)
1548 fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1550 fBrowserLikeLinksKeyModifierText.setText(EditorUtility
1551 .getModifierString(stateMask));
1553 fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1554 private boolean isModifierCandidate;
1556 public void keyPressed(KeyEvent e) {
1557 isModifierCandidate = e.keyCode > 0 && e.character == 0
1558 && e.stateMask == 0;
1561 public void keyReleased(KeyEvent e) {
1562 if (isModifierCandidate && e.stateMask > 0
1563 && e.stateMask == e.stateMask && e.character == 0) {// &&
1569 String modifierString = fBrowserLikeLinksKeyModifierText
1571 Point selection = fBrowserLikeLinksKeyModifierText
1573 int i = selection.x - 1;
1575 && Character.isWhitespace(modifierString.charAt(i))) {
1578 boolean needsPrefixDelimiter = i > -1
1579 && !String.valueOf(modifierString.charAt(i))
1583 while (i < modifierString.length()
1584 && Character.isWhitespace(modifierString.charAt(i))) {
1587 boolean needsPostfixDelimiter = i < modifierString.length()
1588 && !String.valueOf(modifierString.charAt(i))
1591 String insertString;
1593 if (needsPrefixDelimiter && needsPostfixDelimiter)
1594 insertString = PreferencesMessages
1595 .getFormattedString(
1596 "JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1597 new String[] { Action
1598 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1599 else if (needsPrefixDelimiter)
1600 insertString = PreferencesMessages
1601 .getFormattedString(
1602 "JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1603 new String[] { Action
1604 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1605 else if (needsPostfixDelimiter)
1606 insertString = PreferencesMessages
1607 .getFormattedString(
1608 "JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1609 new String[] { Action
1610 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1612 insertString = Action.findModifierString(e.stateMask);
1614 fBrowserLikeLinksKeyModifierText.insert(insertString);
1619 fBrowserLikeLinksKeyModifierText
1620 .addModifyListener(new ModifyListener() {
1621 public void modifyText(ModifyEvent e) {
1622 handleBrowserLikeLinksKeyModifierModified();
1628 private void handleBrowserLikeLinksKeyModifierModified() {
1629 String modifiers = fBrowserLikeLinksKeyModifierText.getText();
1630 int stateMask = computeStateMask(modifiers);
1631 if (fBrowserLikeLinksCheckBox.getSelection()
1632 && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) {
1633 if (stateMask == -1)
1634 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(
1637 .getFormattedString(
1638 "JavaEditorPreferencePage.navigation.modifierIsNotValid", modifiers)); //$NON-NLS-1$
1640 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(
1643 .getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1646 StatusUtil.applyToStatusLine(this,
1647 fBrowserLikeLinksKeyModifierStatus);
1649 fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1650 updateStatus(fBrowserLikeLinksKeyModifierStatus);
1654 // private IStatus getBrowserLikeLinksKeyModifierStatus() {
1655 // if (fBrowserLikeLinksKeyModifierStatus == null)
1656 // fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1657 // return fBrowserLikeLinksKeyModifierStatus;
1661 * Computes the state mask for the given modifier string.
1664 * the string with the modifiers, separated by '+', '-', ';', ','
1666 * @return the state mask or -1 if the input is invalid
1668 private int computeStateMask(String modifiers) {
1669 if (modifiers == null)
1671 if (modifiers.length() == 0)
1674 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers,
1675 ",;.:+-* "); //$NON-NLS-1$
1676 while (modifierTokenizer.hasMoreTokens()) {
1677 int modifier = EditorUtility
1678 .findLocalizedModifier(modifierTokenizer.nextToken());
1679 if (modifier == 0 || (stateMask & modifier) == modifier)
1681 stateMask = stateMask | modifier;
1687 * @see PreferencePage#createContents(Composite)
1689 protected Control createContents(Composite parent) {
1690 initializeDefaultColors();
1691 fFoldingConfigurationBlock = new FoldingConfigurationBlock(
1693 fOverlayStore.load();
1694 fOverlayStore.start();
1695 TabFolder folder = new TabFolder(parent, SWT.NONE);
1696 folder.setLayout(new TabFolderLayout());
1697 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1698 TabItem item = new TabItem(folder, SWT.NONE);
1699 item.setText(PreferencesMessages
1700 .getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1701 item.setControl(createAppearancePage(folder));
1702 item = new TabItem(folder, SWT.NONE);
1703 item.setText(PreferencesMessages
1704 .getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1705 item.setControl(createSyntaxPage(folder));
1707 // item = new TabItem(folder, SWT.NONE);
1708 // item.setText(PreferencesMessages
1709 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1711 // item.setControl(createAnnotationsPage(folder));
1712 item = new TabItem(folder, SWT.NONE);
1713 item.setText(PreferencesMessages
1714 .getString("JavaEditorPreferencePage.typing.tabTitle"));
1716 item.setControl(createTypingPage(folder));
1718 item = new TabItem(folder, SWT.NONE);
1719 item.setText(PreferencesMessages
1720 .getString("JavaEditorPreferencePage.hoverTab.title"));
1722 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(
1723 this, fOverlayStore);
1724 item.setControl(fJavaEditorHoverConfigurationBlock
1725 .createControl(folder));
1726 item = new TabItem(folder, SWT.NONE);
1727 item.setText(PreferencesMessages
1728 .getString("JavaEditorPreferencePage.navigationTab.title"));
1730 item.setControl(createNavigationPage(folder));
1731 item = new TabItem(folder, SWT.NONE);
1732 item.setText(PreferencesMessages
1733 .getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1734 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1737 Dialog.applyDialogFont(folder);
1741 private void initialize() {
1743 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1744 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1745 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1747 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1748 fSyntaxColorList.select(0);
1749 handleSyntaxColorListSelection();
1753 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1754 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1755 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1757 if (fAppearanceColorList != null
1758 && !fAppearanceColorList.isDisposed()) {
1759 fAppearanceColorList.select(0);
1760 handleAppearanceColorListSelection();
1764 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1765 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1766 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1767 // public void run() {
1768 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1769 // fAnnotationList.select(0);
1770 // handleAnnotationListSelection();
1774 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1775 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1776 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1777 // public void run() {
1778 // if (fContentAssistColorList != null &&
1779 // !fContentAssistColorList.isDisposed()) {
1780 // fContentAssistColorList.select(0);
1781 // handleContentAssistColorListSelection();
1785 fFoldingConfigurationBlock.initialize();
1788 private void initializeFields() {
1789 Iterator e = fColorButtons.keySet().iterator();
1790 while (e.hasNext()) {
1791 ColorEditor c = (ColorEditor) e.next();
1792 String key = (String) fColorButtons.get(c);
1793 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1794 c.setColorValue(rgb);
1796 e = fCheckBoxes.keySet().iterator();
1797 while (e.hasNext()) {
1798 Button b = (Button) e.next();
1799 String key = (String) fCheckBoxes.get(b);
1800 b.setSelection(fOverlayStore.getBoolean(key));
1802 e = fTextFields.keySet().iterator();
1803 while (e.hasNext()) {
1804 Text t = (Text) e.next();
1805 String key = (String) fTextFields.get(t);
1806 t.setText(fOverlayStore.getString(key));
1808 RGB rgb = PreferenceConverter.getColor(fOverlayStore,
1809 PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1810 fBackgroundColorEditor.setColorValue(rgb);
1811 boolean default_ = fOverlayStore
1812 .getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1813 fBackgroundDefaultRadioButton.setSelection(default_);
1814 fBackgroundCustomRadioButton.setSelection(!default_);
1815 fBackgroundColorButton.setEnabled(!default_);
1816 // boolean closeJavaDocs = fOverlayStore
1817 // .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1818 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1819 fEscapeStringsButtonDQ.setEnabled(fOverlayStore
1820 .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1821 fEscapeStringsButtonSQ.setEnabled(fOverlayStore
1822 .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1823 // boolean fillMethodArguments=
1824 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1825 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1826 // boolean completionInserts=
1827 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1828 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1829 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1831 fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox
1833 // boolean markOccurrences=
1834 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1835 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1836 updateAutoactivationControls();
1839 private void initializeDefaultColors() {
1840 if (!getPreferenceStore().contains(
1841 PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1842 RGB rgb = getControl().getDisplay().getSystemColor(
1843 SWT.COLOR_LIST_BACKGROUND).getRGB();
1844 PreferenceConverter.setDefault(fOverlayStore,
1845 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1846 PreferenceConverter.setDefault(getPreferenceStore(),
1847 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1849 if (!getPreferenceStore().contains(
1850 PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1851 RGB rgb = getControl().getDisplay().getSystemColor(
1852 SWT.COLOR_LIST_FOREGROUND).getRGB();
1853 PreferenceConverter.setDefault(fOverlayStore,
1854 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1855 PreferenceConverter.setDefault(getPreferenceStore(),
1856 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1860 private void updateAutoactivationControls() {
1861 // boolean autoactivation=
1862 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1863 // fAutoInsertDelayText.setEnabled(autoactivation);
1864 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1865 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1866 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1868 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1869 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1873 * @see PreferencePage#performOk()
1875 public boolean performOk() {
1876 // fJavaEditorHoverConfigurationBlock.performOk();
1877 fFoldingConfigurationBlock.performOk();
1880 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1881 computeStateMask(fBrowserLikeLinksKeyModifierText
1883 fOverlayStore.propagate();
1884 PHPeclipsePlugin.getDefault().savePluginPreferences();
1889 * @see PreferencePage#performDefaults()
1891 protected void performDefaults() {
1892 fOverlayStore.loadDefaults();
1894 handleSyntaxColorListSelection();
1895 handleAppearanceColorListSelection();
1896 // handleAnnotationListSelection();
1897 // handleContentAssistColorListSelection();
1898 // fJavaEditorHoverConfigurationBlock.performDefaults();
1899 fFoldingConfigurationBlock.performDefaults();
1900 super.performDefaults();
1901 fPreviewViewer.invalidateTextPresentation();
1905 * @see DialogPage#dispose()
1907 public void dispose() {
1908 fFoldingConfigurationBlock.dispose();
1910 if (fJavaTextTools != null) {
1911 fJavaTextTools.dispose();
1912 fJavaTextTools = null;
1914 if (fOverlayStore != null) {
1915 fOverlayStore.stop();
1916 fOverlayStore = null;
1918 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1919 fBackgroundColor.dispose();
1923 private Button addCheckBox(Composite parent, String label, String key,
1925 Button checkBox = new Button(parent, SWT.CHECK);
1926 checkBox.setText(label);
1927 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1928 gd.horizontalIndent = indentation;
1929 gd.horizontalSpan = 2;
1930 checkBox.setLayoutData(gd);
1931 checkBox.addSelectionListener(fCheckBoxListener);
1932 fCheckBoxes.put(checkBox, key);
1936 private Text addTextField(Composite composite, String label, String key,
1937 int textLimit, int indentation, boolean isNumber) {
1938 return getTextControl(addLabelledTextField(composite, label, key,
1939 textLimit, indentation, isNumber));
1942 // private static Label getLabelControl(Control[] labelledTextField) {
1943 // return (Label) labelledTextField[0];
1946 private static Text getTextControl(Control[] labelledTextField) {
1947 return (Text) labelledTextField[1];
1951 * Returns an array of size 2: - first element is of type <code>Label</code>-
1952 * second element is of type <code>Text</code> Use
1953 * <code>getLabelControl</code> and <code>getTextControl</code> to get
1956 private Control[] addLabelledTextField(Composite composite, String label,
1957 String key, int textLimit, int indentation, boolean isNumber) {
1958 Label labelControl = new Label(composite, SWT.NONE);
1959 labelControl.setText(label);
1960 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1961 gd.horizontalIndent = indentation;
1962 labelControl.setLayoutData(gd);
1963 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1964 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1965 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1966 textControl.setLayoutData(gd);
1967 textControl.setTextLimit(textLimit);
1968 fTextFields.put(textControl, key);
1970 fNumberFields.add(textControl);
1971 textControl.setText("0");
1972 textControl.addModifyListener(fNumberFieldListener);
1974 textControl.addModifyListener(fTextFieldListener);
1976 return new Control[] { labelControl, textControl };
1979 private String loadPreviewContentFromFile(String filename) {
1981 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1982 StringBuffer buffer = new StringBuffer(512);
1983 BufferedReader reader = null;
1985 reader = new BufferedReader(new InputStreamReader(getClass()
1986 .getResourceAsStream(filename)));
1987 while ((line = reader.readLine()) != null) {
1988 buffer.append(line);
1989 buffer.append(separator);
1991 } catch (IOException io) {
1992 PHPeclipsePlugin.log(io);
1994 if (reader != null) {
1997 } catch (IOException e) {
2001 return buffer.toString();
2004 private void numberFieldChanged(Text textControl) {
2005 String number = textControl.getText();
2006 IStatus status = validatePositiveNumber(number);
2007 if (!status.matches(IStatus.ERROR))
2008 fOverlayStore.setValue((String) fTextFields.get(textControl),
2010 updateStatus(status);
2013 private IStatus validatePositiveNumber(String number) {
2014 StatusInfo status = new StatusInfo();
2015 if (number.length() == 0) {
2016 status.setError(PreferencesMessages
2017 .getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
2020 int value = Integer.parseInt(number);
2022 status.setError(PreferencesMessages.getFormattedString(
2023 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
2024 } catch (NumberFormatException e) {
2025 status.setError(PreferencesMessages.getFormattedString(
2026 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
2032 void updateStatus(IStatus status) {
2033 if (!status.matches(IStatus.ERROR)) {
2034 for (int i = 0; i < fNumberFields.size(); i++) {
2035 Text text = (Text) fNumberFields.get(i);
2036 IStatus s = validatePositiveNumber(text.getText());
2037 status = StatusUtil.getMoreSevere(s, status);
2041 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
2044 // StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
2046 setValid(!status.matches(IStatus.ERROR));
2047 StatusUtil.applyToStatusLine(this, status);