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 },
120 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
122 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
124 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
126 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
129 private final String[][] fAppearanceColorListModel = new String[][] {
130 { PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
131 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR },
133 { PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
134 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
136 { PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"),
137 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
139 { PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"),
140 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
142 { PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
144 { PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
147 // private final String[][] fAnnotationColorListModel;
149 // private final String[][] fAnnotationDecorationListModel = new String[][]{
151 // PreferencesMessages
152 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
153 // AnnotationPreference.STYLE_NONE},
156 // PreferencesMessages
157 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
158 // AnnotationPreference.STYLE_SQUIGGLIES},
161 // PreferencesMessages
162 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
163 // AnnotationPreference.STYLE_UNDERLINE},
166 // PreferencesMessages
167 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
168 // AnnotationPreference.STYLE_BOX},
171 // PreferencesMessages
172 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
173 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
175 private OverlayPreferenceStore fOverlayStore;
177 private JavaTextTools fJavaTextTools;
179 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
181 private FoldingConfigurationBlock fFoldingConfigurationBlock;
183 private Map fColorButtons = new HashMap();
185 private Map fCheckBoxes = new HashMap();
187 private SelectionListener fCheckBoxListener = new SelectionListener() {
188 public void widgetDefaultSelected(SelectionEvent e) {
191 public void widgetSelected(SelectionEvent e) {
192 Button button = (Button) e.widget;
193 fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
197 private Map fTextFields = new HashMap();
199 private ModifyListener fTextFieldListener = new ModifyListener() {
200 public void modifyText(ModifyEvent e) {
201 Text text = (Text) e.widget;
202 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
206 private ArrayList fNumberFields = new ArrayList();
208 private ModifyListener fNumberFieldListener = new ModifyListener() {
209 public void modifyText(ModifyEvent e) {
210 numberFieldChanged((Text) e.widget);
214 private List fSyntaxColorList;
216 private List fAppearanceColorList;
218 // private List fContentAssistColorList;
219 private List fAnnotationList;
221 private ColorEditor fSyntaxForegroundColorEditor;
223 private ColorEditor fAppearanceColorEditor;
225 private ColorEditor fAnnotationForegroundColorEditor;
227 private ColorEditor fContentAssistColorEditor;
229 private ColorEditor fBackgroundColorEditor;
231 private Button fBackgroundDefaultRadioButton;
233 private Button fBackgroundCustomRadioButton;
235 private Button fBackgroundColorButton;
237 private Button fBoldCheckBox;
239 // private Button fAddJavaDocTagsButton;
241 private Button fEscapeStringsButtonDQ;
243 private Button fEscapeStringsButtonSQ;
245 // private Button fGuessMethodArgumentsButton;
246 private SourceViewer fPreviewViewer;
248 private Color fBackgroundColor;
250 private Control fAutoInsertDelayText;
252 private Control fAutoInsertJavaTriggerText;
254 private Control fAutoInsertJavaDocTriggerText;
256 private Label fAutoInsertDelayLabel;
258 private Label fAutoInsertJavaTriggerLabel;
260 private Label fAutoInsertJavaDocTriggerLabel;
262 private Button fShowInTextCheckBox;
264 private Combo fDecorationStyleCombo;
266 private Button fHighlightInTextCheckBox;
268 private Button fShowInOverviewRulerCheckBox;
270 private Button fShowInVerticalRulerCheckBox;
272 // private Text fBrowserLikeLinksKeyModifierText;
273 // private Button fBrowserLikeLinksCheckBox;
274 // private StatusInfo fBrowserLikeLinksKeyModifierStatus;
275 // private Button fCompletionInsertsRadioButton;
276 // private Button fCompletionOverwritesRadioButton;
277 // private Button fStickyOccurrencesButton;
279 * Creates a new preference page.
281 public JavaEditorPreferencePage() {
282 setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
283 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
284 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
285 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
286 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
287 // fAnnotationColorListModel =
288 // createAnnotationTypeListModel(markerAnnotationPreferences);
291 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
292 ArrayList overlayKeys = new ArrayList();
293 Iterator e = preferences.getAnnotationPreferences().iterator();
294 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
295 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
296 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
297 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
298 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
299 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
300 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
301 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
302 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
303 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
304 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
305 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
306 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
307 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
308 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
309 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
310 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
311 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
312 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
313 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
314 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
316 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TAG_COLOR));
317 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TAG_BOLD));
318 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
319 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
320 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
321 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
322 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
323 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
324 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
325 PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
326 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
327 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
328 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
329 PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
331 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
333 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
335 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR));
336 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD));
337 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
338 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
339 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
340 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
342 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
344 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
345 // overlayKeys.add(new
346 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
347 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
348 // overlayKeys.add(new
349 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
350 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
351 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
352 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
353 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
354 PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
355 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
356 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
357 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
358 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
359 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
360 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
361 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
362 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
363 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
364 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
365 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
366 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
367 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
368 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
369 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
370 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
371 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
372 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
373 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
374 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
375 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
376 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
377 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
378 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
379 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
380 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
381 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
382 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
383 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
384 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
385 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
386 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
387 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
388 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
389 // overlayKeys.add(new
390 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
391 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
392 // overlayKeys.add(new
393 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
394 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
395 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
396 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
397 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
398 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
399 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
400 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
401 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
402 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
403 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
404 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
405 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
406 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
407 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
408 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
409 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
410 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
411 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
412 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
413 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
415 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT));
416 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
417 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
418 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
419 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
420 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
421 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
422 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
423 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
424 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
425 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
426 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
427 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
428 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
429 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
430 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
431 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
432 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
433 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
434 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
435 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
436 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
437 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
439 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT));
440 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
441 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
442 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
443 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
444 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
445 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
446 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE));
447 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
448 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
449 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
450 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
451 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
452 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
454 // .add(new OverlayPreferenceStore.OverlayKey(
455 // OverlayPreferenceStore.BOOLEAN,
456 // PreferenceConstants.EDITOR_CLOSE_BRACES));
457 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
458 // OverlayPreferenceStore.BOOLEAN,
459 // PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
460 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
462 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
463 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
465 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
467 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
468 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
470 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
471 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
472 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
473 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
474 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
475 // overlayKeys.add(new
476 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
477 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
478 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
479 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
480 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
481 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
482 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
483 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
484 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
485 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
486 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
487 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
488 while (e.hasNext()) {
489 AnnotationPreference info = (AnnotationPreference) e.next();
490 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
491 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
492 if (info.getHighlightPreferenceKey() != null)
493 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
494 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
495 if (info.getVerticalRulerPreferenceKey() != null)
497 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
498 if (info.getTextStylePreferenceKey() != null)
499 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
501 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
502 overlayKeys.toArray(keys);
505 * @see IWorkbenchPreferencePage#init()
508 public void init(IWorkbench workbench) {
512 * @see PreferencePage#createControl(Composite)
514 public void createControl(Composite parent) {
515 super.createControl(parent);
516 WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
519 private void handleSyntaxColorListSelection() {
520 int i = fSyntaxColorList.getSelectionIndex();
521 String key = fSyntaxColorListModel[i][1];
522 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
523 fSyntaxForegroundColorEditor.setColorValue(rgb);
524 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
527 private void handleAppearanceColorListSelection() {
528 int i = fAppearanceColorList.getSelectionIndex();
529 String key = fAppearanceColorListModel[i][1];
530 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
531 fAppearanceColorEditor.setColorValue(rgb);
534 // private void handleAnnotationListSelection() {
535 // int i = fAnnotationList.getSelectionIndex();
536 // String key = fAnnotationColorListModel[i][1];
537 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
538 // fAnnotationForegroundColorEditor.setColorValue(rgb);
539 // key = fAnnotationColorListModel[i][2];
540 // boolean showInText = fOverlayStore.getBoolean(key);
541 // fShowInTextCheckBox.setSelection(showInText);
542 // key = fAnnotationColorListModel[i][6];
543 // if (key != null) {
544 // fDecorationStyleCombo.setEnabled(showInText);
545 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
546 // String value = fOverlayStore.getString(key);
547 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
548 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
553 // fDecorationStyleCombo.setEnabled(false);
554 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
567 // key = fAnnotationColorListModel[i][3];
568 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
569 // key = fAnnotationColorListModel[i][4];
570 // if (key != null) {
571 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
572 // fHighlightInTextCheckBox.setEnabled(true);
574 // fHighlightInTextCheckBox.setEnabled(false);
575 // key = fAnnotationColorListModel[i][5];
576 // if (key != null) {
577 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
578 // fShowInVerticalRulerCheckBox.setEnabled(true);
580 // fShowInVerticalRulerCheckBox.setSelection(true);
581 // fShowInVerticalRulerCheckBox.setEnabled(false);
584 private Control createSyntaxPage(Composite parent) {
585 Composite colorComposite = new Composite(parent, SWT.NULL);
586 colorComposite.setLayout(new GridLayout());
587 Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
588 backgroundComposite.setLayout(new RowLayout());
589 backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
590 SelectionListener backgroundSelectionListener = new SelectionListener() {
591 public void widgetSelected(SelectionEvent e) {
592 boolean custom = fBackgroundCustomRadioButton.getSelection();
593 fBackgroundColorButton.setEnabled(custom);
594 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
597 public void widgetDefaultSelected(SelectionEvent e) {
600 fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
601 fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
602 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
603 fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
604 fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
605 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
606 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
607 fBackgroundColorButton = fBackgroundColorEditor.getButton();
608 Label label = new Label(colorComposite, SWT.LEFT);
609 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
610 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
611 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
612 GridLayout layout = new GridLayout();
613 layout.numColumns = 2;
614 layout.marginHeight = 0;
615 layout.marginWidth = 0;
616 editorComposite.setLayout(layout);
617 GridData gd = new GridData(GridData.FILL_BOTH);
618 editorComposite.setLayoutData(gd);
619 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
620 gd = new GridData(GridData.FILL_BOTH);
621 gd.heightHint = convertHeightInCharsToPixels(5);
622 fSyntaxColorList.setLayoutData(gd);
623 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
624 layout = new GridLayout();
625 layout.marginHeight = 0;
626 layout.marginWidth = 0;
627 layout.numColumns = 2;
628 stylesComposite.setLayout(layout);
629 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
630 label = new Label(stylesComposite, SWT.LEFT);
631 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
633 gd.horizontalAlignment = GridData.BEGINNING;
634 label.setLayoutData(gd);
635 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
636 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
637 gd = new GridData(GridData.FILL_HORIZONTAL);
638 gd.horizontalAlignment = GridData.BEGINNING;
639 foregroundColorButton.setLayoutData(gd);
640 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
641 fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
642 gd = new GridData(GridData.FILL_HORIZONTAL);
643 gd.horizontalAlignment = GridData.BEGINNING;
644 gd.horizontalSpan = 2;
645 fBoldCheckBox.setLayoutData(gd);
646 label = new Label(colorComposite, SWT.LEFT);
647 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
648 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
649 Control previewer = createPreviewer(colorComposite);
650 gd = new GridData(GridData.FILL_BOTH);
651 gd.widthHint = convertWidthInCharsToPixels(20);
652 gd.heightHint = convertHeightInCharsToPixels(5);
653 previewer.setLayoutData(gd);
654 fSyntaxColorList.addSelectionListener(new SelectionListener() {
655 public void widgetDefaultSelected(SelectionEvent e) {
659 public void widgetSelected(SelectionEvent e) {
660 handleSyntaxColorListSelection();
663 foregroundColorButton.addSelectionListener(new SelectionListener() {
664 public void widgetDefaultSelected(SelectionEvent e) {
668 public void widgetSelected(SelectionEvent e) {
669 int i = fSyntaxColorList.getSelectionIndex();
670 String key = fSyntaxColorListModel[i][1];
671 PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
674 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
675 public void widgetDefaultSelected(SelectionEvent e) {
679 public void widgetSelected(SelectionEvent e) {
680 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
684 fBoldCheckBox.addSelectionListener(new SelectionListener() {
685 public void widgetDefaultSelected(SelectionEvent e) {
689 public void widgetSelected(SelectionEvent e) {
690 int i = fSyntaxColorList.getSelectionIndex();
691 String key = fSyntaxColorListModel[i][1];
692 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
695 return colorComposite;
698 private Control createPreviewer(Composite parent) {
699 Preferences coreStore = createTemporaryCorePreferenceStore();
700 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
701 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
702 IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
703 new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
705 fPreviewViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
706 JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
707 PHPSourceViewerConfiguration configuration= new PHPSourceViewerConfiguration(tools.getColorManager(), store, null, IPHPPartitions.PHP_PARTITIONING);
708 // PHPSourceViewerConfiguration configuration =new PHPSourceViewerConfiguration(fJavaTextTools, null, IPHPPartitions.PHP_PARTITIONING);
709 fPreviewViewer.configure(configuration);
711 Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
712 fPreviewViewer.getTextWidget().setFont(font);
713 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
714 fPreviewViewer.setEditable(false);
715 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
716 IDocument document = new Document(content);
717 fJavaTextTools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
718 fPreviewViewer.setDocument(document);
719 return fPreviewViewer.getControl();
722 private Preferences createTemporaryCorePreferenceStore() {
723 Preferences result = new Preferences();
724 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
728 private Control createAppearancePage(Composite parent) {
729 Composite appearanceComposite = new Composite(parent, SWT.NONE);
730 GridLayout layout = new GridLayout();
731 layout.numColumns = 2;
732 appearanceComposite.setLayout(layout);
733 String label = PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
734 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
735 label = PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
736 addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
737 label = PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
738 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
739 label = PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
740 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
741 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
742 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
743 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
744 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
745 label = PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
746 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
747 label = PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
748 // Button master= addCheckBox(appearanceComposite, label,
749 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
750 label = PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
751 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
752 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
753 // createDependency(master, fStickyOccurrencesButton);
754 Label l = new Label(appearanceComposite, SWT.LEFT);
755 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
756 gd.horizontalSpan = 2;
757 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
759 l = new Label(appearanceComposite, SWT.LEFT);
760 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
761 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
762 gd.horizontalSpan = 2;
764 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
765 layout = new GridLayout();
766 layout.numColumns = 2;
767 layout.marginHeight = 0;
768 layout.marginWidth = 0;
769 editorComposite.setLayout(layout);
770 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
771 gd.horizontalSpan = 2;
772 editorComposite.setLayoutData(gd);
773 fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
774 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
775 gd.heightHint = convertHeightInCharsToPixels(8);
776 fAppearanceColorList.setLayoutData(gd);
777 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
778 layout = new GridLayout();
779 layout.marginHeight = 0;
780 layout.marginWidth = 0;
781 layout.numColumns = 2;
782 stylesComposite.setLayout(layout);
783 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
784 l = new Label(stylesComposite, SWT.LEFT);
785 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
787 gd.horizontalAlignment = GridData.BEGINNING;
789 fAppearanceColorEditor = new ColorEditor(stylesComposite);
790 Button foregroundColorButton = fAppearanceColorEditor.getButton();
791 gd = new GridData(GridData.FILL_HORIZONTAL);
792 gd.horizontalAlignment = GridData.BEGINNING;
793 foregroundColorButton.setLayoutData(gd);
794 fAppearanceColorList.addSelectionListener(new SelectionListener() {
795 public void widgetDefaultSelected(SelectionEvent e) {
799 public void widgetSelected(SelectionEvent e) {
800 handleAppearanceColorListSelection();
803 foregroundColorButton.addSelectionListener(new SelectionListener() {
804 public void widgetDefaultSelected(SelectionEvent e) {
808 public void widgetSelected(SelectionEvent e) {
809 int i = fAppearanceColorList.getSelectionIndex();
810 String key = fAppearanceColorListModel[i][1];
811 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
814 return appearanceComposite;
817 // private Control createAnnotationsPage(Composite parent) {
818 // Composite composite = new Composite(parent, SWT.NULL);
819 // GridLayout layout = new GridLayout();
820 // layout.numColumns = 2;
821 // composite.setLayout(layout);
822 // String text = PreferencesMessages
823 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
825 // addCheckBox(composite, text,
826 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
827 // text = PreferencesMessages
828 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
829 // addCheckBox(composite, text,
830 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
831 // addFiller(composite);
832 // Label label = new Label(composite, SWT.LEFT);
833 // label.setText(PreferencesMessages
834 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
836 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
837 // gd.horizontalSpan = 2;
838 // label.setLayoutData(gd);
839 // Composite editorComposite = new Composite(composite, SWT.NONE);
840 // layout = new GridLayout();
841 // layout.numColumns = 2;
842 // layout.marginHeight = 0;
843 // layout.marginWidth = 0;
844 // editorComposite.setLayout(layout);
845 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
846 // gd.horizontalSpan = 2;
847 // editorComposite.setLayoutData(gd);
848 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
850 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
851 // | GridData.FILL_HORIZONTAL);
852 // gd.heightHint = convertHeightInCharsToPixels(10);
853 // fAnnotationList.setLayoutData(gd);
854 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
855 // layout = new GridLayout();
856 // layout.marginHeight = 0;
857 // layout.marginWidth = 0;
858 // layout.numColumns = 2;
859 // optionsComposite.setLayout(layout);
860 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
861 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
862 // fShowInTextCheckBox.setText(PreferencesMessages
863 // .getString("JavaEditorPreferencePage.annotations.showInText"));
865 // gd = new GridData(GridData.FILL_HORIZONTAL);
866 // gd.horizontalAlignment = GridData.BEGINNING;
867 // gd.horizontalSpan = 2;
868 // fShowInTextCheckBox.setLayoutData(gd);
869 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
870 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
871 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
872 // gd = new GridData(GridData.FILL_HORIZONTAL);
873 // gd.horizontalAlignment = GridData.BEGINNING;
874 // gd.horizontalSpan = 2;
875 // gd.horizontalIndent = 20;
876 // fDecorationStyleCombo.setLayoutData(gd);
877 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
878 // fHighlightInTextCheckBox.setText(PreferencesMessages
879 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
881 // gd = new GridData(GridData.FILL_HORIZONTAL);
882 // gd.horizontalAlignment = GridData.BEGINNING;
883 // gd.horizontalSpan = 2;
884 // fHighlightInTextCheckBox.setLayoutData(gd);
885 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
886 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
887 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
889 // gd = new GridData(GridData.FILL_HORIZONTAL);
890 // gd.horizontalAlignment = GridData.BEGINNING;
891 // gd.horizontalSpan = 2;
892 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
893 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
894 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
895 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
897 // gd = new GridData(GridData.FILL_HORIZONTAL);
898 // gd.horizontalAlignment = GridData.BEGINNING;
899 // gd.horizontalSpan = 2;
900 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
901 // label = new Label(optionsComposite, SWT.LEFT);
902 // label.setText(PreferencesMessages
903 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
904 // gd = new GridData();
905 // gd.horizontalAlignment = GridData.BEGINNING;
906 // label.setLayoutData(gd);
907 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
908 // Button foregroundColorButton =
909 // fAnnotationForegroundColorEditor.getButton();
910 // gd = new GridData(GridData.FILL_HORIZONTAL);
911 // gd.horizontalAlignment = GridData.BEGINNING;
912 // foregroundColorButton.setLayoutData(gd);
913 // fAnnotationList.addSelectionListener(new SelectionListener() {
914 // public void widgetDefaultSelected(SelectionEvent e) {
917 // public void widgetSelected(SelectionEvent e) {
918 // handleAnnotationListSelection();
921 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
922 // public void widgetDefaultSelected(SelectionEvent e) {
925 // public void widgetSelected(SelectionEvent e) {
926 // int i = fAnnotationList.getSelectionIndex();
927 // String key = fAnnotationColorListModel[i][2];
928 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
929 // String decorationKey = fAnnotationColorListModel[i][6];
930 // fDecorationStyleCombo.setEnabled(decorationKey != null
931 // && fShowInTextCheckBox.getSelection());
934 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
935 // public void widgetDefaultSelected(SelectionEvent e) {
938 // public void widgetSelected(SelectionEvent e) {
939 // int i = fAnnotationList.getSelectionIndex();
940 // String key = fAnnotationColorListModel[i][4];
941 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
944 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
945 // public void widgetDefaultSelected(SelectionEvent e) {
948 // public void widgetSelected(SelectionEvent e) {
949 // int i = fAnnotationList.getSelectionIndex();
950 // String key = fAnnotationColorListModel[i][3];
952 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
955 // fShowInVerticalRulerCheckBox.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][5];
963 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
966 // foregroundColorButton.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][1];
973 // PreferenceConverter.setValue(fOverlayStore, key,
974 // fAnnotationForegroundColorEditor.getColorValue());
977 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
981 // public void widgetDefaultSelected(SelectionEvent e) {
987 // public void widgetSelected(SelectionEvent e) {
988 // int i = fAnnotationList.getSelectionIndex();
989 // String key = fAnnotationColorListModel[i][6];
990 // if (key != null) {
991 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
992 // if (fAnnotationDecorationListModel[j][0]
993 // .equals(fDecorationStyleCombo.getText())) {
994 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1001 // return composite;
1003 private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
1004 ArrayList listModelItems = new ArrayList();
1005 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1007 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1009 public int compare(Object o1, Object o2) {
1010 if (!(o2 instanceof AnnotationPreference))
1012 if (!(o1 instanceof AnnotationPreference))
1014 AnnotationPreference a1 = (AnnotationPreference) o1;
1015 AnnotationPreference a2 = (AnnotationPreference) o2;
1016 return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
1019 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1020 Iterator e = sortedPreferences.iterator();
1021 while (e.hasNext()) {
1022 AnnotationPreference info = (AnnotationPreference) e.next();
1023 listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1024 info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(),
1025 info.getTextStylePreferenceKey() });
1027 String[][] items = new String[listModelItems.size()][];
1028 listModelItems.toArray(items);
1032 private Control createTypingPage(Composite parent) {
1033 Composite composite = new Composite(parent, SWT.NONE);
1034 GridLayout layout = new GridLayout();
1035 layout.numColumns = 1;
1036 composite.setLayout(layout);
1038 // label = PreferencesMessages
1039 // .getString("JavaEditorPreferencePage.overwriteMode");
1041 // addCheckBox(composite, label,
1042 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1043 // addFiller(composite);
1045 // label = PreferencesMessages
1046 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1048 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1050 // label = PreferencesMessages
1051 // .getString("JavaEditorPreferencePage.subWordNavigation");
1053 // addCheckBox(composite, label,
1054 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1055 // addFiller(composite);
1056 Group group = new Group(composite, SWT.NONE);
1057 layout = new GridLayout();
1058 layout.numColumns = 2;
1059 group.setLayout(layout);
1060 group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1062 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1063 Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1065 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1066 fEscapeStringsButtonDQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1067 createDependency(button, fEscapeStringsButtonDQ);
1069 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1070 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1072 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsSQ");
1074 fEscapeStringsButtonSQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1075 createDependency(button, fEscapeStringsButtonSQ);
1077 label = PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
1079 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1081 label = PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
1083 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1085 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsDQ");
1087 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1088 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsSQ");
1090 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1092 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
1094 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1096 // label = PreferencesMessages
1097 // .getString("JavaEditorPreferencePage.closeBraces");
1099 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1101 // label = PreferencesMessages
1102 // .getString("JavaEditorPreferencePage.closeJavaDocs");
1104 // button = addCheckBox(group, label,
1105 // PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1107 // label = PreferencesMessages
1108 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1110 // fAddJavaDocTagsButton = addCheckBox(group, label,
1111 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1112 // createDependency(button, fAddJavaDocTagsButton);
1116 private void addFiller(Composite composite) {
1117 Label filler = new Label(composite, SWT.LEFT);
1118 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1119 gd.horizontalSpan = 2;
1120 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1121 filler.setLayoutData(gd);
1124 private static void indent(Control control) {
1125 GridData gridData = new GridData();
1126 gridData.horizontalIndent = 20;
1127 control.setLayoutData(gridData);
1130 private static void createDependency(final Button master, final Control slave) {
1132 master.addSelectionListener(new SelectionListener() {
1133 public void widgetSelected(SelectionEvent e) {
1134 slave.setEnabled(master.getSelection());
1137 public void widgetDefaultSelected(SelectionEvent e) {
1142 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1143 Composite completionComposite = new Composite(contentAssistComposite, SWT.NONE);
1144 GridData ccgd = new GridData();
1145 ccgd.horizontalSpan = 2;
1146 completionComposite.setLayoutData(ccgd);
1147 GridLayout ccgl = new GridLayout();
1148 ccgl.marginWidth = 0;
1149 ccgl.numColumns = 2;
1150 completionComposite.setLayout(ccgl);
1151 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1152 // public void widgetSelected(SelectionEvent e) {
1153 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1154 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1159 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1161 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1163 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1164 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1166 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1167 // SWT.RADIO | SWT.LEFT);
1168 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1170 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1171 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1174 private Control createNavigationPage(Composite parent) {
1175 Composite composite = new Composite(parent, SWT.NULL);
1176 GridLayout layout = new GridLayout();
1177 layout.numColumns = 2;
1178 composite.setLayout(layout);
1180 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1182 // fBrowserLikeLinksCheckBox= addCheckBox(composite, text,
1183 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1184 // fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1185 // public void widgetSelected(SelectionEvent e) {
1186 // boolean state= fBrowserLikeLinksCheckBox.getSelection();
1187 // fBrowserLikeLinksKeyModifierText.setEnabled(state);
1188 // handleBrowserLikeLinksKeyModifierModified();
1190 // public void widgetDefaultSelected(SelectionEvent e) {
1193 // Text field for modifier string
1195 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1197 // fBrowserLikeLinksKeyModifierText= addTextField(composite, text,
1198 // PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0,
1200 // fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1203 // (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER))
1205 // // Fix possible illegal modifier string
1207 // fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1208 // if (stateMask == -1)
1209 // fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1211 // fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1213 // fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1214 // private boolean isModifierCandidate;
1215 // public void keyPressed(KeyEvent e) {
1216 // isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask ==
1220 // public void keyReleased(KeyEvent e) {
1221 // if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask
1222 // && e.character == 0) {// && e.time -time < 1000) {
1223 // String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1224 // Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1225 // int i= selection.x - 1;
1226 // while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1229 // boolean needsPrefixDelimiter= i > -1 &&
1230 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1233 // while (i < modifierString.length() &&
1234 // Character.isWhitespace(modifierString.charAt(i))) {
1237 // boolean needsPostfixDelimiter= i < modifierString.length() &&
1238 // !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1240 // String insertString;
1242 // if (needsPrefixDelimiter && needsPostfixDelimiter)
1244 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1245 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1246 // else if (needsPrefixDelimiter)
1248 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1249 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1250 // else if (needsPostfixDelimiter)
1252 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1253 // new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1255 // insertString= Action.findModifierString(e.stateMask);
1257 // fBrowserLikeLinksKeyModifierText.insert(insertString);
1262 // fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener()
1264 // public void modifyText(ModifyEvent e) {
1265 // handleBrowserLikeLinksKeyModifierModified();
1271 private void handleBrowserLikeLinksKeyModifierModified() {
1272 // String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1273 // int stateMask= computeStateMask(modifiers);
1274 // if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 ||
1275 // (stateMask & SWT.SHIFT) != 0)) {
1276 // if (stateMask == -1)
1277 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1278 // PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid",
1279 // modifiers)); //$NON-NLS-1$
1281 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1282 // PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1285 // StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1287 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1288 // updateStatus(fBrowserLikeLinksKeyModifierStatus);
1292 // private IStatus getBrowserLikeLinksKeyModifierStatus() {
1293 // if (fBrowserLikeLinksKeyModifierStatus == null)
1294 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1295 // return fBrowserLikeLinksKeyModifierStatus;
1298 * Computes the state mask for the given modifier string.
1301 * the string with the modifiers, separated by '+', '-', ';', ',' or '.'
1302 * @return the state mask or -1 if the input is invalid
1304 private int computeStateMask(String modifiers) {
1305 if (modifiers == null)
1307 if (modifiers.length() == 0)
1310 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
1311 while (modifierTokenizer.hasMoreTokens()) {
1312 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
1313 if (modifier == 0 || (stateMask & modifier) == modifier)
1315 stateMask = stateMask | modifier;
1321 * @see PreferencePage#createContents(Composite)
1323 protected Control createContents(Composite parent) {
1324 initializeDefaultColors();
1325 fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore);
1326 fOverlayStore.load();
1327 fOverlayStore.start();
1328 TabFolder folder = new TabFolder(parent, SWT.NONE);
1329 folder.setLayout(new TabFolderLayout());
1330 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1331 TabItem item = new TabItem(folder, SWT.NONE);
1332 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1333 item.setControl(createAppearancePage(folder));
1334 item = new TabItem(folder, SWT.NONE);
1335 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1336 item.setControl(createSyntaxPage(folder));
1338 // item = new TabItem(folder, SWT.NONE);
1339 // item.setText(PreferencesMessages
1340 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1342 // item.setControl(createAnnotationsPage(folder));
1343 item = new TabItem(folder, SWT.NONE);
1344 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
1346 item.setControl(createTypingPage(folder));
1348 item = new TabItem(folder, SWT.NONE);
1349 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
1351 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1352 item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1353 // item= new TabItem(folder, SWT.NONE);
1354 // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1356 // item.setControl(createNavigationPage(folder));
1357 item = new TabItem(folder, SWT.NONE);
1358 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1359 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1362 Dialog.applyDialogFont(folder);
1366 private void initialize() {
1368 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1369 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1370 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1372 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1373 fSyntaxColorList.select(0);
1374 handleSyntaxColorListSelection();
1378 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1379 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1380 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1382 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1383 fAppearanceColorList.select(0);
1384 handleAppearanceColorListSelection();
1388 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1389 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1390 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1391 // public void run() {
1392 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1393 // fAnnotationList.select(0);
1394 // handleAnnotationListSelection();
1398 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1399 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1400 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1401 // public void run() {
1402 // if (fContentAssistColorList != null &&
1403 // !fContentAssistColorList.isDisposed()) {
1404 // fContentAssistColorList.select(0);
1405 // handleContentAssistColorListSelection();
1409 fFoldingConfigurationBlock.initialize();
1412 private void initializeFields() {
1413 Iterator e = fColorButtons.keySet().iterator();
1414 while (e.hasNext()) {
1415 ColorEditor c = (ColorEditor) e.next();
1416 String key = (String) fColorButtons.get(c);
1417 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1418 c.setColorValue(rgb);
1420 e = fCheckBoxes.keySet().iterator();
1421 while (e.hasNext()) {
1422 Button b = (Button) e.next();
1423 String key = (String) fCheckBoxes.get(b);
1424 b.setSelection(fOverlayStore.getBoolean(key));
1426 e = fTextFields.keySet().iterator();
1427 while (e.hasNext()) {
1428 Text t = (Text) e.next();
1429 String key = (String) fTextFields.get(t);
1430 t.setText(fOverlayStore.getString(key));
1432 RGB rgb = PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1433 fBackgroundColorEditor.setColorValue(rgb);
1434 boolean default_ = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1435 fBackgroundDefaultRadioButton.setSelection(default_);
1436 fBackgroundCustomRadioButton.setSelection(!default_);
1437 fBackgroundColorButton.setEnabled(!default_);
1438 // boolean closeJavaDocs = fOverlayStore
1439 // .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1440 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1441 fEscapeStringsButtonDQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1442 fEscapeStringsButtonSQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1443 // boolean fillMethodArguments=
1444 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1445 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1446 // boolean completionInserts=
1447 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1448 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1449 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1451 // fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1452 // boolean markOccurrences=
1453 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1454 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1455 updateAutoactivationControls();
1458 private void initializeDefaultColors() {
1459 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1460 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1461 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1462 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1464 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1465 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1466 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1467 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1471 private void updateAutoactivationControls() {
1472 // boolean autoactivation=
1473 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1474 // fAutoInsertDelayText.setEnabled(autoactivation);
1475 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1476 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1477 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1479 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1480 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1484 * @see PreferencePage#performOk()
1486 public boolean performOk() {
1487 // fJavaEditorHoverConfigurationBlock.performOk();
1488 fFoldingConfigurationBlock.performOk();
1489 // fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1490 // computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1491 fOverlayStore.propagate();
1492 PHPeclipsePlugin.getDefault().savePluginPreferences();
1497 * @see PreferencePage#performDefaults()
1499 protected void performDefaults() {
1500 fOverlayStore.loadDefaults();
1502 handleSyntaxColorListSelection();
1503 handleAppearanceColorListSelection();
1504 // handleAnnotationListSelection();
1505 // handleContentAssistColorListSelection();
1506 // fJavaEditorHoverConfigurationBlock.performDefaults();
1507 fFoldingConfigurationBlock.performDefaults();
1508 super.performDefaults();
1509 fPreviewViewer.invalidateTextPresentation();
1513 * @see DialogPage#dispose()
1515 public void dispose() {
1516 fFoldingConfigurationBlock.dispose();
1518 if (fJavaTextTools != null) {
1519 fJavaTextTools.dispose();
1520 fJavaTextTools = null;
1522 if (fOverlayStore != null) {
1523 fOverlayStore.stop();
1524 fOverlayStore = null;
1526 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1527 fBackgroundColor.dispose();
1531 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1532 Button checkBox = new Button(parent, SWT.CHECK);
1533 checkBox.setText(label);
1534 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1535 gd.horizontalIndent = indentation;
1536 gd.horizontalSpan = 2;
1537 checkBox.setLayoutData(gd);
1538 checkBox.addSelectionListener(fCheckBoxListener);
1539 fCheckBoxes.put(checkBox, key);
1543 private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1544 return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
1547 private static Label getLabelControl(Control[] labelledTextField) {
1548 return (Label) labelledTextField[0];
1551 private static Text getTextControl(Control[] labelledTextField) {
1552 return (Text) labelledTextField[1];
1556 * Returns an array of size 2: - first element is of type <code>Label</code>- second element is of type <code>Text</code> Use
1557 * <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
1559 private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation,
1561 Label labelControl = new Label(composite, SWT.NONE);
1562 labelControl.setText(label);
1563 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1564 gd.horizontalIndent = indentation;
1565 labelControl.setLayoutData(gd);
1566 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1567 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1568 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1569 textControl.setLayoutData(gd);
1570 textControl.setTextLimit(textLimit);
1571 fTextFields.put(textControl, key);
1573 fNumberFields.add(textControl);
1574 textControl.addModifyListener(fNumberFieldListener);
1576 textControl.addModifyListener(fTextFieldListener);
1578 return new Control[] { labelControl, textControl };
1581 private String loadPreviewContentFromFile(String filename) {
1583 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1584 StringBuffer buffer = new StringBuffer(512);
1585 BufferedReader reader = null;
1587 reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1588 while ((line = reader.readLine()) != null) {
1589 buffer.append(line);
1590 buffer.append(separator);
1592 } catch (IOException io) {
1593 PHPeclipsePlugin.log(io);
1595 if (reader != null) {
1598 } catch (IOException e) {
1602 return buffer.toString();
1605 private void numberFieldChanged(Text textControl) {
1606 String number = textControl.getText();
1607 IStatus status = validatePositiveNumber(number);
1608 if (!status.matches(IStatus.ERROR))
1609 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1610 updateStatus(status);
1613 private IStatus validatePositiveNumber(String number) {
1614 StatusInfo status = new StatusInfo();
1615 if (number.length() == 0) {
1616 status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1619 int value = Integer.parseInt(number);
1621 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1622 } catch (NumberFormatException e) {
1623 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1629 void updateStatus(IStatus status) {
1630 if (!status.matches(IStatus.ERROR)) {
1631 for (int i = 0; i < fNumberFields.size(); i++) {
1632 Text text = (Text) fNumberFields.get(i);
1633 IStatus s = validatePositiveNumber(text.getText());
1634 status = StatusUtil.getMoreSevere(s, status);
1638 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1640 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1642 setValid(!status.matches(IStatus.ERROR));
1643 StatusUtil.applyToStatusLine(this, status);