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[][] {
100 PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
101 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
104 PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
105 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
107 { PreferencesMessages.getString("JavaEditorPreferencePage.tags"), PreferenceConstants.EDITOR_PHP_TAG_COLOR },
109 { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
110 { PreferencesMessages.getString("JavaEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
112 { PreferencesMessages.getString("JavaEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
114 { PreferencesMessages.getString("JavaEditorPreferencePage.variables_dollar"), PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR },
116 { PreferencesMessages.getString("JavaEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
118 { PreferencesMessages.getString("JavaEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
120 { PreferencesMessages.getString("JavaEditorPreferencePage.strings_dq"), PreferenceConstants.EDITOR_STRING_COLOR_DQ },
121 { PreferencesMessages.getString("JavaEditorPreferencePage.strings_sq"), PreferenceConstants.EDITOR_STRING_COLOR_SQ },
123 { PreferencesMessages.getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
124 { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
127 PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"),
128 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
129 { PreferencesMessages.getString("JavaEditorPreferencePage.braces"), PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR },
131 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
133 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
135 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
137 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
140 private final String[][] fAppearanceColorListModel = new String[][] {
142 PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
143 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR },
146 PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
147 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
150 PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"),
151 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
154 PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"),
155 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
157 { PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
159 { PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
162 // private final String[][] fAnnotationColorListModel;
164 // private final String[][] fAnnotationDecorationListModel = new String[][]{
166 // PreferencesMessages
167 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
168 // AnnotationPreference.STYLE_NONE},
171 // PreferencesMessages
172 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
173 // AnnotationPreference.STYLE_SQUIGGLIES},
176 // PreferencesMessages
177 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
178 // AnnotationPreference.STYLE_UNDERLINE},
181 // PreferencesMessages
182 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
183 // AnnotationPreference.STYLE_BOX},
186 // PreferencesMessages
187 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
188 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
190 private OverlayPreferenceStore fOverlayStore;
192 private JavaTextTools fJavaTextTools;
194 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
196 private FoldingConfigurationBlock fFoldingConfigurationBlock;
198 private Map fColorButtons = new HashMap();
200 private Map fCheckBoxes = new HashMap();
202 private SelectionListener fCheckBoxListener = new SelectionListener() {
203 public void widgetDefaultSelected(SelectionEvent e) {
206 public void widgetSelected(SelectionEvent e) {
207 Button button = (Button) e.widget;
208 fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
212 private Map fTextFields = new HashMap();
214 private ModifyListener fTextFieldListener = new ModifyListener() {
215 public void modifyText(ModifyEvent e) {
216 Text text = (Text) e.widget;
217 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
221 private ArrayList fNumberFields = new ArrayList();
223 private ModifyListener fNumberFieldListener = new ModifyListener() {
224 public void modifyText(ModifyEvent e) {
225 numberFieldChanged((Text) e.widget);
229 private List fSyntaxColorList;
231 private List fAppearanceColorList;
233 // private List fContentAssistColorList;
234 private List fAnnotationList;
236 private ColorEditor fSyntaxForegroundColorEditor;
238 private ColorEditor fAppearanceColorEditor;
240 private ColorEditor fAnnotationForegroundColorEditor;
242 private ColorEditor fContentAssistColorEditor;
244 private ColorEditor fBackgroundColorEditor;
246 private Button fBackgroundDefaultRadioButton;
248 private Button fBackgroundCustomRadioButton;
250 private Button fBackgroundColorButton;
252 private Button fBoldCheckBox;
254 // private Button fAddJavaDocTagsButton;
256 private Button fEscapeStringsButtonDQ;
258 private Button fEscapeStringsButtonSQ;
260 // private Button fGuessMethodArgumentsButton;
261 private SourceViewer fPreviewViewer;
263 private Color fBackgroundColor;
265 private Control fAutoInsertDelayText;
267 private Control fAutoInsertJavaTriggerText;
269 private Control fAutoInsertJavaDocTriggerText;
271 private Label fAutoInsertDelayLabel;
273 private Label fAutoInsertJavaTriggerLabel;
275 private Label fAutoInsertJavaDocTriggerLabel;
277 private Button fShowInTextCheckBox;
279 private Combo fDecorationStyleCombo;
281 private Button fHighlightInTextCheckBox;
283 private Button fShowInOverviewRulerCheckBox;
285 private Button fShowInVerticalRulerCheckBox;
287 private Text fBrowserLikeLinksKeyModifierText;
289 private Button fBrowserLikeLinksCheckBox;
291 private StatusInfo fBrowserLikeLinksKeyModifierStatus;
293 // private Button fCompletionInsertsRadioButton;
294 // private Button fCompletionOverwritesRadioButton;
295 // private Button fStickyOccurrencesButton;
297 * Creates a new preference page.
299 public JavaEditorPreferencePage() {
300 setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
301 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
302 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
303 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
304 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
305 // fAnnotationColorListModel =
306 // createAnnotationTypeListModel(markerAnnotationPreferences);
309 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
310 ArrayList overlayKeys = new ArrayList();
311 Iterator e = preferences.getAnnotationPreferences().iterator();
312 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
313 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
314 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
315 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
316 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
317 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
318 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
319 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
320 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
321 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
322 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
323 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
324 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
325 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
326 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
327 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
328 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
329 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
330 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
331 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
332 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
334 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TAG_COLOR));
335 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TAG_BOLD));
336 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
337 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
338 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
339 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
340 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
341 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
342 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
343 PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
344 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
345 PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_COLOR));
346 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
347 PreferenceConstants.EDITOR_PHP_VARIABLE_DOLLAR_BOLD));
348 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
349 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
350 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
351 PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
353 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
355 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
358 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR_DQ));
360 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD_DQ));
362 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR_SQ));
364 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD_SQ));
365 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
366 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
367 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
368 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
370 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
372 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
373 // overlayKeys.add(new
374 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING_DQ,
375 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
376 // overlayKeys.add(new
377 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
378 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
379 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
380 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
381 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
382 PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
383 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
384 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
385 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
386 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
387 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
388 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR));
389 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
390 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_BOLD));
391 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
392 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
393 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
394 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
395 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
396 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
397 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
398 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
399 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
400 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
401 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
402 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
403 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
404 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
405 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
406 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
407 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
408 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
409 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
410 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
411 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
412 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
413 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
414 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
415 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
416 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
417 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
418 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
419 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
420 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
421 // overlayKeys.add(new
422 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
423 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
424 // overlayKeys.add(new
425 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
426 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
427 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
428 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
429 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
430 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
431 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
432 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
433 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
434 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
435 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
436 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
437 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
438 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
439 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
440 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
441 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
442 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
443 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
444 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
445 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
447 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT));
448 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
449 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
450 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
451 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
452 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
453 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
454 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
455 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
456 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
457 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
458 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
459 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
460 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
461 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
462 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
463 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
464 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
465 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
466 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
467 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
468 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
469 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
471 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT));
472 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
473 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
474 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
475 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
476 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
477 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
478 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE));
479 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
480 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
481 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
482 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
483 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
484 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
486 // .add(new OverlayPreferenceStore.OverlayKey(
487 // OverlayPreferenceStore.BOOLEAN,
488 // PreferenceConstants.EDITOR_CLOSE_BRACES));
490 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
491 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_WORDS));
492 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
493 PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
494 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
495 PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
496 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
497 PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
498 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
499 PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
501 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
502 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
503 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
504 PreferenceConstants.EDITOR_FORMAT_JAVADOCS));
505 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
506 PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE));
509 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
510 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
511 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
512 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
513 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
514 // overlayKeys.add(new
515 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
516 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
517 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
518 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
519 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
520 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
521 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
522 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
523 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
524 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
525 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
526 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
527 while (e.hasNext()) {
528 AnnotationPreference info = (AnnotationPreference) e.next();
529 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
530 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
531 if (info.getHighlightPreferenceKey() != null)
532 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
533 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
534 if (info.getVerticalRulerPreferenceKey() != null)
536 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
537 if (info.getTextStylePreferenceKey() != null)
538 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
540 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
541 overlayKeys.toArray(keys);
544 * @see IWorkbenchPreferencePage#init()
547 public void init(IWorkbench workbench) {
551 * @see PreferencePage#createControl(Composite)
553 public void createControl(Composite parent) {
554 super.createControl(parent);
555 WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
558 private void handleSyntaxColorListSelection() {
559 int i = fSyntaxColorList.getSelectionIndex();
560 String key = fSyntaxColorListModel[i][1];
561 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
562 fSyntaxForegroundColorEditor.setColorValue(rgb);
563 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
566 private void handleAppearanceColorListSelection() {
567 int i = fAppearanceColorList.getSelectionIndex();
568 String key = fAppearanceColorListModel[i][1];
569 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
570 fAppearanceColorEditor.setColorValue(rgb);
573 // private void handleAnnotationListSelection() {
574 // int i = fAnnotationList.getSelectionIndex();
575 // String key = fAnnotationColorListModel[i][1];
576 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
577 // fAnnotationForegroundColorEditor.setColorValue(rgb);
578 // key = fAnnotationColorListModel[i][2];
579 // boolean showInText = fOverlayStore.getBoolean(key);
580 // fShowInTextCheckBox.setSelection(showInText);
581 // key = fAnnotationColorListModel[i][6];
582 // if (key != null) {
583 // fDecorationStyleCombo.setEnabled(showInText);
584 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
585 // String value = fOverlayStore.getString(key);
586 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
587 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
592 // fDecorationStyleCombo.setEnabled(false);
593 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
606 // key = fAnnotationColorListModel[i][3];
607 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
608 // key = fAnnotationColorListModel[i][4];
609 // if (key != null) {
610 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
611 // fHighlightInTextCheckBox.setEnabled(true);
613 // fHighlightInTextCheckBox.setEnabled(false);
614 // key = fAnnotationColorListModel[i][5];
615 // if (key != null) {
616 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
617 // fShowInVerticalRulerCheckBox.setEnabled(true);
619 // fShowInVerticalRulerCheckBox.setSelection(true);
620 // fShowInVerticalRulerCheckBox.setEnabled(false);
623 private Control createSyntaxPage(Composite parent) {
624 Composite colorComposite = new Composite(parent, SWT.NULL);
625 colorComposite.setLayout(new GridLayout());
626 Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
627 backgroundComposite.setLayout(new RowLayout());
628 backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
629 SelectionListener backgroundSelectionListener = new SelectionListener() {
630 public void widgetSelected(SelectionEvent e) {
631 boolean custom = fBackgroundCustomRadioButton.getSelection();
632 fBackgroundColorButton.setEnabled(custom);
633 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
636 public void widgetDefaultSelected(SelectionEvent e) {
639 fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
640 fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
641 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
642 fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
643 fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
644 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
645 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
646 fBackgroundColorButton = fBackgroundColorEditor.getButton();
647 Label label = new Label(colorComposite, SWT.LEFT);
648 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
649 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
650 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
651 GridLayout layout = new GridLayout();
652 layout.numColumns = 2;
653 layout.marginHeight = 0;
654 layout.marginWidth = 0;
655 editorComposite.setLayout(layout);
656 GridData gd = new GridData(GridData.FILL_BOTH);
657 editorComposite.setLayoutData(gd);
658 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
659 gd = new GridData(GridData.FILL_BOTH);
660 gd.heightHint = convertHeightInCharsToPixels(5);
661 fSyntaxColorList.setLayoutData(gd);
662 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
663 layout = new GridLayout();
664 layout.marginHeight = 0;
665 layout.marginWidth = 0;
666 layout.numColumns = 2;
667 stylesComposite.setLayout(layout);
668 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
669 label = new Label(stylesComposite, SWT.LEFT);
670 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
672 gd.horizontalAlignment = GridData.BEGINNING;
673 label.setLayoutData(gd);
674 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
675 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
676 gd = new GridData(GridData.FILL_HORIZONTAL);
677 gd.horizontalAlignment = GridData.BEGINNING;
678 foregroundColorButton.setLayoutData(gd);
679 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
680 fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
681 gd = new GridData(GridData.FILL_HORIZONTAL);
682 gd.horizontalAlignment = GridData.BEGINNING;
683 gd.horizontalSpan = 2;
684 fBoldCheckBox.setLayoutData(gd);
685 label = new Label(colorComposite, SWT.LEFT);
686 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
687 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
688 Control previewer = createPreviewer(colorComposite);
689 gd = new GridData(GridData.FILL_BOTH);
690 gd.widthHint = convertWidthInCharsToPixels(20);
691 gd.heightHint = convertHeightInCharsToPixels(5);
692 previewer.setLayoutData(gd);
693 fSyntaxColorList.addSelectionListener(new SelectionListener() {
694 public void widgetDefaultSelected(SelectionEvent e) {
698 public void widgetSelected(SelectionEvent e) {
699 handleSyntaxColorListSelection();
702 foregroundColorButton.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 PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
713 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
714 public void widgetDefaultSelected(SelectionEvent e) {
718 public void widgetSelected(SelectionEvent e) {
719 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
723 fBoldCheckBox.addSelectionListener(new SelectionListener() {
724 public void widgetDefaultSelected(SelectionEvent e) {
728 public void widgetSelected(SelectionEvent e) {
729 int i = fSyntaxColorList.getSelectionIndex();
730 String key = fSyntaxColorListModel[i][1];
731 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
734 return colorComposite;
737 private Control createPreviewer(Composite parent) {
738 Preferences coreStore = createTemporaryCorePreferenceStore();
739 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
740 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
741 IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] {
743 new PreferencesAdapter(createTemporaryCorePreferenceStore()),
746 fPreviewViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
747 JavaTextTools tools = PHPeclipsePlugin.getDefault().getJavaTextTools();
748 PHPSourceViewerConfiguration configuration = new PHPSourceViewerConfiguration(tools.getColorManager(), store, null,
749 IPHPPartitions.PHP_PARTITIONING);
750 // PHPSourceViewerConfiguration configuration =new PHPSourceViewerConfiguration(fJavaTextTools, null,
751 // IPHPPartitions.PHP_PARTITIONING);
752 fPreviewViewer.configure(configuration);
754 Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
755 fPreviewViewer.getTextWidget().setFont(font);
756 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
757 fPreviewViewer.setEditable(false);
758 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
759 IDocument document = new Document(content);
760 fJavaTextTools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
761 fPreviewViewer.setDocument(document);
762 return fPreviewViewer.getControl();
765 private Preferences createTemporaryCorePreferenceStore() {
766 Preferences result = new Preferences();
767 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
771 private Control createAppearancePage(Composite parent) {
772 Composite appearanceComposite = new Composite(parent, SWT.NONE);
773 GridLayout layout = new GridLayout();
774 layout.numColumns = 2;
775 appearanceComposite.setLayout(layout);
776 String label = PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
777 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
778 label = PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
779 addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
780 label = PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
781 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
782 label = PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
783 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
784 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
785 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
786 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
787 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
788 label = PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
789 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
790 label = PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
791 // Button master= addCheckBox(appearanceComposite, label,
792 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
793 label = PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
794 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
795 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
796 // createDependency(master, fStickyOccurrencesButton);
797 Label l = new Label(appearanceComposite, SWT.LEFT);
798 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
799 gd.horizontalSpan = 2;
800 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
802 l = new Label(appearanceComposite, SWT.LEFT);
803 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
804 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
805 gd.horizontalSpan = 2;
807 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
808 layout = new GridLayout();
809 layout.numColumns = 2;
810 layout.marginHeight = 0;
811 layout.marginWidth = 0;
812 editorComposite.setLayout(layout);
813 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
814 gd.horizontalSpan = 2;
815 editorComposite.setLayoutData(gd);
816 fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
817 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
818 gd.heightHint = convertHeightInCharsToPixels(8);
819 fAppearanceColorList.setLayoutData(gd);
820 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
821 layout = new GridLayout();
822 layout.marginHeight = 0;
823 layout.marginWidth = 0;
824 layout.numColumns = 2;
825 stylesComposite.setLayout(layout);
826 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
827 l = new Label(stylesComposite, SWT.LEFT);
828 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
830 gd.horizontalAlignment = GridData.BEGINNING;
832 fAppearanceColorEditor = new ColorEditor(stylesComposite);
833 Button foregroundColorButton = fAppearanceColorEditor.getButton();
834 gd = new GridData(GridData.FILL_HORIZONTAL);
835 gd.horizontalAlignment = GridData.BEGINNING;
836 foregroundColorButton.setLayoutData(gd);
837 fAppearanceColorList.addSelectionListener(new SelectionListener() {
838 public void widgetDefaultSelected(SelectionEvent e) {
842 public void widgetSelected(SelectionEvent e) {
843 handleAppearanceColorListSelection();
846 foregroundColorButton.addSelectionListener(new SelectionListener() {
847 public void widgetDefaultSelected(SelectionEvent e) {
851 public void widgetSelected(SelectionEvent e) {
852 int i = fAppearanceColorList.getSelectionIndex();
853 String key = fAppearanceColorListModel[i][1];
854 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
857 return appearanceComposite;
860 // private Control createAnnotationsPage(Composite parent) {
861 // Composite composite = new Composite(parent, SWT.NULL);
862 // GridLayout layout = new GridLayout();
863 // layout.numColumns = 2;
864 // composite.setLayout(layout);
865 // String text = PreferencesMessages
866 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
868 // addCheckBox(composite, text,
869 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
870 // text = PreferencesMessages
871 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
872 // addCheckBox(composite, text,
873 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
874 // addFiller(composite);
875 // Label label = new Label(composite, SWT.LEFT);
876 // label.setText(PreferencesMessages
877 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
879 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
880 // gd.horizontalSpan = 2;
881 // label.setLayoutData(gd);
882 // Composite editorComposite = new Composite(composite, SWT.NONE);
883 // layout = new GridLayout();
884 // layout.numColumns = 2;
885 // layout.marginHeight = 0;
886 // layout.marginWidth = 0;
887 // editorComposite.setLayout(layout);
888 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
889 // gd.horizontalSpan = 2;
890 // editorComposite.setLayoutData(gd);
891 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
893 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
894 // | GridData.FILL_HORIZONTAL);
895 // gd.heightHint = convertHeightInCharsToPixels(10);
896 // fAnnotationList.setLayoutData(gd);
897 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
898 // layout = new GridLayout();
899 // layout.marginHeight = 0;
900 // layout.marginWidth = 0;
901 // layout.numColumns = 2;
902 // optionsComposite.setLayout(layout);
903 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
904 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
905 // fShowInTextCheckBox.setText(PreferencesMessages
906 // .getString("JavaEditorPreferencePage.annotations.showInText"));
908 // gd = new GridData(GridData.FILL_HORIZONTAL);
909 // gd.horizontalAlignment = GridData.BEGINNING;
910 // gd.horizontalSpan = 2;
911 // fShowInTextCheckBox.setLayoutData(gd);
912 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
913 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
914 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
915 // gd = new GridData(GridData.FILL_HORIZONTAL);
916 // gd.horizontalAlignment = GridData.BEGINNING;
917 // gd.horizontalSpan = 2;
918 // gd.horizontalIndent = 20;
919 // fDecorationStyleCombo.setLayoutData(gd);
920 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
921 // fHighlightInTextCheckBox.setText(PreferencesMessages
922 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
924 // gd = new GridData(GridData.FILL_HORIZONTAL);
925 // gd.horizontalAlignment = GridData.BEGINNING;
926 // gd.horizontalSpan = 2;
927 // fHighlightInTextCheckBox.setLayoutData(gd);
928 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
929 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
930 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
932 // gd = new GridData(GridData.FILL_HORIZONTAL);
933 // gd.horizontalAlignment = GridData.BEGINNING;
934 // gd.horizontalSpan = 2;
935 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
936 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
937 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
938 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
940 // gd = new GridData(GridData.FILL_HORIZONTAL);
941 // gd.horizontalAlignment = GridData.BEGINNING;
942 // gd.horizontalSpan = 2;
943 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
944 // label = new Label(optionsComposite, SWT.LEFT);
945 // label.setText(PreferencesMessages
946 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
947 // gd = new GridData();
948 // gd.horizontalAlignment = GridData.BEGINNING;
949 // label.setLayoutData(gd);
950 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
951 // Button foregroundColorButton =
952 // fAnnotationForegroundColorEditor.getButton();
953 // gd = new GridData(GridData.FILL_HORIZONTAL);
954 // gd.horizontalAlignment = GridData.BEGINNING;
955 // foregroundColorButton.setLayoutData(gd);
956 // fAnnotationList.addSelectionListener(new SelectionListener() {
957 // public void widgetDefaultSelected(SelectionEvent e) {
960 // public void widgetSelected(SelectionEvent e) {
961 // handleAnnotationListSelection();
964 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
965 // public void widgetDefaultSelected(SelectionEvent e) {
968 // public void widgetSelected(SelectionEvent e) {
969 // int i = fAnnotationList.getSelectionIndex();
970 // String key = fAnnotationColorListModel[i][2];
971 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
972 // String decorationKey = fAnnotationColorListModel[i][6];
973 // fDecorationStyleCombo.setEnabled(decorationKey != null
974 // && fShowInTextCheckBox.getSelection());
977 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
978 // public void widgetDefaultSelected(SelectionEvent e) {
981 // public void widgetSelected(SelectionEvent e) {
982 // int i = fAnnotationList.getSelectionIndex();
983 // String key = fAnnotationColorListModel[i][4];
984 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
987 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
988 // public void widgetDefaultSelected(SelectionEvent e) {
991 // public void widgetSelected(SelectionEvent e) {
992 // int i = fAnnotationList.getSelectionIndex();
993 // String key = fAnnotationColorListModel[i][3];
995 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
998 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
999 // public void widgetDefaultSelected(SelectionEvent e) {
1002 // public void widgetSelected(SelectionEvent e) {
1003 // int i = fAnnotationList.getSelectionIndex();
1004 // String key = fAnnotationColorListModel[i][5];
1006 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
1009 // foregroundColorButton.addSelectionListener(new SelectionListener() {
1010 // public void widgetDefaultSelected(SelectionEvent e) {
1013 // public void widgetSelected(SelectionEvent e) {
1014 // int i = fAnnotationList.getSelectionIndex();
1015 // String key = fAnnotationColorListModel[i][1];
1016 // PreferenceConverter.setValue(fOverlayStore, key,
1017 // fAnnotationForegroundColorEditor.getColorValue());
1020 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
1024 // public void widgetDefaultSelected(SelectionEvent e) {
1030 // public void widgetSelected(SelectionEvent e) {
1031 // int i = fAnnotationList.getSelectionIndex();
1032 // String key = fAnnotationColorListModel[i][6];
1033 // if (key != null) {
1034 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1035 // if (fAnnotationDecorationListModel[j][0]
1036 // .equals(fDecorationStyleCombo.getText())) {
1037 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1044 // return composite;
1046 private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
1047 ArrayList listModelItems = new ArrayList();
1048 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1050 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1052 public int compare(Object o1, Object o2) {
1053 if (!(o2 instanceof AnnotationPreference))
1055 if (!(o1 instanceof AnnotationPreference))
1057 AnnotationPreference a1 = (AnnotationPreference) o1;
1058 AnnotationPreference a2 = (AnnotationPreference) o2;
1059 return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
1062 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1063 Iterator e = sortedPreferences.iterator();
1064 while (e.hasNext()) {
1065 AnnotationPreference info = (AnnotationPreference) e.next();
1066 listModelItems.add(new String[] {
1067 info.getPreferenceLabel(),
1068 info.getColorPreferenceKey(),
1069 info.getTextPreferenceKey(),
1070 info.getOverviewRulerPreferenceKey(),
1071 info.getHighlightPreferenceKey(),
1072 info.getVerticalRulerPreferenceKey(),
1073 info.getTextStylePreferenceKey() });
1075 String[][] items = new String[listModelItems.size()][];
1076 listModelItems.toArray(items);
1080 private Control createTypingPage(Composite parent) {
1081 Composite composite = new Composite(parent, SWT.NONE);
1082 GridLayout layout = new GridLayout();
1083 layout.numColumns = 1;
1084 composite.setLayout(layout);
1086 // label = PreferencesMessages
1087 // .getString("JavaEditorPreferencePage.overwriteMode");
1089 // addCheckBox(composite, label,
1090 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1091 // addFiller(composite);
1093 // label = PreferencesMessages
1094 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1096 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1098 // label = PreferencesMessages
1099 // .getString("JavaEditorPreferencePage.subWordNavigation");
1101 // addCheckBox(composite, label,
1102 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1103 // addFiller(composite);
1104 Group group = new Group(composite, SWT.NONE);
1105 layout = new GridLayout();
1106 layout.numColumns = 2;
1107 group.setLayout(layout);
1108 group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1110 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapWords");//$NON-NLS-1$
1111 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_WORDS, 1);
1113 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1114 Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1116 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1117 fEscapeStringsButtonDQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1118 createDependency(button, fEscapeStringsButtonDQ);
1120 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1121 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1123 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsSQ");
1125 fEscapeStringsButtonSQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1126 createDependency(button, fEscapeStringsButtonSQ);
1128 label = PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
1130 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1132 label = PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
1134 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1136 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsDQ");
1138 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1139 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsSQ");
1141 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1143 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
1145 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1147 // label = PreferencesMessages
1148 // .getString("JavaEditorPreferencePage.closeBraces");
1150 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1152 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeJavaDocs");
1154 button = addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1155 label = PreferencesMessages.getString("JavaEditorPreferencePage.formatJavaDocs");
1157 button = addCheckBox(group, label, PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
1159 label = PreferencesMessages.getString("JavaEditorPreferencePage.p_rtrim_on_save");
1160 addCheckBox(group, label, PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE, 1);
1162 // label = PreferencesMessages
1163 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1165 // fAddJavaDocTagsButton = addCheckBox(group, label,
1166 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1167 // createDependency(button, fAddJavaDocTagsButton);
1171 private void addFiller(Composite composite) {
1172 Label filler = new Label(composite, SWT.LEFT);
1173 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1174 gd.horizontalSpan = 2;
1175 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1176 filler.setLayoutData(gd);
1179 private static void indent(Control control) {
1180 GridData gridData = new GridData();
1181 gridData.horizontalIndent = 20;
1182 control.setLayoutData(gridData);
1185 private static void createDependency(final Button master, final Control slave) {
1187 master.addSelectionListener(new SelectionListener() {
1188 public void widgetSelected(SelectionEvent e) {
1189 slave.setEnabled(master.getSelection());
1192 public void widgetDefaultSelected(SelectionEvent e) {
1197 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1198 Composite completionComposite = new Composite(contentAssistComposite, SWT.NONE);
1199 GridData ccgd = new GridData();
1200 ccgd.horizontalSpan = 2;
1201 completionComposite.setLayoutData(ccgd);
1202 GridLayout ccgl = new GridLayout();
1203 ccgl.marginWidth = 0;
1204 ccgl.numColumns = 2;
1205 completionComposite.setLayout(ccgl);
1206 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1207 // public void widgetSelected(SelectionEvent e) {
1208 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1209 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1214 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1216 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1218 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1219 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1221 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1222 // SWT.RADIO | SWT.LEFT);
1223 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1225 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1226 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1229 private Control createNavigationPage(Composite parent) {
1230 Composite composite = new Composite(parent, SWT.NULL);
1231 GridLayout layout = new GridLayout();
1232 layout.numColumns = 2;
1233 composite.setLayout(layout);
1234 String text = PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1236 fBrowserLikeLinksCheckBox = addCheckBox(composite, text, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1237 fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1238 public void widgetSelected(SelectionEvent e) {
1239 boolean state = fBrowserLikeLinksCheckBox.getSelection();
1240 fBrowserLikeLinksKeyModifierText.setEnabled(state);
1241 handleBrowserLikeLinksKeyModifierModified();
1244 public void widgetDefaultSelected(SelectionEvent e) {
1247 // Text field for modifier string
1248 text = PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1250 fBrowserLikeLinksKeyModifierText = addTextField(composite, text, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER,
1252 fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1254 if (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) == -1) {
1255 // Fix possible illegal modifier string
1256 int stateMask = fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1257 if (stateMask == -1)
1258 fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1260 fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1262 fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1263 private boolean isModifierCandidate;
1265 public void keyPressed(KeyEvent e) {
1266 isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
1269 public void keyReleased(KeyEvent e) {
1270 if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) {
1271 String modifierString = fBrowserLikeLinksKeyModifierText.getText();
1272 Point selection = fBrowserLikeLinksKeyModifierText.getSelection();
1273 int i = selection.x - 1;
1274 while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1277 boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1280 while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
1283 boolean needsPostfixDelimiter = i < modifierString.length()
1284 && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1286 String insertString;
1288 if (needsPrefixDelimiter && needsPostfixDelimiter)
1289 insertString = PreferencesMessages.getFormattedString(
1290 "JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter", new String[] { Action
1291 .findModifierString(e.stateMask) }); //$NON-NLS-1$
1292 else if (needsPrefixDelimiter)
1293 insertString = PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1294 new String[] { Action.findModifierString(e.stateMask) }); //$NON-NLS-1$
1295 else if (needsPostfixDelimiter)
1296 insertString = PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1297 new String[] { Action.findModifierString(e.stateMask) }); //$NON-NLS-1$
1299 insertString = Action.findModifierString(e.stateMask);
1301 fBrowserLikeLinksKeyModifierText.insert(insertString);
1306 fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener() {
1307 public void modifyText(ModifyEvent e) {
1308 handleBrowserLikeLinksKeyModifierModified();
1314 private void handleBrowserLikeLinksKeyModifierModified() {
1315 String modifiers = fBrowserLikeLinksKeyModifierText.getText();
1316 int stateMask = computeStateMask(modifiers);
1317 if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) {
1318 if (stateMask == -1)
1319 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(IStatus.ERROR, PreferencesMessages.getFormattedString(
1320 "JavaEditorPreferencePage.navigation.modifierIsNotValid", modifiers)); //$NON-NLS-1$
1322 fBrowserLikeLinksKeyModifierStatus = new StatusInfo(IStatus.ERROR, PreferencesMessages
1323 .getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1326 StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1328 fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1329 updateStatus(fBrowserLikeLinksKeyModifierStatus);
1333 private IStatus getBrowserLikeLinksKeyModifierStatus() {
1334 if (fBrowserLikeLinksKeyModifierStatus == null)
1335 fBrowserLikeLinksKeyModifierStatus = new StatusInfo();
1336 return fBrowserLikeLinksKeyModifierStatus;
1340 * Computes the state mask for the given modifier string.
1343 * the string with the modifiers, separated by '+', '-', ';', ',' or '.'
1344 * @return the state mask or -1 if the input is invalid
1346 private int computeStateMask(String modifiers) {
1347 if (modifiers == null)
1349 if (modifiers.length() == 0)
1352 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
1353 while (modifierTokenizer.hasMoreTokens()) {
1354 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
1355 if (modifier == 0 || (stateMask & modifier) == modifier)
1357 stateMask = stateMask | modifier;
1363 * @see PreferencePage#createContents(Composite)
1365 protected Control createContents(Composite parent) {
1366 initializeDefaultColors();
1367 fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore);
1368 fOverlayStore.load();
1369 fOverlayStore.start();
1370 TabFolder folder = new TabFolder(parent, SWT.NONE);
1371 folder.setLayout(new TabFolderLayout());
1372 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1373 TabItem item = new TabItem(folder, SWT.NONE);
1374 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1375 item.setControl(createAppearancePage(folder));
1376 item = new TabItem(folder, SWT.NONE);
1377 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1378 item.setControl(createSyntaxPage(folder));
1380 // item = new TabItem(folder, SWT.NONE);
1381 // item.setText(PreferencesMessages
1382 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1384 // item.setControl(createAnnotationsPage(folder));
1385 item = new TabItem(folder, SWT.NONE);
1386 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
1388 item.setControl(createTypingPage(folder));
1390 item = new TabItem(folder, SWT.NONE);
1391 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
1393 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1394 item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1395 item = new TabItem(folder, SWT.NONE);
1396 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1398 item.setControl(createNavigationPage(folder));
1399 item = new TabItem(folder, SWT.NONE);
1400 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1401 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1404 Dialog.applyDialogFont(folder);
1408 private void initialize() {
1410 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1411 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1412 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1414 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1415 fSyntaxColorList.select(0);
1416 handleSyntaxColorListSelection();
1420 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1421 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1422 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1424 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1425 fAppearanceColorList.select(0);
1426 handleAppearanceColorListSelection();
1430 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1431 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1432 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1433 // public void run() {
1434 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1435 // fAnnotationList.select(0);
1436 // handleAnnotationListSelection();
1440 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1441 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1442 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1443 // public void run() {
1444 // if (fContentAssistColorList != null &&
1445 // !fContentAssistColorList.isDisposed()) {
1446 // fContentAssistColorList.select(0);
1447 // handleContentAssistColorListSelection();
1451 fFoldingConfigurationBlock.initialize();
1454 private void initializeFields() {
1455 Iterator e = fColorButtons.keySet().iterator();
1456 while (e.hasNext()) {
1457 ColorEditor c = (ColorEditor) e.next();
1458 String key = (String) fColorButtons.get(c);
1459 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1460 c.setColorValue(rgb);
1462 e = fCheckBoxes.keySet().iterator();
1463 while (e.hasNext()) {
1464 Button b = (Button) e.next();
1465 String key = (String) fCheckBoxes.get(b);
1466 b.setSelection(fOverlayStore.getBoolean(key));
1468 e = fTextFields.keySet().iterator();
1469 while (e.hasNext()) {
1470 Text t = (Text) e.next();
1471 String key = (String) fTextFields.get(t);
1472 t.setText(fOverlayStore.getString(key));
1474 RGB rgb = PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1475 fBackgroundColorEditor.setColorValue(rgb);
1476 boolean default_ = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1477 fBackgroundDefaultRadioButton.setSelection(default_);
1478 fBackgroundCustomRadioButton.setSelection(!default_);
1479 fBackgroundColorButton.setEnabled(!default_);
1480 boolean closeJavaDocs = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1481 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1482 fEscapeStringsButtonDQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1483 fEscapeStringsButtonSQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1484 // boolean fillMethodArguments=
1485 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1486 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1487 // boolean completionInserts=
1488 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1489 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1490 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1492 fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1493 // boolean markOccurrences=
1494 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1495 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1496 updateAutoactivationControls();
1499 private void initializeDefaultColors() {
1500 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1501 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1502 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1503 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1505 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1506 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1507 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1508 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1512 private void updateAutoactivationControls() {
1513 // boolean autoactivation=
1514 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1515 // fAutoInsertDelayText.setEnabled(autoactivation);
1516 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1517 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1518 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1520 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1521 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1525 * @see PreferencePage#performOk()
1527 public boolean performOk() {
1528 // fJavaEditorHoverConfigurationBlock.performOk();
1529 fFoldingConfigurationBlock.performOk();
1530 fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1531 computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1532 fOverlayStore.propagate();
1533 PHPeclipsePlugin.getDefault().savePluginPreferences();
1538 * @see PreferencePage#performDefaults()
1540 protected void performDefaults() {
1541 fOverlayStore.loadDefaults();
1543 handleSyntaxColorListSelection();
1544 handleAppearanceColorListSelection();
1545 // handleAnnotationListSelection();
1546 // handleContentAssistColorListSelection();
1547 // fJavaEditorHoverConfigurationBlock.performDefaults();
1548 fFoldingConfigurationBlock.performDefaults();
1549 super.performDefaults();
1550 fPreviewViewer.invalidateTextPresentation();
1554 * @see DialogPage#dispose()
1556 public void dispose() {
1557 fFoldingConfigurationBlock.dispose();
1559 if (fJavaTextTools != null) {
1560 fJavaTextTools.dispose();
1561 fJavaTextTools = null;
1563 if (fOverlayStore != null) {
1564 fOverlayStore.stop();
1565 fOverlayStore = null;
1567 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1568 fBackgroundColor.dispose();
1572 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1573 Button checkBox = new Button(parent, SWT.CHECK);
1574 checkBox.setText(label);
1575 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1576 gd.horizontalIndent = indentation;
1577 gd.horizontalSpan = 2;
1578 checkBox.setLayoutData(gd);
1579 checkBox.addSelectionListener(fCheckBoxListener);
1580 fCheckBoxes.put(checkBox, key);
1584 private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1585 return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
1588 private static Label getLabelControl(Control[] labelledTextField) {
1589 return (Label) labelledTextField[0];
1592 private static Text getTextControl(Control[] labelledTextField) {
1593 return (Text) labelledTextField[1];
1597 * Returns an array of size 2: - first element is of type <code>Label</code>- second element is of type <code>Text</code> Use
1598 * <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
1600 private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation,
1602 Label labelControl = new Label(composite, SWT.NONE);
1603 labelControl.setText(label);
1604 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1605 gd.horizontalIndent = indentation;
1606 labelControl.setLayoutData(gd);
1607 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1608 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1609 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1610 textControl.setLayoutData(gd);
1611 textControl.setTextLimit(textLimit);
1612 fTextFields.put(textControl, key);
1614 fNumberFields.add(textControl);
1615 textControl.addModifyListener(fNumberFieldListener);
1617 textControl.addModifyListener(fTextFieldListener);
1619 return new Control[] { labelControl, textControl };
1622 private String loadPreviewContentFromFile(String filename) {
1624 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1625 StringBuffer buffer = new StringBuffer(512);
1626 BufferedReader reader = null;
1628 reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1629 while ((line = reader.readLine()) != null) {
1630 buffer.append(line);
1631 buffer.append(separator);
1633 } catch (IOException io) {
1634 PHPeclipsePlugin.log(io);
1636 if (reader != null) {
1639 } catch (IOException e) {
1643 return buffer.toString();
1646 private void numberFieldChanged(Text textControl) {
1647 String number = textControl.getText();
1648 IStatus status = validatePositiveNumber(number);
1649 if (!status.matches(IStatus.ERROR))
1650 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1651 updateStatus(status);
1654 private IStatus validatePositiveNumber(String number) {
1655 StatusInfo status = new StatusInfo();
1656 if (number.length() == 0) {
1657 status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1660 int value = Integer.parseInt(number);
1662 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1663 } catch (NumberFormatException e) {
1664 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1670 void updateStatus(IStatus status) {
1671 if (!status.matches(IStatus.ERROR)) {
1672 for (int i = 0; i < fNumberFields.size(); i++) {
1673 Text text = (Text) fNumberFields.get(i);
1674 IStatus s = validatePositiveNumber(text.getText());
1675 status = StatusUtil.getMoreSevere(s, status);
1679 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1681 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1683 setValid(!status.matches(IStatus.ERROR));
1684 StatusUtil.applyToStatusLine(this, status);