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));
476 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
477 PreferenceConstants.EDITOR_FORMAT_JAVADOCS));
481 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
482 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
483 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
484 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
485 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
486 // overlayKeys.add(new
487 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
488 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
489 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
490 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
491 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
492 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
493 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
494 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
495 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
496 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
497 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
498 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
499 while (e.hasNext()) {
500 AnnotationPreference info = (AnnotationPreference) e.next();
501 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
502 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
503 if (info.getHighlightPreferenceKey() != null)
504 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
505 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
506 if (info.getVerticalRulerPreferenceKey() != null)
508 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
509 if (info.getTextStylePreferenceKey() != null)
510 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
512 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
513 overlayKeys.toArray(keys);
516 * @see IWorkbenchPreferencePage#init()
519 public void init(IWorkbench workbench) {
523 * @see PreferencePage#createControl(Composite)
525 public void createControl(Composite parent) {
526 super.createControl(parent);
527 WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
530 private void handleSyntaxColorListSelection() {
531 int i = fSyntaxColorList.getSelectionIndex();
532 String key = fSyntaxColorListModel[i][1];
533 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
534 fSyntaxForegroundColorEditor.setColorValue(rgb);
535 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
538 private void handleAppearanceColorListSelection() {
539 int i = fAppearanceColorList.getSelectionIndex();
540 String key = fAppearanceColorListModel[i][1];
541 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
542 fAppearanceColorEditor.setColorValue(rgb);
545 // private void handleAnnotationListSelection() {
546 // int i = fAnnotationList.getSelectionIndex();
547 // String key = fAnnotationColorListModel[i][1];
548 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
549 // fAnnotationForegroundColorEditor.setColorValue(rgb);
550 // key = fAnnotationColorListModel[i][2];
551 // boolean showInText = fOverlayStore.getBoolean(key);
552 // fShowInTextCheckBox.setSelection(showInText);
553 // key = fAnnotationColorListModel[i][6];
554 // if (key != null) {
555 // fDecorationStyleCombo.setEnabled(showInText);
556 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
557 // String value = fOverlayStore.getString(key);
558 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
559 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
564 // fDecorationStyleCombo.setEnabled(false);
565 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
578 // key = fAnnotationColorListModel[i][3];
579 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
580 // key = fAnnotationColorListModel[i][4];
581 // if (key != null) {
582 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
583 // fHighlightInTextCheckBox.setEnabled(true);
585 // fHighlightInTextCheckBox.setEnabled(false);
586 // key = fAnnotationColorListModel[i][5];
587 // if (key != null) {
588 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
589 // fShowInVerticalRulerCheckBox.setEnabled(true);
591 // fShowInVerticalRulerCheckBox.setSelection(true);
592 // fShowInVerticalRulerCheckBox.setEnabled(false);
595 private Control createSyntaxPage(Composite parent) {
596 Composite colorComposite = new Composite(parent, SWT.NULL);
597 colorComposite.setLayout(new GridLayout());
598 Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
599 backgroundComposite.setLayout(new RowLayout());
600 backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
601 SelectionListener backgroundSelectionListener = new SelectionListener() {
602 public void widgetSelected(SelectionEvent e) {
603 boolean custom = fBackgroundCustomRadioButton.getSelection();
604 fBackgroundColorButton.setEnabled(custom);
605 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
608 public void widgetDefaultSelected(SelectionEvent e) {
611 fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
612 fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
613 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
614 fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
615 fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
616 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
617 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
618 fBackgroundColorButton = fBackgroundColorEditor.getButton();
619 Label label = new Label(colorComposite, SWT.LEFT);
620 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
621 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
622 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
623 GridLayout layout = new GridLayout();
624 layout.numColumns = 2;
625 layout.marginHeight = 0;
626 layout.marginWidth = 0;
627 editorComposite.setLayout(layout);
628 GridData gd = new GridData(GridData.FILL_BOTH);
629 editorComposite.setLayoutData(gd);
630 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
631 gd = new GridData(GridData.FILL_BOTH);
632 gd.heightHint = convertHeightInCharsToPixels(5);
633 fSyntaxColorList.setLayoutData(gd);
634 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
635 layout = new GridLayout();
636 layout.marginHeight = 0;
637 layout.marginWidth = 0;
638 layout.numColumns = 2;
639 stylesComposite.setLayout(layout);
640 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
641 label = new Label(stylesComposite, SWT.LEFT);
642 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
644 gd.horizontalAlignment = GridData.BEGINNING;
645 label.setLayoutData(gd);
646 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
647 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
648 gd = new GridData(GridData.FILL_HORIZONTAL);
649 gd.horizontalAlignment = GridData.BEGINNING;
650 foregroundColorButton.setLayoutData(gd);
651 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
652 fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
653 gd = new GridData(GridData.FILL_HORIZONTAL);
654 gd.horizontalAlignment = GridData.BEGINNING;
655 gd.horizontalSpan = 2;
656 fBoldCheckBox.setLayoutData(gd);
657 label = new Label(colorComposite, SWT.LEFT);
658 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
659 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
660 Control previewer = createPreviewer(colorComposite);
661 gd = new GridData(GridData.FILL_BOTH);
662 gd.widthHint = convertWidthInCharsToPixels(20);
663 gd.heightHint = convertHeightInCharsToPixels(5);
664 previewer.setLayoutData(gd);
665 fSyntaxColorList.addSelectionListener(new SelectionListener() {
666 public void widgetDefaultSelected(SelectionEvent e) {
670 public void widgetSelected(SelectionEvent e) {
671 handleSyntaxColorListSelection();
674 foregroundColorButton.addSelectionListener(new SelectionListener() {
675 public void widgetDefaultSelected(SelectionEvent e) {
679 public void widgetSelected(SelectionEvent e) {
680 int i = fSyntaxColorList.getSelectionIndex();
681 String key = fSyntaxColorListModel[i][1];
682 PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
685 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
686 public void widgetDefaultSelected(SelectionEvent e) {
690 public void widgetSelected(SelectionEvent e) {
691 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
695 fBoldCheckBox.addSelectionListener(new SelectionListener() {
696 public void widgetDefaultSelected(SelectionEvent e) {
700 public void widgetSelected(SelectionEvent e) {
701 int i = fSyntaxColorList.getSelectionIndex();
702 String key = fSyntaxColorListModel[i][1];
703 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
706 return colorComposite;
709 private Control createPreviewer(Composite parent) {
710 Preferences coreStore = createTemporaryCorePreferenceStore();
711 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
712 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
713 IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
714 new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
716 fPreviewViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
717 JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
718 PHPSourceViewerConfiguration configuration= new PHPSourceViewerConfiguration(tools.getColorManager(), store, null, IPHPPartitions.PHP_PARTITIONING);
719 // PHPSourceViewerConfiguration configuration =new PHPSourceViewerConfiguration(fJavaTextTools, null, IPHPPartitions.PHP_PARTITIONING);
720 fPreviewViewer.configure(configuration);
722 Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
723 fPreviewViewer.getTextWidget().setFont(font);
724 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
725 fPreviewViewer.setEditable(false);
726 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
727 IDocument document = new Document(content);
728 fJavaTextTools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
729 fPreviewViewer.setDocument(document);
730 return fPreviewViewer.getControl();
733 private Preferences createTemporaryCorePreferenceStore() {
734 Preferences result = new Preferences();
735 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
739 private Control createAppearancePage(Composite parent) {
740 Composite appearanceComposite = new Composite(parent, SWT.NONE);
741 GridLayout layout = new GridLayout();
742 layout.numColumns = 2;
743 appearanceComposite.setLayout(layout);
744 String label = PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
745 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
746 label = PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
747 addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
748 label = PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
749 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
750 label = PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
751 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
752 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
753 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
754 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
755 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
756 label = PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
757 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
758 label = PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
759 // Button master= addCheckBox(appearanceComposite, label,
760 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
761 label = PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
762 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
763 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
764 // createDependency(master, fStickyOccurrencesButton);
765 Label l = new Label(appearanceComposite, SWT.LEFT);
766 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
767 gd.horizontalSpan = 2;
768 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
770 l = new Label(appearanceComposite, SWT.LEFT);
771 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
772 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
773 gd.horizontalSpan = 2;
775 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
776 layout = new GridLayout();
777 layout.numColumns = 2;
778 layout.marginHeight = 0;
779 layout.marginWidth = 0;
780 editorComposite.setLayout(layout);
781 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
782 gd.horizontalSpan = 2;
783 editorComposite.setLayoutData(gd);
784 fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
785 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
786 gd.heightHint = convertHeightInCharsToPixels(8);
787 fAppearanceColorList.setLayoutData(gd);
788 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
789 layout = new GridLayout();
790 layout.marginHeight = 0;
791 layout.marginWidth = 0;
792 layout.numColumns = 2;
793 stylesComposite.setLayout(layout);
794 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
795 l = new Label(stylesComposite, SWT.LEFT);
796 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
798 gd.horizontalAlignment = GridData.BEGINNING;
800 fAppearanceColorEditor = new ColorEditor(stylesComposite);
801 Button foregroundColorButton = fAppearanceColorEditor.getButton();
802 gd = new GridData(GridData.FILL_HORIZONTAL);
803 gd.horizontalAlignment = GridData.BEGINNING;
804 foregroundColorButton.setLayoutData(gd);
805 fAppearanceColorList.addSelectionListener(new SelectionListener() {
806 public void widgetDefaultSelected(SelectionEvent e) {
810 public void widgetSelected(SelectionEvent e) {
811 handleAppearanceColorListSelection();
814 foregroundColorButton.addSelectionListener(new SelectionListener() {
815 public void widgetDefaultSelected(SelectionEvent e) {
819 public void widgetSelected(SelectionEvent e) {
820 int i = fAppearanceColorList.getSelectionIndex();
821 String key = fAppearanceColorListModel[i][1];
822 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
825 return appearanceComposite;
828 // private Control createAnnotationsPage(Composite parent) {
829 // Composite composite = new Composite(parent, SWT.NULL);
830 // GridLayout layout = new GridLayout();
831 // layout.numColumns = 2;
832 // composite.setLayout(layout);
833 // String text = PreferencesMessages
834 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
836 // addCheckBox(composite, text,
837 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
838 // text = PreferencesMessages
839 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
840 // addCheckBox(composite, text,
841 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
842 // addFiller(composite);
843 // Label label = new Label(composite, SWT.LEFT);
844 // label.setText(PreferencesMessages
845 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
847 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
848 // gd.horizontalSpan = 2;
849 // label.setLayoutData(gd);
850 // Composite editorComposite = new Composite(composite, SWT.NONE);
851 // layout = new GridLayout();
852 // layout.numColumns = 2;
853 // layout.marginHeight = 0;
854 // layout.marginWidth = 0;
855 // editorComposite.setLayout(layout);
856 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
857 // gd.horizontalSpan = 2;
858 // editorComposite.setLayoutData(gd);
859 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
861 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
862 // | GridData.FILL_HORIZONTAL);
863 // gd.heightHint = convertHeightInCharsToPixels(10);
864 // fAnnotationList.setLayoutData(gd);
865 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
866 // layout = new GridLayout();
867 // layout.marginHeight = 0;
868 // layout.marginWidth = 0;
869 // layout.numColumns = 2;
870 // optionsComposite.setLayout(layout);
871 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
872 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
873 // fShowInTextCheckBox.setText(PreferencesMessages
874 // .getString("JavaEditorPreferencePage.annotations.showInText"));
876 // gd = new GridData(GridData.FILL_HORIZONTAL);
877 // gd.horizontalAlignment = GridData.BEGINNING;
878 // gd.horizontalSpan = 2;
879 // fShowInTextCheckBox.setLayoutData(gd);
880 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
881 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
882 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
883 // gd = new GridData(GridData.FILL_HORIZONTAL);
884 // gd.horizontalAlignment = GridData.BEGINNING;
885 // gd.horizontalSpan = 2;
886 // gd.horizontalIndent = 20;
887 // fDecorationStyleCombo.setLayoutData(gd);
888 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
889 // fHighlightInTextCheckBox.setText(PreferencesMessages
890 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
892 // gd = new GridData(GridData.FILL_HORIZONTAL);
893 // gd.horizontalAlignment = GridData.BEGINNING;
894 // gd.horizontalSpan = 2;
895 // fHighlightInTextCheckBox.setLayoutData(gd);
896 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
897 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
898 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
900 // gd = new GridData(GridData.FILL_HORIZONTAL);
901 // gd.horizontalAlignment = GridData.BEGINNING;
902 // gd.horizontalSpan = 2;
903 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
904 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
905 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
906 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
908 // gd = new GridData(GridData.FILL_HORIZONTAL);
909 // gd.horizontalAlignment = GridData.BEGINNING;
910 // gd.horizontalSpan = 2;
911 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
912 // label = new Label(optionsComposite, SWT.LEFT);
913 // label.setText(PreferencesMessages
914 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
915 // gd = new GridData();
916 // gd.horizontalAlignment = GridData.BEGINNING;
917 // label.setLayoutData(gd);
918 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
919 // Button foregroundColorButton =
920 // fAnnotationForegroundColorEditor.getButton();
921 // gd = new GridData(GridData.FILL_HORIZONTAL);
922 // gd.horizontalAlignment = GridData.BEGINNING;
923 // foregroundColorButton.setLayoutData(gd);
924 // fAnnotationList.addSelectionListener(new SelectionListener() {
925 // public void widgetDefaultSelected(SelectionEvent e) {
928 // public void widgetSelected(SelectionEvent e) {
929 // handleAnnotationListSelection();
932 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
933 // public void widgetDefaultSelected(SelectionEvent e) {
936 // public void widgetSelected(SelectionEvent e) {
937 // int i = fAnnotationList.getSelectionIndex();
938 // String key = fAnnotationColorListModel[i][2];
939 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
940 // String decorationKey = fAnnotationColorListModel[i][6];
941 // fDecorationStyleCombo.setEnabled(decorationKey != null
942 // && fShowInTextCheckBox.getSelection());
945 // fHighlightInTextCheckBox.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][4];
952 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
955 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
956 // public void widgetDefaultSelected(SelectionEvent e) {
959 // public void widgetSelected(SelectionEvent e) {
960 // int i = fAnnotationList.getSelectionIndex();
961 // String key = fAnnotationColorListModel[i][3];
963 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
966 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
967 // public void widgetDefaultSelected(SelectionEvent e) {
970 // public void widgetSelected(SelectionEvent e) {
971 // int i = fAnnotationList.getSelectionIndex();
972 // String key = fAnnotationColorListModel[i][5];
974 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
977 // foregroundColorButton.addSelectionListener(new SelectionListener() {
978 // public void widgetDefaultSelected(SelectionEvent e) {
981 // public void widgetSelected(SelectionEvent e) {
982 // int i = fAnnotationList.getSelectionIndex();
983 // String key = fAnnotationColorListModel[i][1];
984 // PreferenceConverter.setValue(fOverlayStore, key,
985 // fAnnotationForegroundColorEditor.getColorValue());
988 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
992 // public void widgetDefaultSelected(SelectionEvent e) {
998 // public void widgetSelected(SelectionEvent e) {
999 // int i = fAnnotationList.getSelectionIndex();
1000 // String key = fAnnotationColorListModel[i][6];
1001 // if (key != null) {
1002 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1003 // if (fAnnotationDecorationListModel[j][0]
1004 // .equals(fDecorationStyleCombo.getText())) {
1005 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1012 // return composite;
1014 private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
1015 ArrayList listModelItems = new ArrayList();
1016 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1018 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1020 public int compare(Object o1, Object o2) {
1021 if (!(o2 instanceof AnnotationPreference))
1023 if (!(o1 instanceof AnnotationPreference))
1025 AnnotationPreference a1 = (AnnotationPreference) o1;
1026 AnnotationPreference a2 = (AnnotationPreference) o2;
1027 return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
1030 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1031 Iterator e = sortedPreferences.iterator();
1032 while (e.hasNext()) {
1033 AnnotationPreference info = (AnnotationPreference) e.next();
1034 listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1035 info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(),
1036 info.getTextStylePreferenceKey() });
1038 String[][] items = new String[listModelItems.size()][];
1039 listModelItems.toArray(items);
1043 private Control createTypingPage(Composite parent) {
1044 Composite composite = new Composite(parent, SWT.NONE);
1045 GridLayout layout = new GridLayout();
1046 layout.numColumns = 1;
1047 composite.setLayout(layout);
1049 // label = PreferencesMessages
1050 // .getString("JavaEditorPreferencePage.overwriteMode");
1052 // addCheckBox(composite, label,
1053 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1054 // addFiller(composite);
1056 // label = PreferencesMessages
1057 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1059 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1061 // label = PreferencesMessages
1062 // .getString("JavaEditorPreferencePage.subWordNavigation");
1064 // addCheckBox(composite, label,
1065 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1066 // addFiller(composite);
1067 Group group = new Group(composite, SWT.NONE);
1068 layout = new GridLayout();
1069 layout.numColumns = 2;
1070 group.setLayout(layout);
1071 group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1073 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapWords");//$NON-NLS-1$
1074 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_WORDS, 1);
1076 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1077 Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1079 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1080 fEscapeStringsButtonDQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1081 createDependency(button, fEscapeStringsButtonDQ);
1083 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1084 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1086 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsSQ");
1088 fEscapeStringsButtonSQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1089 createDependency(button, fEscapeStringsButtonSQ);
1091 label = PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
1093 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1095 label = PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
1097 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1099 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsDQ");
1101 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1102 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsSQ");
1104 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1106 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
1108 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1110 // label = PreferencesMessages
1111 // .getString("JavaEditorPreferencePage.closeBraces");
1113 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1115 label = PreferencesMessages
1116 .getString("JavaEditorPreferencePage.closeJavaDocs");
1118 button = addCheckBox(group, label,
1119 PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1120 label = PreferencesMessages
1121 .getString("JavaEditorPreferencePage.formatJavaDocs");
1123 button = addCheckBox(group, label,
1124 PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
1126 // label = PreferencesMessages
1127 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1129 // fAddJavaDocTagsButton = addCheckBox(group, label,
1130 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1131 // createDependency(button, fAddJavaDocTagsButton);
1135 private void addFiller(Composite composite) {
1136 Label filler = new Label(composite, SWT.LEFT);
1137 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1138 gd.horizontalSpan = 2;
1139 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1140 filler.setLayoutData(gd);
1143 private static void indent(Control control) {
1144 GridData gridData = new GridData();
1145 gridData.horizontalIndent = 20;
1146 control.setLayoutData(gridData);
1149 private static void createDependency(final Button master, final Control slave) {
1151 master.addSelectionListener(new SelectionListener() {
1152 public void widgetSelected(SelectionEvent e) {
1153 slave.setEnabled(master.getSelection());
1156 public void widgetDefaultSelected(SelectionEvent e) {
1161 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1162 Composite completionComposite = new Composite(contentAssistComposite, SWT.NONE);
1163 GridData ccgd = new GridData();
1164 ccgd.horizontalSpan = 2;
1165 completionComposite.setLayoutData(ccgd);
1166 GridLayout ccgl = new GridLayout();
1167 ccgl.marginWidth = 0;
1168 ccgl.numColumns = 2;
1169 completionComposite.setLayout(ccgl);
1170 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1171 // public void widgetSelected(SelectionEvent e) {
1172 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1173 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1178 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1180 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1182 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1183 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1185 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1186 // SWT.RADIO | SWT.LEFT);
1187 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1189 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1190 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1193 private Control createNavigationPage(Composite parent) {
1194 Composite composite = new Composite(parent, SWT.NULL);
1195 GridLayout layout = new GridLayout();
1196 layout.numColumns = 2;
1197 composite.setLayout(layout);
1199 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1201 // fBrowserLikeLinksCheckBox= addCheckBox(composite, text,
1202 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1203 // fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1204 // public void widgetSelected(SelectionEvent e) {
1205 // boolean state= fBrowserLikeLinksCheckBox.getSelection();
1206 // fBrowserLikeLinksKeyModifierText.setEnabled(state);
1207 // handleBrowserLikeLinksKeyModifierModified();
1209 // public void widgetDefaultSelected(SelectionEvent e) {
1212 // Text field for modifier string
1214 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1216 // fBrowserLikeLinksKeyModifierText= addTextField(composite, text,
1217 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0,
1219 // fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1222 // (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER))
1224 // // Fix possible illegal modifier string
1226 // fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1227 // if (stateMask == -1)
1228 // fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1230 // fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1232 // fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1233 // private boolean isModifierCandidate;
1234 // public void keyPressed(KeyEvent e) {
1235 // isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask ==
1239 // public void keyReleased(KeyEvent e) {
1240 // if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask
1241 // && e.character == 0) {// && e.time -time < 1000) {
1242 // String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1243 // Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1244 // int i= selection.x - 1;
1245 // while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1248 // boolean needsPrefixDelimiter= i > -1 &&
1249 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1252 // while (i < modifierString.length() &&
1253 // Character.isWhitespace(modifierString.charAt(i))) {
1256 // boolean needsPostfixDelimiter= i < modifierString.length() &&
1257 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1259 // String insertString;
1261 // if (needsPrefixDelimiter && needsPostfixDelimiter)
1263 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1264 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1265 // else if (needsPrefixDelimiter)
1267 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1268 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1269 // else if (needsPostfixDelimiter)
1271 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1272 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1274 // insertString= Action.findModifierString(e.stateMask);
1276 // fBrowserLikeLinksKeyModifierText.insert(insertString);
1281 // fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener()
1283 // public void modifyText(ModifyEvent e) {
1284 // handleBrowserLikeLinksKeyModifierModified();
1290 private void handleBrowserLikeLinksKeyModifierModified() {
1291 // String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1292 // int stateMask= computeStateMask(modifiers);
1293 // if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 ||
1294 // (stateMask & SWT.SHIFT) != 0)) {
1295 // if (stateMask == -1)
1296 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1297 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid",
1298 // modifiers)); //$NON-NLS-1$
1300 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1301 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1304 // StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1306 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1307 // updateStatus(fBrowserLikeLinksKeyModifierStatus);
1311 // private IStatus getBrowserLikeLinksKeyModifierStatus() {
1312 // if (fBrowserLikeLinksKeyModifierStatus == null)
1313 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1314 // return fBrowserLikeLinksKeyModifierStatus;
1317 * Computes the state mask for the given modifier string.
1320 * the string with the modifiers, separated by '+', '-', ';', ',' or '.'
1321 * @return the state mask or -1 if the input is invalid
1323 private int computeStateMask(String modifiers) {
1324 if (modifiers == null)
1326 if (modifiers.length() == 0)
1329 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
1330 while (modifierTokenizer.hasMoreTokens()) {
1331 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
1332 if (modifier == 0 || (stateMask & modifier) == modifier)
1334 stateMask = stateMask | modifier;
1340 * @see PreferencePage#createContents(Composite)
1342 protected Control createContents(Composite parent) {
1343 initializeDefaultColors();
1344 fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore);
1345 fOverlayStore.load();
1346 fOverlayStore.start();
1347 TabFolder folder = new TabFolder(parent, SWT.NONE);
1348 folder.setLayout(new TabFolderLayout());
1349 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1350 TabItem item = new TabItem(folder, SWT.NONE);
1351 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1352 item.setControl(createAppearancePage(folder));
1353 item = new TabItem(folder, SWT.NONE);
1354 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1355 item.setControl(createSyntaxPage(folder));
1357 // item = new TabItem(folder, SWT.NONE);
1358 // item.setText(PreferencesMessages
1359 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1361 // item.setControl(createAnnotationsPage(folder));
1362 item = new TabItem(folder, SWT.NONE);
1363 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
1365 item.setControl(createTypingPage(folder));
1367 item = new TabItem(folder, SWT.NONE);
1368 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
1370 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1371 item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1372 // item= new TabItem(folder, SWT.NONE);
1373 // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1375 // item.setControl(createNavigationPage(folder));
1376 item = new TabItem(folder, SWT.NONE);
1377 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1378 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1381 Dialog.applyDialogFont(folder);
1385 private void initialize() {
1387 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1388 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1389 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1391 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1392 fSyntaxColorList.select(0);
1393 handleSyntaxColorListSelection();
1397 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1398 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1399 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1401 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1402 fAppearanceColorList.select(0);
1403 handleAppearanceColorListSelection();
1407 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1408 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1409 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1410 // public void run() {
1411 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1412 // fAnnotationList.select(0);
1413 // handleAnnotationListSelection();
1417 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1418 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1419 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1420 // public void run() {
1421 // if (fContentAssistColorList != null &&
1422 // !fContentAssistColorList.isDisposed()) {
1423 // fContentAssistColorList.select(0);
1424 // handleContentAssistColorListSelection();
1428 fFoldingConfigurationBlock.initialize();
1431 private void initializeFields() {
1432 Iterator e = fColorButtons.keySet().iterator();
1433 while (e.hasNext()) {
1434 ColorEditor c = (ColorEditor) e.next();
1435 String key = (String) fColorButtons.get(c);
1436 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1437 c.setColorValue(rgb);
1439 e = fCheckBoxes.keySet().iterator();
1440 while (e.hasNext()) {
1441 Button b = (Button) e.next();
1442 String key = (String) fCheckBoxes.get(b);
1443 b.setSelection(fOverlayStore.getBoolean(key));
1445 e = fTextFields.keySet().iterator();
1446 while (e.hasNext()) {
1447 Text t = (Text) e.next();
1448 String key = (String) fTextFields.get(t);
1449 t.setText(fOverlayStore.getString(key));
1451 RGB rgb = PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1452 fBackgroundColorEditor.setColorValue(rgb);
1453 boolean default_ = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1454 fBackgroundDefaultRadioButton.setSelection(default_);
1455 fBackgroundCustomRadioButton.setSelection(!default_);
1456 fBackgroundColorButton.setEnabled(!default_);
1457 boolean closeJavaDocs = fOverlayStore
1458 .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1459 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1460 fEscapeStringsButtonDQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1461 fEscapeStringsButtonSQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1462 // boolean fillMethodArguments=
1463 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1464 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1465 // boolean completionInserts=
1466 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1467 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1468 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1470 // fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1471 // boolean markOccurrences=
1472 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1473 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1474 updateAutoactivationControls();
1477 private void initializeDefaultColors() {
1478 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1479 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1480 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1481 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1483 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1484 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1485 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1486 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1490 private void updateAutoactivationControls() {
1491 // boolean autoactivation=
1492 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1493 // fAutoInsertDelayText.setEnabled(autoactivation);
1494 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1495 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1496 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1498 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1499 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1503 * @see PreferencePage#performOk()
1505 public boolean performOk() {
1506 // fJavaEditorHoverConfigurationBlock.performOk();
1507 fFoldingConfigurationBlock.performOk();
1508 // fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1509 // computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1510 fOverlayStore.propagate();
1511 PHPeclipsePlugin.getDefault().savePluginPreferences();
1516 * @see PreferencePage#performDefaults()
1518 protected void performDefaults() {
1519 fOverlayStore.loadDefaults();
1521 handleSyntaxColorListSelection();
1522 handleAppearanceColorListSelection();
1523 // handleAnnotationListSelection();
1524 // handleContentAssistColorListSelection();
1525 // fJavaEditorHoverConfigurationBlock.performDefaults();
1526 fFoldingConfigurationBlock.performDefaults();
1527 super.performDefaults();
1528 fPreviewViewer.invalidateTextPresentation();
1532 * @see DialogPage#dispose()
1534 public void dispose() {
1535 fFoldingConfigurationBlock.dispose();
1537 if (fJavaTextTools != null) {
1538 fJavaTextTools.dispose();
1539 fJavaTextTools = null;
1541 if (fOverlayStore != null) {
1542 fOverlayStore.stop();
1543 fOverlayStore = null;
1545 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1546 fBackgroundColor.dispose();
1550 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1551 Button checkBox = new Button(parent, SWT.CHECK);
1552 checkBox.setText(label);
1553 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1554 gd.horizontalIndent = indentation;
1555 gd.horizontalSpan = 2;
1556 checkBox.setLayoutData(gd);
1557 checkBox.addSelectionListener(fCheckBoxListener);
1558 fCheckBoxes.put(checkBox, key);
1562 private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1563 return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
1566 private static Label getLabelControl(Control[] labelledTextField) {
1567 return (Label) labelledTextField[0];
1570 private static Text getTextControl(Control[] labelledTextField) {
1571 return (Text) labelledTextField[1];
1575 * Returns an array of size 2: - first element is of type <code>Label</code>- second element is of type <code>Text</code> Use
1576 * <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
1578 private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation,
1580 Label labelControl = new Label(composite, SWT.NONE);
1581 labelControl.setText(label);
1582 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1583 gd.horizontalIndent = indentation;
1584 labelControl.setLayoutData(gd);
1585 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1586 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1587 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1588 textControl.setLayoutData(gd);
1589 textControl.setTextLimit(textLimit);
1590 fTextFields.put(textControl, key);
1592 fNumberFields.add(textControl);
1593 textControl.addModifyListener(fNumberFieldListener);
1595 textControl.addModifyListener(fTextFieldListener);
1597 return new Control[] { labelControl, textControl };
1600 private String loadPreviewContentFromFile(String filename) {
1602 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1603 StringBuffer buffer = new StringBuffer(512);
1604 BufferedReader reader = null;
1606 reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1607 while ((line = reader.readLine()) != null) {
1608 buffer.append(line);
1609 buffer.append(separator);
1611 } catch (IOException io) {
1612 PHPeclipsePlugin.log(io);
1614 if (reader != null) {
1617 } catch (IOException e) {
1621 return buffer.toString();
1624 private void numberFieldChanged(Text textControl) {
1625 String number = textControl.getText();
1626 IStatus status = validatePositiveNumber(number);
1627 if (!status.matches(IStatus.ERROR))
1628 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1629 updateStatus(status);
1632 private IStatus validatePositiveNumber(String number) {
1633 StatusInfo status = new StatusInfo();
1634 if (number.length() == 0) {
1635 status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1638 int value = Integer.parseInt(number);
1640 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1641 } catch (NumberFormatException e) {
1642 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1648 void updateStatus(IStatus status) {
1649 if (!status.matches(IStatus.ERROR)) {
1650 for (int i = 0; i < fNumberFields.size(); i++) {
1651 Text text = (Text) fNumberFields.get(i);
1652 IStatus s = validatePositiveNumber(text.getText());
1653 status = StatusUtil.getMoreSevere(s, status);
1657 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1659 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1661 setValid(!status.matches(IStatus.ERROR));
1662 StatusUtil.applyToStatusLine(this, status);