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;
12 import java.io.BufferedReader;
13 import java.io.IOException;
14 import java.io.InputStreamReader;
15 import java.text.Collator;
16 import java.util.ArrayList;
17 import java.util.Comparator;
18 import java.util.HashMap;
19 import java.util.Iterator;
21 import java.util.SortedSet;
22 import java.util.StringTokenizer;
23 import java.util.TreeSet;
25 import net.sourceforge.phpdt.core.JavaCore;
26 import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
27 import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
28 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
29 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
30 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
31 import net.sourceforge.phpdt.ui.PreferenceConstants;
32 import net.sourceforge.phpdt.ui.text.JavaTextTools;
33 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
34 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
35 import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer;
36 import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration;
37 import net.sourceforge.phpeclipse.preferences.ColorEditor;
39 import org.eclipse.core.runtime.IStatus;
40 import org.eclipse.core.runtime.Preferences;
41 import net.sourceforge.phpdt.internal.ui.preferences.FoldingConfigurationBlock;
42 import net.sourceforge.phpdt.internal.ui.preferences.PreferencesMessages;
43 import org.eclipse.jface.dialogs.Dialog;
44 import org.eclipse.jface.preference.IPreferenceStore;
45 import org.eclipse.jface.preference.PreferenceConverter;
46 import org.eclipse.jface.preference.PreferencePage;
47 import org.eclipse.jface.resource.JFaceResources;
48 import org.eclipse.jface.text.Document;
49 import org.eclipse.jface.text.IDocument;
50 import org.eclipse.jface.text.source.SourceViewer;
51 import org.eclipse.swt.SWT;
52 import org.eclipse.swt.events.ModifyEvent;
53 import org.eclipse.swt.events.ModifyListener;
54 import org.eclipse.swt.events.SelectionAdapter;
55 import org.eclipse.swt.events.SelectionEvent;
56 import org.eclipse.swt.events.SelectionListener;
57 import org.eclipse.swt.graphics.Color;
58 import org.eclipse.swt.graphics.RGB;
59 import org.eclipse.swt.layout.GridData;
60 import org.eclipse.swt.layout.GridLayout;
61 import org.eclipse.swt.layout.RowLayout;
62 import org.eclipse.swt.widgets.Button;
63 import org.eclipse.swt.widgets.Combo;
64 import org.eclipse.swt.widgets.Composite;
65 import org.eclipse.swt.widgets.Control;
66 import org.eclipse.swt.widgets.Group;
67 import org.eclipse.swt.widgets.Label;
68 import org.eclipse.swt.widgets.List;
69 import org.eclipse.swt.widgets.TabFolder;
70 import org.eclipse.swt.widgets.TabItem;
71 import org.eclipse.swt.widgets.Text;
72 import org.eclipse.ui.IWorkbench;
73 import org.eclipse.ui.IWorkbenchPreferencePage;
74 import org.eclipse.ui.editors.text.EditorsUI;
75 import org.eclipse.ui.help.WorkbenchHelp;
76 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
77 import org.eclipse.ui.texteditor.AnnotationPreference;
78 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
79 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
81 * The page for setting the editor options.
83 public class JavaEditorPreferencePage extends PreferencePage
85 IWorkbenchPreferencePage {
86 private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
87 private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
88 private static final String DELIMITER = PreferencesMessages
89 .getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
90 /** The keys of the overlay store. */
91 public final OverlayPreferenceStore.OverlayKey[] fKeys;
92 private final String[][] fSyntaxColorListModel = new String[][]{
94 // PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
95 // PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$
97 // PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
98 // PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$
99 // { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"),
100 // PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$
101 // { PreferencesMessages.getString("JavaEditorPreferencePage.strings"),
102 // PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$
104 // PreferencesMessages.getString("JavaEditorPreferencePage.methodNames"),
105 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR }, //$NON-NLS-1$
106 // { PreferencesMessages.getString("JavaEditorPreferencePage.operators"),
107 // PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR }, //$NON-NLS-1$
108 // { PreferencesMessages.getString("JavaEditorPreferencePage.others"),
109 // PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
111 // PreferencesMessages.getString("JavaEditorPreferencePage.javaCommentTaskTags"),
112 // PreferenceConstants.EDITOR_TASK_TAG_COLOR }, //$NON-NLS-1$
114 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocKeywords"),
115 // PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$
117 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocHtmlTags"),
118 // PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR }, //$NON-NLS-1$
120 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocLinks"),
121 // PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$
123 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocOthers"),
124 // PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
125 { PreferencesMessages
126 .getString("PHPEditorPreferencePage.multiLineComment"),
127 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR},
129 { PreferencesMessages
130 .getString("PHPEditorPreferencePage.singleLineComment"),
131 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR},
133 {PreferencesMessages.getString("PHPEditorPreferencePage.tags"),
134 PreferenceConstants.EDITOR_JAVA_TAG_COLOR},
136 {PreferencesMessages.getString("PHPEditorPreferencePage.keywords"),
137 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR},
138 {PreferencesMessages.getString("PHPEditorPreferencePage.functionNames"),
139 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR},
141 {PreferencesMessages.getString("PHPEditorPreferencePage.variables"),
142 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR},
144 {PreferencesMessages.getString("PHPEditorPreferencePage.constants"),
145 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR},
147 {PreferencesMessages.getString("PHPEditorPreferencePage.types"),
148 PreferenceConstants.EDITOR_PHP_TYPE_COLOR},
150 {PreferencesMessages.getString("PHPEditorPreferencePage.strings"),
151 PreferenceConstants.EDITOR_STRING_COLOR},
153 {PreferencesMessages.getString("PHPEditorPreferencePage.others"),
154 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR},
156 {PreferencesMessages.getString("PHPEditorPreferencePage.phpDocKeywords"),
157 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR},
159 {PreferencesMessages.getString("PHPEditorPreferencePage.phpDocHtmlTags"),
160 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR},
162 {PreferencesMessages.getString("PHPEditorPreferencePage.phpDocLinks"),
163 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR},
165 {PreferencesMessages.getString("PHPEditorPreferencePage.phpDocOthers"),
166 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR} //$NON-NLS-1$
168 private final String[][] fAppearanceColorListModel = new String[][]{
171 .getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
172 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR},
176 .getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
177 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR},
181 .getString("JavaEditorPreferencePage.currentLineHighlighColor"),
182 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR},
186 .getString("JavaEditorPreferencePage.printMarginColor2"),
187 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR},
191 .getString("JavaEditorPreferencePage.findScopeColor2"),
192 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR},
194 {PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"),
195 PreferenceConstants.EDITOR_LINK_COLOR}, //$NON-NLS-1$
197 // private final String[][] fAnnotationColorListModel;
198 private final String[][] fContentAssistColorListModel = new String[][]{
201 .getString("JavaEditorPreferencePage.backgroundForCompletionProposals"),
202 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND},
206 .getString("JavaEditorPreferencePage.foregroundForCompletionProposals"),
207 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND},
211 .getString("JavaEditorPreferencePage.backgroundForMethodParameters"),
212 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND},
216 .getString("JavaEditorPreferencePage.foregroundForMethodParameters"),
217 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND},
221 .getString("JavaEditorPreferencePage.backgroundForCompletionReplacement"),
222 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND},
226 .getString("JavaEditorPreferencePage.foregroundForCompletionReplacement"),
227 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND} //$NON-NLS-1$
229 // private final String[][] fAnnotationDecorationListModel = new String[][]{
231 // PreferencesMessages
232 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
233 // AnnotationPreference.STYLE_NONE},
236 // PreferencesMessages
237 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
238 // AnnotationPreference.STYLE_SQUIGGLIES},
241 // PreferencesMessages
242 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
243 // AnnotationPreference.STYLE_UNDERLINE},
246 // PreferencesMessages
247 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
248 // AnnotationPreference.STYLE_BOX},
251 // PreferencesMessages
252 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
253 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
255 private OverlayPreferenceStore fOverlayStore;
256 private JavaTextTools fJavaTextTools;
257 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
258 private FoldingConfigurationBlock fFoldingConfigurationBlock;
260 private Map fColorButtons = new HashMap();
261 private Map fCheckBoxes = new HashMap();
262 private SelectionListener fCheckBoxListener = new SelectionListener() {
263 public void widgetDefaultSelected(SelectionEvent e) {
265 public void widgetSelected(SelectionEvent e) {
266 Button button = (Button) e.widget;
267 fOverlayStore.setValue((String) fCheckBoxes.get(button), button
271 private Map fTextFields = new HashMap();
272 private ModifyListener fTextFieldListener = new ModifyListener() {
273 public void modifyText(ModifyEvent e) {
274 Text text = (Text) e.widget;
275 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
278 private ArrayList fNumberFields = new ArrayList();
279 private ModifyListener fNumberFieldListener = new ModifyListener() {
280 public void modifyText(ModifyEvent e) {
281 numberFieldChanged((Text) e.widget);
284 private List fSyntaxColorList;
285 private List fAppearanceColorList;
286 private List fContentAssistColorList;
287 private List fAnnotationList;
288 private ColorEditor fSyntaxForegroundColorEditor;
289 private ColorEditor fAppearanceColorEditor;
290 private ColorEditor fAnnotationForegroundColorEditor;
291 private ColorEditor fContentAssistColorEditor;
292 private ColorEditor fBackgroundColorEditor;
293 private Button fBackgroundDefaultRadioButton;
294 private Button fBackgroundCustomRadioButton;
295 private Button fBackgroundColorButton;
296 private Button fBoldCheckBox;
297 private Button fAddJavaDocTagsButton;
298 private Button fEscapeStringsButton;
299 // private Button fGuessMethodArgumentsButton;
300 private SourceViewer fPreviewViewer;
301 private Color fBackgroundColor;
302 private Control fAutoInsertDelayText;
303 private Control fAutoInsertJavaTriggerText;
304 private Control fAutoInsertJavaDocTriggerText;
305 private Label fAutoInsertDelayLabel;
306 private Label fAutoInsertJavaTriggerLabel;
307 private Label fAutoInsertJavaDocTriggerLabel;
308 private Button fShowInTextCheckBox;
309 private Combo fDecorationStyleCombo;
310 private Button fHighlightInTextCheckBox;
311 private Button fShowInOverviewRulerCheckBox;
312 private Button fShowInVerticalRulerCheckBox;
313 // private Text fBrowserLikeLinksKeyModifierText;
314 // private Button fBrowserLikeLinksCheckBox;
315 // private StatusInfo fBrowserLikeLinksKeyModifierStatus;
316 // private Button fCompletionInsertsRadioButton;
317 // private Button fCompletionOverwritesRadioButton;
318 // private Button fStickyOccurrencesButton;
320 * Creates a new preference page.
322 public JavaEditorPreferencePage() {
323 setDescription(PreferencesMessages
324 .getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
325 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
326 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
327 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
328 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
329 // fAnnotationColorListModel = createAnnotationTypeListModel(markerAnnotationPreferences);
331 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(
332 MarkerAnnotationPreferences preferences) {
333 ArrayList overlayKeys = new ArrayList();
334 Iterator e = preferences.getAnnotationPreferences().iterator();
335 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
336 OverlayPreferenceStore.STRING,
337 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
338 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
339 OverlayPreferenceStore.BOOLEAN,
340 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
341 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
342 OverlayPreferenceStore.STRING,
343 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
344 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
345 OverlayPreferenceStore.BOOLEAN,
346 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
347 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
348 OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
349 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
350 OverlayPreferenceStore.STRING,
351 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
352 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
353 OverlayPreferenceStore.BOOLEAN,
354 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
355 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
356 OverlayPreferenceStore.STRING,
357 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
358 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
359 OverlayPreferenceStore.BOOLEAN,
360 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
361 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
362 OverlayPreferenceStore.STRING,
363 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
364 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
365 OverlayPreferenceStore.BOOLEAN,
366 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
368 .add(new OverlayPreferenceStore.OverlayKey(
369 OverlayPreferenceStore.STRING,
370 PreferenceConstants.EDITOR_STRING_COLOR));
372 .add(new OverlayPreferenceStore.OverlayKey(
373 OverlayPreferenceStore.BOOLEAN,
374 PreferenceConstants.EDITOR_STRING_BOLD));
375 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
376 OverlayPreferenceStore.STRING,
377 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
378 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
379 OverlayPreferenceStore.BOOLEAN,
380 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
381 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
382 OverlayPreferenceStore.STRING,
383 PreferenceConstants.EDITOR_TASK_TAG_COLOR));
384 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
385 OverlayPreferenceStore.BOOLEAN,
386 PreferenceConstants.EDITOR_TASK_TAG_BOLD));
387 // overlayKeys.add(new
388 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
389 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
390 // overlayKeys.add(new
391 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
392 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
393 // overlayKeys.add(new
394 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
395 // PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR));
396 // overlayKeys.add(new
397 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
398 // PreferenceConstants.EDITOR_JAVA_OPERATOR_BOLD));
399 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
400 OverlayPreferenceStore.STRING,
401 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
402 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
403 OverlayPreferenceStore.BOOLEAN,
404 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
405 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
406 OverlayPreferenceStore.STRING,
407 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
408 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
409 OverlayPreferenceStore.BOOLEAN,
410 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
411 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
412 OverlayPreferenceStore.STRING,
413 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
414 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
415 OverlayPreferenceStore.BOOLEAN,
416 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
417 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
418 OverlayPreferenceStore.STRING,
419 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
420 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
421 OverlayPreferenceStore.BOOLEAN,
422 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
423 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
424 OverlayPreferenceStore.STRING,
425 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
426 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
427 OverlayPreferenceStore.BOOLEAN,
428 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
429 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
430 OverlayPreferenceStore.STRING,
431 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
432 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
433 OverlayPreferenceStore.BOOLEAN,
434 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
435 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
436 OverlayPreferenceStore.STRING,
437 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
438 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
439 OverlayPreferenceStore.INT,
440 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
441 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
442 OverlayPreferenceStore.BOOLEAN,
443 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
444 // overlayKeys.add(new
445 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
446 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
447 // overlayKeys.add(new
448 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
449 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
450 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
451 OverlayPreferenceStore.STRING,
452 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
453 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
454 OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
455 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
456 OverlayPreferenceStore.BOOLEAN,
457 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
458 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
459 OverlayPreferenceStore.BOOLEAN,
460 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
461 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
462 OverlayPreferenceStore.BOOLEAN,
463 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
464 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
465 OverlayPreferenceStore.STRING,
466 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
467 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
468 OverlayPreferenceStore.BOOLEAN,
469 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
470 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
471 OverlayPreferenceStore.BOOLEAN,
472 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
473 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
474 OverlayPreferenceStore.BOOLEAN,
475 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
476 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
477 OverlayPreferenceStore.INT,
478 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
479 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
480 OverlayPreferenceStore.BOOLEAN,
481 PreferenceConstants.CODEASSIST_AUTOINSERT));
482 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
483 OverlayPreferenceStore.STRING,
484 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
485 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
486 OverlayPreferenceStore.STRING,
487 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
488 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
489 OverlayPreferenceStore.STRING,
490 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
491 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
492 OverlayPreferenceStore.STRING,
493 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
494 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
495 OverlayPreferenceStore.STRING,
496 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
497 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
498 OverlayPreferenceStore.STRING,
499 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
500 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
501 OverlayPreferenceStore.STRING,
502 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
503 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
504 OverlayPreferenceStore.STRING,
505 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
506 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
507 OverlayPreferenceStore.BOOLEAN,
508 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
509 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
510 OverlayPreferenceStore.BOOLEAN,
511 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
512 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
513 OverlayPreferenceStore.BOOLEAN,
514 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
515 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
516 OverlayPreferenceStore.BOOLEAN,
517 PreferenceConstants.CODEASSIST_ADDIMPORT));
518 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
519 OverlayPreferenceStore.BOOLEAN,
520 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
521 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
522 OverlayPreferenceStore.BOOLEAN,
523 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
524 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
525 OverlayPreferenceStore.BOOLEAN,
526 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
528 .add(new OverlayPreferenceStore.OverlayKey(
529 OverlayPreferenceStore.BOOLEAN,
530 PreferenceConstants.EDITOR_SMART_PASTE));
532 OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
533 PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP));
535 OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
536 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
538 .add(new OverlayPreferenceStore.OverlayKey(
539 OverlayPreferenceStore.BOOLEAN,
540 PreferenceConstants.EDITOR_CLOSE_BRACES));
541 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
542 OverlayPreferenceStore.BOOLEAN,
543 PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
545 .add(new OverlayPreferenceStore.OverlayKey(
546 OverlayPreferenceStore.BOOLEAN,
547 PreferenceConstants.EDITOR_WRAP_STRINGS));
549 OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
550 PreferenceConstants.EDITOR_ESCAPE_STRINGS));
551 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
552 OverlayPreferenceStore.BOOLEAN,
553 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
554 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
555 OverlayPreferenceStore.BOOLEAN,
556 PreferenceConstants.EDITOR_SMART_HOME_END));
558 OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
559 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
561 OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
562 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
563 // overlayKeys.add(new
564 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
565 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
566 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
567 OverlayPreferenceStore.STRING,
568 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
569 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
570 OverlayPreferenceStore.STRING,
571 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
572 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
573 OverlayPreferenceStore.BOOLEAN,
574 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
575 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
576 OverlayPreferenceStore.STRING,
577 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
578 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
579 OverlayPreferenceStore.STRING,
580 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
581 while (e.hasNext()) {
582 AnnotationPreference info = (AnnotationPreference) e.next();
583 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
584 OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
585 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
586 OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
587 if (info.getHighlightPreferenceKey() != null)
588 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
589 OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
591 .add(new OverlayPreferenceStore.OverlayKey(
592 OverlayPreferenceStore.BOOLEAN, info
593 .getOverviewRulerPreferenceKey()));
594 if (info.getVerticalRulerPreferenceKey() != null)
595 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
596 OverlayPreferenceStore.BOOLEAN, info
597 .getVerticalRulerPreferenceKey()));
598 if (info.getTextStylePreferenceKey() != null)
599 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
600 OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
602 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
604 overlayKeys.toArray(keys);
607 * @see IWorkbenchPreferencePage#init()
609 public void init(IWorkbench workbench) {
612 * @see PreferencePage#createControl(Composite)
614 public void createControl(Composite parent) {
615 super.createControl(parent);
616 WorkbenchHelp.setHelp(getControl(),
617 IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
619 private void handleSyntaxColorListSelection() {
620 int i = fSyntaxColorList.getSelectionIndex();
621 String key = fSyntaxColorListModel[i][1];
622 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
623 fSyntaxForegroundColorEditor.setColorValue(rgb);
624 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
626 private void handleAppearanceColorListSelection() {
627 int i = fAppearanceColorList.getSelectionIndex();
628 String key = fAppearanceColorListModel[i][1];
629 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
630 fAppearanceColorEditor.setColorValue(rgb);
632 private void handleContentAssistColorListSelection() {
633 int i = fContentAssistColorList.getSelectionIndex();
634 String key = fContentAssistColorListModel[i][1];
635 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
636 fContentAssistColorEditor.setColorValue(rgb);
638 // private void handleAnnotationListSelection() {
639 // int i = fAnnotationList.getSelectionIndex();
640 // String key = fAnnotationColorListModel[i][1];
641 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
642 // fAnnotationForegroundColorEditor.setColorValue(rgb);
643 // key = fAnnotationColorListModel[i][2];
644 // boolean showInText = fOverlayStore.getBoolean(key);
645 // fShowInTextCheckBox.setSelection(showInText);
646 // key = fAnnotationColorListModel[i][6];
647 // if (key != null) {
648 // fDecorationStyleCombo.setEnabled(showInText);
649 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
650 // String value = fOverlayStore.getString(key);
651 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
652 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
657 // fDecorationStyleCombo.setEnabled(false);
658 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
671 // key = fAnnotationColorListModel[i][3];
672 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
673 // key = fAnnotationColorListModel[i][4];
674 // if (key != null) {
675 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
676 // fHighlightInTextCheckBox.setEnabled(true);
678 // fHighlightInTextCheckBox.setEnabled(false);
679 // key = fAnnotationColorListModel[i][5];
680 // if (key != null) {
681 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
682 // fShowInVerticalRulerCheckBox.setEnabled(true);
684 // fShowInVerticalRulerCheckBox.setSelection(true);
685 // fShowInVerticalRulerCheckBox.setEnabled(false);
688 private Control createSyntaxPage(Composite parent) {
689 Composite colorComposite = new Composite(parent, SWT.NULL);
690 colorComposite.setLayout(new GridLayout());
691 Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
692 backgroundComposite.setLayout(new RowLayout());
693 backgroundComposite.setText(PreferencesMessages
694 .getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
695 SelectionListener backgroundSelectionListener = new SelectionListener() {
696 public void widgetSelected(SelectionEvent e) {
697 boolean custom = fBackgroundCustomRadioButton.getSelection();
698 fBackgroundColorButton.setEnabled(custom);
699 fOverlayStore.setValue(
700 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
702 public void widgetDefaultSelected(SelectionEvent e) {
705 fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO
707 fBackgroundDefaultRadioButton.setText(PreferencesMessages
708 .getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
709 fBackgroundDefaultRadioButton
710 .addSelectionListener(backgroundSelectionListener);
711 fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO
713 fBackgroundCustomRadioButton.setText(PreferencesMessages
714 .getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
715 fBackgroundCustomRadioButton
716 .addSelectionListener(backgroundSelectionListener);
717 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
718 fBackgroundColorButton = fBackgroundColorEditor.getButton();
719 Label label = new Label(colorComposite, SWT.LEFT);
720 label.setText(PreferencesMessages
721 .getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
722 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
723 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
724 GridLayout layout = new GridLayout();
725 layout.numColumns = 2;
726 layout.marginHeight = 0;
727 layout.marginWidth = 0;
728 editorComposite.setLayout(layout);
729 GridData gd = new GridData(GridData.FILL_BOTH);
730 editorComposite.setLayoutData(gd);
731 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
733 gd = new GridData(GridData.FILL_BOTH);
734 gd.heightHint = convertHeightInCharsToPixels(5);
735 fSyntaxColorList.setLayoutData(gd);
736 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
737 layout = new GridLayout();
738 layout.marginHeight = 0;
739 layout.marginWidth = 0;
740 layout.numColumns = 2;
741 stylesComposite.setLayout(layout);
742 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
743 label = new Label(stylesComposite, SWT.LEFT);
744 label.setText(PreferencesMessages
745 .getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
747 gd.horizontalAlignment = GridData.BEGINNING;
748 label.setLayoutData(gd);
749 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
750 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
751 gd = new GridData(GridData.FILL_HORIZONTAL);
752 gd.horizontalAlignment = GridData.BEGINNING;
753 foregroundColorButton.setLayoutData(gd);
754 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
755 fBoldCheckBox.setText(PreferencesMessages
756 .getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
757 gd = new GridData(GridData.FILL_HORIZONTAL);
758 gd.horizontalAlignment = GridData.BEGINNING;
759 gd.horizontalSpan = 2;
760 fBoldCheckBox.setLayoutData(gd);
761 label = new Label(colorComposite, SWT.LEFT);
762 label.setText(PreferencesMessages
763 .getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
764 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
765 Control previewer = createPreviewer(colorComposite);
766 gd = new GridData(GridData.FILL_BOTH);
767 gd.widthHint = convertWidthInCharsToPixels(20);
768 gd.heightHint = convertHeightInCharsToPixels(5);
769 previewer.setLayoutData(gd);
770 fSyntaxColorList.addSelectionListener(new SelectionListener() {
771 public void widgetDefaultSelected(SelectionEvent e) {
774 public void widgetSelected(SelectionEvent e) {
775 handleSyntaxColorListSelection();
778 foregroundColorButton.addSelectionListener(new SelectionListener() {
779 public void widgetDefaultSelected(SelectionEvent e) {
782 public void widgetSelected(SelectionEvent e) {
783 int i = fSyntaxColorList.getSelectionIndex();
784 String key = fSyntaxColorListModel[i][1];
785 PreferenceConverter.setValue(fOverlayStore, key,
786 fSyntaxForegroundColorEditor.getColorValue());
789 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
790 public void widgetDefaultSelected(SelectionEvent e) {
793 public void widgetSelected(SelectionEvent e) {
794 PreferenceConverter.setValue(fOverlayStore,
795 PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
799 fBoldCheckBox.addSelectionListener(new SelectionListener() {
800 public void widgetDefaultSelected(SelectionEvent e) {
803 public void widgetSelected(SelectionEvent e) {
804 int i = fSyntaxColorList.getSelectionIndex();
805 String key = fSyntaxColorListModel[i][1];
806 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
809 return colorComposite;
811 private Control createPreviewer(Composite parent) {
812 Preferences coreStore = createTemporaryCorePreferenceStore();
813 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
814 IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
815 IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore, new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
817 fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
819 fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools,
821 // Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
822 // fPreviewViewer.getTextWidget().setFont(font);
823 fPreviewViewer.getTextWidget().setFont(
824 JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
825 // new JavaSourcePreviewerUpdater(fPreviewViewer, fJavaTextTools);
826 fPreviewViewer.setEditable(false);
827 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
828 IDocument document = new Document(content);
829 fJavaTextTools.setupJavaDocumentPartitioner(document, ".php", null); //IJavaPartitions.JAVA_PARTITIONING);
830 fPreviewViewer.setDocument(document);
831 return fPreviewViewer.getControl();
833 private Preferences createTemporaryCorePreferenceStore() {
834 Preferences result = new Preferences();
835 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
838 private Control createAppearancePage(Composite parent) {
839 Composite appearanceComposite = new Composite(parent, SWT.NONE);
840 GridLayout layout = new GridLayout();
841 layout.numColumns = 2;
842 appearanceComposite.setLayout(layout);
843 String label = PreferencesMessages
844 .getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
845 addTextField(appearanceComposite, label,
846 PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
847 label = PreferencesMessages
848 .getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
849 addTextField(appearanceComposite, label,
850 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0,
852 label = PreferencesMessages
853 .getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
854 addCheckBox(appearanceComposite, label,
855 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
856 label = PreferencesMessages
857 .getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
858 addCheckBox(appearanceComposite, label,
859 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
860 label = PreferencesMessages
861 .getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
862 addCheckBox(appearanceComposite, label,
863 PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
864 label = PreferencesMessages
865 .getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
866 addCheckBox(appearanceComposite, label,
867 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
868 label = PreferencesMessages
869 .getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
870 addCheckBox(appearanceComposite, label,
871 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
872 label = PreferencesMessages
873 .getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
874 // Button master= addCheckBox(appearanceComposite, label,
875 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
876 label = PreferencesMessages
877 .getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
878 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
879 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
880 // createDependency(master, fStickyOccurrencesButton);
881 Label l = new Label(appearanceComposite, SWT.LEFT);
882 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
883 gd.horizontalSpan = 2;
884 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
886 l = new Label(appearanceComposite, SWT.LEFT);
887 l.setText(PreferencesMessages
888 .getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
889 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
890 gd.horizontalSpan = 2;
892 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
893 layout = new GridLayout();
894 layout.numColumns = 2;
895 layout.marginHeight = 0;
896 layout.marginWidth = 0;
897 editorComposite.setLayout(layout);
898 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
899 gd.horizontalSpan = 2;
900 editorComposite.setLayoutData(gd);
901 fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
903 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
904 | GridData.FILL_HORIZONTAL);
905 gd.heightHint = convertHeightInCharsToPixels(8);
906 fAppearanceColorList.setLayoutData(gd);
907 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
908 layout = new GridLayout();
909 layout.marginHeight = 0;
910 layout.marginWidth = 0;
911 layout.numColumns = 2;
912 stylesComposite.setLayout(layout);
913 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
914 l = new Label(stylesComposite, SWT.LEFT);
915 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
917 gd.horizontalAlignment = GridData.BEGINNING;
919 fAppearanceColorEditor = new ColorEditor(stylesComposite);
920 Button foregroundColorButton = fAppearanceColorEditor.getButton();
921 gd = new GridData(GridData.FILL_HORIZONTAL);
922 gd.horizontalAlignment = GridData.BEGINNING;
923 foregroundColorButton.setLayoutData(gd);
924 fAppearanceColorList.addSelectionListener(new SelectionListener() {
925 public void widgetDefaultSelected(SelectionEvent e) {
928 public void widgetSelected(SelectionEvent e) {
929 handleAppearanceColorListSelection();
932 foregroundColorButton.addSelectionListener(new SelectionListener() {
933 public void widgetDefaultSelected(SelectionEvent e) {
936 public void widgetSelected(SelectionEvent e) {
937 int i = fAppearanceColorList.getSelectionIndex();
938 String key = fAppearanceColorListModel[i][1];
939 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor
943 return appearanceComposite;
945 // private Control createAnnotationsPage(Composite parent) {
946 // Composite composite = new Composite(parent, SWT.NULL);
947 // GridLayout layout = new GridLayout();
948 // layout.numColumns = 2;
949 // composite.setLayout(layout);
950 // String text = PreferencesMessages
951 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping"); //$NON-NLS-1$
952 // addCheckBox(composite, text,
953 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
954 // text = PreferencesMessages
955 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
956 // addCheckBox(composite, text,
957 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
958 // addFiller(composite);
959 // Label label = new Label(composite, SWT.LEFT);
960 // label.setText(PreferencesMessages
961 // .getString("JavaEditorPreferencePage.annotationPresentationOptions")); //$NON-NLS-1$
962 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
963 // gd.horizontalSpan = 2;
964 // label.setLayoutData(gd);
965 // Composite editorComposite = new Composite(composite, SWT.NONE);
966 // layout = new GridLayout();
967 // layout.numColumns = 2;
968 // layout.marginHeight = 0;
969 // layout.marginWidth = 0;
970 // editorComposite.setLayout(layout);
971 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
972 // gd.horizontalSpan = 2;
973 // editorComposite.setLayoutData(gd);
974 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
976 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
977 // | GridData.FILL_HORIZONTAL);
978 // gd.heightHint = convertHeightInCharsToPixels(10);
979 // fAnnotationList.setLayoutData(gd);
980 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
981 // layout = new GridLayout();
982 // layout.marginHeight = 0;
983 // layout.marginWidth = 0;
984 // layout.numColumns = 2;
985 // optionsComposite.setLayout(layout);
986 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
987 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
988 // fShowInTextCheckBox.setText(PreferencesMessages
989 // .getString("JavaEditorPreferencePage.annotations.showInText")); //$NON-NLS-1$
990 // gd = new GridData(GridData.FILL_HORIZONTAL);
991 // gd.horizontalAlignment = GridData.BEGINNING;
992 // gd.horizontalSpan = 2;
993 // fShowInTextCheckBox.setLayoutData(gd);
994 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
995 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
996 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
997 // gd = new GridData(GridData.FILL_HORIZONTAL);
998 // gd.horizontalAlignment = GridData.BEGINNING;
999 // gd.horizontalSpan = 2;
1000 // gd.horizontalIndent = 20;
1001 // fDecorationStyleCombo.setLayoutData(gd);
1002 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1003 // fHighlightInTextCheckBox.setText(PreferencesMessages
1004 // .getString("TextEditorPreferencePage.annotations.highlightInText")); //$NON-NLS-1$
1005 // gd = new GridData(GridData.FILL_HORIZONTAL);
1006 // gd.horizontalAlignment = GridData.BEGINNING;
1007 // gd.horizontalSpan = 2;
1008 // fHighlightInTextCheckBox.setLayoutData(gd);
1009 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1010 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
1011 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler")); //$NON-NLS-1$
1012 // gd = new GridData(GridData.FILL_HORIZONTAL);
1013 // gd.horizontalAlignment = GridData.BEGINNING;
1014 // gd.horizontalSpan = 2;
1015 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
1016 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1017 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
1018 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler")); //$NON-NLS-1$
1019 // gd = new GridData(GridData.FILL_HORIZONTAL);
1020 // gd.horizontalAlignment = GridData.BEGINNING;
1021 // gd.horizontalSpan = 2;
1022 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
1023 // label = new Label(optionsComposite, SWT.LEFT);
1024 // label.setText(PreferencesMessages
1025 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
1026 // gd = new GridData();
1027 // gd.horizontalAlignment = GridData.BEGINNING;
1028 // label.setLayoutData(gd);
1029 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
1030 // Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton();
1031 // gd = new GridData(GridData.FILL_HORIZONTAL);
1032 // gd.horizontalAlignment = GridData.BEGINNING;
1033 // foregroundColorButton.setLayoutData(gd);
1034 // fAnnotationList.addSelectionListener(new SelectionListener() {
1035 // public void widgetDefaultSelected(SelectionEvent e) {
1038 // public void widgetSelected(SelectionEvent e) {
1039 // handleAnnotationListSelection();
1042 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
1043 // public void widgetDefaultSelected(SelectionEvent e) {
1046 // public void widgetSelected(SelectionEvent e) {
1047 // int i = fAnnotationList.getSelectionIndex();
1048 // String key = fAnnotationColorListModel[i][2];
1049 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
1050 // String decorationKey = fAnnotationColorListModel[i][6];
1051 // fDecorationStyleCombo.setEnabled(decorationKey != null
1052 // && fShowInTextCheckBox.getSelection());
1055 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
1056 // public void widgetDefaultSelected(SelectionEvent e) {
1059 // public void widgetSelected(SelectionEvent e) {
1060 // int i = fAnnotationList.getSelectionIndex();
1061 // String key = fAnnotationColorListModel[i][4];
1062 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
1065 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
1066 // public void widgetDefaultSelected(SelectionEvent e) {
1069 // public void widgetSelected(SelectionEvent e) {
1070 // int i = fAnnotationList.getSelectionIndex();
1071 // String key = fAnnotationColorListModel[i][3];
1073 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
1076 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
1077 // public void widgetDefaultSelected(SelectionEvent e) {
1080 // public void widgetSelected(SelectionEvent e) {
1081 // int i = fAnnotationList.getSelectionIndex();
1082 // String key = fAnnotationColorListModel[i][5];
1084 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
1087 // foregroundColorButton.addSelectionListener(new SelectionListener() {
1088 // public void widgetDefaultSelected(SelectionEvent e) {
1091 // public void widgetSelected(SelectionEvent e) {
1092 // int i = fAnnotationList.getSelectionIndex();
1093 // String key = fAnnotationColorListModel[i][1];
1094 // PreferenceConverter.setValue(fOverlayStore, key,
1095 // fAnnotationForegroundColorEditor.getColorValue());
1098 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
1102 // public void widgetDefaultSelected(SelectionEvent e) {
1108 // public void widgetSelected(SelectionEvent e) {
1109 // int i = fAnnotationList.getSelectionIndex();
1110 // String key = fAnnotationColorListModel[i][6];
1111 // if (key != null) {
1112 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1113 // if (fAnnotationDecorationListModel[j][0]
1114 // .equals(fDecorationStyleCombo.getText())) {
1115 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1122 // return composite;
1124 private String[][] createAnnotationTypeListModel(
1125 MarkerAnnotationPreferences preferences) {
1126 ArrayList listModelItems = new ArrayList();
1127 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1129 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1131 public int compare(Object o1, Object o2) {
1132 if (!(o2 instanceof AnnotationPreference))
1134 if (!(o1 instanceof AnnotationPreference))
1136 AnnotationPreference a1 = (AnnotationPreference) o1;
1137 AnnotationPreference a2 = (AnnotationPreference) o2;
1138 return Collator.getInstance().compare(a1.getPreferenceLabel(),
1139 a2.getPreferenceLabel());
1142 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1143 Iterator e = sortedPreferences.iterator();
1144 while (e.hasNext()) {
1145 AnnotationPreference info = (AnnotationPreference) e.next();
1146 listModelItems.add(new String[]{info.getPreferenceLabel(),
1147 info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1148 info.getOverviewRulerPreferenceKey(),
1149 info.getHighlightPreferenceKey(),
1150 info.getVerticalRulerPreferenceKey(),
1151 info.getTextStylePreferenceKey()});
1153 String[][] items = new String[listModelItems.size()][];
1154 listModelItems.toArray(items);
1157 private Control createTypingPage(Composite parent) {
1158 Composite composite = new Composite(parent, SWT.NONE);
1159 GridLayout layout = new GridLayout();
1160 layout.numColumns = 1;
1161 composite.setLayout(layout);
1163 PreferencesMessages.getString("JavaEditorPreferencePage.overwriteMode");
1165 addCheckBox(composite, label,
1166 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1167 addFiller(composite);
1170 PreferencesMessages.getString("JavaEditorPreferencePage.smartHomeEnd");
1172 addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END,
1176 PreferencesMessages.getString("JavaEditorPreferencePage.subWordNavigation");
1178 addCheckBox(composite, label,
1179 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1180 addFiller(composite);
1181 Group group = new Group(composite, SWT.NONE);
1182 layout = new GridLayout();
1183 layout.numColumns = 2;
1184 group.setLayout(layout);
1185 group.setText(PreferencesMessages
1186 .getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1188 PreferencesMessages.getString("JavaEditorPreferencePage.wrapStrings");
1190 Button button= addCheckBox(group, label,
1191 PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
1194 PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings");
1196 fEscapeStringsButton= addCheckBox(group, label,
1197 PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1);
1198 createDependency(button, fEscapeStringsButton);
1201 PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
1203 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1206 PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
1208 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS,
1212 PreferencesMessages.getString("JavaEditorPreferencePage.closeStrings");
1214 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP, 1);
1217 PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
1219 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1222 PreferencesMessages.getString("JavaEditorPreferencePage.closeBraces");
1224 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1227 PreferencesMessages.getString("JavaEditorPreferencePage.closeJavaDocs");
1229 button= addCheckBox(group, label,
1230 PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1233 PreferencesMessages.getString("JavaEditorPreferencePage.addJavaDocTags");
1235 fAddJavaDocTagsButton= addCheckBox(group, label,
1236 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1237 createDependency(button, fAddJavaDocTagsButton);
1240 private void addFiller(Composite composite) {
1241 Label filler = new Label(composite, SWT.LEFT);
1242 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1243 gd.horizontalSpan = 2;
1244 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1245 filler.setLayoutData(gd);
1247 private static void indent(Control control) {
1248 GridData gridData = new GridData();
1249 gridData.horizontalIndent = 20;
1250 control.setLayoutData(gridData);
1252 private static void createDependency(final Button master, final Control slave) {
1254 master.addSelectionListener(new SelectionListener() {
1255 public void widgetSelected(SelectionEvent e) {
1256 slave.setEnabled(master.getSelection());
1258 public void widgetDefaultSelected(SelectionEvent e) {
1262 private Control createContentAssistPage(Composite parent) {
1263 Composite contentAssistComposite = new Composite(parent, SWT.NULL);
1264 GridLayout layout = new GridLayout();
1265 layout.numColumns = 2;
1266 contentAssistComposite.setLayout(layout);
1267 addCompletionRadioButtons(contentAssistComposite);
1269 label = PreferencesMessages
1270 .getString("JavaEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$
1271 addCheckBox(contentAssistComposite, label,
1272 PreferenceConstants.CODEASSIST_AUTOINSERT, 0);
1273 label = PreferencesMessages
1274 .getString("JavaEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$
1275 addCheckBox(contentAssistComposite, label,
1276 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0);
1277 label = PreferencesMessages
1278 .getString("JavaEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$
1279 addCheckBox(contentAssistComposite, label,
1280 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0);
1281 label = PreferencesMessages
1282 .getString("JavaEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$
1283 addCheckBox(contentAssistComposite, label,
1284 PreferenceConstants.CODEASSIST_ADDIMPORT, 0);
1285 label = PreferencesMessages
1286 .getString("JavaEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
1287 Button button = addCheckBox(contentAssistComposite, label,
1288 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0);
1289 label = PreferencesMessages
1290 .getString("JavaEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
1291 // fGuessMethodArgumentsButton= addCheckBox(contentAssistComposite, label,
1292 // PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0);
1293 // createDependency(button, fGuessMethodArgumentsButton);
1294 label = PreferencesMessages
1295 .getString("JavaEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$
1296 final Button autoactivation = addCheckBox(contentAssistComposite, label,
1297 PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0);
1298 autoactivation.addSelectionListener(new SelectionAdapter() {
1299 public void widgetSelected(SelectionEvent e) {
1300 updateAutoactivationControls();
1303 Control[] labelledTextField;
1304 label = PreferencesMessages
1305 .getString("JavaEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$
1306 labelledTextField = addLabelledTextField(contentAssistComposite, label,
1307 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true);
1308 fAutoInsertDelayLabel = getLabelControl(labelledTextField);
1309 fAutoInsertDelayText = getTextControl(labelledTextField);
1310 label = PreferencesMessages
1311 .getString("JavaEditorPreferencePage.autoActivationTriggersForJava"); //$NON-NLS-1$
1312 labelledTextField = addLabelledTextField(contentAssistComposite, label,
1313 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0,
1315 fAutoInsertJavaTriggerLabel = getLabelControl(labelledTextField);
1316 fAutoInsertJavaTriggerText = getTextControl(labelledTextField);
1317 label = PreferencesMessages
1318 .getString("JavaEditorPreferencePage.autoActivationTriggersForJavaDoc"); //$NON-NLS-1$
1319 labelledTextField = addLabelledTextField(contentAssistComposite, label,
1320 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0,
1322 fAutoInsertJavaDocTriggerLabel = getLabelControl(labelledTextField);
1323 fAutoInsertJavaDocTriggerText = getTextControl(labelledTextField);
1324 Label l = new Label(contentAssistComposite, SWT.LEFT);
1325 l.setText(PreferencesMessages
1326 .getString("JavaEditorPreferencePage.codeAssist.colorOptions")); //$NON-NLS-1$
1327 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1328 gd.horizontalSpan = 2;
1329 l.setLayoutData(gd);
1330 Composite editorComposite = new Composite(contentAssistComposite, SWT.NONE);
1331 layout = new GridLayout();
1332 layout.numColumns = 2;
1333 layout.marginHeight = 0;
1334 layout.marginWidth = 0;
1335 editorComposite.setLayout(layout);
1336 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
1337 gd.horizontalSpan = 2;
1338 editorComposite.setLayoutData(gd);
1339 fContentAssistColorList = new List(editorComposite, SWT.SINGLE
1340 | SWT.V_SCROLL | SWT.BORDER);
1341 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1342 | GridData.FILL_HORIZONTAL);
1343 gd.heightHint = convertHeightInCharsToPixels(8);
1344 fContentAssistColorList.setLayoutData(gd);
1345 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
1346 layout = new GridLayout();
1347 layout.marginHeight = 0;
1348 layout.marginWidth = 0;
1349 layout.numColumns = 2;
1350 stylesComposite.setLayout(layout);
1351 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1352 l = new Label(stylesComposite, SWT.LEFT);
1353 l.setText(PreferencesMessages
1354 .getString("JavaEditorPreferencePage.codeAssist.color")); //$NON-NLS-1$
1355 gd = new GridData();
1356 gd.horizontalAlignment = GridData.BEGINNING;
1357 l.setLayoutData(gd);
1358 fContentAssistColorEditor = new ColorEditor(stylesComposite);
1359 Button colorButton = fContentAssistColorEditor.getButton();
1360 gd = new GridData(GridData.FILL_HORIZONTAL);
1361 gd.horizontalAlignment = GridData.BEGINNING;
1362 colorButton.setLayoutData(gd);
1363 fContentAssistColorList.addSelectionListener(new SelectionListener() {
1364 public void widgetDefaultSelected(SelectionEvent e) {
1367 public void widgetSelected(SelectionEvent e) {
1368 handleContentAssistColorListSelection();
1371 colorButton.addSelectionListener(new SelectionListener() {
1372 public void widgetDefaultSelected(SelectionEvent e) {
1375 public void widgetSelected(SelectionEvent e) {
1376 int i = fContentAssistColorList.getSelectionIndex();
1377 String key = fContentAssistColorListModel[i][1];
1378 PreferenceConverter.setValue(fOverlayStore, key,
1379 fContentAssistColorEditor.getColorValue());
1382 return contentAssistComposite;
1384 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1385 Composite completionComposite = new Composite(contentAssistComposite,
1387 GridData ccgd = new GridData();
1388 ccgd.horizontalSpan = 2;
1389 completionComposite.setLayoutData(ccgd);
1390 GridLayout ccgl = new GridLayout();
1391 ccgl.marginWidth = 0;
1392 ccgl.numColumns = 2;
1393 completionComposite.setLayout(ccgl);
1394 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1395 // public void widgetSelected(SelectionEvent e) {
1396 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1397 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1402 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1404 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1406 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1407 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1409 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1410 // SWT.RADIO | SWT.LEFT);
1411 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1413 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1414 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1416 private Control createNavigationPage(Composite parent) {
1417 Composite composite = new Composite(parent, SWT.NULL);
1418 GridLayout layout = new GridLayout();
1419 layout.numColumns = 2;
1420 composite.setLayout(layout);
1422 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1424 // fBrowserLikeLinksCheckBox= addCheckBox(composite, text,
1425 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1426 // fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1427 // public void widgetSelected(SelectionEvent e) {
1428 // boolean state= fBrowserLikeLinksCheckBox.getSelection();
1429 // fBrowserLikeLinksKeyModifierText.setEnabled(state);
1430 // handleBrowserLikeLinksKeyModifierModified();
1432 // public void widgetDefaultSelected(SelectionEvent e) {
1435 // Text field for modifier string
1437 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1439 // fBrowserLikeLinksKeyModifierText= addTextField(composite, text,
1440 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0,
1442 // fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1445 // (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER))
1447 // // Fix possible illegal modifier string
1449 // fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1450 // if (stateMask == -1)
1451 // fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1453 // fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1455 // fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1456 // private boolean isModifierCandidate;
1457 // public void keyPressed(KeyEvent e) {
1458 // isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask ==
1462 // public void keyReleased(KeyEvent e) {
1463 // if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask
1464 // && e.character == 0) {// && e.time -time < 1000) {
1465 // String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1466 // Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1467 // int i= selection.x - 1;
1468 // while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1471 // boolean needsPrefixDelimiter= i > -1 &&
1472 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1475 // while (i < modifierString.length() &&
1476 // Character.isWhitespace(modifierString.charAt(i))) {
1479 // boolean needsPostfixDelimiter= i < modifierString.length() &&
1480 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1482 // String insertString;
1484 // if (needsPrefixDelimiter && needsPostfixDelimiter)
1486 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1487 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1488 // else if (needsPrefixDelimiter)
1490 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1491 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1492 // else if (needsPostfixDelimiter)
1494 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1495 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1497 // insertString= Action.findModifierString(e.stateMask);
1499 // fBrowserLikeLinksKeyModifierText.insert(insertString);
1504 // fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener()
1506 // public void modifyText(ModifyEvent e) {
1507 // handleBrowserLikeLinksKeyModifierModified();
1512 private void handleBrowserLikeLinksKeyModifierModified() {
1513 // String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1514 // int stateMask= computeStateMask(modifiers);
1515 // if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 ||
1516 // (stateMask & SWT.SHIFT) != 0)) {
1517 // if (stateMask == -1)
1518 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1519 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid",
1520 // modifiers)); //$NON-NLS-1$
1522 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1523 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1526 // StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1528 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1529 // updateStatus(fBrowserLikeLinksKeyModifierStatus);
1532 // private IStatus getBrowserLikeLinksKeyModifierStatus() {
1533 // if (fBrowserLikeLinksKeyModifierStatus == null)
1534 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1535 // return fBrowserLikeLinksKeyModifierStatus;
1538 * Computes the state mask for the given modifier string.
1541 * the string with the modifiers, separated by '+', '-', ';', ','
1543 * @return the state mask or -1 if the input is invalid
1545 private int computeStateMask(String modifiers) {
1546 if (modifiers == null)
1548 if (modifiers.length() == 0)
1551 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers,
1552 ",;.:+-* "); //$NON-NLS-1$
1553 while (modifierTokenizer.hasMoreTokens()) {
1554 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer
1556 if (modifier == 0 || (stateMask & modifier) == modifier)
1558 stateMask = stateMask | modifier;
1563 * @see PreferencePage#createContents(Composite)
1565 protected Control createContents(Composite parent) {
1566 initializeDefaultColors();
1567 fFoldingConfigurationBlock= new FoldingConfigurationBlock(fOverlayStore);
1568 fOverlayStore.load();
1569 fOverlayStore.start();
1570 TabFolder folder = new TabFolder(parent, SWT.NONE);
1571 folder.setLayout(new TabFolderLayout());
1572 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1573 TabItem item = new TabItem(folder, SWT.NONE);
1574 item.setText(PreferencesMessages
1575 .getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1576 item.setControl(createAppearancePage(folder));
1577 item = new TabItem(folder, SWT.NONE);
1578 item.setText(PreferencesMessages
1579 .getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1580 item.setControl(createSyntaxPage(folder));
1581 item= new TabItem(folder, SWT.NONE);
1582 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist"));
1584 item.setControl(createContentAssistPage(folder));
1585 // item = new TabItem(folder, SWT.NONE);
1586 // item.setText(PreferencesMessages
1587 // .getString("JavaEditorPreferencePage.annotationsTab.title")); //$NON-NLS-1$
1588 // item.setControl(createAnnotationsPage(folder));
1589 item= new TabItem(folder, SWT.NONE);
1590 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
1592 item.setControl(createTypingPage(folder));
1594 item= new TabItem(folder, SWT.NONE);
1595 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
1597 fJavaEditorHoverConfigurationBlock= new
1598 JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1599 item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1600 item= new TabItem(folder, SWT.NONE);
1601 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1603 item.setControl(createNavigationPage(folder));
1604 item= new TabItem(folder, SWT.NONE);
1605 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1606 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1609 Dialog.applyDialogFont(folder);
1612 private void initialize() {
1614 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1615 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1616 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1618 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1619 fSyntaxColorList.select(0);
1620 handleSyntaxColorListSelection();
1624 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1625 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1626 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1628 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1629 fAppearanceColorList.select(0);
1630 handleAppearanceColorListSelection();
1634 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1635 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1636 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1637 // public void run() {
1638 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1639 // fAnnotationList.select(0);
1640 // handleAnnotationListSelection();
1644 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1645 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1646 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1647 // public void run() {
1648 // if (fContentAssistColorList != null &&
1649 // !fContentAssistColorList.isDisposed()) {
1650 // fContentAssistColorList.select(0);
1651 // handleContentAssistColorListSelection();
1655 fFoldingConfigurationBlock.initialize();
1657 private void initializeFields() {
1658 Iterator e = fColorButtons.keySet().iterator();
1659 while (e.hasNext()) {
1660 ColorEditor c = (ColorEditor) e.next();
1661 String key = (String) fColorButtons.get(c);
1662 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1663 c.setColorValue(rgb);
1665 e = fCheckBoxes.keySet().iterator();
1666 while (e.hasNext()) {
1667 Button b = (Button) e.next();
1668 String key = (String) fCheckBoxes.get(b);
1669 b.setSelection(fOverlayStore.getBoolean(key));
1671 e = fTextFields.keySet().iterator();
1672 while (e.hasNext()) {
1673 Text t = (Text) e.next();
1674 String key = (String) fTextFields.get(t);
1675 t.setText(fOverlayStore.getString(key));
1677 RGB rgb = PreferenceConverter.getColor(fOverlayStore,
1678 PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1679 fBackgroundColorEditor.setColorValue(rgb);
1680 boolean default_ = fOverlayStore
1681 .getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1682 fBackgroundDefaultRadioButton.setSelection(default_);
1683 fBackgroundCustomRadioButton.setSelection(!default_);
1684 fBackgroundColorButton.setEnabled(!default_);
1685 boolean closeJavaDocs=
1686 fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1687 fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1688 fEscapeStringsButton.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS));
1689 // boolean fillMethodArguments=
1690 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1691 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1692 // boolean completionInserts=
1693 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1694 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1695 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1697 // fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1698 // boolean markOccurrences=
1699 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1700 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1701 updateAutoactivationControls();
1703 private void initializeDefaultColors() {
1704 if (!getPreferenceStore().contains(
1705 PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1706 RGB rgb = getControl().getDisplay().getSystemColor(
1707 SWT.COLOR_LIST_BACKGROUND).getRGB();
1708 PreferenceConverter.setDefault(fOverlayStore,
1709 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1710 PreferenceConverter.setDefault(getPreferenceStore(),
1711 PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1713 if (!getPreferenceStore().contains(
1714 PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1715 RGB rgb = getControl().getDisplay().getSystemColor(
1716 SWT.COLOR_LIST_FOREGROUND).getRGB();
1717 PreferenceConverter.setDefault(fOverlayStore,
1718 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1719 PreferenceConverter.setDefault(getPreferenceStore(),
1720 PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1723 private void updateAutoactivationControls() {
1724 // boolean autoactivation=
1725 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1726 // fAutoInsertDelayText.setEnabled(autoactivation);
1727 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1728 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1729 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1731 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1732 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1735 * @see PreferencePage#performOk()
1737 public boolean performOk() {
1738 // fJavaEditorHoverConfigurationBlock.performOk();
1739 fFoldingConfigurationBlock.performOk();
1740 // fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1741 // computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1742 fOverlayStore.propagate();
1743 PHPeclipsePlugin.getDefault().savePluginPreferences();
1747 * @see PreferencePage#performDefaults()
1749 protected void performDefaults() {
1750 fOverlayStore.loadDefaults();
1752 handleSyntaxColorListSelection();
1753 handleAppearanceColorListSelection();
1754 // handleAnnotationListSelection();
1755 // handleContentAssistColorListSelection();
1756 // fJavaEditorHoverConfigurationBlock.performDefaults();
1757 fFoldingConfigurationBlock.performDefaults();
1758 super.performDefaults();
1759 fPreviewViewer.invalidateTextPresentation();
1762 * @see DialogPage#dispose()
1764 public void dispose() {
1765 fFoldingConfigurationBlock.dispose();
1767 if (fJavaTextTools != null) {
1768 fJavaTextTools.dispose();
1769 fJavaTextTools = null;
1771 if (fOverlayStore != null) {
1772 fOverlayStore.stop();
1773 fOverlayStore = null;
1775 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1776 fBackgroundColor.dispose();
1779 private Button addCheckBox(Composite parent, String label, String key,
1781 Button checkBox = new Button(parent, SWT.CHECK);
1782 checkBox.setText(label);
1783 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1784 gd.horizontalIndent = indentation;
1785 gd.horizontalSpan = 2;
1786 checkBox.setLayoutData(gd);
1787 checkBox.addSelectionListener(fCheckBoxListener);
1788 fCheckBoxes.put(checkBox, key);
1791 private Text addTextField(Composite composite, String label, String key,
1792 int textLimit, int indentation, boolean isNumber) {
1793 return getTextControl(addLabelledTextField(composite, label, key,
1794 textLimit, indentation, isNumber));
1796 private static Label getLabelControl(Control[] labelledTextField) {
1797 return (Label) labelledTextField[0];
1799 private static Text getTextControl(Control[] labelledTextField) {
1800 return (Text) labelledTextField[1];
1803 * Returns an array of size 2: - first element is of type <code>Label</code>-
1804 * second element is of type <code>Text</code> Use <code>getLabelControl</code>
1805 * and <code>getTextControl</code> to get the 2 controls.
1807 private Control[] addLabelledTextField(Composite composite, String label,
1808 String key, int textLimit, int indentation, boolean isNumber) {
1809 Label labelControl = new Label(composite, SWT.NONE);
1810 labelControl.setText(label);
1811 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1812 gd.horizontalIndent = indentation;
1813 labelControl.setLayoutData(gd);
1814 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1815 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1816 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1817 textControl.setLayoutData(gd);
1818 textControl.setTextLimit(textLimit);
1819 fTextFields.put(textControl, key);
1821 fNumberFields.add(textControl);
1822 textControl.addModifyListener(fNumberFieldListener);
1824 textControl.addModifyListener(fTextFieldListener);
1826 return new Control[]{labelControl, textControl};
1828 private String loadPreviewContentFromFile(String filename) {
1830 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1831 StringBuffer buffer = new StringBuffer(512);
1832 BufferedReader reader = null;
1834 reader = new BufferedReader(new InputStreamReader(getClass()
1835 .getResourceAsStream(filename)));
1836 while ((line = reader.readLine()) != null) {
1837 buffer.append(line);
1838 buffer.append(separator);
1840 } catch (IOException io) {
1841 PHPeclipsePlugin.log(io);
1843 if (reader != null) {
1846 } catch (IOException e) {
1850 return buffer.toString();
1852 private void numberFieldChanged(Text textControl) {
1853 String number = textControl.getText();
1854 IStatus status = validatePositiveNumber(number);
1855 if (!status.matches(IStatus.ERROR))
1856 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1857 updateStatus(status);
1859 private IStatus validatePositiveNumber(String number) {
1860 StatusInfo status = new StatusInfo();
1861 if (number.length() == 0) {
1862 status.setError(PreferencesMessages
1863 .getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1866 int value = Integer.parseInt(number);
1868 status.setError(PreferencesMessages.getFormattedString(
1869 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1870 } catch (NumberFormatException e) {
1871 status.setError(PreferencesMessages.getFormattedString(
1872 "JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1877 void updateStatus(IStatus status) {
1878 if (!status.matches(IStatus.ERROR)) {
1879 for (int i = 0; i < fNumberFields.size(); i++) {
1880 Text text = (Text) fNumberFields.get(i);
1881 IStatus s = validatePositiveNumber(text.getText());
1882 status = StatusUtil.getMoreSevere(s, status);
1886 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1888 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1890 setValid(!status.matches(IStatus.ERROR));
1891 StatusUtil.applyToStatusLine(this, status);