1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. 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 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.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.Iterator;
23 import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
24 import net.sourceforge.phpdt.internal.ui.dialog.StatusInfo;
25 import net.sourceforge.phpdt.internal.ui.dialog.StatusUtil;
26 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
27 import net.sourceforge.phpdt.ui.PreferenceConstants;
28 import net.sourceforge.phpdt.ui.text.JavaTextTools;
29 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
30 import net.sourceforge.phpeclipse.phpeditor.PHPEditorEnvironment;
31 import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration;
32 import net.sourceforge.phpeclipse.preferences.ColorEditor;
34 import org.eclipse.core.runtime.IStatus;
35 import org.eclipse.jface.preference.IPreferenceStore;
36 import org.eclipse.jface.preference.PreferenceConverter;
37 import org.eclipse.jface.preference.PreferencePage;
38 import org.eclipse.jface.resource.JFaceResources;
39 import org.eclipse.jface.text.Document;
40 import org.eclipse.jface.text.IDocument;
41 import org.eclipse.jface.text.IDocumentPartitioner;
42 import org.eclipse.jface.text.source.ISourceViewer;
43 import org.eclipse.jface.text.source.SourceViewer;
44 import org.eclipse.jface.util.IPropertyChangeListener;
45 import org.eclipse.jface.util.PropertyChangeEvent;
46 import org.eclipse.swt.SWT;
47 import org.eclipse.swt.custom.StyledText;
48 import org.eclipse.swt.events.ModifyEvent;
49 import org.eclipse.swt.events.ModifyListener;
50 import org.eclipse.swt.events.SelectionAdapter;
51 import org.eclipse.swt.events.SelectionEvent;
52 import org.eclipse.swt.events.SelectionListener;
53 import org.eclipse.swt.graphics.Color;
54 import org.eclipse.swt.graphics.RGB;
55 import org.eclipse.swt.layout.GridData;
56 import org.eclipse.swt.layout.GridLayout;
57 import org.eclipse.swt.layout.RowLayout;
58 import org.eclipse.swt.widgets.Button;
59 import org.eclipse.swt.widgets.Composite;
60 import org.eclipse.swt.widgets.Control;
61 import org.eclipse.swt.widgets.Display;
62 import org.eclipse.swt.widgets.Group;
63 import org.eclipse.swt.widgets.Label;
64 import org.eclipse.swt.widgets.List;
65 import org.eclipse.swt.widgets.TabFolder;
66 import org.eclipse.swt.widgets.TabItem;
67 import org.eclipse.swt.widgets.Text;
68 import org.eclipse.ui.IWorkbench;
69 import org.eclipse.ui.IWorkbenchPreferencePage;
70 import org.eclipse.ui.texteditor.AbstractTextEditor;
71 import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
74 * The page for setting the editor options.
76 public class PHPEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
78 private static final String BOLD= PreferenceConstants.EDITOR_BOLD_SUFFIX;
80 public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
82 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOREGROUND_COLOR),
83 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR),
85 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BACKGROUND_COLOR),
86 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR),
88 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH),
90 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR),
91 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD),
93 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR),
94 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD),
96 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR),
97 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD),
99 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR),
100 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD),
102 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR),
103 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD),
105 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR),
106 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD),
108 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD),
109 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD),
111 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR),
112 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD),
114 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR),
115 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD),
117 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR),
118 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS),
120 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CURRENT_LINE_COLOR),
121 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CURRENT_LINE),
123 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR),
124 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN),
125 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PRINT_MARGIN),
127 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR),
129 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINKED_POSITION_COLOR),
130 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR),
132 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR),
133 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PROBLEM_INDICATION),
135 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR),
136 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WARNING_INDICATION),
138 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR),
139 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION),
141 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR),
142 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BOOKMARK_INDICATION),
144 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR),
145 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION),
147 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR),
148 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_UNKNOWN_INDICATION),
150 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER),
151 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER),
152 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER),
153 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER),
154 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER),
155 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER),
157 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CORRECTION_INDICATION),
158 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE),
160 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS),
162 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_OVERVIEW_RULER),
164 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR),
165 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_LINE_NUMBER_RULER),
167 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SPACES_FOR_TABS),
169 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOACTIVATION),
170 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY),
171 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT),
172 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND),
173 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND),
174 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND),
175 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND),
176 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND),
177 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND),
178 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA),
179 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC),
180 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS),
181 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS),
182 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_CASE_SENSITIVITY),
183 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT),
184 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_INSERT_COMPLETION),
185 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES),
186 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS),
188 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE),
189 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS),
190 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS),
191 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES),
192 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_JAVADOCS),
193 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS),
194 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS),
195 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FORMAT_JAVADOCS),
197 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END),
199 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_DEFAULT_HOVER),
200 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_NONE_HOVER),
201 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_HOVER),
202 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SHIFT_HOVER),
203 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
204 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_ALT_HOVER),
205 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_ALT_SHIFT_HOVER),
206 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
207 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_ALT_SHIFT_HOVER),
210 // private final String[][] fSyntaxColorListModel= new String[][] {
211 // { PHPUIMessages.getString("PHPEditorPreferencePage.multiLineComment"), PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$
212 // { PHPUIMessages.getString("PHPEditorPreferencePage.singleLineComment"), PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$
213 // { PHPUIMessages.getString("PHPEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$
214 // { PHPUIMessages.getString("PHPEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$
215 // { PHPUIMessages.getString("PHPEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
216 // { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$
217 // { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD }, //$NON-NLS-1$
218 // { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$
219 // { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
222 private final String[][] fAppearanceColorListModel= new String[][] {
223 {PHPUIMessages.getString("PHPEditorPreferencePage.lineNumberForegroundColor"), PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$
224 {PHPUIMessages.getString("PHPEditorPreferencePage.matchingBracketsHighlightColor2"), PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR}, //$NON-NLS-1$
225 {PHPUIMessages.getString("PHPEditorPreferencePage.currentLineHighlighColor"), PreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$
226 {PHPUIMessages.getString("PHPEditorPreferencePage.printMarginColor2"), PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$
227 {PHPUIMessages.getString("PHPEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR}, //$NON-NLS-1$
228 {PHPUIMessages.getString("PHPEditorPreferencePage.linkedPositionColor2"), PreferenceConstants.EDITOR_LINKED_POSITION_COLOR}, //$NON-NLS-1$
229 {PHPUIMessages.getString("PHPEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR}, //$NON-NLS-1$
232 private final String[][] fProblemIndicationColorListModel= new String[][] {
233 {"Errors", PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR, PreferenceConstants.EDITOR_PROBLEM_INDICATION, PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER },
234 {"Warnings", PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR, PreferenceConstants.EDITOR_WARNING_INDICATION, PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER },
235 {"Tasks", PreferenceConstants.EDITOR_TASK_INDICATION_COLOR, PreferenceConstants.EDITOR_TASK_INDICATION, PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER },
236 {"Search Results", PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER },
237 {"Bookmarks", PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR, PreferenceConstants.EDITOR_BOOKMARK_INDICATION, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER },
238 {"Others", PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, PreferenceConstants.EDITOR_UNKNOWN_INDICATION, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER }
241 private OverlayPreferenceStore fOverlayStore;
242 private JavaTextTools fJavaTextTools;
243 // private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
245 private Map fColorButtons= new HashMap();
246 private SelectionListener fColorButtonListener= new SelectionListener() {
247 public void widgetDefaultSelected(SelectionEvent e) {
249 public void widgetSelected(SelectionEvent e) {
250 ColorEditor editor= (ColorEditor) e.widget.getData();
251 PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue());
255 private Map fCheckBoxes= new HashMap();
256 private SelectionListener fCheckBoxListener= new SelectionListener() {
257 public void widgetDefaultSelected(SelectionEvent e) {
259 public void widgetSelected(SelectionEvent e) {
260 Button button= (Button) e.widget;
261 fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
265 private Map fTextFields= new HashMap();
266 private ModifyListener fTextFieldListener= new ModifyListener() {
267 public void modifyText(ModifyEvent e) {
268 Text text= (Text) e.widget;
269 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
273 private ArrayList fNumberFields= new ArrayList();
274 private ModifyListener fNumberFieldListener= new ModifyListener() {
275 public void modifyText(ModifyEvent e) {
276 numberFieldChanged((Text) e.widget);
280 private WorkbenchChainedTextFontFieldEditor fFontEditor;
281 private List fSyntaxColorList;
282 private List fAppearanceColorList;
283 private List fProblemIndicationList;
284 private ColorEditor fSyntaxForegroundColorEditor;
285 private ColorEditor fAppearanceForegroundColorEditor;
286 private ColorEditor fProblemIndicationForegroundColorEditor;
287 private ColorEditor fBackgroundColorEditor;
288 private Button fBackgroundDefaultRadioButton;
289 private Button fBackgroundCustomRadioButton;
290 private Button fBackgroundColorButton;
291 private Button fBoldCheckBox;
292 // private Button fAddJavaDocTagsButton;
293 private Button fGuessMethodArgumentsButton;
294 private SourceViewer fPreviewViewer;
295 private Color fBackgroundColor;
296 private Control fAutoInsertDelayText;
297 private Control fAutoInsertJavaTriggerText;
298 private Control fAutoInsertJavaDocTriggerText;
299 private Button fShowInTextCheckBox;
300 private Button fShowInOverviewRulerCheckBox;
302 public PHPEditorPreferencePage() {
303 setDescription(PHPUIMessages.getString("PHPEditorPreferencePage.description")); //$NON-NLS-1$
304 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
305 fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys);
309 * @see IWorkbenchPreferencePage#init()
311 public void init(IWorkbench workbench) {
315 * @see PreferencePage#createControl(Composite)
317 public void createControl(Composite parent) {
318 super.createControl(parent);
319 // WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
322 private void handleSyntaxColorListSelection() {
323 int i= fSyntaxColorList.getSelectionIndex();
324 // String key= fSyntaxColorListModel[i][1];
325 // RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
326 // fSyntaxForegroundColorEditor.setColorValue(rgb);
327 // fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
330 private void handleAppearanceColorListSelection() {
331 int i= fAppearanceColorList.getSelectionIndex();
332 String key= fAppearanceColorListModel[i][1];
333 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
334 fAppearanceForegroundColorEditor.setColorValue(rgb);
337 private void handleProblemIndicationColorListSelection() {
338 int i= fProblemIndicationList.getSelectionIndex();
340 String key= fProblemIndicationColorListModel[i][1];
341 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
342 fProblemIndicationForegroundColorEditor.setColorValue(rgb);
344 key= fProblemIndicationColorListModel[i][2];
345 fShowInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
347 key= fProblemIndicationColorListModel[i][3];
348 fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
351 private Control createSyntaxPage(Composite parent) {
353 Composite colorComposite= new Composite(parent, SWT.NULL);
354 colorComposite.setLayout(new GridLayout());
356 Group backgroundComposite= new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
357 backgroundComposite.setLayout(new RowLayout());
358 backgroundComposite.setText(PHPUIMessages.getString("PHPEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
360 SelectionListener backgroundSelectionListener= new SelectionListener() {
361 public void widgetSelected(SelectionEvent e) {
362 boolean custom= fBackgroundCustomRadioButton.getSelection();
363 fBackgroundColorButton.setEnabled(custom);
364 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
366 public void widgetDefaultSelected(SelectionEvent e) {}
369 fBackgroundDefaultRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
370 fBackgroundDefaultRadioButton.setText(PHPUIMessages.getString("PHPEditorPreferencePage.systemDefault")); //$NON-NLS-1$
371 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
373 fBackgroundCustomRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
374 fBackgroundCustomRadioButton.setText(PHPUIMessages.getString("PHPEditorPreferencePage.custom")); //$NON-NLS-1$
375 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
377 fBackgroundColorEditor= new ColorEditor(backgroundComposite);
378 fBackgroundColorButton= fBackgroundColorEditor.getButton();
380 Label label= new Label(colorComposite, SWT.LEFT);
381 label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.foreground")); //$NON-NLS-1$
382 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
384 Composite editorComposite= new Composite(colorComposite, SWT.NONE);
385 GridLayout layout= new GridLayout();
386 layout.numColumns= 2;
387 layout.marginHeight= 0;
388 layout.marginWidth= 0;
389 editorComposite.setLayout(layout);
390 GridData gd= new GridData(GridData.FILL_BOTH);
391 editorComposite.setLayoutData(gd);
393 fSyntaxColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
394 gd= new GridData(GridData.FILL_BOTH);
395 gd.heightHint= convertHeightInCharsToPixels(5);
396 fSyntaxColorList.setLayoutData(gd);
398 Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
399 layout= new GridLayout();
400 layout.marginHeight= 0;
401 layout.marginWidth= 0;
402 layout.numColumns= 2;
403 stylesComposite.setLayout(layout);
404 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
406 label= new Label(stylesComposite, SWT.LEFT);
407 label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
409 gd.horizontalAlignment= GridData.BEGINNING;
410 label.setLayoutData(gd);
412 fSyntaxForegroundColorEditor= new ColorEditor(stylesComposite);
413 Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton();
414 gd= new GridData(GridData.FILL_HORIZONTAL);
415 gd.horizontalAlignment= GridData.BEGINNING;
416 foregroundColorButton.setLayoutData(gd);
418 fBoldCheckBox= new Button(stylesComposite, SWT.CHECK);
419 fBoldCheckBox.setText(PHPUIMessages.getString("PHPEditorPreferencePage.bold")); //$NON-NLS-1$
420 gd= new GridData(GridData.FILL_HORIZONTAL);
421 gd.horizontalAlignment= GridData.BEGINNING;
422 gd.horizontalSpan= 2;
423 fBoldCheckBox.setLayoutData(gd);
425 label= new Label(colorComposite, SWT.LEFT);
426 label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.preview")); //$NON-NLS-1$
427 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
429 Control previewer= createPreviewer(colorComposite);
430 gd= new GridData(GridData.FILL_BOTH);
431 gd.widthHint= convertWidthInCharsToPixels(20);
432 gd.heightHint= convertHeightInCharsToPixels(5);
433 previewer.setLayoutData(gd);
436 fSyntaxColorList.addSelectionListener(new SelectionListener() {
437 public void widgetDefaultSelected(SelectionEvent e) {
440 public void widgetSelected(SelectionEvent e) {
441 handleSyntaxColorListSelection();
445 foregroundColorButton.addSelectionListener(new SelectionListener() {
446 public void widgetDefaultSelected(SelectionEvent e) {
449 public void widgetSelected(SelectionEvent e) {
450 int i= fSyntaxColorList.getSelectionIndex();
451 // String key= fSyntaxColorListModel[i][1];
453 // PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
457 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
458 public void widgetDefaultSelected(SelectionEvent e) {
461 public void widgetSelected(SelectionEvent e) {
462 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor.getColorValue());
466 fBoldCheckBox.addSelectionListener(new SelectionListener() {
467 public void widgetDefaultSelected(SelectionEvent e) {
470 public void widgetSelected(SelectionEvent e) {
471 int i= fSyntaxColorList.getSelectionIndex();
472 // String key= fSyntaxColorListModel[i][1];
473 // fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
477 return colorComposite;
480 private Control createPreviewer(Composite parent) {
482 fJavaTextTools= new JavaTextTools(fOverlayStore);
484 fPreviewViewer= new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
485 fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools, null));
486 fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
487 fPreviewViewer.setEditable(false);
489 initializeViewerColors(fPreviewViewer);
491 String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
492 IDocument document= new Document(content);
493 PHPEditorEnvironment pe;
494 IDocumentPartitioner partitioner= fJavaTextTools.createDocumentPartitioner();
495 partitioner.connect(document);
496 document.setDocumentPartitioner(partitioner);
498 fPreviewViewer.setDocument(document);
500 fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() {
501 public void propertyChange(PropertyChangeEvent event) {
502 String p= event.getProperty();
503 if (p.equals(PreferenceConstants.EDITOR_BACKGROUND_COLOR) ||
504 p.equals(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR))
506 initializeViewerColors(fPreviewViewer);
509 fPreviewViewer.invalidateTextPresentation();
513 return fPreviewViewer.getControl();
517 * Initializes the given viewer's colors.
519 * @param viewer the viewer to be initialized
521 private void initializeViewerColors(ISourceViewer viewer) {
523 IPreferenceStore store= fOverlayStore;
526 StyledText styledText= viewer.getTextWidget();
528 // ---------- background color ----------------------
529 Color color= store.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)
531 : createColor(store, PreferenceConstants.EDITOR_BACKGROUND_COLOR, styledText.getDisplay());
532 styledText.setBackground(color);
534 if (fBackgroundColor != null)
535 fBackgroundColor.dispose();
537 fBackgroundColor= color;
542 * Creates a color from the information stored in the given preference store.
543 * Returns <code>null</code> if there is no such information available.
545 private Color createColor(IPreferenceStore store, String key, Display display) {
549 if (store.contains(key)) {
551 if (store.isDefault(key))
552 rgb= PreferenceConverter.getDefaultColor(store, key);
554 rgb= PreferenceConverter.getColor(store, key);
557 return new Color(display, rgb);
563 // sets enabled flag for a control and all its sub-tree
564 private static void setEnabled(Control control, boolean enable) {
565 control.setEnabled(enable);
566 if (control instanceof Composite) {
567 Composite composite= (Composite) control;
568 Control[] children= composite.getChildren();
569 for (int i= 0; i < children.length; i++)
570 setEnabled(children[i], enable);
574 private Control createAppearancePage(Composite parent) {
576 Composite appearanceComposite= new Composite(parent, SWT.NONE);
577 GridLayout layout= new GridLayout(); layout.numColumns= 2;
578 appearanceComposite.setLayout(layout);
580 String label= PHPUIMessages.getString("PHPEditorPreferencePage.textFont"); //$NON-NLS-1$
581 addTextFontEditor(appearanceComposite, label, AbstractTextEditor.PREFERENCE_FONT);
583 label= PHPUIMessages.getString("PHPEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
584 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
586 label= PHPUIMessages.getString("PHPEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
587 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
589 label= PHPUIMessages.getString("PHPEditorPreferencePage.synchronizeOnCursor"); //$NON-NLS-1$
590 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, 0);
592 label= PHPUIMessages.getString("PHPEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
593 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
595 label= PHPUIMessages.getString("PHPEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
596 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
598 label= PHPUIMessages.getString("PHPEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
599 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
601 label= PHPUIMessages.getString("PHPEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
602 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_CURRENT_LINE, 0);
604 label= PHPUIMessages.getString("PHPEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
605 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_PRINT_MARGIN, 0);
608 Label l= new Label(appearanceComposite, SWT.LEFT );
609 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
610 gd.horizontalSpan= 2;
611 gd.heightHint= convertHeightInCharsToPixels(1) / 2;
614 l= new Label(appearanceComposite, SWT.LEFT);
615 l.setText(PHPUIMessages.getString("PHPEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
616 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
617 gd.horizontalSpan= 2;
620 Composite editorComposite= new Composite(appearanceComposite, SWT.NONE);
621 layout= new GridLayout();
622 layout.numColumns= 2;
623 layout.marginHeight= 0;
624 layout.marginWidth= 0;
625 editorComposite.setLayout(layout);
626 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
627 gd.horizontalSpan= 2;
628 editorComposite.setLayoutData(gd);
630 fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
631 gd= new GridData(GridData.FILL_BOTH);
632 gd.heightHint= convertHeightInCharsToPixels(5);
633 fAppearanceColorList.setLayoutData(gd);
635 Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
636 layout= new GridLayout();
637 layout.marginHeight= 0;
638 layout.marginWidth= 0;
639 layout.numColumns= 2;
640 stylesComposite.setLayout(layout);
641 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
643 l= new Label(stylesComposite, SWT.LEFT);
644 l.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
646 gd.horizontalAlignment= GridData.BEGINNING;
649 fAppearanceForegroundColorEditor= new ColorEditor(stylesComposite);
650 Button foregroundColorButton= fAppearanceForegroundColorEditor.getButton();
651 gd= new GridData(GridData.FILL_HORIZONTAL);
652 gd.horizontalAlignment= GridData.BEGINNING;
653 foregroundColorButton.setLayoutData(gd);
655 fAppearanceColorList.addSelectionListener(new SelectionListener() {
656 public void widgetDefaultSelected(SelectionEvent e) {
659 public void widgetSelected(SelectionEvent e) {
660 handleAppearanceColorListSelection();
663 foregroundColorButton.addSelectionListener(new SelectionListener() {
664 public void widgetDefaultSelected(SelectionEvent e) {
667 public void widgetSelected(SelectionEvent e) {
668 int i= fAppearanceColorList.getSelectionIndex();
669 String key= fAppearanceColorListModel[i][1];
671 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceForegroundColorEditor.getColorValue());
674 return appearanceComposite;
678 private Control createProblemIndicationPage(Composite parent) {
679 Composite composite= new Composite(parent, SWT.NULL);
680 GridLayout layout= new GridLayout(); layout.numColumns= 2;
681 composite.setLayout(layout);
683 String text= "Analyse &problems while typing";
684 addCheckBox(composite, text, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
686 text= PHPUIMessages.getString("PHPEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
687 addCheckBox(composite, text, PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
689 Label label= new Label(composite, SWT.LEFT );
690 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
691 gd.horizontalSpan= 2;
692 gd.heightHint= convertHeightInCharsToPixels(1) / 2;
693 label.setLayoutData(gd);
695 label= new Label(composite, SWT.LEFT);
696 label.setText("&Marker presentation options:");
697 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
698 gd.horizontalSpan= 2;
699 label.setLayoutData(gd);
701 Composite editorComposite= new Composite(composite, SWT.NONE);
702 layout= new GridLayout();
703 layout.numColumns= 2;
704 layout.marginHeight= 0;
705 layout.marginWidth= 0;
706 editorComposite.setLayout(layout);
707 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
708 gd.horizontalSpan= 2;
709 editorComposite.setLayoutData(gd);
711 fProblemIndicationList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
712 gd= new GridData(GridData.FILL_BOTH);
713 gd.heightHint= convertHeightInCharsToPixels(5);
714 fProblemIndicationList.setLayoutData(gd);
716 Composite optionsComposite= new Composite(editorComposite, SWT.NONE);
717 layout= new GridLayout();
718 layout.marginHeight= 0;
719 layout.marginWidth= 0;
720 layout.numColumns= 2;
721 optionsComposite.setLayout(layout);
722 optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
724 fShowInTextCheckBox= new Button(optionsComposite, SWT.CHECK);
725 fShowInTextCheckBox.setText("Show in &text");
726 gd= new GridData(GridData.FILL_HORIZONTAL);
727 gd.horizontalAlignment= GridData.BEGINNING;
728 gd.horizontalSpan= 2;
729 fShowInTextCheckBox.setLayoutData(gd);
731 fShowInOverviewRulerCheckBox= new Button(optionsComposite, SWT.CHECK);
732 fShowInOverviewRulerCheckBox.setText("Show in overview &ruler");
733 gd= new GridData(GridData.FILL_HORIZONTAL);
734 gd.horizontalAlignment= GridData.BEGINNING;
735 gd.horizontalSpan= 2;
736 fShowInOverviewRulerCheckBox.setLayoutData(gd);
738 label= new Label(optionsComposite, SWT.LEFT);
739 label.setText("C&olor:");
741 gd.horizontalAlignment= GridData.BEGINNING;
742 label.setLayoutData(gd);
744 fProblemIndicationForegroundColorEditor= new ColorEditor(optionsComposite);
745 Button foregroundColorButton= fProblemIndicationForegroundColorEditor.getButton();
746 gd= new GridData(GridData.FILL_HORIZONTAL);
747 gd.horizontalAlignment= GridData.BEGINNING;
748 foregroundColorButton.setLayoutData(gd);
750 fProblemIndicationList.addSelectionListener(new SelectionListener() {
751 public void widgetDefaultSelected(SelectionEvent e) {
755 public void widgetSelected(SelectionEvent e) {
756 handleProblemIndicationColorListSelection();
760 fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
761 public void widgetDefaultSelected(SelectionEvent e) {
765 public void widgetSelected(SelectionEvent e) {
766 int i= fProblemIndicationList.getSelectionIndex();
767 String key= fProblemIndicationColorListModel[i][2];
768 fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
772 fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
773 public void widgetDefaultSelected(SelectionEvent e) {
777 public void widgetSelected(SelectionEvent e) {
778 int i= fProblemIndicationList.getSelectionIndex();
779 String key= fProblemIndicationColorListModel[i][3];
780 fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection());
784 foregroundColorButton.addSelectionListener(new SelectionListener() {
785 public void widgetDefaultSelected(SelectionEvent e) {
789 public void widgetSelected(SelectionEvent e) {
790 int i= fProblemIndicationList.getSelectionIndex();
791 String key= fProblemIndicationColorListModel[i][1];
792 PreferenceConverter.setValue(fOverlayStore, key, fProblemIndicationForegroundColorEditor.getColorValue());
799 // private Control createBehaviourPage(Composite parent) {
800 // Composite composite= new Composite(parent, SWT.NULL);
801 // GridLayout layout= new GridLayout(); layout.numColumns= 2;
802 // composite.setLayout(layout);
804 // String label= PHPUIMessages.getString("PHPEditorPreferencePage.wrapStrings"); //$NON-NLS-1$
805 // addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
807 // label= PHPUIMessages.getString("PHPEditorPreferencePage.smartHomeEnd"); //$NON-NLS-1$
808 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
810 // label= PHPUIMessages.getString("PHPEditorPreferencePage.smartPaste"); //$NON-NLS-1$
811 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
813 // label= PHPUIMessages.getString("PHPEditorPreferencePage.insertSpaceForTabs"); //$NON-NLS-1$
814 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
816 // label= PHPUIMessages.getString("PHPEditorPreferencePage.closeStrings"); //$NON-NLS-1$
817 // addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 1);
819 // label= PHPUIMessages.getString("PHPEditorPreferencePage.closeBrackets"); //$NON-NLS-1$
820 // addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 1);
822 // label= PHPUIMessages.getString("PHPEditorPreferencePage.closeBraces"); //$NON-NLS-1$
823 // addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
825 // label= PHPUIMessages.getString("PHPEditorPreferencePage.closePHPDocs"); //$NON-NLS-1$
826 // Button button= addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
828 // label= PHPUIMessages.getString("PHPEditorPreferencePage.addPHPDocTags"); //$NON-NLS-1$
829 // fAddJavaDocTagsButton= addCheckBox(composite, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
830 // createDependency(button, fAddJavaDocTagsButton);
832 // label= PHPUIMessages.getString("PHPEditorPreferencePage.formatPHPDocs"); //$NON-NLS-1$
833 // addCheckBox(composite, label, PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
838 private static void indent(Control control) {
839 GridData gridData= new GridData();
840 gridData.horizontalIndent= 20;
841 control.setLayoutData(gridData);
844 private static void createDependency(final Button master, final Control slave) {
846 master.addSelectionListener(new SelectionListener() {
847 public void widgetSelected(SelectionEvent e) {
848 slave.setEnabled(master.getSelection());
851 public void widgetDefaultSelected(SelectionEvent e) {}
855 private Control createContentAssistPage(Composite parent) {
857 Composite contentAssistComposite= new Composite(parent, SWT.NULL);
858 GridLayout layout= new GridLayout(); layout.numColumns= 2;
859 contentAssistComposite.setLayout(layout);
861 String label= PHPUIMessages.getString("PHPEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$
862 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOINSERT, 0);
864 label= PHPUIMessages.getString("PHPEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$
865 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0);
867 label= PHPUIMessages.getString("PHPEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$
868 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0);
870 label= PHPUIMessages.getString("PHPEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$
871 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ADDIMPORT, 0);
873 label= PHPUIMessages.getString("PHPEditorPreferencePage.insertCompletion"); //$NON-NLS-1$
874 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_INSERT_COMPLETION, 0);
876 label= PHPUIMessages.getString("PHPEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
877 Button button= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0);
879 label= PHPUIMessages.getString("PHPEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
880 fGuessMethodArgumentsButton= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0);
881 createDependency(button, fGuessMethodArgumentsButton);
883 label= PHPUIMessages.getString("PHPEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$
884 final Button autoactivation= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0);
886 label= PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$
887 fAutoInsertDelayText= addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true);
889 label= PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationTriggersForPHP"); //$NON-NLS-1$
890 fAutoInsertJavaTriggerText= addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, false);
892 label= PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationTriggersForPHPDoc"); //$NON-NLS-1$
893 fAutoInsertJavaDocTriggerText= addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, false);
895 label= PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForCompletionProposals"); //$NON-NLS-1$
896 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, 0);
898 label= PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForCompletionProposals"); //$NON-NLS-1$
899 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, 0);
901 label= PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForMethodParameters"); //$NON-NLS-1$
902 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, 0);
904 label= PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForMethodParameters"); //$NON-NLS-1$
905 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, 0);
907 label= PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForCompletionReplacement"); //$NON-NLS-1$
908 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, 0);
910 label= PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForCompletionReplacement"); //$NON-NLS-1$
911 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, 0);
913 autoactivation.addSelectionListener(new SelectionAdapter(){
914 public void widgetSelected(SelectionEvent e) {
915 updateAutoactivationControls();
918 return contentAssistComposite;
922 * @see PreferencePage#createContents(Composite)
924 protected Control createContents(Composite parent) {
926 fOverlayStore.load();
927 fOverlayStore.start();
929 TabFolder folder= new TabFolder(parent, SWT.NONE);
930 folder.setLayout(new TabFolderLayout());
931 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
933 TabItem item= new TabItem(folder, SWT.NONE);
934 item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.general")); //$NON-NLS-1$
935 item.setControl(createAppearancePage(folder));
937 item= new TabItem(folder, SWT.NONE);
938 item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.colors")); //$NON-NLS-1$
939 item.setControl(createSyntaxPage(folder));
941 item= new TabItem(folder, SWT.NONE);
942 item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.codeAssist")); //$NON-NLS-1$
943 item.setControl(createContentAssistPage(folder));
945 item= new TabItem(folder, SWT.NONE);
946 item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.problemIndicationTab.title")); //$NON-NLS-1$
947 item.setControl(createProblemIndicationPage(folder));
949 // item= new TabItem(folder, SWT.NONE);
950 // item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.behaviourTab.title")); //$NON-NLS-1$
951 // item.setControl(createBehaviourPage(folder));
953 // item= new TabItem(folder, SWT.NONE);
954 // item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.hoverTab.title")); //$NON-NLS-1$
955 // fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(fOverlayStore);
956 // item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
963 private void initialize() {
965 fFontEditor.setPreferenceStore(getPreferenceStore());
966 fFontEditor.setPreferencePage(this);
971 // for (int i= 0; i < fSyntaxColorListModel.length; i++)
972 // fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
974 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
976 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
977 fSyntaxColorList.select(0);
978 handleSyntaxColorListSelection();
983 for (int i= 0; i < fAppearanceColorListModel.length; i++)
984 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
986 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
988 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
989 fAppearanceColorList.select(0);
990 handleAppearanceColorListSelection();
995 for (int i= 0; i < fProblemIndicationColorListModel.length; i++)
996 fProblemIndicationList.add(fProblemIndicationColorListModel[i][0]);
998 fProblemIndicationList.getDisplay().asyncExec(new Runnable() {
1000 if (fProblemIndicationList != null && !fProblemIndicationList.isDisposed()) {
1001 fProblemIndicationList.select(0);
1002 handleProblemIndicationColorListSelection();
1008 private void initializeFields() {
1010 Iterator e= fColorButtons.keySet().iterator();
1011 while (e.hasNext()) {
1012 ColorEditor c= (ColorEditor) e.next();
1013 String key= (String) fColorButtons.get(c);
1014 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
1015 c.setColorValue(rgb);
1018 e= fCheckBoxes.keySet().iterator();
1019 while (e.hasNext()) {
1020 Button b= (Button) e.next();
1021 String key= (String) fCheckBoxes.get(b);
1022 b.setSelection(fOverlayStore.getBoolean(key));
1025 e= fTextFields.keySet().iterator();
1026 while (e.hasNext()) {
1027 Text t= (Text) e.next();
1028 String key= (String) fTextFields.get(t);
1029 t.setText(fOverlayStore.getString(key));
1032 RGB rgb= PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1033 fBackgroundColorEditor.setColorValue(rgb);
1035 boolean default_= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1036 fBackgroundDefaultRadioButton.setSelection(default_);
1037 fBackgroundCustomRadioButton.setSelection(!default_);
1038 fBackgroundColorButton.setEnabled(!default_);
1040 // boolean closeJavaDocs= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1041 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1043 boolean fillMethodArguments= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1044 fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1046 updateAutoactivationControls();
1048 // fJavaEditorHoverConfigurationBlock.initializeFields();
1051 private void updateAutoactivationControls() {
1052 boolean autoactivation= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1053 fAutoInsertDelayText.setEnabled(autoactivation);
1054 fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1055 fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1059 * @see PreferencePage#performOk()
1061 public boolean performOk() {
1062 fFontEditor.store();
1063 // fJavaEditorHoverConfigurationBlock.performOk();
1064 fOverlayStore.propagate();
1065 PHPeclipsePlugin.getDefault().savePluginPreferences();
1070 * @see PreferencePage#performDefaults()
1072 protected void performDefaults() {
1074 fFontEditor.loadDefault();
1076 fOverlayStore.loadDefaults();
1079 handleSyntaxColorListSelection();
1080 handleAppearanceColorListSelection();
1081 handleProblemIndicationColorListSelection();
1082 super.performDefaults();
1084 fPreviewViewer.invalidateTextPresentation();
1088 * @see DialogPage#dispose()
1090 public void dispose() {
1092 if (fJavaTextTools != null) {
1093 fJavaTextTools= null;
1096 fFontEditor.setPreferencePage(null);
1097 fFontEditor.setPreferenceStore(null);
1099 if (fOverlayStore != null) {
1100 fOverlayStore.stop();
1101 fOverlayStore= null;
1107 private Control addColorButton(Composite composite, String label, String key, int indentation) {
1109 Label labelControl= new Label(composite, SWT.NONE);
1110 labelControl.setText(label);
1112 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1113 gd.horizontalIndent= indentation;
1114 labelControl.setLayoutData(gd);
1116 ColorEditor editor= new ColorEditor(composite);
1117 Button button= editor.getButton();
1118 button.setData(editor);
1120 gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1121 button.setLayoutData(gd);
1122 button.addSelectionListener(fColorButtonListener);
1124 fColorButtons.put(editor, key);
1129 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1130 Button checkBox= new Button(parent, SWT.CHECK);
1131 checkBox.setText(label);
1133 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1134 gd.horizontalIndent= indentation;
1135 gd.horizontalSpan= 2;
1136 checkBox.setLayoutData(gd);
1137 checkBox.addSelectionListener(fCheckBoxListener);
1139 fCheckBoxes.put(checkBox, key);
1144 private Control addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1146 Label labelControl= new Label(composite, SWT.NONE);
1147 labelControl.setText(label);
1148 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1149 gd.horizontalIndent= indentation;
1150 labelControl.setLayoutData(gd);
1152 Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE);
1153 gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1154 gd.widthHint= convertWidthInCharsToPixels(textLimit + 1);
1155 textControl.setLayoutData(gd);
1156 textControl.setTextLimit(textLimit);
1157 fTextFields.put(textControl, key);
1159 fNumberFields.add(textControl);
1160 textControl.addModifyListener(fNumberFieldListener);
1162 textControl.addModifyListener(fTextFieldListener);
1168 private void addTextFontEditor(Composite parent, String label, String key) {
1170 Composite editorComposite= new Composite(parent, SWT.NONE);
1171 GridLayout layout= new GridLayout();
1172 layout.numColumns= 3;
1173 editorComposite.setLayout(layout);
1174 fFontEditor= new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
1175 fFontEditor.setChangeButtonText(PHPUIMessages.getString("PHPEditorPreferencePage.change")); //$NON-NLS-1$
1177 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1178 gd.horizontalSpan= 2;
1179 editorComposite.setLayoutData(gd);
1182 private String loadPreviewContentFromFile(String filename) {
1184 String separator= System.getProperty("line.separator"); //$NON-NLS-1$
1185 StringBuffer buffer= new StringBuffer(512);
1186 BufferedReader reader= null;
1188 reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1189 while ((line= reader.readLine()) != null) {
1190 buffer.append(line);
1191 buffer.append(separator);
1193 } catch (IOException io) {
1194 PHPeclipsePlugin.log(io);
1196 if (reader != null) {
1197 try { reader.close(); } catch (IOException e) {}
1200 return buffer.toString();
1203 private void numberFieldChanged(Text textControl) {
1204 String number= textControl.getText();
1205 IStatus status= validatePositiveNumber(number);
1206 if (!status.matches(IStatus.ERROR))
1207 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1208 updateStatus(status);
1211 private IStatus validatePositiveNumber(String number) {
1212 StatusInfo status= new StatusInfo();
1213 if (number.length() == 0) {
1214 status.setError(PHPUIMessages.getString("PHPEditorPreferencePage.empty_input")); //$NON-NLS-1$
1217 int value= Integer.parseInt(number);
1219 status.setError(PHPUIMessages.getFormattedString("PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1220 } catch (NumberFormatException e) {
1221 status.setError(PHPUIMessages.getFormattedString("PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1227 private void updateStatus(IStatus status) {
1228 if (!status.matches(IStatus.ERROR)) {
1229 for (int i= 0; i < fNumberFields.size(); i++) {
1230 Text text= (Text) fNumberFields.get(i);
1231 IStatus s= validatePositiveNumber(text.getText());
1232 status= StatusUtil.getMoreSevere(s, status);
1235 setValid(!status.matches(IStatus.ERROR));
1236 StatusUtil.applyToStatusLine(this, status);
1240 * @deprecated Inline to avoid reference to preference page
1242 public static boolean indicateQuixFixableProblems() {
1243 return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
1247 * @deprecated Inline to avoid reference to preference page
1249 static public boolean synchronizeOutlineOnCursorMove() {
1250 return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);