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 *******************************************************************************/
12 package net.sourceforge.phpdt.internal.ui.preferences;
15 import java.io.BufferedReader;
16 import java.io.IOException;
17 import java.io.InputStreamReader;
18 import java.text.Collator;
19 import java.util.ArrayList;
20 import java.util.Comparator;
21 import java.util.HashMap;
22 import java.util.Iterator;
24 import java.util.SortedSet;
25 import java.util.StringTokenizer;
26 import java.util.TreeSet;
28 import net.sourceforge.phpdt.core.JavaCore;
29 import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
30 import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
31 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
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.phpeclipse.PHPeclipsePlugin;
36 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
37 import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer;
38 import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration;
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.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.KeyEvent;
53 import org.eclipse.swt.events.KeyListener;
54 import org.eclipse.swt.events.ModifyEvent;
55 import org.eclipse.swt.events.ModifyListener;
56 import org.eclipse.swt.events.SelectionAdapter;
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.help.WorkbenchHelp;
79 import org.eclipse.ui.texteditor.AnnotationPreference;
80 import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants;
81 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
83 * The page for setting the editor options.
85 public class JavaEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
87 private static final String BOLD= PreferenceConstants.EDITOR_BOLD_SUFFIX;
88 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;
93 private final String[][] fSyntaxColorListModel= new String[][] {
94 { PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"), PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$
95 { PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"), PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$
96 { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$
97 { PreferencesMessages.getString("JavaEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$
98 // { PreferencesMessages.getString("JavaEditorPreferencePage.methodNames"), PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR }, //$NON-NLS-1$
99 // { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR }, //$NON-NLS-1$
100 { PreferencesMessages.getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
101 // { PreferencesMessages.getString("JavaEditorPreferencePage.javaCommentTaskTags"), PreferenceConstants.EDITOR_TASK_TAG_COLOR }, //$NON-NLS-1$
102 { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$
103 { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR }, //$NON-NLS-1$
104 { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$
105 { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
108 private final String[][] fAppearanceColorListModel= new String[][] {
109 {PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"), ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$
110 {PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"), PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR}, //$NON-NLS-1$
111 {PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"), ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$
112 {PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"), ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$
113 {PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR}, //$NON-NLS-1$
114 {PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR}, //$NON-NLS-1$
117 private final String[][] fAnnotationColorListModel;
119 private final String[][] fContentAssistColorListModel= new String[][] {
120 {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForCompletionProposals"), PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND }, //$NON-NLS-1$
121 {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForCompletionProposals"), PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND }, //$NON-NLS-1$
122 {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForMethodParameters"), PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND }, //$NON-NLS-1$
123 {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForMethodParameters"), PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND }, //$NON-NLS-1$
124 {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForCompletionReplacement"), PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND }, //$NON-NLS-1$
125 {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForCompletionReplacement"), PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND } //$NON-NLS-1$
128 private final String[][] fAnnotationDecorationListModel= new String[][] {
129 {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"), AnnotationPreference.STYLE_NONE}, //$NON-NLS-1$
130 {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"), AnnotationPreference.STYLE_SQUIGGLIES}, //$NON-NLS-1$
131 {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"), AnnotationPreference.STYLE_UNDERLINE}, //$NON-NLS-1$
132 {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"), AnnotationPreference.STYLE_BOX}, //$NON-NLS-1$
133 {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"), AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
136 private OverlayPreferenceStore fOverlayStore;
137 private JavaTextTools fJavaTextTools;
138 private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
140 private Map fColorButtons= new HashMap();
142 private Map fCheckBoxes= new HashMap();
143 private SelectionListener fCheckBoxListener= new SelectionListener() {
144 public void widgetDefaultSelected(SelectionEvent e) {
146 public void widgetSelected(SelectionEvent e) {
147 Button button= (Button) e.widget;
148 fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
152 private Map fTextFields= new HashMap();
153 private ModifyListener fTextFieldListener= new ModifyListener() {
154 public void modifyText(ModifyEvent e) {
155 Text text= (Text) e.widget;
156 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
160 private ArrayList fNumberFields= new ArrayList();
161 private ModifyListener fNumberFieldListener= new ModifyListener() {
162 public void modifyText(ModifyEvent e) {
163 numberFieldChanged((Text) e.widget);
167 private List fSyntaxColorList;
168 private List fAppearanceColorList;
169 private List fContentAssistColorList;
170 private List fAnnotationList;
171 private ColorEditor fSyntaxForegroundColorEditor;
172 private ColorEditor fAppearanceColorEditor;
173 private ColorEditor fAnnotationForegroundColorEditor;
174 private ColorEditor fContentAssistColorEditor;
175 private ColorEditor fBackgroundColorEditor;
176 private Button fBackgroundDefaultRadioButton;
177 private Button fBackgroundCustomRadioButton;
178 private Button fBackgroundColorButton;
179 private Button fBoldCheckBox;
180 // private Button fAddJavaDocTagsButton;
181 // private Button fEscapeStringsButton;
182 // private Button fGuessMethodArgumentsButton;
183 private SourceViewer fPreviewViewer;
184 private Color fBackgroundColor;
185 private Control fAutoInsertDelayText;
186 private Control fAutoInsertJavaTriggerText;
187 private Control fAutoInsertJavaDocTriggerText;
188 private Label fAutoInsertDelayLabel;
189 private Label fAutoInsertJavaTriggerLabel;
190 private Label fAutoInsertJavaDocTriggerLabel;
191 private Button fShowInTextCheckBox;
192 private Combo fDecorationStyleCombo;
193 private Button fHighlightInTextCheckBox;
194 private Button fShowInOverviewRulerCheckBox;
195 private Button fShowInVerticalRulerCheckBox;
196 // private Text fBrowserLikeLinksKeyModifierText;
197 // private Button fBrowserLikeLinksCheckBox;
198 // private StatusInfo fBrowserLikeLinksKeyModifierStatus;
199 // private Button fCompletionInsertsRadioButton;
200 // private Button fCompletionOverwritesRadioButton;
201 // private Button fStickyOccurrencesButton;
204 * Creates a new preference page.
206 public JavaEditorPreferencePage() {
207 setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$
208 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
210 MarkerAnnotationPreferences markerAnnotationPreferences= new MarkerAnnotationPreferences();
211 fKeys= createOverlayStoreKeys(markerAnnotationPreferences);
212 fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys);
213 fAnnotationColorListModel= createAnnotationTypeListModel(markerAnnotationPreferences);
216 private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
218 ArrayList overlayKeys= new ArrayList();
219 Iterator e= preferences.getAnnotationPreferences().iterator();
221 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOREGROUND_COLOR));
222 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
224 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BACKGROUND_COLOR));
225 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
227 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
229 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
230 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
232 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
233 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
235 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
236 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
238 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR));
239 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD));
241 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
242 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
244 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
245 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
247 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
248 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
250 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR));
251 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_OPERATOR_BOLD));
253 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
254 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
256 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
257 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
259 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
260 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
262 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
263 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
265 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
266 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS));
268 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
269 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
271 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
272 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
273 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
275 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES));
276 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
278 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
280 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
282 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CORRECTION_INDICATION));
284 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
286 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
288 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
289 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
291 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SPACES_FOR_TABS));
293 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOACTIVATION));
294 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
295 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT));
296 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
297 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
298 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
299 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
300 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
301 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
302 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
303 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
304 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
305 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
306 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
307 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT));
308 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
309 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
310 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
312 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE));
313 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS));
314 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS));
315 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES));
316 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
317 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS));
318 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS));
319 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
321 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
322 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
324 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
326 // overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
327 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
328 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
330 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
331 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
332 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
334 while (e.hasNext()) {
335 AnnotationPreference info= (AnnotationPreference) e.next();
336 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
337 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
338 if (info.getHighlightPreferenceKey() != null)
339 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
340 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
341 if (info.getVerticalRulerPreferenceKey() != null)
342 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
343 if (info.getTextStylePreferenceKey() != null)
344 overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
346 OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
347 overlayKeys.toArray(keys);
350 * @see IWorkbenchPreferencePage#init()
352 public void init(IWorkbench workbench) {
356 * @see PreferencePage#createControl(Composite)
358 public void createControl(Composite parent) {
359 super.createControl(parent);
360 WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
363 private void handleSyntaxColorListSelection() {
364 int i= fSyntaxColorList.getSelectionIndex();
365 String key= fSyntaxColorListModel[i][1];
366 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
367 fSyntaxForegroundColorEditor.setColorValue(rgb);
368 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
371 private void handleAppearanceColorListSelection() {
372 int i= fAppearanceColorList.getSelectionIndex();
373 String key= fAppearanceColorListModel[i][1];
374 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
375 fAppearanceColorEditor.setColorValue(rgb);
378 private void handleContentAssistColorListSelection() {
379 int i= fContentAssistColorList.getSelectionIndex();
380 String key= fContentAssistColorListModel[i][1];
381 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
382 fContentAssistColorEditor.setColorValue(rgb);
385 private void handleAnnotationListSelection() {
386 int i= fAnnotationList.getSelectionIndex();
388 String key= fAnnotationColorListModel[i][1];
389 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
390 fAnnotationForegroundColorEditor.setColorValue(rgb);
392 key= fAnnotationColorListModel[i][2];
393 boolean showInText = fOverlayStore.getBoolean(key);
394 fShowInTextCheckBox.setSelection(showInText);
396 key= fAnnotationColorListModel[i][6];
398 fDecorationStyleCombo.setEnabled(showInText);
399 for (int j= 0; j < fAnnotationDecorationListModel.length; j++) {
400 String value= fOverlayStore.getString(key);
401 if (fAnnotationDecorationListModel[j][1].equals(value)) {
402 fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
407 fDecorationStyleCombo.setEnabled(false);
408 fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set selection to squigglies if the key is not there (legacy support)
411 key= fAnnotationColorListModel[i][3];
412 fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
414 key= fAnnotationColorListModel[i][4];
416 fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
417 fHighlightInTextCheckBox.setEnabled(true);
419 fHighlightInTextCheckBox.setEnabled(false);
421 key= fAnnotationColorListModel[i][5];
423 fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
424 fShowInVerticalRulerCheckBox.setEnabled(true);
426 fShowInVerticalRulerCheckBox.setSelection(true);
427 fShowInVerticalRulerCheckBox.setEnabled(false);
431 private Control createSyntaxPage(Composite parent) {
433 Composite colorComposite= new Composite(parent, SWT.NULL);
434 colorComposite.setLayout(new GridLayout());
436 Group backgroundComposite= new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
437 backgroundComposite.setLayout(new RowLayout());
438 backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
440 SelectionListener backgroundSelectionListener= new SelectionListener() {
441 public void widgetSelected(SelectionEvent e) {
442 boolean custom= fBackgroundCustomRadioButton.getSelection();
443 fBackgroundColorButton.setEnabled(custom);
444 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
446 public void widgetDefaultSelected(SelectionEvent e) {}
449 fBackgroundDefaultRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
450 fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$
451 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
453 fBackgroundCustomRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
454 fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$
455 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
457 fBackgroundColorEditor= new ColorEditor(backgroundComposite);
458 fBackgroundColorButton= fBackgroundColorEditor.getButton();
460 Label label= new Label(colorComposite, SWT.LEFT);
461 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$
462 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
464 Composite editorComposite= new Composite(colorComposite, SWT.NONE);
465 GridLayout layout= new GridLayout();
466 layout.numColumns= 2;
467 layout.marginHeight= 0;
468 layout.marginWidth= 0;
469 editorComposite.setLayout(layout);
470 GridData gd= new GridData(GridData.FILL_BOTH);
471 editorComposite.setLayoutData(gd);
473 fSyntaxColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
474 gd= new GridData(GridData.FILL_BOTH);
475 gd.heightHint= convertHeightInCharsToPixels(5);
476 fSyntaxColorList.setLayoutData(gd);
478 Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
479 layout= new GridLayout();
480 layout.marginHeight= 0;
481 layout.marginWidth= 0;
482 layout.numColumns= 2;
483 stylesComposite.setLayout(layout);
484 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
486 label= new Label(stylesComposite, SWT.LEFT);
487 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
489 gd.horizontalAlignment= GridData.BEGINNING;
490 label.setLayoutData(gd);
492 fSyntaxForegroundColorEditor= new ColorEditor(stylesComposite);
493 Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton();
494 gd= new GridData(GridData.FILL_HORIZONTAL);
495 gd.horizontalAlignment= GridData.BEGINNING;
496 foregroundColorButton.setLayoutData(gd);
498 fBoldCheckBox= new Button(stylesComposite, SWT.CHECK);
499 fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$
500 gd= new GridData(GridData.FILL_HORIZONTAL);
501 gd.horizontalAlignment= GridData.BEGINNING;
502 gd.horizontalSpan= 2;
503 fBoldCheckBox.setLayoutData(gd);
505 label= new Label(colorComposite, SWT.LEFT);
506 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$
507 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
509 Control previewer= createPreviewer(colorComposite);
510 gd= new GridData(GridData.FILL_BOTH);
511 gd.widthHint= convertWidthInCharsToPixels(20);
512 gd.heightHint= convertHeightInCharsToPixels(5);
513 previewer.setLayoutData(gd);
516 fSyntaxColorList.addSelectionListener(new SelectionListener() {
517 public void widgetDefaultSelected(SelectionEvent e) {
520 public void widgetSelected(SelectionEvent e) {
521 handleSyntaxColorListSelection();
525 foregroundColorButton.addSelectionListener(new SelectionListener() {
526 public void widgetDefaultSelected(SelectionEvent e) {
529 public void widgetSelected(SelectionEvent e) {
530 int i= fSyntaxColorList.getSelectionIndex();
531 String key= fSyntaxColorListModel[i][1];
533 PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
537 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
538 public void widgetDefaultSelected(SelectionEvent e) {
541 public void widgetSelected(SelectionEvent e) {
542 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor.getColorValue());
546 fBoldCheckBox.addSelectionListener(new SelectionListener() {
547 public void widgetDefaultSelected(SelectionEvent e) {
550 public void widgetSelected(SelectionEvent e) {
551 int i= fSyntaxColorList.getSelectionIndex();
552 String key= fSyntaxColorListModel[i][1];
553 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
557 return colorComposite;
560 private Control createPreviewer(Composite parent) {
562 Preferences coreStore= createTemporaryCorePreferenceStore();
564 fJavaTextTools= new JavaTextTools(fOverlayStore, coreStore, false);
566 fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
567 fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools, null));
568 // Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
569 // fPreviewViewer.getTextWidget().setFont(font);
570 fPreviewViewer.getTextWidget().setFont(
571 JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
573 // new JavaSourcePreviewerUpdater(fPreviewViewer, fJavaTextTools);
574 fPreviewViewer.setEditable(false);
576 String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
577 IDocument document= new Document(content);
578 fJavaTextTools.setupJavaDocumentPartitioner(document, ".php"); //IJavaPartitions.JAVA_PARTITIONING);
579 fPreviewViewer.setDocument(document);
581 return fPreviewViewer.getControl();
584 private Preferences createTemporaryCorePreferenceStore() {
585 Preferences result= new Preferences();
587 result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
592 private Control createAppearancePage(Composite parent) {
594 Composite appearanceComposite= new Composite(parent, SWT.NONE);
595 GridLayout layout= new GridLayout(); layout.numColumns= 2;
596 appearanceComposite.setLayout(layout);
598 String label= PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
599 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
601 label= PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
602 addTextField(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
604 label= PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
605 addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
607 label= PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
608 addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
610 label= PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
611 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
613 label= PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
614 addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
616 label= PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
617 addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
619 label= PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
620 // Button master= addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
622 label= PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
623 // fStickyOccurrencesButton= addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
624 // createDependency(master, fStickyOccurrencesButton);
626 Label l= new Label(appearanceComposite, SWT.LEFT );
627 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
628 gd.horizontalSpan= 2;
629 gd.heightHint= convertHeightInCharsToPixels(1) / 2;
632 l= new Label(appearanceComposite, SWT.LEFT);
633 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
634 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
635 gd.horizontalSpan= 2;
638 Composite editorComposite= new Composite(appearanceComposite, SWT.NONE);
639 layout= new GridLayout();
640 layout.numColumns= 2;
641 layout.marginHeight= 0;
642 layout.marginWidth= 0;
643 editorComposite.setLayout(layout);
644 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
645 gd.horizontalSpan= 2;
646 editorComposite.setLayoutData(gd);
648 fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
649 gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
650 gd.heightHint= convertHeightInCharsToPixels(8);
651 fAppearanceColorList.setLayoutData(gd);
653 Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
654 layout= new GridLayout();
655 layout.marginHeight= 0;
656 layout.marginWidth= 0;
657 layout.numColumns= 2;
658 stylesComposite.setLayout(layout);
659 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
661 l= new Label(stylesComposite, SWT.LEFT);
662 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$
664 gd.horizontalAlignment= GridData.BEGINNING;
667 fAppearanceColorEditor= new ColorEditor(stylesComposite);
668 Button foregroundColorButton= fAppearanceColorEditor.getButton();
669 gd= new GridData(GridData.FILL_HORIZONTAL);
670 gd.horizontalAlignment= GridData.BEGINNING;
671 foregroundColorButton.setLayoutData(gd);
673 fAppearanceColorList.addSelectionListener(new SelectionListener() {
674 public void widgetDefaultSelected(SelectionEvent e) {
677 public void widgetSelected(SelectionEvent e) {
678 handleAppearanceColorListSelection();
681 foregroundColorButton.addSelectionListener(new SelectionListener() {
682 public void widgetDefaultSelected(SelectionEvent e) {
685 public void widgetSelected(SelectionEvent e) {
686 int i= fAppearanceColorList.getSelectionIndex();
687 String key= fAppearanceColorListModel[i][1];
689 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
692 return appearanceComposite;
696 private Control createAnnotationsPage(Composite parent) {
697 Composite composite= new Composite(parent, SWT.NULL);
698 GridLayout layout= new GridLayout(); layout.numColumns= 2;
699 composite.setLayout(layout);
701 String text= PreferencesMessages.getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping"); //$NON-NLS-1$
702 addCheckBox(composite, text, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
704 text= PreferencesMessages.getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
705 addCheckBox(composite, text, PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
707 addFiller(composite);
709 Label label= new Label(composite, SWT.LEFT);
710 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotationPresentationOptions")); //$NON-NLS-1$
711 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
712 gd.horizontalSpan= 2;
713 label.setLayoutData(gd);
715 Composite editorComposite= new Composite(composite, SWT.NONE);
716 layout= new GridLayout();
717 layout.numColumns= 2;
718 layout.marginHeight= 0;
719 layout.marginWidth= 0;
720 editorComposite.setLayout(layout);
721 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
722 gd.horizontalSpan= 2;
723 editorComposite.setLayoutData(gd);
725 fAnnotationList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
726 gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
727 gd.heightHint= convertHeightInCharsToPixels(10);
728 fAnnotationList.setLayoutData(gd);
730 Composite optionsComposite= new Composite(editorComposite, SWT.NONE);
731 layout= new GridLayout();
732 layout.marginHeight= 0;
733 layout.marginWidth= 0;
734 layout.numColumns= 2;
735 optionsComposite.setLayout(layout);
736 optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
738 fShowInTextCheckBox= new Button(optionsComposite, SWT.CHECK);
739 fShowInTextCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.showInText")); //$NON-NLS-1$
740 gd= new GridData(GridData.FILL_HORIZONTAL);
741 gd.horizontalAlignment= GridData.BEGINNING;
742 gd.horizontalSpan= 2;
743 fShowInTextCheckBox.setLayoutData(gd);
745 fDecorationStyleCombo= new Combo(optionsComposite, SWT.READ_ONLY);
746 for(int i= 0; i < fAnnotationDecorationListModel.length; i++)
747 fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
748 gd= new GridData(GridData.FILL_HORIZONTAL);
749 gd.horizontalAlignment= GridData.BEGINNING;
750 gd.horizontalSpan= 2;
751 gd.horizontalIndent= 20;
752 fDecorationStyleCombo.setLayoutData(gd);
754 fHighlightInTextCheckBox= new Button(optionsComposite, SWT.CHECK);
755 fHighlightInTextCheckBox.setText(PreferencesMessages.getString("TextEditorPreferencePage.annotations.highlightInText")); //$NON-NLS-1$
756 gd= new GridData(GridData.FILL_HORIZONTAL);
757 gd.horizontalAlignment= GridData.BEGINNING;
758 gd.horizontalSpan= 2;
759 fHighlightInTextCheckBox.setLayoutData(gd);
761 fShowInOverviewRulerCheckBox= new Button(optionsComposite, SWT.CHECK);
762 fShowInOverviewRulerCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.showInOverviewRuler")); //$NON-NLS-1$
763 gd= new GridData(GridData.FILL_HORIZONTAL);
764 gd.horizontalAlignment= GridData.BEGINNING;
765 gd.horizontalSpan= 2;
766 fShowInOverviewRulerCheckBox.setLayoutData(gd);
768 fShowInVerticalRulerCheckBox= new Button(optionsComposite, SWT.CHECK);
769 fShowInVerticalRulerCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.showInVerticalRuler")); //$NON-NLS-1$
770 gd= new GridData(GridData.FILL_HORIZONTAL);
771 gd.horizontalAlignment= GridData.BEGINNING;
772 gd.horizontalSpan= 2;
773 fShowInVerticalRulerCheckBox.setLayoutData(gd);
775 label= new Label(optionsComposite, SWT.LEFT);
776 label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
778 gd.horizontalAlignment= GridData.BEGINNING;
779 label.setLayoutData(gd);
781 fAnnotationForegroundColorEditor= new ColorEditor(optionsComposite);
782 Button foregroundColorButton= fAnnotationForegroundColorEditor.getButton();
783 gd= new GridData(GridData.FILL_HORIZONTAL);
784 gd.horizontalAlignment= GridData.BEGINNING;
785 foregroundColorButton.setLayoutData(gd);
787 fAnnotationList.addSelectionListener(new SelectionListener() {
788 public void widgetDefaultSelected(SelectionEvent e) {
792 public void widgetSelected(SelectionEvent e) {
793 handleAnnotationListSelection();
797 fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
798 public void widgetDefaultSelected(SelectionEvent e) {
802 public void widgetSelected(SelectionEvent e) {
803 int i= fAnnotationList.getSelectionIndex();
804 String key= fAnnotationColorListModel[i][2];
805 fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
806 String decorationKey= fAnnotationColorListModel[i][6];
807 fDecorationStyleCombo.setEnabled(decorationKey != null && fShowInTextCheckBox.getSelection());
811 fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
812 public void widgetDefaultSelected(SelectionEvent e) {
816 public void widgetSelected(SelectionEvent e) {
817 int i= fAnnotationList.getSelectionIndex();
818 String key= fAnnotationColorListModel[i][4];
819 fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
823 fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
824 public void widgetDefaultSelected(SelectionEvent e) {
828 public void widgetSelected(SelectionEvent e) {
829 int i= fAnnotationList.getSelectionIndex();
830 String key= fAnnotationColorListModel[i][3];
831 fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection());
835 fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
836 public void widgetDefaultSelected(SelectionEvent e) {
840 public void widgetSelected(SelectionEvent e) {
841 int i= fAnnotationList.getSelectionIndex();
842 String key= fAnnotationColorListModel[i][5];
843 fOverlayStore.setValue(key, fShowInVerticalRulerCheckBox.getSelection());
847 foregroundColorButton.addSelectionListener(new SelectionListener() {
848 public void widgetDefaultSelected(SelectionEvent e) {
852 public void widgetSelected(SelectionEvent e) {
853 int i= fAnnotationList.getSelectionIndex();
854 String key= fAnnotationColorListModel[i][1];
855 PreferenceConverter.setValue(fOverlayStore, key, fAnnotationForegroundColorEditor.getColorValue());
859 fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
863 public void widgetDefaultSelected(SelectionEvent e) {
870 public void widgetSelected(SelectionEvent e) {
871 int i= fAnnotationList.getSelectionIndex();
872 String key= fAnnotationColorListModel[i][6];
874 for (int j= 0; j < fAnnotationDecorationListModel.length; j++) {
875 if (fAnnotationDecorationListModel[j][0].equals(fDecorationStyleCombo.getText())) {
876 fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
887 private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
888 ArrayList listModelItems= new ArrayList();
889 SortedSet sortedPreferences= new TreeSet(new Comparator() {
891 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
893 public int compare(Object o1, Object o2) {
894 if (!(o2 instanceof AnnotationPreference))
896 if (!(o1 instanceof AnnotationPreference))
899 AnnotationPreference a1= (AnnotationPreference)o1;
900 AnnotationPreference a2= (AnnotationPreference)o2;
902 return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
906 sortedPreferences.addAll(preferences.getAnnotationPreferences());
907 Iterator e= sortedPreferences.iterator();
908 while (e.hasNext()) {
909 AnnotationPreference info= (AnnotationPreference) e.next();
910 listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(), info.getTextStylePreferenceKey()});
912 String[][] items= new String[listModelItems.size()][];
913 listModelItems.toArray(items);
917 private Control createTypingPage(Composite parent) {
918 Composite composite= new Composite(parent, SWT.NONE);
919 GridLayout layout= new GridLayout();
920 layout.numColumns= 1;
921 composite.setLayout(layout);
923 // String label= PreferencesMessages.getString("JavaEditorPreferencePage.overwriteMode"); //$NON-NLS-1$
924 // addCheckBox(composite, label, PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1);
926 // addFiller(composite);
928 // label= PreferencesMessages.getString("JavaEditorPreferencePage.smartHomeEnd"); //$NON-NLS-1$
929 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
931 // label= PreferencesMessages.getString("JavaEditorPreferencePage.subWordNavigation"); //$NON-NLS-1$
932 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1);
934 addFiller(composite);
936 Group group= new Group(composite, SWT.NONE);
937 layout= new GridLayout();
938 layout.numColumns= 2;
939 group.setLayout(layout);
941 group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$
943 // label= PreferencesMessages.getString("JavaEditorPreferencePage.wrapStrings"); //$NON-NLS-1$
944 // Button button= addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
946 // label= PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings"); //$NON-NLS-1$
947 // fEscapeStringsButton= addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1);
948 // createDependency(button, fEscapeStringsButton);
950 // label= PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste"); //$NON-NLS-1$
951 // addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
953 // label= PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs"); //$NON-NLS-1$
954 // addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
956 // label= PreferencesMessages.getString("JavaEditorPreferencePage.closeStrings"); //$NON-NLS-1$
957 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 1);
959 // label= PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets"); //$NON-NLS-1$
960 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 1);
962 // label= PreferencesMessages.getString("JavaEditorPreferencePage.closeBraces"); //$NON-NLS-1$
963 // addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
965 // label= PreferencesMessages.getString("JavaEditorPreferencePage.closeJavaDocs"); //$NON-NLS-1$
966 // button= addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
968 // label= PreferencesMessages.getString("JavaEditorPreferencePage.addJavaDocTags"); //$NON-NLS-1$
969 // fAddJavaDocTagsButton= addCheckBox(group, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
970 // createDependency(button, fAddJavaDocTagsButton);
974 private void addFiller(Composite composite) {
975 Label filler= new Label(composite, SWT.LEFT );
976 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
977 gd.horizontalSpan= 2;
978 gd.heightHint= convertHeightInCharsToPixels(1) / 2;
979 filler.setLayoutData(gd);
982 private static void indent(Control control) {
983 GridData gridData= new GridData();
984 gridData.horizontalIndent= 20;
985 control.setLayoutData(gridData);
988 private static void createDependency(final Button master, final Control slave) {
990 master.addSelectionListener(new SelectionListener() {
991 public void widgetSelected(SelectionEvent e) {
992 slave.setEnabled(master.getSelection());
995 public void widgetDefaultSelected(SelectionEvent e) {}
999 private Control createContentAssistPage(Composite parent) {
1001 Composite contentAssistComposite= new Composite(parent, SWT.NULL);
1002 GridLayout layout= new GridLayout();
1003 layout.numColumns= 2;
1004 contentAssistComposite.setLayout(layout);
1006 addCompletionRadioButtons(contentAssistComposite);
1009 label= PreferencesMessages.getString("JavaEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$
1010 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOINSERT, 0);
1012 label= PreferencesMessages.getString("JavaEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$
1013 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0);
1015 label= PreferencesMessages.getString("JavaEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$
1016 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0);
1018 label= PreferencesMessages.getString("JavaEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$
1019 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ADDIMPORT, 0);
1021 label= PreferencesMessages.getString("JavaEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
1022 Button button= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0);
1024 label= PreferencesMessages.getString("JavaEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
1025 // fGuessMethodArgumentsButton= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0);
1026 // createDependency(button, fGuessMethodArgumentsButton);
1028 label= PreferencesMessages.getString("JavaEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$
1029 final Button autoactivation= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0);
1030 autoactivation.addSelectionListener(new SelectionAdapter(){
1031 public void widgetSelected(SelectionEvent e) {
1032 updateAutoactivationControls();
1036 Control[] labelledTextField;
1037 label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$
1038 labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true);
1039 fAutoInsertDelayLabel= getLabelControl(labelledTextField);
1040 fAutoInsertDelayText= getTextControl(labelledTextField);
1042 label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationTriggersForJava"); //$NON-NLS-1$
1043 labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, false);
1044 fAutoInsertJavaTriggerLabel= getLabelControl(labelledTextField);
1045 fAutoInsertJavaTriggerText= getTextControl(labelledTextField);
1047 label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationTriggersForJavaDoc"); //$NON-NLS-1$
1048 labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, false);
1049 fAutoInsertJavaDocTriggerLabel= getLabelControl(labelledTextField);
1050 fAutoInsertJavaDocTriggerText= getTextControl(labelledTextField);
1053 Label l= new Label(contentAssistComposite, SWT.LEFT);
1054 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist.colorOptions")); //$NON-NLS-1$
1055 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1056 gd.horizontalSpan= 2;
1057 l.setLayoutData(gd);
1059 Composite editorComposite= new Composite(contentAssistComposite, SWT.NONE);
1060 layout= new GridLayout();
1061 layout.numColumns= 2;
1062 layout.marginHeight= 0;
1063 layout.marginWidth= 0;
1064 editorComposite.setLayout(layout);
1065 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
1066 gd.horizontalSpan= 2;
1067 editorComposite.setLayoutData(gd);
1069 fContentAssistColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
1070 gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
1071 gd.heightHint= convertHeightInCharsToPixels(8);
1072 fContentAssistColorList.setLayoutData(gd);
1074 Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
1075 layout= new GridLayout();
1076 layout.marginHeight= 0;
1077 layout.marginWidth= 0;
1078 layout.numColumns= 2;
1079 stylesComposite.setLayout(layout);
1080 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1082 l= new Label(stylesComposite, SWT.LEFT);
1083 l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist.color")); //$NON-NLS-1$
1085 gd.horizontalAlignment= GridData.BEGINNING;
1086 l.setLayoutData(gd);
1088 fContentAssistColorEditor= new ColorEditor(stylesComposite);
1089 Button colorButton= fContentAssistColorEditor.getButton();
1090 gd= new GridData(GridData.FILL_HORIZONTAL);
1091 gd.horizontalAlignment= GridData.BEGINNING;
1092 colorButton.setLayoutData(gd);
1094 fContentAssistColorList.addSelectionListener(new SelectionListener() {
1095 public void widgetDefaultSelected(SelectionEvent e) {
1098 public void widgetSelected(SelectionEvent e) {
1099 handleContentAssistColorListSelection();
1102 colorButton.addSelectionListener(new SelectionListener() {
1103 public void widgetDefaultSelected(SelectionEvent e) {
1106 public void widgetSelected(SelectionEvent e) {
1107 int i= fContentAssistColorList.getSelectionIndex();
1108 String key= fContentAssistColorListModel[i][1];
1110 PreferenceConverter.setValue(fOverlayStore, key, fContentAssistColorEditor.getColorValue());
1114 return contentAssistComposite;
1116 private void addCompletionRadioButtons(Composite contentAssistComposite) {
1117 Composite completionComposite= new Composite(contentAssistComposite, SWT.NONE);
1118 GridData ccgd= new GridData();
1119 ccgd.horizontalSpan= 2;
1120 completionComposite.setLayoutData(ccgd);
1121 GridLayout ccgl= new GridLayout();
1122 ccgl.marginWidth= 0;
1124 completionComposite.setLayout(ccgl);
1126 // SelectionListener completionSelectionListener= new SelectionAdapter() {
1127 // public void widgetSelected(SelectionEvent e) {
1128 // boolean insert= fCompletionInsertsRadioButton.getSelection();
1129 // fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, insert);
1133 // fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT);
1134 // fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts")); //$NON-NLS-1$
1135 // fCompletionInsertsRadioButton.setLayoutData(new GridData());
1136 // fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener);
1138 // fCompletionOverwritesRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT);
1139 // fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites")); //$NON-NLS-1$
1140 // fCompletionOverwritesRadioButton.setLayoutData(new GridData());
1141 // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener);
1144 private Control createNavigationPage(Composite parent) {
1145 Composite composite= new Composite(parent, SWT.NULL);
1146 GridLayout layout= new GridLayout(); layout.numColumns= 2;
1147 composite.setLayout(layout);
1149 // String text= PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks"); //$NON-NLS-1$
1150 // fBrowserLikeLinksCheckBox= addCheckBox(composite, text, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0);
1151 // fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
1152 // public void widgetSelected(SelectionEvent e) {
1153 // boolean state= fBrowserLikeLinksCheckBox.getSelection();
1154 // fBrowserLikeLinksKeyModifierText.setEnabled(state);
1155 // handleBrowserLikeLinksKeyModifierModified();
1157 // public void widgetDefaultSelected(SelectionEvent e) {
1161 // Text field for modifier string
1162 // text= PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier"); //$NON-NLS-1$
1163 // fBrowserLikeLinksKeyModifierText= addTextField(composite, text, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0, false);
1164 // fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
1166 // if (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) == -1) {
1167 // // Fix possible illegal modifier string
1168 // int stateMask= fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
1169 // if (stateMask == -1)
1170 // fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
1172 // fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask));
1175 // fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
1176 // private boolean isModifierCandidate;
1177 // public void keyPressed(KeyEvent e) {
1178 // isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
1181 // public void keyReleased(KeyEvent e) {
1182 // if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) {
1183 // String modifierString= fBrowserLikeLinksKeyModifierText.getText();
1184 // Point selection= fBrowserLikeLinksKeyModifierText.getSelection();
1185 // int i= selection.x - 1;
1186 // while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
1189 // boolean needsPrefixDelimiter= i > -1 && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1192 // while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
1195 // boolean needsPostfixDelimiter= i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
1197 // String insertString;
1199 // if (needsPrefixDelimiter && needsPostfixDelimiter)
1200 // insertString= PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1201 // else if (needsPrefixDelimiter)
1202 // insertString= PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1203 // else if (needsPostfixDelimiter)
1204 // insertString= PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
1206 // insertString= Action.findModifierString(e.stateMask);
1208 // fBrowserLikeLinksKeyModifierText.insert(insertString);
1213 // fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener() {
1214 // public void modifyText(ModifyEvent e) {
1215 // handleBrowserLikeLinksKeyModifierModified();
1222 private void handleBrowserLikeLinksKeyModifierModified() {
1223 // String modifiers= fBrowserLikeLinksKeyModifierText.getText();
1224 // int stateMask= computeStateMask(modifiers);
1226 // if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) {
1227 // if (stateMask == -1)
1228 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid", modifiers)); //$NON-NLS-1$
1230 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled")); //$NON-NLS-1$
1232 // StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus);
1234 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1235 // updateStatus(fBrowserLikeLinksKeyModifierStatus);
1239 // private IStatus getBrowserLikeLinksKeyModifierStatus() {
1240 // if (fBrowserLikeLinksKeyModifierStatus == null)
1241 // fBrowserLikeLinksKeyModifierStatus= new StatusInfo();
1242 // return fBrowserLikeLinksKeyModifierStatus;
1246 * Computes the state mask for the given modifier string.
1248 * @param modifiers the string with the modifiers, separated by '+', '-', ';', ',' or '.'
1249 * @return the state mask or -1 if the input is invalid
1251 private int computeStateMask(String modifiers) {
1252 if (modifiers == null)
1255 if (modifiers.length() == 0)
1259 StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
1260 while (modifierTokenizer.hasMoreTokens()) {
1261 int modifier= EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
1262 if (modifier == 0 || (stateMask & modifier) == modifier)
1264 stateMask= stateMask | modifier;
1270 * @see PreferencePage#createContents(Composite)
1272 protected Control createContents(Composite parent) {
1274 initializeDefaultColors();
1276 fOverlayStore.load();
1277 fOverlayStore.start();
1279 TabFolder folder= new TabFolder(parent, SWT.NONE);
1280 folder.setLayout(new TabFolderLayout());
1281 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1283 TabItem item= new TabItem(folder, SWT.NONE);
1284 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$
1285 item.setControl(createAppearancePage(folder));
1287 item= new TabItem(folder, SWT.NONE);
1288 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$
1289 item.setControl(createSyntaxPage(folder));
1291 // item= new TabItem(folder, SWT.NONE);
1292 // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist")); //$NON-NLS-1$
1293 // item.setControl(createContentAssistPage(folder));
1295 item= new TabItem(folder, SWT.NONE);
1296 item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotationsTab.title")); //$NON-NLS-1$
1297 item.setControl(createAnnotationsPage(folder));
1299 // item= new TabItem(folder, SWT.NONE);
1300 // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle")); //$NON-NLS-1$
1301 // item.setControl(createTypingPage(folder));
1303 // item= new TabItem(folder, SWT.NONE);
1304 // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title")); //$NON-NLS-1$
1305 // fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
1306 // item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1308 // item= new TabItem(folder, SWT.NONE);
1309 // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title")); //$NON-NLS-1$
1310 // item.setControl(createNavigationPage(folder));
1314 Dialog.applyDialogFont(folder);
1318 private void initialize() {
1322 for (int i= 0; i < fSyntaxColorListModel.length; i++)
1323 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1324 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1326 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1327 fSyntaxColorList.select(0);
1328 handleSyntaxColorListSelection();
1333 for (int i= 0; i < fAppearanceColorListModel.length; i++)
1334 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1335 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1337 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1338 fAppearanceColorList.select(0);
1339 handleAppearanceColorListSelection();
1344 for (int i= 0; i < fAnnotationColorListModel.length; i++)
1345 fAnnotationList.add(fAnnotationColorListModel[i][0]);
1346 fAnnotationList.getDisplay().asyncExec(new Runnable() {
1348 if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1349 fAnnotationList.select(0);
1350 handleAnnotationListSelection();
1355 // for (int i= 0; i < fContentAssistColorListModel.length; i++)
1356 // fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1357 // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1358 // public void run() {
1359 // if (fContentAssistColorList != null && !fContentAssistColorList.isDisposed()) {
1360 // fContentAssistColorList.select(0);
1361 // handleContentAssistColorListSelection();
1367 private void initializeFields() {
1369 Iterator e= fColorButtons.keySet().iterator();
1370 while (e.hasNext()) {
1371 ColorEditor c= (ColorEditor) e.next();
1372 String key= (String) fColorButtons.get(c);
1373 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
1374 c.setColorValue(rgb);
1377 e= fCheckBoxes.keySet().iterator();
1378 while (e.hasNext()) {
1379 Button b= (Button) e.next();
1380 String key= (String) fCheckBoxes.get(b);
1381 b.setSelection(fOverlayStore.getBoolean(key));
1384 e= fTextFields.keySet().iterator();
1385 while (e.hasNext()) {
1386 Text t= (Text) e.next();
1387 String key= (String) fTextFields.get(t);
1388 t.setText(fOverlayStore.getString(key));
1391 RGB rgb= PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1392 fBackgroundColorEditor.setColorValue(rgb);
1394 boolean default_= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1395 fBackgroundDefaultRadioButton.setSelection(default_);
1396 fBackgroundCustomRadioButton.setSelection(!default_);
1397 fBackgroundColorButton.setEnabled(!default_);
1399 // boolean closeJavaDocs= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1400 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1402 // fEscapeStringsButton.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS));
1404 // boolean fillMethodArguments= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1405 // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1407 // boolean completionInserts= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
1408 // fCompletionInsertsRadioButton.setSelection(completionInserts);
1409 // fCompletionOverwritesRadioButton.setSelection(! completionInserts);
1411 // fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
1413 // boolean markOccurrences= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1414 // fStickyOccurrencesButton.setEnabled(markOccurrences);
1416 updateAutoactivationControls();
1419 private void initializeDefaultColors() {
1420 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1421 RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1422 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1423 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1425 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1426 RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1427 PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1428 PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1432 private void updateAutoactivationControls() {
1433 // boolean autoactivation= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1434 // fAutoInsertDelayText.setEnabled(autoactivation);
1435 // fAutoInsertDelayLabel.setEnabled(autoactivation);
1437 // fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1438 // fAutoInsertJavaTriggerLabel.setEnabled(autoactivation);
1440 // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1441 // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation);
1445 * @see PreferencePage#performOk()
1447 public boolean performOk() {
1448 // fJavaEditorHoverConfigurationBlock.performOk();
1449 // fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK, computeStateMask(fBrowserLikeLinksKeyModifierText.getText()));
1450 fOverlayStore.propagate();
1451 PHPeclipsePlugin.getDefault().savePluginPreferences();
1456 * @see PreferencePage#performDefaults()
1458 protected void performDefaults() {
1460 fOverlayStore.loadDefaults();
1464 handleSyntaxColorListSelection();
1465 handleAppearanceColorListSelection();
1466 handleAnnotationListSelection();
1467 // handleContentAssistColorListSelection();
1469 // fJavaEditorHoverConfigurationBlock.performDefaults();
1471 super.performDefaults();
1473 fPreviewViewer.invalidateTextPresentation();
1477 * @see DialogPage#dispose()
1479 public void dispose() {
1481 if (fJavaTextTools != null) {
1482 fJavaTextTools.dispose();
1483 fJavaTextTools= null;
1486 if (fOverlayStore != null) {
1487 fOverlayStore.stop();
1488 fOverlayStore= null;
1490 if (fBackgroundColor != null && !fBackgroundColor.isDisposed())
1491 fBackgroundColor.dispose();
1496 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1497 Button checkBox= new Button(parent, SWT.CHECK);
1498 checkBox.setText(label);
1500 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1501 gd.horizontalIndent= indentation;
1502 gd.horizontalSpan= 2;
1503 checkBox.setLayoutData(gd);
1504 checkBox.addSelectionListener(fCheckBoxListener);
1506 fCheckBoxes.put(checkBox, key);
1511 private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1512 return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
1515 private static Label getLabelControl(Control[] labelledTextField){
1516 return (Label)labelledTextField[0];
1519 private static Text getTextControl(Control[] labelledTextField){
1520 return (Text)labelledTextField[1];
1524 * Returns an array of size 2:
1525 * - first element is of type <code>Label</code>
1526 * - second element is of type <code>Text</code>
1527 * Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
1529 private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1530 Label labelControl= new Label(composite, SWT.NONE);
1531 labelControl.setText(label);
1532 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1533 gd.horizontalIndent= indentation;
1534 labelControl.setLayoutData(gd);
1536 Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE);
1537 gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1538 gd.widthHint= convertWidthInCharsToPixels(textLimit + 1);
1539 textControl.setLayoutData(gd);
1540 textControl.setTextLimit(textLimit);
1541 fTextFields.put(textControl, key);
1543 fNumberFields.add(textControl);
1544 textControl.addModifyListener(fNumberFieldListener);
1546 textControl.addModifyListener(fTextFieldListener);
1549 return new Control[]{labelControl, textControl};
1552 private String loadPreviewContentFromFile(String filename) {
1554 String separator= System.getProperty("line.separator"); //$NON-NLS-1$
1555 StringBuffer buffer= new StringBuffer(512);
1556 BufferedReader reader= null;
1558 reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1559 while ((line= reader.readLine()) != null) {
1560 buffer.append(line);
1561 buffer.append(separator);
1563 } catch (IOException io) {
1564 PHPeclipsePlugin.log(io);
1566 if (reader != null) {
1567 try { reader.close(); } catch (IOException e) {}
1570 return buffer.toString();
1573 private void numberFieldChanged(Text textControl) {
1574 String number= textControl.getText();
1575 IStatus status= validatePositiveNumber(number);
1576 if (!status.matches(IStatus.ERROR))
1577 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1578 updateStatus(status);
1581 private IStatus validatePositiveNumber(String number) {
1582 StatusInfo status= new StatusInfo();
1583 if (number.length() == 0) {
1584 status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$
1587 int value= Integer.parseInt(number);
1589 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1590 } catch (NumberFormatException e) {
1591 status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1597 void updateStatus(IStatus status) {
1598 if (!status.matches(IStatus.ERROR)) {
1599 for (int i= 0; i < fNumberFields.size(); i++) {
1600 Text text= (Text) fNumberFields.get(i);
1601 IStatus s= validatePositiveNumber(text.getText());
1602 status= StatusUtil.getMoreSevere(s, status);
1605 // status= StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(), status);
1606 // status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(), status);
1607 setValid(!status.matches(IStatus.ERROR));
1608 StatusUtil.applyToStatusLine(this, status);