1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.preferences;
13 import java.io.BufferedReader;
14 import java.io.IOException;
15 import java.io.InputStreamReader;
16 import java.text.Collator;
17 import java.util.ArrayList;
18 import java.util.Comparator;
19 import java.util.HashMap;
20 import java.util.Iterator;
22 import java.util.SortedSet;
23 import java.util.StringTokenizer;
24 import java.util.TreeSet;
26 import net.sourceforge.phpdt.core.JavaCore;
27 import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
28 import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
29 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
30 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
31 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
32 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
33 import net.sourceforge.phpdt.ui.PreferenceConstants;
34 import net.sourceforge.phpdt.ui.text.JavaTextTools;
35 import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
36 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
37 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
38 import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer;
39 import net.sourceforge.phpeclipse.preferences.ColorEditor;
41 import org.eclipse.core.runtime.IStatus;
42 import org.eclipse.core.runtime.Preferences;
43 import org.eclipse.jface.action.Action;
44 import org.eclipse.jface.dialogs.Dialog;
45 import org.eclipse.jface.preference.IPreferenceStore;
46 import org.eclipse.jface.preference.PreferenceConverter;
47 import org.eclipse.jface.preference.PreferencePage;
48 import org.eclipse.jface.resource.JFaceResources;
49 import org.eclipse.jface.text.Document;
50 import org.eclipse.jface.text.IDocument;
51 import org.eclipse.jface.text.source.SourceViewer;
52 import org.eclipse.swt.SWT;
53 import org.eclipse.swt.events.KeyEvent;
54 import org.eclipse.swt.events.KeyListener;
55 import org.eclipse.swt.events.ModifyEvent;
56 import org.eclipse.swt.events.ModifyListener;
57 import org.eclipse.swt.events.SelectionEvent;
58 import org.eclipse.swt.events.SelectionListener;
59 import org.eclipse.swt.graphics.Color;
60 import org.eclipse.swt.graphics.Font;
61 import org.eclipse.swt.graphics.Point;
62 import org.eclipse.swt.graphics.RGB;
63 import org.eclipse.swt.layout.GridData;
64 import org.eclipse.swt.layout.GridLayout;
65 import org.eclipse.swt.layout.RowLayout;
66 import org.eclipse.swt.widgets.Button;
67 import org.eclipse.swt.widgets.Combo;
68 import org.eclipse.swt.widgets.Composite;
69 import org.eclipse.swt.widgets.Control;
70 import org.eclipse.swt.widgets.Group;
71 import org.eclipse.swt.widgets.Label;
72 import org.eclipse.swt.widgets.List;
73 import org.eclipse.swt.widgets.TabFolder;
74 import org.eclipse.swt.widgets.TabItem;
75 import org.eclipse.swt.widgets.Text;
76 import org.eclipse.ui.IWorkbench;
77 import org.eclipse.ui.IWorkbenchPreferencePage;
78 import org.eclipse.ui.editors.text.EditorsUI;
79 import org.eclipse.ui.help.WorkbenchHelp;
80 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
81 import org.eclipse.ui.texteditor.AnnotationPreference;
82 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
83 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
86 * The page for setting the editor options.
88 public class JavaEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
89 private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
91 private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
93 private static final String DELIMITER = PreferencesMessages.getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
95 /** The keys of the overlay store. */
96 public final OverlayPreferenceStore.OverlayKey[] fKeys;
98 private final String[][] fSyntaxColorListModel = new String[][] {
99 { PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
100 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
102 { PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
103 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
105 { PreferencesMessages.getString("JavaEditorPreferencePage.tags"), PreferenceConstants.EDITOR_PHP_TAG_COLOR },
107 { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
108 { PreferencesMessages.getString("JavaEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
110 { PreferencesMessages.getString("JavaEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
112 { PreferencesMessages.getString("JavaEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
114 { PreferencesMessages.getString("JavaEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
116 { PreferencesMessages.getString("JavaEditorPreferencePage.strings_dq"), PreferenceConstants.EDITOR_STRING_COLOR_DQ },
117 { PreferencesMessages.getString("JavaEditorPreferencePage.strings_sq"), PreferenceConstants.EDITOR_STRING_COLOR_SQ },
119 { PreferencesMessages.getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
120 { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
122 { PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"),
123 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
124 { PreferencesMessages.getString("JavaEditorPreferencePage.braces"),
125 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR },
127 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
129 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
131 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
133 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
136 private final String[][] fAppearanceColorListModel = new String[][] {
137 { PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
138 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR },
140 { PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
141 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
143 { PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"),
144 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
146 { PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"),
147 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
149 { PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
151 { PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
154 // private final String[][] fAnnotationColorListModel;
156 // private final String[][] fAnnotationDecorationListModel = new String[][]{
158 // PreferencesMessages
159 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
160 // AnnotationPreference.STYLE_NONE},
163 // PreferencesMessages
164 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
165 // AnnotationPreference.STYLE_SQUIGGLIES},
168 // PreferencesMessages
169 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
170 // AnnotationPreference.STYLE_UNDERLINE},
173 // PreferencesMessages
174 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
175 // AnnotationPreference.STYLE_BOX},
178 // PreferencesMessages
179 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
180 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
182 private OverlayPreferenceStore fOverlayStore;
184 private JavaTextTools fJavaTextTools;
186 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
188 private FoldingConfigurationBlock fFoldingConfigurationBlock;
190 private Map fColorButtons = new HashMap();
192 private Map fCheckBoxes = new HashMap();
194 private SelectionListener fCheckBoxListener = new SelectionListener() {
195 public void widgetDefaultSelected(SelectionEvent e) {
198 public void widgetSelected(SelectionEvent e) {
199 Button button = (Button) e.widget;
200 fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
204 private Map fTextFields = new HashMap();
206 private ModifyListener fTextFieldListener = new ModifyListener() {
207 public void modifyText(ModifyEvent e) {
208 Text text = (Text) e.widget;
209 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
213 private ArrayList fNumberFields = new ArrayList();
215 private ModifyListener fNumberFieldListener = new ModifyListener() {
216 public void modifyText(ModifyEvent e) {
217 numberFieldChanged((Text) e.widget);
221 private List fSyntaxColorList;
223 private List fAppearanceColorList;
225 // private List fContentAssistColorList;
226 private List fAnnotationList;
228 private ColorEditor fSyntaxForegroundColorEditor;
230 private ColorEditor fAppearanceColorEditor;
232 private ColorEditor fAnnotationForegroundColorEditor;
234 private ColorEditor fContentAssistColorEditor;
236 private ColorEditor fBackgroundColorEditor;
238 private Button fBackgroundDefaultRadioButton;
240 private Button fBackgroundCustomRadioButton;
242 private Button fBackgroundColorButton;
244 private Button fBoldCheckBox;
246 // private Button fAddJavaDocTagsButton;
248 private Button fEscapeStringsButtonDQ;
250 private Button fEscapeStringsButtonSQ;
252 // private Button fGuessMethodArgumentsButton;
253 private SourceViewer fPreviewViewer;
255 private Color fBackgroundColor;
257 private Control fAutoInsertDelayText;
259 private Control fAutoInsertJavaTriggerText;
261 private Control fAutoInsertJavaDocTriggerText;
263 private Label fAutoInsertDelayLabel;
265 private Label fAutoInsertJavaTriggerLabel;
267 private Label fAutoInsertJavaDocTriggerLabel;
269 private Button fShowInTextCheckBox;
271 private Combo fDecorationStyleCombo;
273 private Button fHighlightInTextCheckBox;
275 private Button fShowInOverviewRulerCheckBox;
277 private Button fShowInVerticalRulerCheckBox;
279 private Text fBrowserLikeLinksKeyModifierText;
280 private Button fBrowserLikeLinksCheckBox;
281 private StatusInfo fBrowserLikeLinksKeyModifierStatus;
282 // private Button fCompletionInsertsRadioButton;
283 // private Button fCompletionOverwritesRadioButton;
284 // private Button fStickyOccurrencesButton;
286 * Creates a new preference page.
288 public JavaEditorPreferencePage() {
289 setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
290 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
291 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
292 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
293 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
294 // fAnnotationColorListModel =
295 // createAnnotationTypeListModel(markerAnnotationPreferences);
298 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
299 ArrayList overlayKeys = new ArrayList();
300 Iterator e = preferences.getAnnotationPreferences().iterator();
301 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
302 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
303 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
304 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
305 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
306 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
307 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
308 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
309 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
310 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
311 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
312 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
313 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
314 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
315 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
316 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
317 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
318 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
319 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
320 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
321 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
323 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TAG_COLOR));
324 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TAG_BOLD));
325 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
326 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
327 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
328 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
329 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
330 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
331 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
332 PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
333 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
334 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
335 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
336 PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
338 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
340 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
342 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR_DQ));
343 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD_DQ));
344 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR_SQ));
345 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD_SQ));
346 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
347 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
348 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
349 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
351 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
353 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
354 // overlayKeys.add(new
355 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING_DQ,
356 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
357 // overlayKeys.add(new
358 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
359 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
360 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
361 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
362 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
363 PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
364 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
365 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
366 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
367 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
368 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
369 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR));
370 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
371 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_BOLD));
372 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
373 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
374 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
375 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
376 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
377 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
378 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
379 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
380 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
381 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
382 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
383 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
384 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
385 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
386 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
387 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
388 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
389 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
390 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
391 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
392 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
393 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
394 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
395 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
396 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
397 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
398 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
399 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
400 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
401 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
402 // overlayKeys.add(new
403 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
404 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
405 // overlayKeys.add(new
406 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
407 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
408 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
409 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
410 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
411 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
412 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
413 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
414 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
415 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
416 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
417 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
418 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
419 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
420 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
421 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
422 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
423 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
424 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
425 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
426 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
428 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT));
429 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
430 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
431 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
432 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
433 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
434 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
435 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
436 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
437 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
438 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
439 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
440 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
441 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
442 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
443 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
444 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
445 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
446 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
447 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
448 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
449 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
450 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
452 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT));
453 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
454 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
455 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
456 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
457 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
458 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
459 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE));
460 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
461 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
462 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
463 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
464 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
465 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
467 // .add(new OverlayPreferenceStore.OverlayKey(
468 // OverlayPreferenceStore.BOOLEAN,
469 // PreferenceConstants.EDITOR_CLOSE_BRACES));
470 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
471 OverlayPreferenceStore.BOOLEAN,
472 PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
473 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_WORDS));
474 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
476 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
477 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
479 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
481 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
482 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
483 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
484 PreferenceConstants.EDITOR_FORMAT_JAVADOCS));
488 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
489 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
490 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
491 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
492 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
493 // overlayKeys.add(new
494 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
495 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
496 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
497 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
498 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
499 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
500 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
501 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
502 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
503 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
504 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
505 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
506 while (e.hasNext()) {
507 AnnotationPreference info = (AnnotationPreference) e.next();
508 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
509 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
510 if (info.getHighlightPreferenceKey() != null)
511 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
512 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
513 if (info.getVerticalRulerPreferenceKey() != null)
515 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
516 if (info.getTextStylePreferenceKey() != null)
517 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
519 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
520 overlayKeys.toArray(keys);
523 * @see IWorkbenchPreferencePage#init()
526 public void init(IWorkbench workbench) {
530 * @see PreferencePage#createControl(Composite)
532 public void createControl(Composite parent) {
533 super.createControl(parent);
534 WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
537 private void handleSyntaxColorListSelection() {
538 int i = fSyntaxColorList.getSelectionIndex();
539 String key = fSyntaxColorListModel[i][1];
540 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
541 fSyntaxForegroundColorEditor.setColorValue(rgb);
542 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
545 private void handleAppearanceColorListSelection() {
546 int i = fAppearanceColorList.getSelectionIndex();
547 String key = fAppearanceColorListModel[i][1];
548 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
549 fAppearanceColorEditor.setColorValue(rgb);
552 // private void handleAnnotationListSelection() {
553 // int i = fAnnotationList.getSelectionIndex();
554 // String key = fAnnotationColorListModel[i][1];
555 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
556 // fAnnotationForegroundColorEditor.setColorValue(rgb);
557 // key = fAnnotationColorListModel[i][2];
558 // boolean showInText = fOverlayStore.getBoolean(key);
559 // fShowInTextCheckBox.setSelection(showInText);
560 // key = fAnnotationColorListModel[i][6];
561 // if (key != null) {
562 // fDecorationStyleCombo.setEnabled(showInText);
563 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
564 // String value = fOverlayStore.getString(key);
565 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
566 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
571 // fDecorationStyleCombo.setEnabled(false);
572 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
585 // key = fAnnotationColorListModel[i][3];
586 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
587 // key = fAnnotationColorListModel[i][4];
588 // if (key != null) {
589 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
590 // fHighlightInTextCheckBox.setEnabled(true);
592 // fHighlightInTextCheckBox.setEnabled(false);
593 // key = fAnnotationColorListModel[i][5];
594 // if (key != null) {
595 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
596 // fShowInVerticalRulerCheckBox.setEnabled(true);
598 // fShowInVerticalRulerCheckBox.setSelection(true);
599 // fShowInVerticalRulerCheckBox.setEnabled(false);
602 private Control createSyntaxPage(Composite parent) {
603 Composite colorComposite = new Composite(parent, SWT.NULL);
604 colorComposite.setLayout(new GridLayout());
605 Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
606 backgroundComposite.setLayout(new RowLayout());
607 backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
608 SelectionListener backgroundSelectionListener = new SelectionListener() {
609 public void widgetSelected(SelectionEvent e) {
610 boolean custom = fBackgroundCustomRadioButton.getSelection();
611 fBackgroundColorButton.setEnabled(custom);
612 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
615 public void widgetDefaultSelected(SelectionEvent e) {
618 fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
619 fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
620 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
621 fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
622 fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
623 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
624 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
625 fBackgroundColorButton = fBackgroundColorEditor.getButton();
626 Label label = new Label(colorComposite, SWT.LEFT);
627 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
628 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
629 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
630 GridLayout layout = new GridLayout();
631 layout.numColumns = 2;
632 layout.marginHeight = 0;
633 layout.marginWidth = 0;
634 editorComposite.setLayout(layout);
635 GridData gd = new GridData(GridData.FILL_BOTH);
636 editorComposite.setLayoutData(gd);
637 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
638 gd = new GridData(GridData.FILL_BOTH);
639 gd.heightHint = convertHeightInCharsToPixels(5);
640 fSyntaxColorList.setLayoutData(gd);
641 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
642 layout = new GridLayout();
643 layout.marginHeight = 0;
644 layout.marginWidth = 0;
645 layout.numColumns = 2;
646 stylesComposite.setLayout(layout);
647 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
648 label = new Label(stylesComposite, SWT.LEFT);
649 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
651 gd.horizontalAlignment = GridData.BEGINNING;
652 label.setLayoutData(gd);
653 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
654 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
655 gd = new GridData(GridData.FILL_HORIZONTAL);
656 gd.horizontalAlignment = GridData.BEGINNING;
657 foregroundColorButton.setLayoutData(gd);
658 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
659 fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
660 gd = new GridData(GridData.FILL_HORIZONTAL);
661 gd.horizontalAlignment = GridData.BEGINNING;
662 gd.horizontalSpan = 2;
663 fBoldCheckBox.setLayoutData(gd);
664 label = new Label(colorComposite, SWT.LEFT);
665 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
666 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
667 Control previewer = createPreviewer(colorComposite);
668 gd = new GridData(GridData.FILL_BOTH);
669 gd.widthHint = convertWidthInCharsToPixels(20);
670 gd.heightHint = convertHeightInCharsToPixels(5);
671 previewer.setLayoutData(gd);
672 fSyntaxColorList.addSelectionListener(new SelectionListener() {
673 public void widgetDefaultSelected(SelectionEvent e) {
677 public void widgetSelected(SelectionEvent e) {
678 handleSyntaxColorListSelection();
681 foregroundColorButton.addSelectionListener(new SelectionListener() {
682 public void widgetDefaultSelected(SelectionEvent e) {
686 public void widgetSelected(SelectionEvent e) {
687 int i = fSyntaxColorList.getSelectionIndex();
688 String key = fSyntaxColorListModel[i][1];
689 PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
692 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
693 public void widgetDefaultSelected(SelectionEvent e) {
697 public void widgetSelected(SelectionEvent e) {
698 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
702 fBoldCheckBox.addSelectionListener(new SelectionListener() {
703 public void widgetDefaultSelected(SelectionEvent e) {
707 public void widgetSelected(SelectionEvent e) {
708 int i = fSyntaxColorList.getSelectionIndex();
709 String key = fSyntaxColorListModel[i][1];
710 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
713 return colorComposite;
716 private Control createPreviewer(Composite parent) {
717 Preferences coreStore = createTemporaryCorePreferenceStore();
718 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
719 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
720 IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
721 new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
723 fPreviewViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
724 JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
725 PHPSourceViewerConfiguration configuration= new PHPSourceViewerConfiguration(tools.getColorManager(), store, null, IPHPPartitions.PHP_PARTITIONING);
726 // PHPSourceViewerConfiguration configuration =new PHPSourceViewerConfiguration(fJavaTextTools, null, IPHPPartitions.PHP_PARTITIONING);
727 fPreviewViewer.configure(configuration);
729 Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
730 fPreviewViewer.getTextWidget().setFont(font);
731 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
732 fPreviewViewer.setEditable(false);
733 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
734 IDocument document = new Document(content);
735 fJavaTextTools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
736 fPreviewViewer.setDocument(document);
737 return fPreviewViewer.getControl();
740 private Preferences createTemporaryCorePreferenceStore() {
741 Preferences result = new Preferences();
742 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
746 private Control createAppearancePage(Composite parent) {
747 Composite appearanceComposite = new Composite(parent, SWT.NONE);
748 GridLayout layout = new GridLayout();
749 layout.numColumns = 2;
750 appearanceComposite.setLayout(layout);
751 String label = PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
752 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
753 label = PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
754 addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
755 label = PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
756 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
757 label = PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
758 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
759 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
760 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
761 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
762 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
763 label = PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
764 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
765 label = PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
766 // Button master= addCheckBox(appearanceComposite, label,
767 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
768 label = PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
769 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
770 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
771 // createDependency(master, fStickyOccurrencesButton);
772 Label l = new Label(appearanceComposite, SWT.LEFT);
773 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
774 gd.horizontalSpan = 2;
775 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
777 l = new Label(appearanceComposite, SWT.LEFT);
778 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
779 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
780 gd.horizontalSpan = 2;
782 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
783 layout = new GridLayout();
784 layout.numColumns = 2;
785 layout.marginHeight = 0;
786 layout.marginWidth = 0;
787 editorComposite.setLayout(layout);
788 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
789 gd.horizontalSpan = 2;
790 editorComposite.setLayoutData(gd);
791 fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
792 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
793 gd.heightHint = convertHeightInCharsToPixels(8);
794 fAppearanceColorList.setLayoutData(gd);
795 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
796 layout = new GridLayout();
797 layout.marginHeight = 0;
798 layout.marginWidth = 0;
799 layout.numColumns = 2;
800 stylesComposite.setLayout(layout);
801 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
802 l = new Label(stylesComposite, SWT.LEFT);
803 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
805 gd.horizontalAlignment = GridData.BEGINNING;
807 fAppearanceColorEditor = new ColorEditor(stylesComposite);
808 Button foregroundColorButton = fAppearanceColorEditor.getButton();
809 gd = new GridData(GridData.FILL_HORIZONTAL);
810 gd.horizontalAlignment = GridData.BEGINNING;
811 foregroundColorButton.setLayoutData(gd);
812 fAppearanceColorList.addSelectionListener(new SelectionListener() {
813 public void widgetDefaultSelected(SelectionEvent e) {
817 public void widgetSelected(SelectionEvent e) {
818 handleAppearanceColorListSelection();
821 foregroundColorButton.addSelectionListener(new SelectionListener() {
822 public void widgetDefaultSelected(SelectionEvent e) {
826 public void widgetSelected(SelectionEvent e) {
827 int i = fAppearanceColorList.getSelectionIndex();
828 String key = fAppearanceColorListModel[i][1];
829 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
832 return appearanceComposite;
835 // private Control createAnnotationsPage(Composite parent) {
836 // Composite composite = new Composite(parent, SWT.NULL);
837 // GridLayout layout = new GridLayout();
838 // layout.numColumns = 2;
839 // composite.setLayout(layout);
840 // String text = PreferencesMessages
841 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
843 // addCheckBox(composite, text,
844 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
845 // text = PreferencesMessages
846 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
847 // addCheckBox(composite, text,
848 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
849 // addFiller(composite);
850 // Label label = new Label(composite, SWT.LEFT);
851 // label.setText(PreferencesMessages
852 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
854 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
855 // gd.horizontalSpan = 2;
856 // label.setLayoutData(gd);
857 // Composite editorComposite = new Composite(composite, SWT.NONE);
858 // layout = new GridLayout();
859 // layout.numColumns = 2;
860 // layout.marginHeight = 0;
861 // layout.marginWidth = 0;
862 // editorComposite.setLayout(layout);
863 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
864 // gd.horizontalSpan = 2;
865 // editorComposite.setLayoutData(gd);
866 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
868 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
869 // | GridData.FILL_HORIZONTAL);
870 // gd.heightHint = convertHeightInCharsToPixels(10);
871 // fAnnotationList.setLayoutData(gd);
872 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
873 // layout = new GridLayout();
874 // layout.marginHeight = 0;
875 // layout.marginWidth = 0;
876 // layout.numColumns = 2;
877 // optionsComposite.setLayout(layout);
878 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
879 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
880 // fShowInTextCheckBox.setText(PreferencesMessages
881 // .getString("JavaEditorPreferencePage.annotations.showInText"));
883 // gd = new GridData(GridData.FILL_HORIZONTAL);
884 // gd.horizontalAlignment = GridData.BEGINNING;
885 // gd.horizontalSpan = 2;
886 // fShowInTextCheckBox.setLayoutData(gd);
887 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
888 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
889 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
890 // gd = new GridData(GridData.FILL_HORIZONTAL);
891 // gd.horizontalAlignment = GridData.BEGINNING;
892 // gd.horizontalSpan = 2;
893 // gd.horizontalIndent = 20;
894 // fDecorationStyleCombo.setLayoutData(gd);
895 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
896 // fHighlightInTextCheckBox.setText(PreferencesMessages
897 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
899 // gd = new GridData(GridData.FILL_HORIZONTAL);
900 // gd.horizontalAlignment = GridData.BEGINNING;
901 // gd.horizontalSpan = 2;
902 // fHighlightInTextCheckBox.setLayoutData(gd);
903 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
904 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
905 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
907 // gd = new GridData(GridData.FILL_HORIZONTAL);
908 // gd.horizontalAlignment = GridData.BEGINNING;
909 // gd.horizontalSpan = 2;
910 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
911 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
912 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
913 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
915 // gd = new GridData(GridData.FILL_HORIZONTAL);
916 // gd.horizontalAlignment = GridData.BEGINNING;
917 // gd.horizontalSpan = 2;
918 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
919 // label = new Label(optionsComposite, SWT.LEFT);
920 // label.setText(PreferencesMessages
921 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
922 // gd = new GridData();
923 // gd.horizontalAlignment = GridData.BEGINNING;
924 // label.setLayoutData(gd);
925 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
926 // Button foregroundColorButton =
927 // fAnnotationForegroundColorEditor.getButton();
928 // gd = new GridData(GridData.FILL_HORIZONTAL);
929 // gd.horizontalAlignment = GridData.BEGINNING;
930 // foregroundColorButton.setLayoutData(gd);
931 // fAnnotationList.addSelectionListener(new SelectionListener() {
932 // public void widgetDefaultSelected(SelectionEvent e) {
935 // public void widgetSelected(SelectionEvent e) {
936 // handleAnnotationListSelection();
939 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
940 // public void widgetDefaultSelected(SelectionEvent e) {
943 // public void widgetSelected(SelectionEvent e) {
944 // int i = fAnnotationList.getSelectionIndex();
945 // String key = fAnnotationColorListModel[i][2];
946 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
947 // String decorationKey = fAnnotationColorListModel[i][6];
948 // fDecorationStyleCombo.setEnabled(decorationKey != null
949 // && fShowInTextCheckBox.getSelection());
952 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
953 // public void widgetDefaultSelected(SelectionEvent e) {
956 // public void widgetSelected(SelectionEvent e) {
957 // int i = fAnnotationList.getSelectionIndex();
958 // String key = fAnnotationColorListModel[i][4];
959 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
962 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
963 // public void widgetDefaultSelected(SelectionEvent e) {
966 // public void widgetSelected(SelectionEvent e) {
967 // int i = fAnnotationList.getSelectionIndex();
968 // String key = fAnnotationColorListModel[i][3];
970 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
973 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
974 // public void widgetDefaultSelected(SelectionEvent e) {
977 // public void widgetSelected(SelectionEvent e) {
978 // int i = fAnnotationList.getSelectionIndex();
979 // String key = fAnnotationColorListModel[i][5];
981 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
984 // foregroundColorButton.addSelectionListener(new SelectionListener() {
985 // public void widgetDefaultSelected(SelectionEvent e) {
988 // public void widgetSelected(SelectionEvent e) {
989 // int i = fAnnotationList.getSelectionIndex();
990 // String key = fAnnotationColorListModel[i][1];
991 // PreferenceConverter.setValue(fOverlayStore, key,
992 // fAnnotationForegroundColorEditor.getColorValue());
995 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
999 // public void widgetDefaultSelected(SelectionEvent e) {
1005 // public void widgetSelected(SelectionEvent e) {
1006 // int i = fAnnotationList.getSelectionIndex();
1007 // String key = fAnnotationColorListModel[i][6];
1008 // if (key != null) {
1009 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1010 // if (fAnnotationDecorationListModel[j][0]
1011 // .equals(fDecorationStyleCombo.getText())) {
1012 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1019 // return composite;
1021 private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
1022 ArrayList listModelItems = new ArrayList();
1023 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1025 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1027 public int compare(Object o1, Object o2) {
1028 if (!(o2 instanceof AnnotationPreference))
1030 if (!(o1 instanceof AnnotationPreference))
1032 AnnotationPreference a1 = (AnnotationPreference) o1;
1033 AnnotationPreference a2 = (AnnotationPreference) o2;
1034 return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
1037 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1038 Iterator e = sortedPreferences.iterator();
1039 while (e.hasNext()) {
1040 AnnotationPreference info = (AnnotationPreference) e.next();
1041 listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1042 info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(),
1043 info.getTextStylePreferenceKey() });
1045 String[][] items = new String[listModelItems.size()][];
1046 listModelItems.toArray(items);
1050 private Control createTypingPage(Composite parent) {
1051 Composite composite = new Composite(parent, SWT.NONE);
1052 GridLayout layout = new GridLayout();
1053 layout.numColumns = 1;
1054 composite.setLayout(layout);
1056 // label = PreferencesMessages
1057 // .getString("JavaEditorPreferencePage.overwriteMode");
1059 // addCheckBox(composite, label,
1060 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1061 // addFiller(composite);
1063 // label = PreferencesMessages
1064 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1066 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1068 // label = PreferencesMessages
1069 // .getString("JavaEditorPreferencePage.subWordNavigation");
1071 // addCheckBox(composite, label,
1072 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1073 // addFiller(composite);
1074 Group group = new Group(composite, SWT.NONE);
1075 layout = new GridLayout();
1076 layout.numColumns = 2;
1077 group.setLayout(layout);
1078 group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1080 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapWords");//$NON-NLS-1$
1081 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_WORDS, 1);
1083 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1084 Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1086 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1087 fEscapeStringsButtonDQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1088 createDependency(button, fEscapeStringsButtonDQ);
1090 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1091 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1093 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsSQ");
1095 fEscapeStringsButtonSQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1096 createDependency(button, fEscapeStringsButtonSQ);
1098 label = PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
1100 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1102 label = PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
1104 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1106 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsDQ");
1108 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1109 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsSQ");
1111 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1113 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
1115 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1117 // label = PreferencesMessages
1118 // .getString("JavaEditorPreferencePage.closeBraces");
1120 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1122 label = PreferencesMessages
1123 .getString("JavaEditorPreferencePage.closeJavaDocs");
1125 button = addCheckBox(group, label,
1126 PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1127 label = PreferencesMessages
1128 .getString("JavaEditorPreferencePage.formatJavaDocs");
1130 button = addCheckBox(group, label,
1131 PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
1133 // label = PreferencesMessages
1134 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1136 // fAddJavaDocTagsButton = addCheckBox(group, label,
1137 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1138 // createDependency(button, fAddJavaDocTagsButton);
1142 private void addFiller(Composite composite) {
1143 Label filler = new Label(composite, SWT.LEFT);
1144 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1145 gd.horizontalSpan = 2;
1146 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1147 filler.setLayoutData(gd);
1150 private static void indent(Control control) {
1151 GridData gridData = new GridData();
1152 gridData.horizontalIndent = 20;
1153 control.setLayoutData(gridData);
1156 private static void createDependency(final Button master, final Control slave) {
1158 master.addSelectionListener(new SelectionListener() {
1159 public void widgetSelected(SelectionEvent e) {
1160 slave.setEnabled(master.getSelection());
1163 public void widgetDefaultSelected(SelectionEvent e) {
1168 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1169 Composite completionComposite = new Composite(contentAssistComposite, SWT.NONE);
1170 GridData ccgd = new GridData();
1171 ccgd.horizontalSpan = 2;
1172 completionComposite.setLayoutData(ccgd);
1173 GridLayout ccgl = new GridLayout();
1174 ccgl.marginWidth = 0;
1175 ccgl.numColumns = 2;
1176 completionComposite.setLayout(ccgl);
1177 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1178 // public void widgetSelected(SelectionEvent e) {
1179 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1180 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1185 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1187 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1189 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1190 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1192 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1193 // SWT.RADIO | SWT.LEFT);
1194 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1196 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1197 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1200 private Control createNavigationPage(Composite parent) {
1201 Composite composite = new Composite(parent, SWT.NULL);
1202 GridLayout layout = new GridLayout();
1203 layout.numColumns = 2;
1204 composite.setLayout(layout);
1206 PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1208 fBrowserLikeLinksCheckBox= addCheckBox(composite, text,
1209 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1210 fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1211 public void widgetSelected(SelectionEvent e) {
1212 boolean state= fBrowserLikeLinksCheckBox.getSelection();
1213 fBrowserLikeLinksKeyModifierText.setEnabled(state);
1214 handleBrowserLikeLinksKeyModifierModified();
1216 public void widgetDefaultSelected(SelectionEvent e) {
1219 // Text field for modifier string
1221 PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1223 fBrowserLikeLinksKeyModifierText= addTextField(composite, text,
1224 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0,
1226 fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1229 (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER))
1231 // Fix possible illegal modifier string
1233 fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1234 if (stateMask == -1)
1235 fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1237 fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1239 fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1240 private boolean isModifierCandidate;
1241 public void keyPressed(KeyEvent e) {
1242 isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask ==
1246 public void keyReleased(KeyEvent e) {
1247 if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask
1248 && e.character == 0) {// && e.time -time < 1000) {
1249 String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1250 Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1251 int i= selection.x - 1;
1252 while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1255 boolean needsPrefixDelimiter= i > -1 &&
1256 !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1259 while (i < modifierString.length() &&
1260 Character.isWhitespace(modifierString.charAt(i))) {
1263 boolean needsPostfixDelimiter= i < modifierString.length() &&
1264 !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1266 String insertString;
1268 if (needsPrefixDelimiter && needsPostfixDelimiter)
1270 PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1271 new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1272 else if (needsPrefixDelimiter)
1274 PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1275 new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1276 else if (needsPostfixDelimiter)
1278 PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1279 new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1281 insertString= Action.findModifierString(e.stateMask);
1283 fBrowserLikeLinksKeyModifierText.insert(insertString);
1288 fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener()
1290 public void modifyText(ModifyEvent e) {
1291 handleBrowserLikeLinksKeyModifierModified();
1297 private void handleBrowserLikeLinksKeyModifierModified() {
1298 String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1299 int stateMask= computeStateMask(modifiers);
1300 if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 ||
1301 (stateMask & SWT.SHIFT) != 0)) {
1302 if (stateMask == -1)
1303 fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1304 PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid",
1305 modifiers)); //$NON-NLS-1$
1307 fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1308 PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1311 StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1313 fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1314 updateStatus(fBrowserLikeLinksKeyModifierStatus);
1318 private IStatus getBrowserLikeLinksKeyModifierStatus() {
1319 if (fBrowserLikeLinksKeyModifierStatus == null)
1320 fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1321 return fBrowserLikeLinksKeyModifierStatus;
1324 * Computes the state mask for the given modifier string.
1327 * the string with the modifiers, separated by '+', '-', ';', ',' or '.'
1328 * @return the state mask or -1 if the input is invalid
1330 private int computeStateMask(String modifiers) {
1331 if (modifiers == null)
1333 if (modifiers.length() == 0)
1336 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
1337 while (modifierTokenizer.hasMoreTokens()) {
1338 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
1339 if (modifier == 0 || (stateMask & modifier) == modifier)
1341 stateMask = stateMask | modifier;
1347 * @see PreferencePage#createContents(Composite)
1349 protected Control createContents(Composite parent) {
1350 initializeDefaultColors();
1351 fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore);
1352 fOverlayStore.load();
1353 fOverlayStore.start();
1354 TabFolder folder = new TabFolder(parent, SWT.NONE);
1355 folder.setLayout(new TabFolderLayout());
1356 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1357 TabItem item = new TabItem(folder, SWT.NONE);
1358 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1359 item.setControl(createAppearancePage(folder));
1360 item = new TabItem(folder, SWT.NONE);
1361 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1362 item.setControl(createSyntaxPage(folder));
1364 // item = new TabItem(folder, SWT.NONE);
1365 // item.setText(PreferencesMessages
1366 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1368 // item.setControl(createAnnotationsPage(folder));
1369 item = new TabItem(folder, SWT.NONE);
1370 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
1372 item.setControl(createTypingPage(folder));
1374 item = new TabItem(folder, SWT.NONE);
1375 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
1377 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1378 item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1379 item = new TabItem(folder, SWT.NONE);
1380 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1382 item.setControl(createNavigationPage(folder));
1383 item = new TabItem(folder, SWT.NONE);
1384 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1385 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1388 Dialog.applyDialogFont(folder);
1392 private void initialize() {
1394 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1395 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1396 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1398 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1399 fSyntaxColorList.select(0);
1400 handleSyntaxColorListSelection();
1404 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1405 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1406 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1408 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1409 fAppearanceColorList.select(0);
1410 handleAppearanceColorListSelection();
1414 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1415 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1416 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1417 // public void run() {
1418 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1419 // fAnnotationList.select(0);
1420 // handleAnnotationListSelection();
1424 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1425 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1426 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1427 // public void run() {
1428 // if (fContentAssistColorList != null &&
1429 // !fContentAssistColorList.isDisposed()) {
1430 // fContentAssistColorList.select(0);
1431 // handleContentAssistColorListSelection();
1435 fFoldingConfigurationBlock.initialize();
1438 private void initializeFields() {
1439 Iterator e = fColorButtons.keySet().iterator();
1440 while (e.hasNext()) {
1441 ColorEditor c = (ColorEditor) e.next();
1442 String key = (String) fColorButtons.get(c);
1443 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1444 c.setColorValue(rgb);
1446 e = fCheckBoxes.keySet().iterator();
1447 while (e.hasNext()) {
1448 Button b = (Button) e.next();
1449 String key = (String) fCheckBoxes.get(b);
1450 b.setSelection(fOverlayStore.getBoolean(key));
1452 e = fTextFields.keySet().iterator();
1453 while (e.hasNext()) {
1454 Text t = (Text) e.next();
1455 String key = (String) fTextFields.get(t);
1456 t.setText(fOverlayStore.getString(key));
1458 RGB rgb = PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1459 fBackgroundColorEditor.setColorValue(rgb);
1460 boolean default_ = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1461 fBackgroundDefaultRadioButton.setSelection(default_);
1462 fBackgroundCustomRadioButton.setSelection(!default_);
1463 fBackgroundColorButton.setEnabled(!default_);
1464 boolean closeJavaDocs = fOverlayStore
1465 .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1466 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1467 fEscapeStringsButtonDQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1468 fEscapeStringsButtonSQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1469 // boolean fillMethodArguments=
1470 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1471 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1472 // boolean completionInserts=
1473 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1474 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1475 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1477 fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1478 // boolean markOccurrences=
1479 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1480 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1481 updateAutoactivationControls();
1484 private void initializeDefaultColors() {
1485 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1486 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1487 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1488 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1490 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1491 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1492 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1493 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1497 private void updateAutoactivationControls() {
1498 // boolean autoactivation=
1499 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1500 // fAutoInsertDelayText.setEnabled(autoactivation);
1501 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1502 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1503 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1505 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1506 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1510 * @see PreferencePage#performOk()
1512 public boolean performOk() {
1513 // fJavaEditorHoverConfigurationBlock.performOk();
1514 fFoldingConfigurationBlock.performOk();
1515 fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1516 computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1517 fOverlayStore.propagate();
1518 PHPeclipsePlugin.getDefault().savePluginPreferences();
1523 * @see PreferencePage#performDefaults()
1525 protected void performDefaults() {
1526 fOverlayStore.loadDefaults();
1528 handleSyntaxColorListSelection();
1529 handleAppearanceColorListSelection();
1530 // handleAnnotationListSelection();
1531 // handleContentAssistColorListSelection();
1532 // fJavaEditorHoverConfigurationBlock.performDefaults();
1533 fFoldingConfigurationBlock.performDefaults();
1534 super.performDefaults();
1535 fPreviewViewer.invalidateTextPresentation();
1539 * @see DialogPage#dispose()
1541 public void dispose() {
1542 fFoldingConfigurationBlock.dispose();
1544 if (fJavaTextTools != null) {
1545 fJavaTextTools.dispose();
1546 fJavaTextTools = null;
1548 if (fOverlayStore != null) {
1549 fOverlayStore.stop();
1550 fOverlayStore = null;
1552 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1553 fBackgroundColor.dispose();
1557 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1558 Button checkBox = new Button(parent, SWT.CHECK);
1559 checkBox.setText(label);
1560 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1561 gd.horizontalIndent = indentation;
1562 gd.horizontalSpan = 2;
1563 checkBox.setLayoutData(gd);
1564 checkBox.addSelectionListener(fCheckBoxListener);
1565 fCheckBoxes.put(checkBox, key);
1569 private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1570 return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
1573 private static Label getLabelControl(Control[] labelledTextField) {
1574 return (Label) labelledTextField[0];
1577 private static Text getTextControl(Control[] labelledTextField) {
1578 return (Text) labelledTextField[1];
1582 * Returns an array of size 2: - first element is of type <code>Label</code>- second element is of type <code>Text</code> Use
1583 * <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
1585 private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation,
1587 Label labelControl = new Label(composite, SWT.NONE);
1588 labelControl.setText(label);
1589 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1590 gd.horizontalIndent = indentation;
1591 labelControl.setLayoutData(gd);
1592 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1593 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1594 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1595 textControl.setLayoutData(gd);
1596 textControl.setTextLimit(textLimit);
1597 fTextFields.put(textControl, key);
1599 fNumberFields.add(textControl);
1600 textControl.addModifyListener(fNumberFieldListener);
1602 textControl.addModifyListener(fTextFieldListener);
1604 return new Control[] { labelControl, textControl };
1607 private String loadPreviewContentFromFile(String filename) {
1609 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1610 StringBuffer buffer = new StringBuffer(512);
1611 BufferedReader reader = null;
1613 reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1614 while ((line = reader.readLine()) != null) {
1615 buffer.append(line);
1616 buffer.append(separator);
1618 } catch (IOException io) {
1619 PHPeclipsePlugin.log(io);
1621 if (reader != null) {
1624 } catch (IOException e) {
1628 return buffer.toString();
1631 private void numberFieldChanged(Text textControl) {
1632 String number = textControl.getText();
1633 IStatus status = validatePositiveNumber(number);
1634 if (!status.matches(IStatus.ERROR))
1635 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1636 updateStatus(status);
1639 private IStatus validatePositiveNumber(String number) {
1640 StatusInfo status = new StatusInfo();
1641 if (number.length() == 0) {
1642 status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1645 int value = Integer.parseInt(number);
1647 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1648 } catch (NumberFormatException e) {
1649 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1655 void updateStatus(IStatus status) {
1656 if (!status.matches(IStatus.ERROR)) {
1657 for (int i = 0; i < fNumberFields.size(); i++) {
1658 Text text = (Text) fNumberFields.get(i);
1659 IStatus s = validatePositiveNumber(text.getText());
1660 status = StatusUtil.getMoreSevere(s, status);
1664 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1666 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1668 setValid(!status.matches(IStatus.ERROR));
1669 StatusUtil.applyToStatusLine(this, status);