1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.preferences;
13 import java.io.BufferedReader;
14 import java.io.IOException;
15 import java.io.InputStreamReader;
16 import java.text.Collator;
17 import java.util.ArrayList;
18 import java.util.Comparator;
19 import java.util.HashMap;
20 import java.util.Iterator;
22 import java.util.SortedSet;
23 import java.util.StringTokenizer;
24 import java.util.TreeSet;
26 import net.sourceforge.phpdt.core.JavaCore;
27 import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
28 import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
29 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
30 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
31 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
32 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
33 import net.sourceforge.phpdt.ui.PreferenceConstants;
34 import net.sourceforge.phpdt.ui.text.JavaTextTools;
35 import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
36 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
37 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
38 import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer;
39 import net.sourceforge.phpeclipse.preferences.ColorEditor;
41 import org.eclipse.core.runtime.IStatus;
42 import org.eclipse.core.runtime.Preferences;
43 import org.eclipse.jface.action.Action;
44 import org.eclipse.jface.dialogs.Dialog;
45 import org.eclipse.jface.preference.IPreferenceStore;
46 import org.eclipse.jface.preference.PreferenceConverter;
47 import org.eclipse.jface.preference.PreferencePage;
48 import org.eclipse.jface.resource.JFaceResources;
49 import org.eclipse.jface.text.Document;
50 import org.eclipse.jface.text.IDocument;
51 import org.eclipse.jface.text.source.SourceViewer;
52 import org.eclipse.swt.SWT;
53 import org.eclipse.swt.events.KeyEvent;
54 import org.eclipse.swt.events.KeyListener;
55 import org.eclipse.swt.events.ModifyEvent;
56 import org.eclipse.swt.events.ModifyListener;
57 import org.eclipse.swt.events.SelectionEvent;
58 import org.eclipse.swt.events.SelectionListener;
59 import org.eclipse.swt.graphics.Color;
60 import org.eclipse.swt.graphics.Font;
61 import org.eclipse.swt.graphics.Point;
62 import org.eclipse.swt.graphics.RGB;
63 import org.eclipse.swt.layout.GridData;
64 import org.eclipse.swt.layout.GridLayout;
65 import org.eclipse.swt.layout.RowLayout;
66 import org.eclipse.swt.widgets.Button;
67 import org.eclipse.swt.widgets.Combo;
68 import org.eclipse.swt.widgets.Composite;
69 import org.eclipse.swt.widgets.Control;
70 import org.eclipse.swt.widgets.Group;
71 import org.eclipse.swt.widgets.Label;
72 import org.eclipse.swt.widgets.List;
73 import org.eclipse.swt.widgets.TabFolder;
74 import org.eclipse.swt.widgets.TabItem;
75 import org.eclipse.swt.widgets.Text;
76 import org.eclipse.ui.IWorkbench;
77 import org.eclipse.ui.IWorkbenchPreferencePage;
78 import org.eclipse.ui.editors.text.EditorsUI;
79 import org.eclipse.ui.help.WorkbenchHelp;
80 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
81 import org.eclipse.ui.texteditor.AnnotationPreference;
82 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
83 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
86 * The page for setting the editor options.
88 public class JavaEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
89 private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
91 private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
93 private static final String DELIMITER = PreferencesMessages.getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$
95 /** The keys of the overlay store. */
96 public final OverlayPreferenceStore.OverlayKey[] fKeys;
98 private final String[][] fSyntaxColorListModel = new String[][] {
99 { PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
100 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
102 { PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
103 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
105 { PreferencesMessages.getString("JavaEditorPreferencePage.tags"), PreferenceConstants.EDITOR_PHP_TAG_COLOR },
107 { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
108 { PreferencesMessages.getString("JavaEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
110 { PreferencesMessages.getString("JavaEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
112 { PreferencesMessages.getString("JavaEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
114 { PreferencesMessages.getString("JavaEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
116 { PreferencesMessages.getString("JavaEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR },
118 { PreferencesMessages.getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
119 { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
121 { PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"),
122 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
123 { PreferencesMessages.getString("JavaEditorPreferencePage.braces"),
124 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR },
126 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
128 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
130 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
132 { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
135 private final String[][] fAppearanceColorListModel = new String[][] {
136 { PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"),
137 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR },
139 { PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"),
140 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR },
142 { PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"),
143 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR },
145 { PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"),
146 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR },
148 { PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR },
150 { PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
153 // private final String[][] fAnnotationColorListModel;
155 // private final String[][] fAnnotationDecorationListModel = new String[][]{
157 // PreferencesMessages
158 // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
159 // AnnotationPreference.STYLE_NONE},
162 // PreferencesMessages
163 // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
164 // AnnotationPreference.STYLE_SQUIGGLIES},
167 // PreferencesMessages
168 // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
169 // AnnotationPreference.STYLE_UNDERLINE},
172 // PreferencesMessages
173 // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
174 // AnnotationPreference.STYLE_BOX},
177 // PreferencesMessages
178 // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
179 // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
181 private OverlayPreferenceStore fOverlayStore;
183 private JavaTextTools fJavaTextTools;
185 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
187 private FoldingConfigurationBlock fFoldingConfigurationBlock;
189 private Map fColorButtons = new HashMap();
191 private Map fCheckBoxes = new HashMap();
193 private SelectionListener fCheckBoxListener = new SelectionListener() {
194 public void widgetDefaultSelected(SelectionEvent e) {
197 public void widgetSelected(SelectionEvent e) {
198 Button button = (Button) e.widget;
199 fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
203 private Map fTextFields = new HashMap();
205 private ModifyListener fTextFieldListener = new ModifyListener() {
206 public void modifyText(ModifyEvent e) {
207 Text text = (Text) e.widget;
208 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
212 private ArrayList fNumberFields = new ArrayList();
214 private ModifyListener fNumberFieldListener = new ModifyListener() {
215 public void modifyText(ModifyEvent e) {
216 numberFieldChanged((Text) e.widget);
220 private List fSyntaxColorList;
222 private List fAppearanceColorList;
224 // private List fContentAssistColorList;
225 private List fAnnotationList;
227 private ColorEditor fSyntaxForegroundColorEditor;
229 private ColorEditor fAppearanceColorEditor;
231 private ColorEditor fAnnotationForegroundColorEditor;
233 private ColorEditor fContentAssistColorEditor;
235 private ColorEditor fBackgroundColorEditor;
237 private Button fBackgroundDefaultRadioButton;
239 private Button fBackgroundCustomRadioButton;
241 private Button fBackgroundColorButton;
243 private Button fBoldCheckBox;
245 // private Button fAddJavaDocTagsButton;
247 private Button fEscapeStringsButtonDQ;
249 private Button fEscapeStringsButtonSQ;
251 // private Button fGuessMethodArgumentsButton;
252 private SourceViewer fPreviewViewer;
254 private Color fBackgroundColor;
256 private Control fAutoInsertDelayText;
258 private Control fAutoInsertJavaTriggerText;
260 private Control fAutoInsertJavaDocTriggerText;
262 private Label fAutoInsertDelayLabel;
264 private Label fAutoInsertJavaTriggerLabel;
266 private Label fAutoInsertJavaDocTriggerLabel;
268 private Button fShowInTextCheckBox;
270 private Combo fDecorationStyleCombo;
272 private Button fHighlightInTextCheckBox;
274 private Button fShowInOverviewRulerCheckBox;
276 private Button fShowInVerticalRulerCheckBox;
278 private Text fBrowserLikeLinksKeyModifierText;
279 private Button fBrowserLikeLinksCheckBox;
280 private StatusInfo fBrowserLikeLinksKeyModifierStatus;
281 // private Button fCompletionInsertsRadioButton;
282 // private Button fCompletionOverwritesRadioButton;
283 // private Button fStickyOccurrencesButton;
285 * Creates a new preference page.
287 public JavaEditorPreferencePage() {
288 setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
289 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
290 MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
291 fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
292 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
293 // fAnnotationColorListModel =
294 // createAnnotationTypeListModel(markerAnnotationPreferences);
297 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
298 ArrayList overlayKeys = new ArrayList();
299 Iterator e = preferences.getAnnotationPreferences().iterator();
300 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
301 PreferenceConstants.EDITOR_FOREGROUND_COLOR));
302 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
303 PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
304 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
305 PreferenceConstants.EDITOR_BACKGROUND_COLOR));
306 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
307 PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
308 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
309 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
310 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
311 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
312 PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
313 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
314 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
315 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
316 PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
317 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
318 PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
319 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
320 PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
322 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TAG_COLOR));
323 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TAG_BOLD));
324 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
325 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
326 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
327 PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
328 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
329 PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
330 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
331 PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
332 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
333 PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
334 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
335 PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
337 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
339 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
341 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR));
342 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD));
343 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
344 PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
345 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
346 PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
348 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
350 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
351 // overlayKeys.add(new
352 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
353 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
354 // overlayKeys.add(new
355 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
356 // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
357 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
358 PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR));
359 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
360 PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD));
361 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
362 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR));
363 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
364 PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD));
365 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
366 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_COLOR));
367 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
368 PreferenceConstants.EDITOR_PHP_BRACE_OPERATOR_BOLD));
369 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
370 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
371 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
372 PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
373 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
374 PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
375 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
376 PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
377 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
378 PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
379 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
380 PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
381 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
382 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
383 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
384 PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
385 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
386 PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
387 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
388 PreferenceConstants.EDITOR_MATCHING_BRACKETS));
389 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
390 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
391 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
392 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
393 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
394 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
395 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
396 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
397 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
398 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
399 // overlayKeys.add(new
400 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
401 // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
402 // overlayKeys.add(new
403 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
404 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
405 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
406 PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
407 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
408 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
409 PreferenceConstants.EDITOR_CORRECTION_INDICATION));
410 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
411 PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
412 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
413 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
414 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
415 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
416 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
417 AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
418 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
419 PreferenceConstants.EDITOR_SPACES_FOR_TABS));
420 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
421 PreferenceConstants.CODEASSIST_AUTOACTIVATION));
422 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
423 PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
425 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT));
426 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
427 PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
428 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
429 PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
430 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
431 PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
432 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
433 PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
434 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
435 PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
436 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
437 PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
438 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
439 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
440 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
441 PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
442 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
443 PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
444 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
445 PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
446 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
447 PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
449 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT));
450 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
451 PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
452 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
453 PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
454 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
455 PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
456 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE));
457 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
458 PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP));
459 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
460 PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP));
461 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
462 PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
464 // .add(new OverlayPreferenceStore.OverlayKey(
465 // OverlayPreferenceStore.BOOLEAN,
466 // PreferenceConstants.EDITOR_CLOSE_BRACES));
467 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
468 OverlayPreferenceStore.BOOLEAN,
469 PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
470 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_WORDS));
471 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
473 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ));
474 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
476 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ));
478 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
479 PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
480 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
481 PreferenceConstants.EDITOR_FORMAT_JAVADOCS));
485 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
486 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
487 PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
488 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
489 PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
490 // overlayKeys.add(new
491 // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
492 // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
493 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
494 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
495 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
496 PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
497 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
498 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
499 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
500 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
501 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
502 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
503 while (e.hasNext()) {
504 AnnotationPreference info = (AnnotationPreference) e.next();
505 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
506 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
507 if (info.getHighlightPreferenceKey() != null)
508 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
509 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
510 if (info.getVerticalRulerPreferenceKey() != null)
512 .add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
513 if (info.getTextStylePreferenceKey() != null)
514 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
516 OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
517 overlayKeys.toArray(keys);
520 * @see IWorkbenchPreferencePage#init()
523 public void init(IWorkbench workbench) {
527 * @see PreferencePage#createControl(Composite)
529 public void createControl(Composite parent) {
530 super.createControl(parent);
531 WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
534 private void handleSyntaxColorListSelection() {
535 int i = fSyntaxColorList.getSelectionIndex();
536 String key = fSyntaxColorListModel[i][1];
537 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
538 fSyntaxForegroundColorEditor.setColorValue(rgb);
539 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
542 private void handleAppearanceColorListSelection() {
543 int i = fAppearanceColorList.getSelectionIndex();
544 String key = fAppearanceColorListModel[i][1];
545 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
546 fAppearanceColorEditor.setColorValue(rgb);
549 // private void handleAnnotationListSelection() {
550 // int i = fAnnotationList.getSelectionIndex();
551 // String key = fAnnotationColorListModel[i][1];
552 // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
553 // fAnnotationForegroundColorEditor.setColorValue(rgb);
554 // key = fAnnotationColorListModel[i][2];
555 // boolean showInText = fOverlayStore.getBoolean(key);
556 // fShowInTextCheckBox.setSelection(showInText);
557 // key = fAnnotationColorListModel[i][6];
558 // if (key != null) {
559 // fDecorationStyleCombo.setEnabled(showInText);
560 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
561 // String value = fOverlayStore.getString(key);
562 // if (fAnnotationDecorationListModel[j][1].equals(value)) {
563 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
568 // fDecorationStyleCombo.setEnabled(false);
569 // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
582 // key = fAnnotationColorListModel[i][3];
583 // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
584 // key = fAnnotationColorListModel[i][4];
585 // if (key != null) {
586 // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
587 // fHighlightInTextCheckBox.setEnabled(true);
589 // fHighlightInTextCheckBox.setEnabled(false);
590 // key = fAnnotationColorListModel[i][5];
591 // if (key != null) {
592 // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
593 // fShowInVerticalRulerCheckBox.setEnabled(true);
595 // fShowInVerticalRulerCheckBox.setSelection(true);
596 // fShowInVerticalRulerCheckBox.setEnabled(false);
599 private Control createSyntaxPage(Composite parent) {
600 Composite colorComposite = new Composite(parent, SWT.NULL);
601 colorComposite.setLayout(new GridLayout());
602 Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
603 backgroundComposite.setLayout(new RowLayout());
604 backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
605 SelectionListener backgroundSelectionListener = new SelectionListener() {
606 public void widgetSelected(SelectionEvent e) {
607 boolean custom = fBackgroundCustomRadioButton.getSelection();
608 fBackgroundColorButton.setEnabled(custom);
609 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
612 public void widgetDefaultSelected(SelectionEvent e) {
615 fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
616 fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
617 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
618 fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
619 fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
620 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
621 fBackgroundColorEditor = new ColorEditor(backgroundComposite);
622 fBackgroundColorButton = fBackgroundColorEditor.getButton();
623 Label label = new Label(colorComposite, SWT.LEFT);
624 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
625 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
626 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
627 GridLayout layout = new GridLayout();
628 layout.numColumns = 2;
629 layout.marginHeight = 0;
630 layout.marginWidth = 0;
631 editorComposite.setLayout(layout);
632 GridData gd = new GridData(GridData.FILL_BOTH);
633 editorComposite.setLayoutData(gd);
634 fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
635 gd = new GridData(GridData.FILL_BOTH);
636 gd.heightHint = convertHeightInCharsToPixels(5);
637 fSyntaxColorList.setLayoutData(gd);
638 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
639 layout = new GridLayout();
640 layout.marginHeight = 0;
641 layout.marginWidth = 0;
642 layout.numColumns = 2;
643 stylesComposite.setLayout(layout);
644 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
645 label = new Label(stylesComposite, SWT.LEFT);
646 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
648 gd.horizontalAlignment = GridData.BEGINNING;
649 label.setLayoutData(gd);
650 fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
651 Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
652 gd = new GridData(GridData.FILL_HORIZONTAL);
653 gd.horizontalAlignment = GridData.BEGINNING;
654 foregroundColorButton.setLayoutData(gd);
655 fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
656 fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
657 gd = new GridData(GridData.FILL_HORIZONTAL);
658 gd.horizontalAlignment = GridData.BEGINNING;
659 gd.horizontalSpan = 2;
660 fBoldCheckBox.setLayoutData(gd);
661 label = new Label(colorComposite, SWT.LEFT);
662 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
663 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
664 Control previewer = createPreviewer(colorComposite);
665 gd = new GridData(GridData.FILL_BOTH);
666 gd.widthHint = convertWidthInCharsToPixels(20);
667 gd.heightHint = convertHeightInCharsToPixels(5);
668 previewer.setLayoutData(gd);
669 fSyntaxColorList.addSelectionListener(new SelectionListener() {
670 public void widgetDefaultSelected(SelectionEvent e) {
674 public void widgetSelected(SelectionEvent e) {
675 handleSyntaxColorListSelection();
678 foregroundColorButton.addSelectionListener(new SelectionListener() {
679 public void widgetDefaultSelected(SelectionEvent e) {
683 public void widgetSelected(SelectionEvent e) {
684 int i = fSyntaxColorList.getSelectionIndex();
685 String key = fSyntaxColorListModel[i][1];
686 PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
689 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
690 public void widgetDefaultSelected(SelectionEvent e) {
694 public void widgetSelected(SelectionEvent e) {
695 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
699 fBoldCheckBox.addSelectionListener(new SelectionListener() {
700 public void widgetDefaultSelected(SelectionEvent e) {
704 public void widgetSelected(SelectionEvent e) {
705 int i = fSyntaxColorList.getSelectionIndex();
706 String key = fSyntaxColorListModel[i][1];
707 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
710 return colorComposite;
713 private Control createPreviewer(Composite parent) {
714 Preferences coreStore = createTemporaryCorePreferenceStore();
715 fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
716 IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
717 IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
718 new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
720 fPreviewViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
721 JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
722 PHPSourceViewerConfiguration configuration= new PHPSourceViewerConfiguration(tools.getColorManager(), store, null, IPHPPartitions.PHP_PARTITIONING);
723 // PHPSourceViewerConfiguration configuration =new PHPSourceViewerConfiguration(fJavaTextTools, null, IPHPPartitions.PHP_PARTITIONING);
724 fPreviewViewer.configure(configuration);
726 Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
727 fPreviewViewer.getTextWidget().setFont(font);
728 new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
729 fPreviewViewer.setEditable(false);
730 String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
731 IDocument document = new Document(content);
732 fJavaTextTools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
733 fPreviewViewer.setDocument(document);
734 return fPreviewViewer.getControl();
737 private Preferences createTemporaryCorePreferenceStore() {
738 Preferences result = new Preferences();
739 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
743 private Control createAppearancePage(Composite parent) {
744 Composite appearanceComposite = new Composite(parent, SWT.NONE);
745 GridLayout layout = new GridLayout();
746 layout.numColumns = 2;
747 appearanceComposite.setLayout(layout);
748 String label = PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
749 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
750 label = PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
751 addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
752 label = PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
753 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
754 label = PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
755 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
756 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
757 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
758 label = PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
759 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
760 label = PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
761 addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
762 label = PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
763 // Button master= addCheckBox(appearanceComposite, label,
764 // PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
765 label = PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
766 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label,
767 // PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
768 // createDependency(master, fStickyOccurrencesButton);
769 Label l = new Label(appearanceComposite, SWT.LEFT);
770 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
771 gd.horizontalSpan = 2;
772 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
774 l = new Label(appearanceComposite, SWT.LEFT);
775 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
776 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
777 gd.horizontalSpan = 2;
779 Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
780 layout = new GridLayout();
781 layout.numColumns = 2;
782 layout.marginHeight = 0;
783 layout.marginWidth = 0;
784 editorComposite.setLayout(layout);
785 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
786 gd.horizontalSpan = 2;
787 editorComposite.setLayoutData(gd);
788 fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
789 gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
790 gd.heightHint = convertHeightInCharsToPixels(8);
791 fAppearanceColorList.setLayoutData(gd);
792 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
793 layout = new GridLayout();
794 layout.marginHeight = 0;
795 layout.marginWidth = 0;
796 layout.numColumns = 2;
797 stylesComposite.setLayout(layout);
798 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
799 l = new Label(stylesComposite, SWT.LEFT);
800 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
802 gd.horizontalAlignment = GridData.BEGINNING;
804 fAppearanceColorEditor = new ColorEditor(stylesComposite);
805 Button foregroundColorButton = fAppearanceColorEditor.getButton();
806 gd = new GridData(GridData.FILL_HORIZONTAL);
807 gd.horizontalAlignment = GridData.BEGINNING;
808 foregroundColorButton.setLayoutData(gd);
809 fAppearanceColorList.addSelectionListener(new SelectionListener() {
810 public void widgetDefaultSelected(SelectionEvent e) {
814 public void widgetSelected(SelectionEvent e) {
815 handleAppearanceColorListSelection();
818 foregroundColorButton.addSelectionListener(new SelectionListener() {
819 public void widgetDefaultSelected(SelectionEvent e) {
823 public void widgetSelected(SelectionEvent e) {
824 int i = fAppearanceColorList.getSelectionIndex();
825 String key = fAppearanceColorListModel[i][1];
826 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
829 return appearanceComposite;
832 // private Control createAnnotationsPage(Composite parent) {
833 // Composite composite = new Composite(parent, SWT.NULL);
834 // GridLayout layout = new GridLayout();
835 // layout.numColumns = 2;
836 // composite.setLayout(layout);
837 // String text = PreferencesMessages
838 // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping");
840 // addCheckBox(composite, text,
841 // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
842 // text = PreferencesMessages
843 // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
844 // addCheckBox(composite, text,
845 // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
846 // addFiller(composite);
847 // Label label = new Label(composite, SWT.LEFT);
848 // label.setText(PreferencesMessages
849 // .getString("JavaEditorPreferencePage.annotationPresentationOptions"));
851 // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
852 // gd.horizontalSpan = 2;
853 // label.setLayoutData(gd);
854 // Composite editorComposite = new Composite(composite, SWT.NONE);
855 // layout = new GridLayout();
856 // layout.numColumns = 2;
857 // layout.marginHeight = 0;
858 // layout.marginWidth = 0;
859 // editorComposite.setLayout(layout);
860 // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
861 // gd.horizontalSpan = 2;
862 // editorComposite.setLayoutData(gd);
863 // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
865 // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
866 // | GridData.FILL_HORIZONTAL);
867 // gd.heightHint = convertHeightInCharsToPixels(10);
868 // fAnnotationList.setLayoutData(gd);
869 // Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
870 // layout = new GridLayout();
871 // layout.marginHeight = 0;
872 // layout.marginWidth = 0;
873 // layout.numColumns = 2;
874 // optionsComposite.setLayout(layout);
875 // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
876 // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
877 // fShowInTextCheckBox.setText(PreferencesMessages
878 // .getString("JavaEditorPreferencePage.annotations.showInText"));
880 // gd = new GridData(GridData.FILL_HORIZONTAL);
881 // gd.horizontalAlignment = GridData.BEGINNING;
882 // gd.horizontalSpan = 2;
883 // fShowInTextCheckBox.setLayoutData(gd);
884 // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
885 // for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
886 // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
887 // gd = new GridData(GridData.FILL_HORIZONTAL);
888 // gd.horizontalAlignment = GridData.BEGINNING;
889 // gd.horizontalSpan = 2;
890 // gd.horizontalIndent = 20;
891 // fDecorationStyleCombo.setLayoutData(gd);
892 // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
893 // fHighlightInTextCheckBox.setText(PreferencesMessages
894 // .getString("TextEditorPreferencePage.annotations.highlightInText"));
896 // gd = new GridData(GridData.FILL_HORIZONTAL);
897 // gd.horizontalAlignment = GridData.BEGINNING;
898 // gd.horizontalSpan = 2;
899 // fHighlightInTextCheckBox.setLayoutData(gd);
900 // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
901 // fShowInOverviewRulerCheckBox.setText(PreferencesMessages
902 // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler"));
904 // gd = new GridData(GridData.FILL_HORIZONTAL);
905 // gd.horizontalAlignment = GridData.BEGINNING;
906 // gd.horizontalSpan = 2;
907 // fShowInOverviewRulerCheckBox.setLayoutData(gd);
908 // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
909 // fShowInVerticalRulerCheckBox.setText(PreferencesMessages
910 // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler"));
912 // gd = new GridData(GridData.FILL_HORIZONTAL);
913 // gd.horizontalAlignment = GridData.BEGINNING;
914 // gd.horizontalSpan = 2;
915 // fShowInVerticalRulerCheckBox.setLayoutData(gd);
916 // label = new Label(optionsComposite, SWT.LEFT);
917 // label.setText(PreferencesMessages
918 // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
919 // gd = new GridData();
920 // gd.horizontalAlignment = GridData.BEGINNING;
921 // label.setLayoutData(gd);
922 // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
923 // Button foregroundColorButton =
924 // fAnnotationForegroundColorEditor.getButton();
925 // gd = new GridData(GridData.FILL_HORIZONTAL);
926 // gd.horizontalAlignment = GridData.BEGINNING;
927 // foregroundColorButton.setLayoutData(gd);
928 // fAnnotationList.addSelectionListener(new SelectionListener() {
929 // public void widgetDefaultSelected(SelectionEvent e) {
932 // public void widgetSelected(SelectionEvent e) {
933 // handleAnnotationListSelection();
936 // fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
937 // public void widgetDefaultSelected(SelectionEvent e) {
940 // public void widgetSelected(SelectionEvent e) {
941 // int i = fAnnotationList.getSelectionIndex();
942 // String key = fAnnotationColorListModel[i][2];
943 // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
944 // String decorationKey = fAnnotationColorListModel[i][6];
945 // fDecorationStyleCombo.setEnabled(decorationKey != null
946 // && fShowInTextCheckBox.getSelection());
949 // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
950 // public void widgetDefaultSelected(SelectionEvent e) {
953 // public void widgetSelected(SelectionEvent e) {
954 // int i = fAnnotationList.getSelectionIndex();
955 // String key = fAnnotationColorListModel[i][4];
956 // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
959 // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
960 // public void widgetDefaultSelected(SelectionEvent e) {
963 // public void widgetSelected(SelectionEvent e) {
964 // int i = fAnnotationList.getSelectionIndex();
965 // String key = fAnnotationColorListModel[i][3];
967 // .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
970 // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
971 // public void widgetDefaultSelected(SelectionEvent e) {
974 // public void widgetSelected(SelectionEvent e) {
975 // int i = fAnnotationList.getSelectionIndex();
976 // String key = fAnnotationColorListModel[i][5];
978 // .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
981 // foregroundColorButton.addSelectionListener(new SelectionListener() {
982 // public void widgetDefaultSelected(SelectionEvent e) {
985 // public void widgetSelected(SelectionEvent e) {
986 // int i = fAnnotationList.getSelectionIndex();
987 // String key = fAnnotationColorListModel[i][1];
988 // PreferenceConverter.setValue(fOverlayStore, key,
989 // fAnnotationForegroundColorEditor.getColorValue());
992 // fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
996 // public void widgetDefaultSelected(SelectionEvent e) {
1002 // public void widgetSelected(SelectionEvent e) {
1003 // int i = fAnnotationList.getSelectionIndex();
1004 // String key = fAnnotationColorListModel[i][6];
1005 // if (key != null) {
1006 // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1007 // if (fAnnotationDecorationListModel[j][0]
1008 // .equals(fDecorationStyleCombo.getText())) {
1009 // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1016 // return composite;
1018 private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
1019 ArrayList listModelItems = new ArrayList();
1020 SortedSet sortedPreferences = new TreeSet(new Comparator() {
1022 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1024 public int compare(Object o1, Object o2) {
1025 if (!(o2 instanceof AnnotationPreference))
1027 if (!(o1 instanceof AnnotationPreference))
1029 AnnotationPreference a1 = (AnnotationPreference) o1;
1030 AnnotationPreference a2 = (AnnotationPreference) o2;
1031 return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
1034 sortedPreferences.addAll(preferences.getAnnotationPreferences());
1035 Iterator e = sortedPreferences.iterator();
1036 while (e.hasNext()) {
1037 AnnotationPreference info = (AnnotationPreference) e.next();
1038 listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1039 info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(),
1040 info.getTextStylePreferenceKey() });
1042 String[][] items = new String[listModelItems.size()][];
1043 listModelItems.toArray(items);
1047 private Control createTypingPage(Composite parent) {
1048 Composite composite = new Composite(parent, SWT.NONE);
1049 GridLayout layout = new GridLayout();
1050 layout.numColumns = 1;
1051 composite.setLayout(layout);
1053 // label = PreferencesMessages
1054 // .getString("JavaEditorPreferencePage.overwriteMode");
1056 // addCheckBox(composite, label,
1057 // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
1058 // addFiller(composite);
1060 // label = PreferencesMessages
1061 // .getString("JavaEditorPreferencePage.smartHomeEnd");
1063 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
1065 // label = PreferencesMessages
1066 // .getString("JavaEditorPreferencePage.subWordNavigation");
1068 // addCheckBox(composite, label,
1069 // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
1070 // addFiller(composite);
1071 Group group = new Group(composite, SWT.NONE);
1072 layout = new GridLayout();
1073 layout.numColumns = 2;
1074 group.setLayout(layout);
1075 group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
1077 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapWords");//$NON-NLS-1$
1078 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_WORDS, 1);
1080 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsDQ");//$NON-NLS-1$
1081 Button button = addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_DQ, 1);
1083 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsDQ");//$NON-NLS-1$
1084 fEscapeStringsButtonDQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_DQ, 1);
1085 createDependency(button, fEscapeStringsButtonDQ);
1087 label = PreferencesMessages.getString("JavaEditorPreferencePage.wrapStringsSQ");//$NON-NLS-1$
1088 addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS_SQ, 1);
1090 label = PreferencesMessages.getString("JavaEditorPreferencePage.escapeStringsSQ");
1092 fEscapeStringsButtonSQ = addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS_SQ, 1);
1093 createDependency(button, fEscapeStringsButtonSQ);
1095 label = PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste");
1097 addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
1099 label = PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs");
1101 addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1103 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsDQ");
1105 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP, 1);
1106 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeStringsSQ");
1108 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP, 1);
1110 label = PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets");
1112 addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1114 // label = PreferencesMessages
1115 // .getString("JavaEditorPreferencePage.closeBraces");
1117 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
1119 label = PreferencesMessages
1120 .getString("JavaEditorPreferencePage.closeJavaDocs");
1122 button = addCheckBox(group, label,
1123 PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1124 label = PreferencesMessages
1125 .getString("JavaEditorPreferencePage.formatJavaDocs");
1127 button = addCheckBox(group, label,
1128 PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
1130 // label = PreferencesMessages
1131 // .getString("JavaEditorPreferencePage.addJavaDocTags");
1133 // fAddJavaDocTagsButton = addCheckBox(group, label,
1134 // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1135 // createDependency(button, fAddJavaDocTagsButton);
1139 private void addFiller(Composite composite) {
1140 Label filler = new Label(composite, SWT.LEFT);
1141 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1142 gd.horizontalSpan = 2;
1143 gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1144 filler.setLayoutData(gd);
1147 private static void indent(Control control) {
1148 GridData gridData = new GridData();
1149 gridData.horizontalIndent = 20;
1150 control.setLayoutData(gridData);
1153 private static void createDependency(final Button master, final Control slave) {
1155 master.addSelectionListener(new SelectionListener() {
1156 public void widgetSelected(SelectionEvent e) {
1157 slave.setEnabled(master.getSelection());
1160 public void widgetDefaultSelected(SelectionEvent e) {
1165 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1166 Composite completionComposite = new Composite(contentAssistComposite, SWT.NONE);
1167 GridData ccgd = new GridData();
1168 ccgd.horizontalSpan = 2;
1169 completionComposite.setLayoutData(ccgd);
1170 GridLayout ccgl = new GridLayout();
1171 ccgl.marginWidth = 0;
1172 ccgl.numColumns = 2;
1173 completionComposite.setLayout(ccgl);
1174 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1175 // public void widgetSelected(SelectionEvent e) {
1176 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1177 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION,
1182 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO
1184 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts"));
1186 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1187 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1189 // fCompletionOverwritesRadioButton= new Button(completionComposite,
1190 // SWT.RADIO | SWT.LEFT);
1191 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites"));
1193 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1194 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1197 private Control createNavigationPage(Composite parent) {
1198 Composite composite = new Composite(parent, SWT.NULL);
1199 GridLayout layout = new GridLayout();
1200 layout.numColumns = 2;
1201 composite.setLayout(layout);
1203 PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks");
1205 fBrowserLikeLinksCheckBox= addCheckBox(composite, text,
1206 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1207 fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1208 public void widgetSelected(SelectionEvent e) {
1209 boolean state= fBrowserLikeLinksCheckBox.getSelection();
1210 fBrowserLikeLinksKeyModifierText.setEnabled(state);
1211 handleBrowserLikeLinksKeyModifierModified();
1213 public void widgetDefaultSelected(SelectionEvent e) {
1216 // Text field for modifier string
1218 PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier");
1220 fBrowserLikeLinksKeyModifierText= addTextField(composite, text,
1221 PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0,
1223 fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1226 (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER))
1228 // Fix possible illegal modifier string
1230 fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1231 if (stateMask == -1)
1232 fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1234 fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1236 fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1237 private boolean isModifierCandidate;
1238 public void keyPressed(KeyEvent e) {
1239 isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask ==
1243 public void keyReleased(KeyEvent e) {
1244 if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask
1245 && e.character == 0) {// && e.time -time < 1000) {
1246 String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1247 Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1248 int i= selection.x - 1;
1249 while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1252 boolean needsPrefixDelimiter= i > -1 &&
1253 !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1256 while (i < modifierString.length() &&
1257 Character.isWhitespace(modifierString.charAt(i))) {
1260 boolean needsPostfixDelimiter= i < modifierString.length() &&
1261 !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1263 String insertString;
1265 if (needsPrefixDelimiter && needsPostfixDelimiter)
1267 PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter",
1268 new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1269 else if (needsPrefixDelimiter)
1271 PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier",
1272 new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1273 else if (needsPostfixDelimiter)
1275 PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter",
1276 new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1278 insertString= Action.findModifierString(e.stateMask);
1280 fBrowserLikeLinksKeyModifierText.insert(insertString);
1285 fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener()
1287 public void modifyText(ModifyEvent e) {
1288 handleBrowserLikeLinksKeyModifierModified();
1294 private void handleBrowserLikeLinksKeyModifierModified() {
1295 String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1296 int stateMask= computeStateMask(modifiers);
1297 if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 ||
1298 (stateMask & SWT.SHIFT) != 0)) {
1299 if (stateMask == -1)
1300 fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1301 PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid",
1302 modifiers)); //$NON-NLS-1$
1304 fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR,
1305 PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled"));
1308 StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1310 fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1311 updateStatus(fBrowserLikeLinksKeyModifierStatus);
1315 private IStatus getBrowserLikeLinksKeyModifierStatus() {
1316 if (fBrowserLikeLinksKeyModifierStatus == null)
1317 fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1318 return fBrowserLikeLinksKeyModifierStatus;
1321 * Computes the state mask for the given modifier string.
1324 * the string with the modifiers, separated by '+', '-', ';', ',' or '.'
1325 * @return the state mask or -1 if the input is invalid
1327 private int computeStateMask(String modifiers) {
1328 if (modifiers == null)
1330 if (modifiers.length() == 0)
1333 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
1334 while (modifierTokenizer.hasMoreTokens()) {
1335 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
1336 if (modifier == 0 || (stateMask & modifier) == modifier)
1338 stateMask = stateMask | modifier;
1344 * @see PreferencePage#createContents(Composite)
1346 protected Control createContents(Composite parent) {
1347 initializeDefaultColors();
1348 fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore);
1349 fOverlayStore.load();
1350 fOverlayStore.start();
1351 TabFolder folder = new TabFolder(parent, SWT.NONE);
1352 folder.setLayout(new TabFolderLayout());
1353 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1354 TabItem item = new TabItem(folder, SWT.NONE);
1355 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1356 item.setControl(createAppearancePage(folder));
1357 item = new TabItem(folder, SWT.NONE);
1358 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1359 item.setControl(createSyntaxPage(folder));
1361 // item = new TabItem(folder, SWT.NONE);
1362 // item.setText(PreferencesMessages
1363 // .getString("JavaEditorPreferencePage.annotationsTab.title"));
1365 // item.setControl(createAnnotationsPage(folder));
1366 item = new TabItem(folder, SWT.NONE);
1367 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle"));
1369 item.setControl(createTypingPage(folder));
1371 item = new TabItem(folder, SWT.NONE);
1372 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title"));
1374 fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1375 item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1376 item = new TabItem(folder, SWT.NONE);
1377 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title"));
1379 item.setControl(createNavigationPage(folder));
1380 item = new TabItem(folder, SWT.NONE);
1381 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$
1382 item.setControl(fFoldingConfigurationBlock.createControl(folder));
1385 Dialog.applyDialogFont(folder);
1389 private void initialize() {
1391 for (int i = 0; i < fSyntaxColorListModel.length; i++)
1392 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1393 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1395 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1396 fSyntaxColorList.select(0);
1397 handleSyntaxColorListSelection();
1401 for (int i = 0; i < fAppearanceColorListModel.length; i++)
1402 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1403 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1405 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1406 fAppearanceColorList.select(0);
1407 handleAppearanceColorListSelection();
1411 // for (int i = 0; i < fAnnotationColorListModel.length; i++)
1412 // fAnnotationList.add(fAnnotationColorListModel[i][0]);
1413 // fAnnotationList.getDisplay().asyncExec(new Runnable() {
1414 // public void run() {
1415 // if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1416 // fAnnotationList.select(0);
1417 // handleAnnotationListSelection();
1421 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1422 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1423 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1424 // public void run() {
1425 // if (fContentAssistColorList != null &&
1426 // !fContentAssistColorList.isDisposed()) {
1427 // fContentAssistColorList.select(0);
1428 // handleContentAssistColorListSelection();
1432 fFoldingConfigurationBlock.initialize();
1435 private void initializeFields() {
1436 Iterator e = fColorButtons.keySet().iterator();
1437 while (e.hasNext()) {
1438 ColorEditor c = (ColorEditor) e.next();
1439 String key = (String) fColorButtons.get(c);
1440 RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1441 c.setColorValue(rgb);
1443 e = fCheckBoxes.keySet().iterator();
1444 while (e.hasNext()) {
1445 Button b = (Button) e.next();
1446 String key = (String) fCheckBoxes.get(b);
1447 b.setSelection(fOverlayStore.getBoolean(key));
1449 e = fTextFields.keySet().iterator();
1450 while (e.hasNext()) {
1451 Text t = (Text) e.next();
1452 String key = (String) fTextFields.get(t);
1453 t.setText(fOverlayStore.getString(key));
1455 RGB rgb = PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1456 fBackgroundColorEditor.setColorValue(rgb);
1457 boolean default_ = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1458 fBackgroundDefaultRadioButton.setSelection(default_);
1459 fBackgroundCustomRadioButton.setSelection(!default_);
1460 fBackgroundColorButton.setEnabled(!default_);
1461 boolean closeJavaDocs = fOverlayStore
1462 .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1463 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1464 fEscapeStringsButtonDQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_DQ));
1465 fEscapeStringsButtonSQ.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS_SQ));
1466 // boolean fillMethodArguments=
1467 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1468 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1469 // boolean completionInserts=
1470 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1471 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1472 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1474 fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1475 // boolean markOccurrences=
1476 // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1477 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1478 updateAutoactivationControls();
1481 private void initializeDefaultColors() {
1482 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1483 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1484 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1485 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1487 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1488 RGB rgb = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1489 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1490 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1494 private void updateAutoactivationControls() {
1495 // boolean autoactivation=
1496 // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1497 // fAutoInsertDelayText.setEnabled(autoactivation);
1498 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1499 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1500 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1502 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1503 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1507 * @see PreferencePage#performOk()
1509 public boolean performOk() {
1510 // fJavaEditorHoverConfigurationBlock.performOk();
1511 fFoldingConfigurationBlock.performOk();
1512 fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK,
1513 computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1514 fOverlayStore.propagate();
1515 PHPeclipsePlugin.getDefault().savePluginPreferences();
1520 * @see PreferencePage#performDefaults()
1522 protected void performDefaults() {
1523 fOverlayStore.loadDefaults();
1525 handleSyntaxColorListSelection();
1526 handleAppearanceColorListSelection();
1527 // handleAnnotationListSelection();
1528 // handleContentAssistColorListSelection();
1529 // fJavaEditorHoverConfigurationBlock.performDefaults();
1530 fFoldingConfigurationBlock.performDefaults();
1531 super.performDefaults();
1532 fPreviewViewer.invalidateTextPresentation();
1536 * @see DialogPage#dispose()
1538 public void dispose() {
1539 fFoldingConfigurationBlock.dispose();
1541 if (fJavaTextTools != null) {
1542 fJavaTextTools.dispose();
1543 fJavaTextTools = null;
1545 if (fOverlayStore != null) {
1546 fOverlayStore.stop();
1547 fOverlayStore = null;
1549 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1550 fBackgroundColor.dispose();
1554 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1555 Button checkBox = new Button(parent, SWT.CHECK);
1556 checkBox.setText(label);
1557 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1558 gd.horizontalIndent = indentation;
1559 gd.horizontalSpan = 2;
1560 checkBox.setLayoutData(gd);
1561 checkBox.addSelectionListener(fCheckBoxListener);
1562 fCheckBoxes.put(checkBox, key);
1566 private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1567 return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
1570 private static Label getLabelControl(Control[] labelledTextField) {
1571 return (Label) labelledTextField[0];
1574 private static Text getTextControl(Control[] labelledTextField) {
1575 return (Text) labelledTextField[1];
1579 * Returns an array of size 2: - first element is of type <code>Label</code>- second element is of type <code>Text</code> Use
1580 * <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
1582 private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation,
1584 Label labelControl = new Label(composite, SWT.NONE);
1585 labelControl.setText(label);
1586 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1587 gd.horizontalIndent = indentation;
1588 labelControl.setLayoutData(gd);
1589 Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1590 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1591 gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1592 textControl.setLayoutData(gd);
1593 textControl.setTextLimit(textLimit);
1594 fTextFields.put(textControl, key);
1596 fNumberFields.add(textControl);
1597 textControl.addModifyListener(fNumberFieldListener);
1599 textControl.addModifyListener(fTextFieldListener);
1601 return new Control[] { labelControl, textControl };
1604 private String loadPreviewContentFromFile(String filename) {
1606 String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1607 StringBuffer buffer = new StringBuffer(512);
1608 BufferedReader reader = null;
1610 reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1611 while ((line = reader.readLine()) != null) {
1612 buffer.append(line);
1613 buffer.append(separator);
1615 } catch (IOException io) {
1616 PHPeclipsePlugin.log(io);
1618 if (reader != null) {
1621 } catch (IOException e) {
1625 return buffer.toString();
1628 private void numberFieldChanged(Text textControl) {
1629 String number = textControl.getText();
1630 IStatus status = validatePositiveNumber(number);
1631 if (!status.matches(IStatus.ERROR))
1632 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1633 updateStatus(status);
1636 private IStatus validatePositiveNumber(String number) {
1637 StatusInfo status = new StatusInfo();
1638 if (number.length() == 0) {
1639 status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1642 int value = Integer.parseInt(number);
1644 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1645 } catch (NumberFormatException e) {
1646 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1652 void updateStatus(IStatus status) {
1653 if (!status.matches(IStatus.ERROR)) {
1654 for (int i = 0; i < fNumberFields.size(); i++) {
1655 Text text = (Text) fNumberFields.get(i);
1656 IStatus s = validatePositiveNumber(text.getText());
1657 status = StatusUtil.getMoreSevere(s, status);
1661 // StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(),
1663 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(),
1665 setValid(!status.matches(IStatus.ERROR));
1666 StatusUtil.applyToStatusLine(this, status);