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.dialogs.Dialog;
44 import org.eclipse.jface.preference.IPreferenceStore;
45 import org.eclipse.jface.preference.PreferenceConverter;
46 import org.eclipse.jface.preference.PreferencePage;
47 import org.eclipse.jface.resource.JFaceResources;
48 import org.eclipse.jface.text.Document;
49 import org.eclipse.jface.text.IDocument;
50 import org.eclipse.jface.text.source.SourceViewer;
51 import org.eclipse.swt.SWT;
52 import org.eclipse.swt.events.ModifyEvent;
53 import org.eclipse.swt.events.ModifyListener;
54 import org.eclipse.swt.events.SelectionEvent;
55 import org.eclipse.swt.events.SelectionListener;
56 import org.eclipse.swt.graphics.Color;
57 import org.eclipse.swt.graphics.RGB;
58 import org.eclipse.swt.layout.GridData;
59 import org.eclipse.swt.layout.GridLayout;
60 import org.eclipse.swt.layout.RowLayout;
61 import org.eclipse.swt.widgets.Button;
62 import org.eclipse.swt.widgets.Combo;
63 import org.eclipse.swt.widgets.Composite;
64 import org.eclipse.swt.widgets.Control;
65 import org.eclipse.swt.widgets.Group;
66 import org.eclipse.swt.widgets.Label;
67 import org.eclipse.swt.widgets.List;
68 import org.eclipse.swt.widgets.TabFolder;
69 import org.eclipse.swt.widgets.TabItem;
70 import org.eclipse.swt.widgets.Text;
71 import org.eclipse.ui.IWorkbench;
72 import org.eclipse.ui.IWorkbenchPreferencePage;
73 import org.eclipse.ui.editors.text.EditorsUI;
74 import org.eclipse.ui.help.WorkbenchHelp;
75 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
76 import org.eclipse.ui.texteditor.AnnotationPreference;
77 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
78 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
81 * The page for setting the editor options.
83 public class JavaEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
84 private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
86 private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
88 private static final String DELIMITER = PreferencesMessages.getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
90 /** The keys of the overlay store. */
91 public final OverlayPreferenceStore.OverlayKey[] fKeys;
93 private final String[][] fSyntaxColorListModel = new String[][] {
95 // PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
96 // PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$
98 // PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
99 // PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$
100 // { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"),
101 // PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$
102 // { PreferencesMessages.getString("JavaEditorPreferencePage.strings"),
103 // PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$
105 // PreferencesMessages.getString("JavaEditorPreferencePage.methodNames"),
106 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR }, //$NON-NLS-1$
107 // { PreferencesMessages.getString("JavaEditorPreferencePage.operators"),
108 // PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR }, //$NON-NLS-1$
109 // { PreferencesMessages.getString("JavaEditorPreferencePage.others"),
110 // PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
112 // PreferencesMessages.getString("JavaEditorPreferencePage.javaCommentTaskTags"),
113 // PreferenceConstants.EDITOR_TASK_TAG_COLOR }, //$NON-NLS-1$
115 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocKeywords"),
116 // PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$
118 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocHtmlTags"),
119 // PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR }, //$NON-NLS-1$
121 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocLinks"),
122 // PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$
124 // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocOthers"),
125 // PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
126 { PreferencesMessages.getString("PHPEditorPreferencePage.multiLineComment"),
127 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
129 { PreferencesMessages.getString("PHPEditorPreferencePage.singleLineComment"),
130 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
132 { PreferencesMessages.getString("PHPEditorPreferencePage.tags"), PreferenceConstants.EDITOR_PHP_TAG_COLOR },
134 { PreferencesMessages.getString("PHPEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
135 { PreferencesMessages.getString("PHPEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
137 { PreferencesMessages.getString("PHPEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
139 { PreferencesMessages.getString("PHPEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
141 { PreferencesMessages.getString("PHPEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
143 { PreferencesMessages.getString("PHPEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR },
145 { PreferencesMessages.getString("PHPEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
146 { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
148 { PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"),
149 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
151 { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
153 { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
155 { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
157 { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
160 private final String[][] fAppearanceColorListModel = new String[][] {
161 { PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
162 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR },
164 { PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
165 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
167 { PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"),
168 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
170 { PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"),
171 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
173 { PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
175 { PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
178 // private final String[][] fAnnotationColorListModel;
180 // private final String[][] fAnnotationDecorationListModel = new String[][]{
182 // PreferencesMessages
183 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
184 // AnnotationPreference.STYLE_NONE},
187 // PreferencesMessages
188 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
189 // AnnotationPreference.STYLE_SQUIGGLIES},
192 // PreferencesMessages
193 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
194 // AnnotationPreference.STYLE_UNDERLINE},
197 // PreferencesMessages
198 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
199 // AnnotationPreference.STYLE_BOX},
202 // PreferencesMessages
203 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
204 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
206 private OverlayPreferenceStore fOverlayStore;
208 private JavaTextTools fJavaTextTools;
210 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
212 private FoldingConfigurationBlock fFoldingConfigurationBlock;
214 private Map fColorButtons = new HashMap();
216 private Map fCheckBoxes = new HashMap();
218 private SelectionListener fCheckBoxListener = new SelectionListener() {
219 public void widgetDefaultSelected(SelectionEvent e) {
222 public void widgetSelected(SelectionEvent e) {
223 Button button = (Button) e.widget;
224 fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
228 private Map fTextFields = new HashMap();
230 private ModifyListener fTextFieldListener = new ModifyListener() {
231 public void modifyText(ModifyEvent e) {
232 Text text = (Text) e.widget;
233 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
237 private ArrayList fNumberFields = new ArrayList();
239 private ModifyListener fNumberFieldListener = new ModifyListener() {
240 public void modifyText(ModifyEvent e) {
241 numberFieldChanged((Text) e.widget);
245 private List fSyntaxColorList;
247 private List fAppearanceColorList;
249 // private List fContentAssistColorList;
250 private List fAnnotationList;
252 private ColorEditor fSyntaxForegroundColorEditor;
254 private ColorEditor fAppearanceColorEditor;
256 private ColorEditor fAnnotationForegroundColorEditor;
258 private ColorEditor fContentAssistColorEditor;
260 private ColorEditor fBackgroundColorEditor;
262 private Button fBackgroundDefaultRadioButton;
264 private Button fBackgroundCustomRadioButton;
266 private Button fBackgroundColorButton;
268 private Button fBoldCheckBox;
270 // private Button fAddJavaDocTagsButton;
272 private Button fEscapeStringsButton;
274 // private Button fGuessMethodArgumentsButton;
275 private SourceViewer fPreviewViewer;
277 private Color fBackgroundColor;
279 private Control fAutoInsertDelayText;
281 private Control fAutoInsertJavaTriggerText;
283 private Control fAutoInsertJavaDocTriggerText;
285 private Label fAutoInsertDelayLabel;
287 private Label fAutoInsertJavaTriggerLabel;
289 private Label fAutoInsertJavaDocTriggerLabel;
291 private Button fShowInTextCheckBox;
293 private Combo fDecorationStyleCombo;
295 private Button fHighlightInTextCheckBox;
297 private Button fShowInOverviewRulerCheckBox;
299 private Button fShowInVerticalRulerCheckBox;
301 // private Text fBrowserLikeLinksKeyModifierText;
302 // private Button fBrowserLikeLinksCheckBox;
303 // private StatusInfo fBrowserLikeLinksKeyModifierStatus;
304 // private Button fCompletionInsertsRadioButton;
305 // private Button fCompletionOverwritesRadioButton;
306 // private Button fStickyOccurrencesButton;
308 * Creates a new preference page.
310 public JavaEditorPreferencePage() {
311 setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
312 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
313 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
314 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
315 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
316 // fAnnotationColorListModel =
317 // createAnnotationTypeListModel(markerAnnotationPreferences);
320 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
321 ArrayList overlayKeys = new ArrayList();
322 Iterator e = preferences.getAnnotationPreferences().iterator();
323 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
324 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
325 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
326 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
327 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
328 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
329 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
330 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
331 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
332 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
333 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
334 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
335 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
336 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
337 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
338 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
339 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
340 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
341 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
342 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
343 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
345 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TAG_COLOR));
346 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TAG_BOLD));
347 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
348 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
349 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
350 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
351 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
352 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
353 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
354 PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
355 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
356 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
357 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
358 PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
360 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
362 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
364 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR));
365 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD));
366 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
367 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
368 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
369 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
371 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
373 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
374 // overlayKeys.add(new
375 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
376 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
377 // overlayKeys.add(new
378 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
379 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
380 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
381 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
382 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
383 PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
384 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
385 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
386 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
387 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
388 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
389 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
390 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
391 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
392 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
393 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
394 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
395 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
396 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
397 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
398 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
399 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
400 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
401 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
402 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
403 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
404 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
405 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
406 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
407 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
408 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
409 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
410 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
411 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
412 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
413 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
414 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
415 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
416 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
417 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
418 // overlayKeys.add(new
419 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
420 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
421 // overlayKeys.add(new
422 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
423 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
424 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
425 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
426 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
427 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
428 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
429 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
430 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
431 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
432 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
433 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
434 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
435 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
436 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
437 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
438 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
439 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
440 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
441 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
442 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
444 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT));
445 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
446 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
447 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
448 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
449 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
450 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
451 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
452 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
453 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
454 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
455 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
456 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
457 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
458 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
459 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
460 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
461 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
462 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
463 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
464 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
465 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
466 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
468 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT));
469 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
470 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
471 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
472 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
473 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
474 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
475 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE));
476 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
477 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
478 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
479 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
480 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
481 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
483 // .add(new OverlayPreferenceStore.OverlayKey(
484 // OverlayPreferenceStore.BOOLEAN,
485 // PreferenceConstants.EDITOR_CLOSE_BRACES));
486 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
487 // OverlayPreferenceStore.BOOLEAN,
488 // PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
489 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS));
491 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS));
492 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
493 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
495 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
496 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
497 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
498 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
499 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
500 // overlayKeys.add(new
501 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
502 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
503 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
504 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
505 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
506 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
507 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
508 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
509 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
510 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
511 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
512 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
513 while (e.hasNext()) {
514 AnnotationPreference info = (AnnotationPreference) e.next();
515 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
516 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
517 if (info.getHighlightPreferenceKey() != null)
518 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
519 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
520 if (info.getVerticalRulerPreferenceKey() != null)
522 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
523 if (info.getTextStylePreferenceKey() != null)
524 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
526 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
527 overlayKeys.toArray(keys);
530 * @see IWorkbenchPreferencePage#init()
533 public void init(IWorkbench workbench) {
537 * @see PreferencePage#createControl(Composite)
539 public void createControl(Composite parent) {
540 super.createControl(parent);
541 WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
544 private void handleSyntaxColorListSelection() {
545 int i = fSyntaxColorList.getSelectionIndex();
546 String key = fSyntaxColorListModel[i][1];
547 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
548 fSyntaxForegroundColorEditor.setColorValue(rgb);
549 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
552 private void handleAppearanceColorListSelection() {
553 int i = fAppearanceColorList.getSelectionIndex();
554 String key = fAppearanceColorListModel[i][1];
555 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
556 fAppearanceColorEditor.setColorValue(rgb);
559 // private void handleAnnotationListSelection() {
560 // int i = fAnnotationList.getSelectionIndex();
561 // String key = fAnnotationColorListModel[i][1];
562 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
563 // fAnnotationForegroundColorEditor.setColorValue(rgb);
564 // key = fAnnotationColorListModel[i][2];
565 // boolean showInText = fOverlayStore.getBoolean(key);
566 // fShowInTextCheckBox.setSelection(showInText);
567 // key = fAnnotationColorListModel[i][6];
568 // if (key != null) {
569 // fDecorationStyleCombo.setEnabled(showInText);
570 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
571 // String value = fOverlayStore.getString(key);
572 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
573 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
578 // fDecorationStyleCombo.setEnabled(false);
579 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
592 // key = fAnnotationColorListModel[i][3];
593 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
594 // key = fAnnotationColorListModel[i][4];
595 // if (key != null) {
596 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
597 // fHighlightInTextCheckBox.setEnabled(true);
599 // fHighlightInTextCheckBox.setEnabled(false);
600 // key = fAnnotationColorListModel[i][5];
601 // if (key != null) {
602 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
603 // fShowInVerticalRulerCheckBox.setEnabled(true);
605 // fShowInVerticalRulerCheckBox.setSelection(true);
606 // fShowInVerticalRulerCheckBox.setEnabled(false);
609 private Control createSyntaxPage(Composite parent) {
610 Composite colorComposite = new Composite(parent, SWT.NULL);
611 colorComposite.setLayout(new GridLayout());
612 Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
613 backgroundComposite.setLayout(new RowLayout());
614 backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
615 SelectionListener backgroundSelectionListener = new SelectionListener() {
616 public void widgetSelected(SelectionEvent e) {
617 boolean custom = fBackgroundCustomRadioButton.getSelection();
618 fBackgroundColorButton.setEnabled(custom);
619 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
622 public void widgetDefaultSelected(SelectionEvent e) {
625 fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
626 fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
627 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
628 fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
629 fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
630 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
631 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
632 fBackgroundColorButton = fBackgroundColorEditor.getButton();
633 Label label = new Label(colorComposite, SWT.LEFT);
634 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
635 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
636 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
637 GridLayout layout = new GridLayout();
638 layout.numColumns = 2;
639 layout.marginHeight = 0;
640 layout.marginWidth = 0;
641 editorComposite.setLayout(layout);
642 GridData gd = new GridData(GridData.FILL_BOTH);
643 editorComposite.setLayoutData(gd);
644 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
645 gd = new GridData(GridData.FILL_BOTH);
646 gd.heightHint = convertHeightInCharsToPixels(5);
647 fSyntaxColorList.setLayoutData(gd);
648 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
649 layout = new GridLayout();
650 layout.marginHeight = 0;
651 layout.marginWidth = 0;
652 layout.numColumns = 2;
653 stylesComposite.setLayout(layout);
654 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
655 label = new Label(stylesComposite, SWT.LEFT);
656 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
658 gd.horizontalAlignment = GridData.BEGINNING;
659 label.setLayoutData(gd);
660 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
661 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
662 gd = new GridData(GridData.FILL_HORIZONTAL);
663 gd.horizontalAlignment = GridData.BEGINNING;
664 foregroundColorButton.setLayoutData(gd);
665 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
666 fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
667 gd = new GridData(GridData.FILL_HORIZONTAL);
668 gd.horizontalAlignment = GridData.BEGINNING;
669 gd.horizontalSpan = 2;
670 fBoldCheckBox.setLayoutData(gd);
671 label = new Label(colorComposite, SWT.LEFT);
672 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
673 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
674 Control previewer = createPreviewer(colorComposite);
675 gd = new GridData(GridData.FILL_BOTH);
676 gd.widthHint = convertWidthInCharsToPixels(20);
677 gd.heightHint = convertHeightInCharsToPixels(5);
678 previewer.setLayoutData(gd);
679 fSyntaxColorList.addSelectionListener(new SelectionListener() {
680 public void widgetDefaultSelected(SelectionEvent e) {
684 public void widgetSelected(SelectionEvent e) {
685 handleSyntaxColorListSelection();
688 foregroundColorButton.addSelectionListener(new SelectionListener() {
689 public void widgetDefaultSelected(SelectionEvent e) {
693 public void widgetSelected(SelectionEvent e) {
694 int i = fSyntaxColorList.getSelectionIndex();
695 String key = fSyntaxColorListModel[i][1];
696 PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
699 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
700 public void widgetDefaultSelected(SelectionEvent e) {
704 public void widgetSelected(SelectionEvent e) {
705 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
709 fBoldCheckBox.addSelectionListener(new SelectionListener() {
710 public void widgetDefaultSelected(SelectionEvent e) {
714 public void widgetSelected(SelectionEvent e) {
715 int i = fSyntaxColorList.getSelectionIndex();
716 String key = fSyntaxColorListModel[i][1];
717 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
720 return colorComposite;
723 private Control createPreviewer(Composite parent) {
724 Preferences coreStore = createTemporaryCorePreferenceStore();
725 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
726 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
727 IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
728 new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
730 fPreviewViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
732 fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools, null, IPHPPartitions.PHP_PARTITIONING));
733 // Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
734 // fPreviewViewer.getTextWidget().setFont(font);
735 fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
736 // new JavaSourcePreviewerUpdater(fPreviewViewer, fJavaTextTools);
737 fPreviewViewer.setEditable(false);
738 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
739 IDocument document = new Document(content);
740 // fJavaTextTools.setupJavaDocumentPartitioner(document, ".php", null); //IJavaPartitions.JAVA_PARTITIONING);
741 fJavaTextTools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
742 fPreviewViewer.setDocument(document);
743 return fPreviewViewer.getControl();
746 private Preferences createTemporaryCorePreferenceStore() {
747 Preferences result = new Preferences();
748 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
752 private Control createAppearancePage(Composite parent) {
753 Composite appearanceComposite = new Composite(parent, SWT.NONE);
754 GridLayout layout = new GridLayout();
755 layout.numColumns = 2;
756 appearanceComposite.setLayout(layout);
757 String label = PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
758 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
759 label = PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
760 addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
761 label = PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
762 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
763 label = PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
764 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
765 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
766 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
767 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
768 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
769 label = PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
770 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
771 label = PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
772 // Button master= addCheckBox(appearanceComposite, label,
773 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
774 label = PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
775 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
776 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
777 // createDependency(master, fStickyOccurrencesButton);
778 Label l = new Label(appearanceComposite, SWT.LEFT);
779 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
780 gd.horizontalSpan = 2;
781 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
783 l = new Label(appearanceComposite, SWT.LEFT);
784 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
785 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
786 gd.horizontalSpan = 2;
788 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
789 layout = new GridLayout();
790 layout.numColumns = 2;
791 layout.marginHeight = 0;
792 layout.marginWidth = 0;
793 editorComposite.setLayout(layout);
794 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
795 gd.horizontalSpan = 2;
796 editorComposite.setLayoutData(gd);
797 fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
798 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
799 gd.heightHint = convertHeightInCharsToPixels(8);
800 fAppearanceColorList.setLayoutData(gd);
801 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
802 layout = new GridLayout();
803 layout.marginHeight = 0;
804 layout.marginWidth = 0;
805 layout.numColumns = 2;
806 stylesComposite.setLayout(layout);
807 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
808 l = new Label(stylesComposite, SWT.LEFT);
809 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
811 gd.horizontalAlignment = GridData.BEGINNING;
813 fAppearanceColorEditor = new ColorEditor(stylesComposite);
814 Button foregroundColorButton = fAppearanceColorEditor.getButton();
815 gd = new GridData(GridData.FILL_HORIZONTAL);
816 gd.horizontalAlignment = GridData.BEGINNING;
817 foregroundColorButton.setLayoutData(gd);
818 fAppearanceColorList.addSelectionListener(new SelectionListener() {
819 public void widgetDefaultSelected(SelectionEvent e) {
823 public void widgetSelected(SelectionEvent e) {
824 handleAppearanceColorListSelection();
827 foregroundColorButton.addSelectionListener(new SelectionListener() {
828 public void widgetDefaultSelected(SelectionEvent e) {
832 public void widgetSelected(SelectionEvent e) {
833 int i = fAppearanceColorList.getSelectionIndex();
834 String key = fAppearanceColorListModel[i][1];
835 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
838 return appearanceComposite;
841 // private Control createAnnotationsPage(Composite parent) {
842 // Composite composite = new Composite(parent, SWT.NULL);
843 // GridLayout layout = new GridLayout();
844 // layout.numColumns = 2;
845 // composite.setLayout(layout);
846 // String text = PreferencesMessages
847 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
849 // addCheckBox(composite, text,
850 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
851 // text = PreferencesMessages
852 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
853 // addCheckBox(composite, text,
854 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
855 // addFiller(composite);
856 // Label label = new Label(composite, SWT.LEFT);
857 // label.setText(PreferencesMessages
858 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
860 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
861 // gd.horizontalSpan = 2;
862 // label.setLayoutData(gd);
863 // Composite editorComposite = new Composite(composite, SWT.NONE);
864 // layout = new GridLayout();
865 // layout.numColumns = 2;
866 // layout.marginHeight = 0;
867 // layout.marginWidth = 0;
868 // editorComposite.setLayout(layout);
869 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
870 // gd.horizontalSpan = 2;
871 // editorComposite.setLayoutData(gd);
872 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
874 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
875 // | GridData.FILL_HORIZONTAL);
876 // gd.heightHint = convertHeightInCharsToPixels(10);
877 // fAnnotationList.setLayoutData(gd);
878 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
879 // layout = new GridLayout();
880 // layout.marginHeight = 0;
881 // layout.marginWidth = 0;
882 // layout.numColumns = 2;
883 // optionsComposite.setLayout(layout);
884 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
885 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
886 // fShowInTextCheckBox.setText(PreferencesMessages
887 // .getString("JavaEditorPreferencePage.annotations.showInText"));
889 // gd = new GridData(GridData.FILL_HORIZONTAL);
890 // gd.horizontalAlignment = GridData.BEGINNING;
891 // gd.horizontalSpan = 2;
892 // fShowInTextCheckBox.setLayoutData(gd);
893 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
894 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
895 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
896 // gd = new GridData(GridData.FILL_HORIZONTAL);
897 // gd.horizontalAlignment = GridData.BEGINNING;
898 // gd.horizontalSpan = 2;
899 // gd.horizontalIndent = 20;
900 // fDecorationStyleCombo.setLayoutData(gd);
901 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
902 // fHighlightInTextCheckBox.setText(PreferencesMessages
903 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
905 // gd = new GridData(GridData.FILL_HORIZONTAL);
906 // gd.horizontalAlignment = GridData.BEGINNING;
907 // gd.horizontalSpan = 2;
908 // fHighlightInTextCheckBox.setLayoutData(gd);
909 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
910 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
911 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
913 // gd = new GridData(GridData.FILL_HORIZONTAL);
914 // gd.horizontalAlignment = GridData.BEGINNING;
915 // gd.horizontalSpan = 2;
916 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
917 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
918 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
919 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
921 // gd = new GridData(GridData.FILL_HORIZONTAL);
922 // gd.horizontalAlignment = GridData.BEGINNING;
923 // gd.horizontalSpan = 2;
924 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
925 // label = new Label(optionsComposite, SWT.LEFT);
926 // label.setText(PreferencesMessages
927 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
928 // gd = new GridData();
929 // gd.horizontalAlignment = GridData.BEGINNING;
930 // label.setLayoutData(gd);
931 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
932 // Button foregroundColorButton =
933 // fAnnotationForegroundColorEditor.getButton();
934 // gd = new GridData(GridData.FILL_HORIZONTAL);
935 // gd.horizontalAlignment = GridData.BEGINNING;
936 // foregroundColorButton.setLayoutData(gd);
937 // fAnnotationList.addSelectionListener(new SelectionListener() {
938 // public void widgetDefaultSelected(SelectionEvent e) {
941 // public void widgetSelected(SelectionEvent e) {
942 // handleAnnotationListSelection();
945 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
946 // public void widgetDefaultSelected(SelectionEvent e) {
949 // public void widgetSelected(SelectionEvent e) {
950 // int i = fAnnotationList.getSelectionIndex();
951 // String key = fAnnotationColorListModel[i][2];
952 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
953 // String decorationKey = fAnnotationColorListModel[i][6];
954 // fDecorationStyleCombo.setEnabled(decorationKey != null
955 // && fShowInTextCheckBox.getSelection());
958 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
959 // public void widgetDefaultSelected(SelectionEvent e) {
962 // public void widgetSelected(SelectionEvent e) {
963 // int i = fAnnotationList.getSelectionIndex();
964 // String key = fAnnotationColorListModel[i][4];
965 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
968 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
969 // public void widgetDefaultSelected(SelectionEvent e) {
972 // public void widgetSelected(SelectionEvent e) {
973 // int i = fAnnotationList.getSelectionIndex();
974 // String key = fAnnotationColorListModel[i][3];
976 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
979 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
980 // public void widgetDefaultSelected(SelectionEvent e) {
983 // public void widgetSelected(SelectionEvent e) {
984 // int i = fAnnotationList.getSelectionIndex();
985 // String key = fAnnotationColorListModel[i][5];
987 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
990 // foregroundColorButton.addSelectionListener(new SelectionListener() {
991 // public void widgetDefaultSelected(SelectionEvent e) {
994 // public void widgetSelected(SelectionEvent e) {
995 // int i = fAnnotationList.getSelectionIndex();
996 // String key = fAnnotationColorListModel[i][1];
997 // PreferenceConverter.setValue(fOverlayStore, key,
998 // fAnnotationForegroundColorEditor.getColorValue());
1001 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
1005 // public void widgetDefaultSelected(SelectionEvent e) {
1011 // public void widgetSelected(SelectionEvent e) {
1012 // int i = fAnnotationList.getSelectionIndex();
1013 // String key = fAnnotationColorListModel[i][6];
1014 // if (key != null) {
1015 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1016 // if (fAnnotationDecorationListModel[j][0]
1017 // .equals(fDecorationStyleCombo.getText())) {
1018 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1025 // return composite;
1027 private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
1028 ArrayList listModelItems = new ArrayList();
1029 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1031 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1033 public int compare(Object o1, Object o2) {
1034 if (!(o2 instanceof AnnotationPreference))
1036 if (!(o1 instanceof AnnotationPreference))
1038 AnnotationPreference a1 = (AnnotationPreference) o1;
1039 AnnotationPreference a2 = (AnnotationPreference) o2;
1040 return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
1043 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1044 Iterator e = sortedPreferences.iterator();
1045 while (e.hasNext()) {
1046 AnnotationPreference info = (AnnotationPreference) e.next();
1047 listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1048 info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(),
1049 info.getTextStylePreferenceKey() });
1051 String[][] items = new String[listModelItems.size()][];
1052 listModelItems.toArray(items);
1056 private Control createTypingPage(Composite parent) {
1057 Composite composite = new Composite(parent, SWT.NONE);
1058 GridLayout layout = new GridLayout();
1059 layout.numColumns = 1;
1060 composite.setLayout(layout);
1062 // label = PreferencesMessages
1063 // .getString("JavaEditorPreferencePage.overwriteMode");
1065 // addCheckBox(composite, label,
1066 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1067 // addFiller(composite);
1069 // label = PreferencesMessages
1070 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1072 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1074 // label = PreferencesMessages
1075 // .getString("JavaEditorPreferencePage.subWordNavigation");
1077 // addCheckBox(composite, label,
1078 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1079 // addFiller(composite);
1080 Group group = new Group(composite, SWT.NONE);
1081 layout = new GridLayout();
1082 layout.numColumns = 2;
1083 group.setLayout(layout);
1084 group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1086 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStrings");
1088 Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
1090 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings");
1092 fEscapeStringsButton = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1);
1093 createDependency(button, fEscapeStringsButton);
1095 label = PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
1097 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1099 label = PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
1101 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1103 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsDQ");
1105 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1106 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsSQ");
1108 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1110 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
1112 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1114 // label = PreferencesMessages
1115 // .getString("JavaEditorPreferencePage.closeBraces");
1117 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1119 // label = PreferencesMessages
1120 // .getString("JavaEditorPreferencePage.closeJavaDocs");
1122 // button = addCheckBox(group, label,
1123 // PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1125 // label = PreferencesMessages
1126 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1128 // fAddJavaDocTagsButton = addCheckBox(group, label,
1129 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1130 // createDependency(button, fAddJavaDocTagsButton);
1134 private void addFiller(Composite composite) {
1135 Label filler = new Label(composite, SWT.LEFT);
1136 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1137 gd.horizontalSpan = 2;
1138 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1139 filler.setLayoutData(gd);
1142 private static void indent(Control control) {
1143 GridData gridData = new GridData();
1144 gridData.horizontalIndent = 20;
1145 control.setLayoutData(gridData);
1148 private static void createDependency(final Button master, final Control slave) {
1150 master.addSelectionListener(new SelectionListener() {
1151 public void widgetSelected(SelectionEvent e) {
1152 slave.setEnabled(master.getSelection());
1155 public void widgetDefaultSelected(SelectionEvent e) {
1160 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1161 Composite completionComposite = new Composite(contentAssistComposite, SWT.NONE);
1162 GridData ccgd = new GridData();
1163 ccgd.horizontalSpan = 2;
1164 completionComposite.setLayoutData(ccgd);
1165 GridLayout ccgl = new GridLayout();
1166 ccgl.marginWidth = 0;
1167 ccgl.numColumns = 2;
1168 completionComposite.setLayout(ccgl);
1169 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1170 // public void widgetSelected(SelectionEvent e) {
1171 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1172 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1177 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1179 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1181 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1182 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1184 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1185 // SWT.RADIO | SWT.LEFT);
1186 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1188 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1189 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1192 private Control createNavigationPage(Composite parent) {
1193 Composite composite = new Composite(parent, SWT.NULL);
1194 GridLayout layout = new GridLayout();
1195 layout.numColumns = 2;
1196 composite.setLayout(layout);
1198 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1200 // fBrowserLikeLinksCheckBox= addCheckBox(composite, text,
1201 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1202 // fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1203 // public void widgetSelected(SelectionEvent e) {
1204 // boolean state= fBrowserLikeLinksCheckBox.getSelection();
1205 // fBrowserLikeLinksKeyModifierText.setEnabled(state);
1206 // handleBrowserLikeLinksKeyModifierModified();
1208 // public void widgetDefaultSelected(SelectionEvent e) {
1211 // Text field for modifier string
1213 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1215 // fBrowserLikeLinksKeyModifierText= addTextField(composite, text,
1216 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0,
1218 // fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1221 // (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER))
1223 // // Fix possible illegal modifier string
1225 // fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1226 // if (stateMask == -1)
1227 // fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1229 // fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1231 // fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1232 // private boolean isModifierCandidate;
1233 // public void keyPressed(KeyEvent e) {
1234 // isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask ==
1238 // public void keyReleased(KeyEvent e) {
1239 // if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask
1240 // && e.character == 0) {// && e.time -time < 1000) {
1241 // String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1242 // Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1243 // int i= selection.x - 1;
1244 // while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1247 // boolean needsPrefixDelimiter= i > -1 &&
1248 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1251 // while (i < modifierString.length() &&
1252 // Character.isWhitespace(modifierString.charAt(i))) {
1255 // boolean needsPostfixDelimiter= i < modifierString.length() &&
1256 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1258 // String insertString;
1260 // if (needsPrefixDelimiter && needsPostfixDelimiter)
1262 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1263 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1264 // else if (needsPrefixDelimiter)
1266 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1267 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1268 // else if (needsPostfixDelimiter)
1270 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1271 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1273 // insertString= Action.findModifierString(e.stateMask);
1275 // fBrowserLikeLinksKeyModifierText.insert(insertString);
1280 // fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener()
1282 // public void modifyText(ModifyEvent e) {
1283 // handleBrowserLikeLinksKeyModifierModified();
1289 private void handleBrowserLikeLinksKeyModifierModified() {
1290 // String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1291 // int stateMask= computeStateMask(modifiers);
1292 // if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 ||
1293 // (stateMask & SWT.SHIFT) != 0)) {
1294 // if (stateMask == -1)
1295 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1296 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid",
1297 // modifiers)); //$NON-NLS-1$
1299 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1300 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1303 // StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1305 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1306 // updateStatus(fBrowserLikeLinksKeyModifierStatus);
1310 // private IStatus getBrowserLikeLinksKeyModifierStatus() {
1311 // if (fBrowserLikeLinksKeyModifierStatus == null)
1312 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1313 // return fBrowserLikeLinksKeyModifierStatus;
1316 * Computes the state mask for the given modifier string.
1319 * the string with the modifiers, separated by '+', '-', ';', ',' or '.'
1320 * @return the state mask or -1 if the input is invalid
1322 private int computeStateMask(String modifiers) {
1323 if (modifiers == null)
1325 if (modifiers.length() == 0)
1328 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
1329 while (modifierTokenizer.hasMoreTokens()) {
1330 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
1331 if (modifier == 0 || (stateMask & modifier) == modifier)
1333 stateMask = stateMask | modifier;
1339 * @see PreferencePage#createContents(Composite)
1341 protected Control createContents(Composite parent) {
1342 initializeDefaultColors();
1343 fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore);
1344 fOverlayStore.load();
1345 fOverlayStore.start();
1346 TabFolder folder = new TabFolder(parent, SWT.NONE);
1347 folder.setLayout(new TabFolderLayout());
1348 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1349 TabItem item = new TabItem(folder, SWT.NONE);
1350 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1351 item.setControl(createAppearancePage(folder));
1352 item = new TabItem(folder, SWT.NONE);
1353 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1354 item.setControl(createSyntaxPage(folder));
1356 // item = new TabItem(folder, SWT.NONE);
1357 // item.setText(PreferencesMessages
1358 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1360 // item.setControl(createAnnotationsPage(folder));
1361 item = new TabItem(folder, SWT.NONE);
1362 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
1364 item.setControl(createTypingPage(folder));
1366 item = new TabItem(folder, SWT.NONE);
1367 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
1369 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1370 item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1371 // item= new TabItem(folder, SWT.NONE);
1372 // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1374 // item.setControl(createNavigationPage(folder));
1375 item = new TabItem(folder, SWT.NONE);
1376 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1377 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1380 Dialog.applyDialogFont(folder);
1384 private void initialize() {
1386 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1387 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1388 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1390 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1391 fSyntaxColorList.select(0);
1392 handleSyntaxColorListSelection();
1396 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1397 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1398 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1400 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1401 fAppearanceColorList.select(0);
1402 handleAppearanceColorListSelection();
1406 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1407 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1408 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1409 // public void run() {
1410 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1411 // fAnnotationList.select(0);
1412 // handleAnnotationListSelection();
1416 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1417 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1418 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1419 // public void run() {
1420 // if (fContentAssistColorList != null &&
1421 // !fContentAssistColorList.isDisposed()) {
1422 // fContentAssistColorList.select(0);
1423 // handleContentAssistColorListSelection();
1427 fFoldingConfigurationBlock.initialize();
1430 private void initializeFields() {
1431 Iterator e = fColorButtons.keySet().iterator();
1432 while (e.hasNext()) {
1433 ColorEditor c = (ColorEditor) e.next();
1434 String key = (String) fColorButtons.get(c);
1435 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1436 c.setColorValue(rgb);
1438 e = fCheckBoxes.keySet().iterator();
1439 while (e.hasNext()) {
1440 Button b = (Button) e.next();
1441 String key = (String) fCheckBoxes.get(b);
1442 b.setSelection(fOverlayStore.getBoolean(key));
1444 e = fTextFields.keySet().iterator();
1445 while (e.hasNext()) {
1446 Text t = (Text) e.next();
1447 String key = (String) fTextFields.get(t);
1448 t.setText(fOverlayStore.getString(key));
1450 RGB rgb = PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1451 fBackgroundColorEditor.setColorValue(rgb);
1452 boolean default_ = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1453 fBackgroundDefaultRadioButton.setSelection(default_);
1454 fBackgroundCustomRadioButton.setSelection(!default_);
1455 fBackgroundColorButton.setEnabled(!default_);
1456 // boolean closeJavaDocs = fOverlayStore
1457 // .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1458 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1459 fEscapeStringsButton.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS));
1460 // boolean fillMethodArguments=
1461 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1462 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1463 // boolean completionInserts=
1464 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1465 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1466 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1468 // fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1469 // boolean markOccurrences=
1470 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1471 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1472 updateAutoactivationControls();
1475 private void initializeDefaultColors() {
1476 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1477 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1478 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1479 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1481 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1482 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1483 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1484 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1488 private void updateAutoactivationControls() {
1489 // boolean autoactivation=
1490 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1491 // fAutoInsertDelayText.setEnabled(autoactivation);
1492 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1493 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1494 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1496 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1497 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1501 * @see PreferencePage#performOk()
1503 public boolean performOk() {
1504 // fJavaEditorHoverConfigurationBlock.performOk();
1505 fFoldingConfigurationBlock.performOk();
1506 // fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1507 // computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1508 fOverlayStore.propagate();
1509 PHPeclipsePlugin.getDefault().savePluginPreferences();
1514 * @see PreferencePage#performDefaults()
1516 protected void performDefaults() {
1517 fOverlayStore.loadDefaults();
1519 handleSyntaxColorListSelection();
1520 handleAppearanceColorListSelection();
1521 // handleAnnotationListSelection();
1522 // handleContentAssistColorListSelection();
1523 // fJavaEditorHoverConfigurationBlock.performDefaults();
1524 fFoldingConfigurationBlock.performDefaults();
1525 super.performDefaults();
1526 fPreviewViewer.invalidateTextPresentation();
1530 * @see DialogPage#dispose()
1532 public void dispose() {
1533 fFoldingConfigurationBlock.dispose();
1535 if (fJavaTextTools != null) {
1536 fJavaTextTools.dispose();
1537 fJavaTextTools = null;
1539 if (fOverlayStore != null) {
1540 fOverlayStore.stop();
1541 fOverlayStore = null;
1543 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1544 fBackgroundColor.dispose();
1548 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1549 Button checkBox = new Button(parent, SWT.CHECK);
1550 checkBox.setText(label);
1551 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1552 gd.horizontalIndent = indentation;
1553 gd.horizontalSpan = 2;
1554 checkBox.setLayoutData(gd);
1555 checkBox.addSelectionListener(fCheckBoxListener);
1556 fCheckBoxes.put(checkBox, key);
1560 private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1561 return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
1564 private static Label getLabelControl(Control[] labelledTextField) {
1565 return (Label) labelledTextField[0];
1568 private static Text getTextControl(Control[] labelledTextField) {
1569 return (Text) labelledTextField[1];
1573 * Returns an array of size 2: - first element is of type <code>Label</code>- second element is of type <code>Text</code> Use
1574 * <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
1576 private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation,
1578 Label labelControl = new Label(composite, SWT.NONE);
1579 labelControl.setText(label);
1580 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1581 gd.horizontalIndent = indentation;
1582 labelControl.setLayoutData(gd);
1583 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1584 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1585 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1586 textControl.setLayoutData(gd);
1587 textControl.setTextLimit(textLimit);
1588 fTextFields.put(textControl, key);
1590 fNumberFields.add(textControl);
1591 textControl.addModifyListener(fNumberFieldListener);
1593 textControl.addModifyListener(fTextFieldListener);
1595 return new Control[] { labelControl, textControl };
1598 private String loadPreviewContentFromFile(String filename) {
1600 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1601 StringBuffer buffer = new StringBuffer(512);
1602 BufferedReader reader = null;
1604 reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1605 while ((line = reader.readLine()) != null) {
1606 buffer.append(line);
1607 buffer.append(separator);
1609 } catch (IOException io) {
1610 PHPeclipsePlugin.log(io);
1612 if (reader != null) {
1615 } catch (IOException e) {
1619 return buffer.toString();
1622 private void numberFieldChanged(Text textControl) {
1623 String number = textControl.getText();
1624 IStatus status = validatePositiveNumber(number);
1625 if (!status.matches(IStatus.ERROR))
1626 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1627 updateStatus(status);
1630 private IStatus validatePositiveNumber(String number) {
1631 StatusInfo status = new StatusInfo();
1632 if (number.length() == 0) {
1633 status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1636 int value = Integer.parseInt(number);
1638 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1639 } catch (NumberFormatException e) {
1640 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1646 void updateStatus(IStatus status) {
1647 if (!status.matches(IStatus.ERROR)) {
1648 for (int i = 0; i < fNumberFields.size(); i++) {
1649 Text text = (Text) fNumberFields.get(i);
1650 IStatus s = validatePositiveNumber(text.getText());
1651 status = StatusUtil.getMoreSevere(s, status);
1655 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1657 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1659 setValid(!status.matches(IStatus.ERROR));
1660 StatusUtil.applyToStatusLine(this, status);