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.Font;
58 import org.eclipse.swt.graphics.RGB;
59 import org.eclipse.swt.layout.GridData;
60 import org.eclipse.swt.layout.GridLayout;
61 import org.eclipse.swt.layout.RowLayout;
62 import org.eclipse.swt.widgets.Button;
63 import org.eclipse.swt.widgets.Combo;
64 import org.eclipse.swt.widgets.Composite;
65 import org.eclipse.swt.widgets.Control;
66 import org.eclipse.swt.widgets.Group;
67 import org.eclipse.swt.widgets.Label;
68 import org.eclipse.swt.widgets.List;
69 import org.eclipse.swt.widgets.TabFolder;
70 import org.eclipse.swt.widgets.TabItem;
71 import org.eclipse.swt.widgets.Text;
72 import org.eclipse.ui.IWorkbench;
73 import org.eclipse.ui.IWorkbenchPreferencePage;
74 import org.eclipse.ui.editors.text.EditorsUI;
75 import org.eclipse.ui.help.WorkbenchHelp;
76 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
77 import org.eclipse.ui.texteditor.AnnotationPreference;
78 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
79 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
82 * The page for setting the editor options.
84 public class JavaEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
85 private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
87 private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
89 private static final String DELIMITER = PreferencesMessages.getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
91 /** The keys of the overlay store. */
92 public final OverlayPreferenceStore.OverlayKey[] fKeys;
94 private final String[][] fSyntaxColorListModel = new String[][] {
95 { PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
96 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
98 { PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
99 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
101 { PreferencesMessages.getString("JavaEditorPreferencePage.tags"), PreferenceConstants.EDITOR_PHP_TAG_COLOR },
103 { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
104 { PreferencesMessages.getString("JavaEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
106 { PreferencesMessages.getString("JavaEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
108 { PreferencesMessages.getString("JavaEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
110 { PreferencesMessages.getString("JavaEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
112 { PreferencesMessages.getString("JavaEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR },
114 { PreferencesMessages.getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
115 { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
117 { PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"),
118 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
119 { PreferencesMessages.getString("JavaEditorPreferencePage.braces"),
120 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR },
122 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
124 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
126 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
128 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
131 private final String[][] fAppearanceColorListModel = new String[][] {
132 { PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
133 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR },
135 { PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
136 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
138 { PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"),
139 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
141 { PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"),
142 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
144 { PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
146 { PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
149 // private final String[][] fAnnotationColorListModel;
151 // private final String[][] fAnnotationDecorationListModel = new String[][]{
153 // PreferencesMessages
154 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
155 // AnnotationPreference.STYLE_NONE},
158 // PreferencesMessages
159 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
160 // AnnotationPreference.STYLE_SQUIGGLIES},
163 // PreferencesMessages
164 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
165 // AnnotationPreference.STYLE_UNDERLINE},
168 // PreferencesMessages
169 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
170 // AnnotationPreference.STYLE_BOX},
173 // PreferencesMessages
174 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
175 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
177 private OverlayPreferenceStore fOverlayStore;
179 private JavaTextTools fJavaTextTools;
181 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
183 private FoldingConfigurationBlock fFoldingConfigurationBlock;
185 private Map fColorButtons = new HashMap();
187 private Map fCheckBoxes = new HashMap();
189 private SelectionListener fCheckBoxListener = new SelectionListener() {
190 public void widgetDefaultSelected(SelectionEvent e) {
193 public void widgetSelected(SelectionEvent e) {
194 Button button = (Button) e.widget;
195 fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
199 private Map fTextFields = new HashMap();
201 private ModifyListener fTextFieldListener = new ModifyListener() {
202 public void modifyText(ModifyEvent e) {
203 Text text = (Text) e.widget;
204 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
208 private ArrayList fNumberFields = new ArrayList();
210 private ModifyListener fNumberFieldListener = new ModifyListener() {
211 public void modifyText(ModifyEvent e) {
212 numberFieldChanged((Text) e.widget);
216 private List fSyntaxColorList;
218 private List fAppearanceColorList;
220 // private List fContentAssistColorList;
221 private List fAnnotationList;
223 private ColorEditor fSyntaxForegroundColorEditor;
225 private ColorEditor fAppearanceColorEditor;
227 private ColorEditor fAnnotationForegroundColorEditor;
229 private ColorEditor fContentAssistColorEditor;
231 private ColorEditor fBackgroundColorEditor;
233 private Button fBackgroundDefaultRadioButton;
235 private Button fBackgroundCustomRadioButton;
237 private Button fBackgroundColorButton;
239 private Button fBoldCheckBox;
241 // private Button fAddJavaDocTagsButton;
243 private Button fEscapeStringsButtonDQ;
245 private Button fEscapeStringsButtonSQ;
247 // private Button fGuessMethodArgumentsButton;
248 private SourceViewer fPreviewViewer;
250 private Color fBackgroundColor;
252 private Control fAutoInsertDelayText;
254 private Control fAutoInsertJavaTriggerText;
256 private Control fAutoInsertJavaDocTriggerText;
258 private Label fAutoInsertDelayLabel;
260 private Label fAutoInsertJavaTriggerLabel;
262 private Label fAutoInsertJavaDocTriggerLabel;
264 private Button fShowInTextCheckBox;
266 private Combo fDecorationStyleCombo;
268 private Button fHighlightInTextCheckBox;
270 private Button fShowInOverviewRulerCheckBox;
272 private Button fShowInVerticalRulerCheckBox;
274 // private Text fBrowserLikeLinksKeyModifierText;
275 // private Button fBrowserLikeLinksCheckBox;
276 // private StatusInfo fBrowserLikeLinksKeyModifierStatus;
277 // private Button fCompletionInsertsRadioButton;
278 // private Button fCompletionOverwritesRadioButton;
279 // private Button fStickyOccurrencesButton;
281 * Creates a new preference page.
283 public JavaEditorPreferencePage() {
284 setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
285 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
286 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
287 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
288 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
289 // fAnnotationColorListModel =
290 // createAnnotationTypeListModel(markerAnnotationPreferences);
293 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
294 ArrayList overlayKeys = new ArrayList();
295 Iterator e = preferences.getAnnotationPreferences().iterator();
296 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
297 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
298 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
299 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
300 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
301 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
302 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
303 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
304 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
305 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
306 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
307 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
308 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
309 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
310 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
311 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
312 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
313 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
314 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
315 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
316 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
318 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TAG_COLOR));
319 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TAG_BOLD));
320 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
321 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
322 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
323 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
324 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
325 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
326 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
327 PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
328 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
329 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
330 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
331 PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
333 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
335 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
337 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR));
338 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD));
339 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
340 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
341 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
342 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
344 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
346 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
347 // overlayKeys.add(new
348 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
349 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
350 // overlayKeys.add(new
351 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
352 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
353 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
354 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
355 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
356 PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
357 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
358 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
359 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
360 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
361 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
362 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR));
363 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
364 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_BOLD));
365 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
366 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
367 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
368 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
369 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
370 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
371 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
372 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
373 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
374 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
375 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
376 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
377 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
378 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
379 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
380 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
381 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
382 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
383 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
384 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
385 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
386 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
387 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
388 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
389 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
390 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
391 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
392 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
393 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
394 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
395 // overlayKeys.add(new
396 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
397 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
398 // overlayKeys.add(new
399 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
400 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
401 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
402 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
403 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
404 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
405 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
406 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
407 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
408 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
409 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
410 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
411 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
412 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
413 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
414 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
415 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
416 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
417 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
418 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
419 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
421 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT));
422 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
423 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
424 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
425 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
426 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
427 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
428 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
429 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
430 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
431 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
432 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
433 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
434 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
435 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
436 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
437 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
438 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
439 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
440 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
441 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
442 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
443 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
445 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT));
446 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
447 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
448 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
449 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
450 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
451 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
452 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE));
453 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
454 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
455 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
456 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
457 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
458 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
460 // .add(new OverlayPreferenceStore.OverlayKey(
461 // OverlayPreferenceStore.BOOLEAN,
462 // PreferenceConstants.EDITOR_CLOSE_BRACES));
463 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
464 // OverlayPreferenceStore.BOOLEAN,
465 // PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
466 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_WORDS));
467 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
469 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
470 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
472 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
474 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
475 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
477 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
478 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
479 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
480 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
481 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
482 // overlayKeys.add(new
483 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
484 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
485 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
486 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
487 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
488 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
489 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
490 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
491 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
492 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
493 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
494 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
495 while (e.hasNext()) {
496 AnnotationPreference info = (AnnotationPreference) e.next();
497 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
498 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
499 if (info.getHighlightPreferenceKey() != null)
500 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
501 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
502 if (info.getVerticalRulerPreferenceKey() != null)
504 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
505 if (info.getTextStylePreferenceKey() != null)
506 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
508 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
509 overlayKeys.toArray(keys);
512 * @see IWorkbenchPreferencePage#init()
515 public void init(IWorkbench workbench) {
519 * @see PreferencePage#createControl(Composite)
521 public void createControl(Composite parent) {
522 super.createControl(parent);
523 WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
526 private void handleSyntaxColorListSelection() {
527 int i = fSyntaxColorList.getSelectionIndex();
528 String key = fSyntaxColorListModel[i][1];
529 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
530 fSyntaxForegroundColorEditor.setColorValue(rgb);
531 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
534 private void handleAppearanceColorListSelection() {
535 int i = fAppearanceColorList.getSelectionIndex();
536 String key = fAppearanceColorListModel[i][1];
537 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
538 fAppearanceColorEditor.setColorValue(rgb);
541 // private void handleAnnotationListSelection() {
542 // int i = fAnnotationList.getSelectionIndex();
543 // String key = fAnnotationColorListModel[i][1];
544 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
545 // fAnnotationForegroundColorEditor.setColorValue(rgb);
546 // key = fAnnotationColorListModel[i][2];
547 // boolean showInText = fOverlayStore.getBoolean(key);
548 // fShowInTextCheckBox.setSelection(showInText);
549 // key = fAnnotationColorListModel[i][6];
550 // if (key != null) {
551 // fDecorationStyleCombo.setEnabled(showInText);
552 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
553 // String value = fOverlayStore.getString(key);
554 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
555 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
560 // fDecorationStyleCombo.setEnabled(false);
561 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
574 // key = fAnnotationColorListModel[i][3];
575 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
576 // key = fAnnotationColorListModel[i][4];
577 // if (key != null) {
578 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
579 // fHighlightInTextCheckBox.setEnabled(true);
581 // fHighlightInTextCheckBox.setEnabled(false);
582 // key = fAnnotationColorListModel[i][5];
583 // if (key != null) {
584 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
585 // fShowInVerticalRulerCheckBox.setEnabled(true);
587 // fShowInVerticalRulerCheckBox.setSelection(true);
588 // fShowInVerticalRulerCheckBox.setEnabled(false);
591 private Control createSyntaxPage(Composite parent) {
592 Composite colorComposite = new Composite(parent, SWT.NULL);
593 colorComposite.setLayout(new GridLayout());
594 Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
595 backgroundComposite.setLayout(new RowLayout());
596 backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
597 SelectionListener backgroundSelectionListener = new SelectionListener() {
598 public void widgetSelected(SelectionEvent e) {
599 boolean custom = fBackgroundCustomRadioButton.getSelection();
600 fBackgroundColorButton.setEnabled(custom);
601 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
604 public void widgetDefaultSelected(SelectionEvent e) {
607 fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
608 fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
609 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
610 fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
611 fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
612 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
613 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
614 fBackgroundColorButton = fBackgroundColorEditor.getButton();
615 Label label = new Label(colorComposite, SWT.LEFT);
616 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
617 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
618 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
619 GridLayout layout = new GridLayout();
620 layout.numColumns = 2;
621 layout.marginHeight = 0;
622 layout.marginWidth = 0;
623 editorComposite.setLayout(layout);
624 GridData gd = new GridData(GridData.FILL_BOTH);
625 editorComposite.setLayoutData(gd);
626 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
627 gd = new GridData(GridData.FILL_BOTH);
628 gd.heightHint = convertHeightInCharsToPixels(5);
629 fSyntaxColorList.setLayoutData(gd);
630 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
631 layout = new GridLayout();
632 layout.marginHeight = 0;
633 layout.marginWidth = 0;
634 layout.numColumns = 2;
635 stylesComposite.setLayout(layout);
636 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
637 label = new Label(stylesComposite, SWT.LEFT);
638 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
640 gd.horizontalAlignment = GridData.BEGINNING;
641 label.setLayoutData(gd);
642 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
643 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
644 gd = new GridData(GridData.FILL_HORIZONTAL);
645 gd.horizontalAlignment = GridData.BEGINNING;
646 foregroundColorButton.setLayoutData(gd);
647 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
648 fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
649 gd = new GridData(GridData.FILL_HORIZONTAL);
650 gd.horizontalAlignment = GridData.BEGINNING;
651 gd.horizontalSpan = 2;
652 fBoldCheckBox.setLayoutData(gd);
653 label = new Label(colorComposite, SWT.LEFT);
654 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
655 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
656 Control previewer = createPreviewer(colorComposite);
657 gd = new GridData(GridData.FILL_BOTH);
658 gd.widthHint = convertWidthInCharsToPixels(20);
659 gd.heightHint = convertHeightInCharsToPixels(5);
660 previewer.setLayoutData(gd);
661 fSyntaxColorList.addSelectionListener(new SelectionListener() {
662 public void widgetDefaultSelected(SelectionEvent e) {
666 public void widgetSelected(SelectionEvent e) {
667 handleSyntaxColorListSelection();
670 foregroundColorButton.addSelectionListener(new SelectionListener() {
671 public void widgetDefaultSelected(SelectionEvent e) {
675 public void widgetSelected(SelectionEvent e) {
676 int i = fSyntaxColorList.getSelectionIndex();
677 String key = fSyntaxColorListModel[i][1];
678 PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
681 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
682 public void widgetDefaultSelected(SelectionEvent e) {
686 public void widgetSelected(SelectionEvent e) {
687 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
691 fBoldCheckBox.addSelectionListener(new SelectionListener() {
692 public void widgetDefaultSelected(SelectionEvent e) {
696 public void widgetSelected(SelectionEvent e) {
697 int i = fSyntaxColorList.getSelectionIndex();
698 String key = fSyntaxColorListModel[i][1];
699 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
702 return colorComposite;
705 private Control createPreviewer(Composite parent) {
706 Preferences coreStore = createTemporaryCorePreferenceStore();
707 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
708 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
709 IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
710 new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
712 fPreviewViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
713 JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
714 PHPSourceViewerConfiguration configuration= new PHPSourceViewerConfiguration(tools.getColorManager(), store, null, IPHPPartitions.PHP_PARTITIONING);
715 // PHPSourceViewerConfiguration configuration =new PHPSourceViewerConfiguration(fJavaTextTools, null, IPHPPartitions.PHP_PARTITIONING);
716 fPreviewViewer.configure(configuration);
718 Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
719 fPreviewViewer.getTextWidget().setFont(font);
720 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
721 fPreviewViewer.setEditable(false);
722 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
723 IDocument document = new Document(content);
724 fJavaTextTools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
725 fPreviewViewer.setDocument(document);
726 return fPreviewViewer.getControl();
729 private Preferences createTemporaryCorePreferenceStore() {
730 Preferences result = new Preferences();
731 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
735 private Control createAppearancePage(Composite parent) {
736 Composite appearanceComposite = new Composite(parent, SWT.NONE);
737 GridLayout layout = new GridLayout();
738 layout.numColumns = 2;
739 appearanceComposite.setLayout(layout);
740 String label = PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
741 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
742 label = PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
743 addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
744 label = PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
745 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
746 label = PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
747 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
748 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
749 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
750 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
751 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
752 label = PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
753 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
754 label = PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
755 // Button master= addCheckBox(appearanceComposite, label,
756 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
757 label = PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
758 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
759 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
760 // createDependency(master, fStickyOccurrencesButton);
761 Label l = new Label(appearanceComposite, SWT.LEFT);
762 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
763 gd.horizontalSpan = 2;
764 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
766 l = new Label(appearanceComposite, SWT.LEFT);
767 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
768 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
769 gd.horizontalSpan = 2;
771 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
772 layout = new GridLayout();
773 layout.numColumns = 2;
774 layout.marginHeight = 0;
775 layout.marginWidth = 0;
776 editorComposite.setLayout(layout);
777 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
778 gd.horizontalSpan = 2;
779 editorComposite.setLayoutData(gd);
780 fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
781 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
782 gd.heightHint = convertHeightInCharsToPixels(8);
783 fAppearanceColorList.setLayoutData(gd);
784 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
785 layout = new GridLayout();
786 layout.marginHeight = 0;
787 layout.marginWidth = 0;
788 layout.numColumns = 2;
789 stylesComposite.setLayout(layout);
790 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
791 l = new Label(stylesComposite, SWT.LEFT);
792 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
794 gd.horizontalAlignment = GridData.BEGINNING;
796 fAppearanceColorEditor = new ColorEditor(stylesComposite);
797 Button foregroundColorButton = fAppearanceColorEditor.getButton();
798 gd = new GridData(GridData.FILL_HORIZONTAL);
799 gd.horizontalAlignment = GridData.BEGINNING;
800 foregroundColorButton.setLayoutData(gd);
801 fAppearanceColorList.addSelectionListener(new SelectionListener() {
802 public void widgetDefaultSelected(SelectionEvent e) {
806 public void widgetSelected(SelectionEvent e) {
807 handleAppearanceColorListSelection();
810 foregroundColorButton.addSelectionListener(new SelectionListener() {
811 public void widgetDefaultSelected(SelectionEvent e) {
815 public void widgetSelected(SelectionEvent e) {
816 int i = fAppearanceColorList.getSelectionIndex();
817 String key = fAppearanceColorListModel[i][1];
818 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
821 return appearanceComposite;
824 // private Control createAnnotationsPage(Composite parent) {
825 // Composite composite = new Composite(parent, SWT.NULL);
826 // GridLayout layout = new GridLayout();
827 // layout.numColumns = 2;
828 // composite.setLayout(layout);
829 // String text = PreferencesMessages
830 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
832 // addCheckBox(composite, text,
833 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
834 // text = PreferencesMessages
835 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
836 // addCheckBox(composite, text,
837 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
838 // addFiller(composite);
839 // Label label = new Label(composite, SWT.LEFT);
840 // label.setText(PreferencesMessages
841 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
843 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
844 // gd.horizontalSpan = 2;
845 // label.setLayoutData(gd);
846 // Composite editorComposite = new Composite(composite, SWT.NONE);
847 // layout = new GridLayout();
848 // layout.numColumns = 2;
849 // layout.marginHeight = 0;
850 // layout.marginWidth = 0;
851 // editorComposite.setLayout(layout);
852 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
853 // gd.horizontalSpan = 2;
854 // editorComposite.setLayoutData(gd);
855 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
857 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
858 // | GridData.FILL_HORIZONTAL);
859 // gd.heightHint = convertHeightInCharsToPixels(10);
860 // fAnnotationList.setLayoutData(gd);
861 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
862 // layout = new GridLayout();
863 // layout.marginHeight = 0;
864 // layout.marginWidth = 0;
865 // layout.numColumns = 2;
866 // optionsComposite.setLayout(layout);
867 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
868 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
869 // fShowInTextCheckBox.setText(PreferencesMessages
870 // .getString("JavaEditorPreferencePage.annotations.showInText"));
872 // gd = new GridData(GridData.FILL_HORIZONTAL);
873 // gd.horizontalAlignment = GridData.BEGINNING;
874 // gd.horizontalSpan = 2;
875 // fShowInTextCheckBox.setLayoutData(gd);
876 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
877 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
878 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
879 // gd = new GridData(GridData.FILL_HORIZONTAL);
880 // gd.horizontalAlignment = GridData.BEGINNING;
881 // gd.horizontalSpan = 2;
882 // gd.horizontalIndent = 20;
883 // fDecorationStyleCombo.setLayoutData(gd);
884 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
885 // fHighlightInTextCheckBox.setText(PreferencesMessages
886 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
888 // gd = new GridData(GridData.FILL_HORIZONTAL);
889 // gd.horizontalAlignment = GridData.BEGINNING;
890 // gd.horizontalSpan = 2;
891 // fHighlightInTextCheckBox.setLayoutData(gd);
892 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
893 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
894 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
896 // gd = new GridData(GridData.FILL_HORIZONTAL);
897 // gd.horizontalAlignment = GridData.BEGINNING;
898 // gd.horizontalSpan = 2;
899 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
900 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
901 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
902 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
904 // gd = new GridData(GridData.FILL_HORIZONTAL);
905 // gd.horizontalAlignment = GridData.BEGINNING;
906 // gd.horizontalSpan = 2;
907 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
908 // label = new Label(optionsComposite, SWT.LEFT);
909 // label.setText(PreferencesMessages
910 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
911 // gd = new GridData();
912 // gd.horizontalAlignment = GridData.BEGINNING;
913 // label.setLayoutData(gd);
914 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
915 // Button foregroundColorButton =
916 // fAnnotationForegroundColorEditor.getButton();
917 // gd = new GridData(GridData.FILL_HORIZONTAL);
918 // gd.horizontalAlignment = GridData.BEGINNING;
919 // foregroundColorButton.setLayoutData(gd);
920 // fAnnotationList.addSelectionListener(new SelectionListener() {
921 // public void widgetDefaultSelected(SelectionEvent e) {
924 // public void widgetSelected(SelectionEvent e) {
925 // handleAnnotationListSelection();
928 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
929 // public void widgetDefaultSelected(SelectionEvent e) {
932 // public void widgetSelected(SelectionEvent e) {
933 // int i = fAnnotationList.getSelectionIndex();
934 // String key = fAnnotationColorListModel[i][2];
935 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
936 // String decorationKey = fAnnotationColorListModel[i][6];
937 // fDecorationStyleCombo.setEnabled(decorationKey != null
938 // && fShowInTextCheckBox.getSelection());
941 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
942 // public void widgetDefaultSelected(SelectionEvent e) {
945 // public void widgetSelected(SelectionEvent e) {
946 // int i = fAnnotationList.getSelectionIndex();
947 // String key = fAnnotationColorListModel[i][4];
948 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
951 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
952 // public void widgetDefaultSelected(SelectionEvent e) {
955 // public void widgetSelected(SelectionEvent e) {
956 // int i = fAnnotationList.getSelectionIndex();
957 // String key = fAnnotationColorListModel[i][3];
959 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
962 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
963 // public void widgetDefaultSelected(SelectionEvent e) {
966 // public void widgetSelected(SelectionEvent e) {
967 // int i = fAnnotationList.getSelectionIndex();
968 // String key = fAnnotationColorListModel[i][5];
970 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
973 // foregroundColorButton.addSelectionListener(new SelectionListener() {
974 // public void widgetDefaultSelected(SelectionEvent e) {
977 // public void widgetSelected(SelectionEvent e) {
978 // int i = fAnnotationList.getSelectionIndex();
979 // String key = fAnnotationColorListModel[i][1];
980 // PreferenceConverter.setValue(fOverlayStore, key,
981 // fAnnotationForegroundColorEditor.getColorValue());
984 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
988 // public void widgetDefaultSelected(SelectionEvent e) {
994 // public void widgetSelected(SelectionEvent e) {
995 // int i = fAnnotationList.getSelectionIndex();
996 // String key = fAnnotationColorListModel[i][6];
997 // if (key != null) {
998 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
999 // if (fAnnotationDecorationListModel[j][0]
1000 // .equals(fDecorationStyleCombo.getText())) {
1001 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1008 // return composite;
1010 private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
1011 ArrayList listModelItems = new ArrayList();
1012 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1014 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1016 public int compare(Object o1, Object o2) {
1017 if (!(o2 instanceof AnnotationPreference))
1019 if (!(o1 instanceof AnnotationPreference))
1021 AnnotationPreference a1 = (AnnotationPreference) o1;
1022 AnnotationPreference a2 = (AnnotationPreference) o2;
1023 return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
1026 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1027 Iterator e = sortedPreferences.iterator();
1028 while (e.hasNext()) {
1029 AnnotationPreference info = (AnnotationPreference) e.next();
1030 listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1031 info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(),
1032 info.getTextStylePreferenceKey() });
1034 String[][] items = new String[listModelItems.size()][];
1035 listModelItems.toArray(items);
1039 private Control createTypingPage(Composite parent) {
1040 Composite composite = new Composite(parent, SWT.NONE);
1041 GridLayout layout = new GridLayout();
1042 layout.numColumns = 1;
1043 composite.setLayout(layout);
1045 // label = PreferencesMessages
1046 // .getString("JavaEditorPreferencePage.overwriteMode");
1048 // addCheckBox(composite, label,
1049 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1050 // addFiller(composite);
1052 // label = PreferencesMessages
1053 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1055 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1057 // label = PreferencesMessages
1058 // .getString("JavaEditorPreferencePage.subWordNavigation");
1060 // addCheckBox(composite, label,
1061 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1062 // addFiller(composite);
1063 Group group = new Group(composite, SWT.NONE);
1064 layout = new GridLayout();
1065 layout.numColumns = 2;
1066 group.setLayout(layout);
1067 group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1069 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapWords");//$NON-NLS-1$
1070 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_WORDS, 1);
1072 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1073 Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1075 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1076 fEscapeStringsButtonDQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1077 createDependency(button, fEscapeStringsButtonDQ);
1079 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1080 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1082 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsSQ");
1084 fEscapeStringsButtonSQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1085 createDependency(button, fEscapeStringsButtonSQ);
1087 label = PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
1089 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1091 label = PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
1093 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1095 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsDQ");
1097 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1098 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsSQ");
1100 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1102 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
1104 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1106 // label = PreferencesMessages
1107 // .getString("JavaEditorPreferencePage.closeBraces");
1109 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1111 // label = PreferencesMessages
1112 // .getString("JavaEditorPreferencePage.closeJavaDocs");
1114 // button = addCheckBox(group, label,
1115 // PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1117 // label = PreferencesMessages
1118 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1120 // fAddJavaDocTagsButton = addCheckBox(group, label,
1121 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1122 // createDependency(button, fAddJavaDocTagsButton);
1126 private void addFiller(Composite composite) {
1127 Label filler = new Label(composite, SWT.LEFT);
1128 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1129 gd.horizontalSpan = 2;
1130 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1131 filler.setLayoutData(gd);
1134 private static void indent(Control control) {
1135 GridData gridData = new GridData();
1136 gridData.horizontalIndent = 20;
1137 control.setLayoutData(gridData);
1140 private static void createDependency(final Button master, final Control slave) {
1142 master.addSelectionListener(new SelectionListener() {
1143 public void widgetSelected(SelectionEvent e) {
1144 slave.setEnabled(master.getSelection());
1147 public void widgetDefaultSelected(SelectionEvent e) {
1152 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1153 Composite completionComposite = new Composite(contentAssistComposite, SWT.NONE);
1154 GridData ccgd = new GridData();
1155 ccgd.horizontalSpan = 2;
1156 completionComposite.setLayoutData(ccgd);
1157 GridLayout ccgl = new GridLayout();
1158 ccgl.marginWidth = 0;
1159 ccgl.numColumns = 2;
1160 completionComposite.setLayout(ccgl);
1161 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1162 // public void widgetSelected(SelectionEvent e) {
1163 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1164 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1169 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1171 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1173 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1174 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1176 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1177 // SWT.RADIO | SWT.LEFT);
1178 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1180 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1181 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1184 private Control createNavigationPage(Composite parent) {
1185 Composite composite = new Composite(parent, SWT.NULL);
1186 GridLayout layout = new GridLayout();
1187 layout.numColumns = 2;
1188 composite.setLayout(layout);
1190 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1192 // fBrowserLikeLinksCheckBox= addCheckBox(composite, text,
1193 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1194 // fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1195 // public void widgetSelected(SelectionEvent e) {
1196 // boolean state= fBrowserLikeLinksCheckBox.getSelection();
1197 // fBrowserLikeLinksKeyModifierText.setEnabled(state);
1198 // handleBrowserLikeLinksKeyModifierModified();
1200 // public void widgetDefaultSelected(SelectionEvent e) {
1203 // Text field for modifier string
1205 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1207 // fBrowserLikeLinksKeyModifierText= addTextField(composite, text,
1208 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0,
1210 // fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1213 // (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER))
1215 // // Fix possible illegal modifier string
1217 // fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1218 // if (stateMask == -1)
1219 // fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1221 // fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1223 // fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1224 // private boolean isModifierCandidate;
1225 // public void keyPressed(KeyEvent e) {
1226 // isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask ==
1230 // public void keyReleased(KeyEvent e) {
1231 // if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask
1232 // && e.character == 0) {// && e.time -time < 1000) {
1233 // String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1234 // Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1235 // int i= selection.x - 1;
1236 // while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1239 // boolean needsPrefixDelimiter= i > -1 &&
1240 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1243 // while (i < modifierString.length() &&
1244 // Character.isWhitespace(modifierString.charAt(i))) {
1247 // boolean needsPostfixDelimiter= i < modifierString.length() &&
1248 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1250 // String insertString;
1252 // if (needsPrefixDelimiter && needsPostfixDelimiter)
1254 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1255 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1256 // else if (needsPrefixDelimiter)
1258 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1259 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1260 // else if (needsPostfixDelimiter)
1262 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1263 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1265 // insertString= Action.findModifierString(e.stateMask);
1267 // fBrowserLikeLinksKeyModifierText.insert(insertString);
1272 // fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener()
1274 // public void modifyText(ModifyEvent e) {
1275 // handleBrowserLikeLinksKeyModifierModified();
1281 private void handleBrowserLikeLinksKeyModifierModified() {
1282 // String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1283 // int stateMask= computeStateMask(modifiers);
1284 // if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 ||
1285 // (stateMask & SWT.SHIFT) != 0)) {
1286 // if (stateMask == -1)
1287 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1288 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid",
1289 // modifiers)); //$NON-NLS-1$
1291 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1292 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1295 // StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1297 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1298 // updateStatus(fBrowserLikeLinksKeyModifierStatus);
1302 // private IStatus getBrowserLikeLinksKeyModifierStatus() {
1303 // if (fBrowserLikeLinksKeyModifierStatus == null)
1304 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1305 // return fBrowserLikeLinksKeyModifierStatus;
1308 * Computes the state mask for the given modifier string.
1311 * the string with the modifiers, separated by '+', '-', ';', ',' or '.'
1312 * @return the state mask or -1 if the input is invalid
1314 private int computeStateMask(String modifiers) {
1315 if (modifiers == null)
1317 if (modifiers.length() == 0)
1320 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
1321 while (modifierTokenizer.hasMoreTokens()) {
1322 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
1323 if (modifier == 0 || (stateMask & modifier) == modifier)
1325 stateMask = stateMask | modifier;
1331 * @see PreferencePage#createContents(Composite)
1333 protected Control createContents(Composite parent) {
1334 initializeDefaultColors();
1335 fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore);
1336 fOverlayStore.load();
1337 fOverlayStore.start();
1338 TabFolder folder = new TabFolder(parent, SWT.NONE);
1339 folder.setLayout(new TabFolderLayout());
1340 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1341 TabItem item = new TabItem(folder, SWT.NONE);
1342 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1343 item.setControl(createAppearancePage(folder));
1344 item = new TabItem(folder, SWT.NONE);
1345 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1346 item.setControl(createSyntaxPage(folder));
1348 // item = new TabItem(folder, SWT.NONE);
1349 // item.setText(PreferencesMessages
1350 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1352 // item.setControl(createAnnotationsPage(folder));
1353 item = new TabItem(folder, SWT.NONE);
1354 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
1356 item.setControl(createTypingPage(folder));
1358 item = new TabItem(folder, SWT.NONE);
1359 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
1361 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1362 item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1363 // item= new TabItem(folder, SWT.NONE);
1364 // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1366 // item.setControl(createNavigationPage(folder));
1367 item = new TabItem(folder, SWT.NONE);
1368 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1369 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1372 Dialog.applyDialogFont(folder);
1376 private void initialize() {
1378 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1379 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1380 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1382 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1383 fSyntaxColorList.select(0);
1384 handleSyntaxColorListSelection();
1388 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1389 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1390 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1392 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1393 fAppearanceColorList.select(0);
1394 handleAppearanceColorListSelection();
1398 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1399 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1400 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1401 // public void run() {
1402 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1403 // fAnnotationList.select(0);
1404 // handleAnnotationListSelection();
1408 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1409 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1410 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1411 // public void run() {
1412 // if (fContentAssistColorList != null &&
1413 // !fContentAssistColorList.isDisposed()) {
1414 // fContentAssistColorList.select(0);
1415 // handleContentAssistColorListSelection();
1419 fFoldingConfigurationBlock.initialize();
1422 private void initializeFields() {
1423 Iterator e = fColorButtons.keySet().iterator();
1424 while (e.hasNext()) {
1425 ColorEditor c = (ColorEditor) e.next();
1426 String key = (String) fColorButtons.get(c);
1427 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1428 c.setColorValue(rgb);
1430 e = fCheckBoxes.keySet().iterator();
1431 while (e.hasNext()) {
1432 Button b = (Button) e.next();
1433 String key = (String) fCheckBoxes.get(b);
1434 b.setSelection(fOverlayStore.getBoolean(key));
1436 e = fTextFields.keySet().iterator();
1437 while (e.hasNext()) {
1438 Text t = (Text) e.next();
1439 String key = (String) fTextFields.get(t);
1440 t.setText(fOverlayStore.getString(key));
1442 RGB rgb = PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1443 fBackgroundColorEditor.setColorValue(rgb);
1444 boolean default_ = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1445 fBackgroundDefaultRadioButton.setSelection(default_);
1446 fBackgroundCustomRadioButton.setSelection(!default_);
1447 fBackgroundColorButton.setEnabled(!default_);
1448 // boolean closeJavaDocs = fOverlayStore
1449 // .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1450 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1451 fEscapeStringsButtonDQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1452 fEscapeStringsButtonSQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1453 // boolean fillMethodArguments=
1454 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1455 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1456 // boolean completionInserts=
1457 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1458 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1459 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1461 // fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1462 // boolean markOccurrences=
1463 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1464 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1465 updateAutoactivationControls();
1468 private void initializeDefaultColors() {
1469 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1470 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1471 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1472 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1474 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1475 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1476 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1477 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1481 private void updateAutoactivationControls() {
1482 // boolean autoactivation=
1483 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1484 // fAutoInsertDelayText.setEnabled(autoactivation);
1485 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1486 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1487 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1489 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1490 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1494 * @see PreferencePage#performOk()
1496 public boolean performOk() {
1497 // fJavaEditorHoverConfigurationBlock.performOk();
1498 fFoldingConfigurationBlock.performOk();
1499 // fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1500 // computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1501 fOverlayStore.propagate();
1502 PHPeclipsePlugin.getDefault().savePluginPreferences();
1507 * @see PreferencePage#performDefaults()
1509 protected void performDefaults() {
1510 fOverlayStore.loadDefaults();
1512 handleSyntaxColorListSelection();
1513 handleAppearanceColorListSelection();
1514 // handleAnnotationListSelection();
1515 // handleContentAssistColorListSelection();
1516 // fJavaEditorHoverConfigurationBlock.performDefaults();
1517 fFoldingConfigurationBlock.performDefaults();
1518 super.performDefaults();
1519 fPreviewViewer.invalidateTextPresentation();
1523 * @see DialogPage#dispose()
1525 public void dispose() {
1526 fFoldingConfigurationBlock.dispose();
1528 if (fJavaTextTools != null) {
1529 fJavaTextTools.dispose();
1530 fJavaTextTools = null;
1532 if (fOverlayStore != null) {
1533 fOverlayStore.stop();
1534 fOverlayStore = null;
1536 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1537 fBackgroundColor.dispose();
1541 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1542 Button checkBox = new Button(parent, SWT.CHECK);
1543 checkBox.setText(label);
1544 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1545 gd.horizontalIndent = indentation;
1546 gd.horizontalSpan = 2;
1547 checkBox.setLayoutData(gd);
1548 checkBox.addSelectionListener(fCheckBoxListener);
1549 fCheckBoxes.put(checkBox, key);
1553 private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1554 return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
1557 private static Label getLabelControl(Control[] labelledTextField) {
1558 return (Label) labelledTextField[0];
1561 private static Text getTextControl(Control[] labelledTextField) {
1562 return (Text) labelledTextField[1];
1566 * Returns an array of size 2: - first element is of type <code>Label</code>- second element is of type <code>Text</code> Use
1567 * <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
1569 private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation,
1571 Label labelControl = new Label(composite, SWT.NONE);
1572 labelControl.setText(label);
1573 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1574 gd.horizontalIndent = indentation;
1575 labelControl.setLayoutData(gd);
1576 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1577 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1578 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1579 textControl.setLayoutData(gd);
1580 textControl.setTextLimit(textLimit);
1581 fTextFields.put(textControl, key);
1583 fNumberFields.add(textControl);
1584 textControl.addModifyListener(fNumberFieldListener);
1586 textControl.addModifyListener(fTextFieldListener);
1588 return new Control[] { labelControl, textControl };
1591 private String loadPreviewContentFromFile(String filename) {
1593 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1594 StringBuffer buffer = new StringBuffer(512);
1595 BufferedReader reader = null;
1597 reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1598 while ((line = reader.readLine()) != null) {
1599 buffer.append(line);
1600 buffer.append(separator);
1602 } catch (IOException io) {
1603 PHPeclipsePlugin.log(io);
1605 if (reader != null) {
1608 } catch (IOException e) {
1612 return buffer.toString();
1615 private void numberFieldChanged(Text textControl) {
1616 String number = textControl.getText();
1617 IStatus status = validatePositiveNumber(number);
1618 if (!status.matches(IStatus.ERROR))
1619 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1620 updateStatus(status);
1623 private IStatus validatePositiveNumber(String number) {
1624 StatusInfo status = new StatusInfo();
1625 if (number.length() == 0) {
1626 status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1629 int value = Integer.parseInt(number);
1631 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1632 } catch (NumberFormatException e) {
1633 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1639 void updateStatus(IStatus status) {
1640 if (!status.matches(IStatus.ERROR)) {
1641 for (int i = 0; i < fNumberFields.size(); i++) {
1642 Text text = (Text) fNumberFields.get(i);
1643 IStatus s = validatePositiveNumber(text.getText());
1644 status = StatusUtil.getMoreSevere(s, status);
1648 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1650 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1652 setValid(!status.matches(IStatus.ERROR));
1653 StatusUtil.applyToStatusLine(this, status);