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_PHP_FUNCTIONNAME_COLOR),
100 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD),
102 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR),
103 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD),
105 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR),
106 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD),
108 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TYPE_COLOR),
109 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD),
111 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR),
112 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD),
114 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR),
115 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD),
117 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR),
118 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD),
120 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD),
121 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD),
123 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR),
124 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD),
126 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR),
127 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD),
129 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR),
130 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS),
132 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CURRENT_LINE_COLOR),
133 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CURRENT_LINE),
135 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR),
136 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN),
137 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PRINT_MARGIN),
139 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR),
141 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINKED_POSITION_COLOR),
142 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR),
144 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR),
145 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PROBLEM_INDICATION),
147 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR),
148 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WARNING_INDICATION),
150 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR),
151 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION),
153 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR),
154 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BOOKMARK_INDICATION),
156 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR),
157 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION),
159 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR),
160 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_UNKNOWN_INDICATION),
162 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER),
163 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER),
164 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER),
165 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER),
166 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER),
167 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER),
169 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CORRECTION_INDICATION),
170 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE),
172 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS),
174 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_OVERVIEW_RULER),
176 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR),
177 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_LINE_NUMBER_RULER),
179 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SPACES_FOR_TABS),
181 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOACTIVATION),
182 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY),
183 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT),
184 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND),
185 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND),
186 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND),
187 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND),
188 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND),
189 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND),
190 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA),
191 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC),
192 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS),
193 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS),
194 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_CASE_SENSITIVITY),
195 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT),
196 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_INSERT_COMPLETION),
197 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES),
198 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS),
200 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE),
201 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS),
202 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS),
203 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES),
204 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_JAVADOCS),
205 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS),
206 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS),
207 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FORMAT_JAVADOCS),
209 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END),
211 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_DEFAULT_HOVER),
212 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_NONE_HOVER),
213 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_HOVER),
214 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SHIFT_HOVER),
215 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
216 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_ALT_HOVER),
217 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_ALT_SHIFT_HOVER),
218 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
219 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_ALT_SHIFT_HOVER),
222 private final String[][] fSyntaxColorListModel= new String[][] {
223 { PHPUIMessages.getString("PHPEditorPreferencePage.multiLineComment"), PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$
224 { PHPUIMessages.getString("PHPEditorPreferencePage.singleLineComment"), PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$
225 { PHPUIMessages.getString("PHPEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$
226 { PHPUIMessages.getString("PHPEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR }, //$NON-NLS-1$
227 { PHPUIMessages.getString("PHPEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR }, //$NON-NLS-1$
228 { PHPUIMessages.getString("PHPEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR }, //$NON-NLS-1$
229 { PHPUIMessages.getString("PHPEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR }, //$NON-NLS-1$
230 { PHPUIMessages.getString("PHPEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$
231 { PHPUIMessages.getString("PHPEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
232 { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$
233 { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD }, //$NON-NLS-1$
234 { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$
235 { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
238 private final String[][] fAppearanceColorListModel= new String[][] {
239 {PHPUIMessages.getString("PHPEditorPreferencePage.lineNumberForegroundColor"), PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$
240 {PHPUIMessages.getString("PHPEditorPreferencePage.matchingBracketsHighlightColor2"), PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR}, //$NON-NLS-1$
241 {PHPUIMessages.getString("PHPEditorPreferencePage.currentLineHighlighColor"), PreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$
242 {PHPUIMessages.getString("PHPEditorPreferencePage.printMarginColor2"), PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$
243 {PHPUIMessages.getString("PHPEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR}, //$NON-NLS-1$
244 {PHPUIMessages.getString("PHPEditorPreferencePage.linkedPositionColor2"), PreferenceConstants.EDITOR_LINKED_POSITION_COLOR}, //$NON-NLS-1$
245 {PHPUIMessages.getString("PHPEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR}, //$NON-NLS-1$
248 private final String[][] fProblemIndicationColorListModel= new String[][] {
249 {"Errors", PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR, PreferenceConstants.EDITOR_PROBLEM_INDICATION, PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER },
250 {"Warnings", PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR, PreferenceConstants.EDITOR_WARNING_INDICATION, PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER },
251 {"Tasks", PreferenceConstants.EDITOR_TASK_INDICATION_COLOR, PreferenceConstants.EDITOR_TASK_INDICATION, PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER },
252 {"Search Results", PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER },
253 {"Bookmarks", PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR, PreferenceConstants.EDITOR_BOOKMARK_INDICATION, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER },
254 {"Others", PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, PreferenceConstants.EDITOR_UNKNOWN_INDICATION, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER }
257 private OverlayPreferenceStore fOverlayStore;
258 private JavaTextTools fJavaTextTools;
259 // private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
261 private Map fColorButtons= new HashMap();
262 private SelectionListener fColorButtonListener= new SelectionListener() {
263 public void widgetDefaultSelected(SelectionEvent e) {
265 public void widgetSelected(SelectionEvent e) {
266 ColorEditor editor= (ColorEditor) e.widget.getData();
267 PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue());
271 private Map fCheckBoxes= new HashMap();
272 private SelectionListener fCheckBoxListener= new SelectionListener() {
273 public void widgetDefaultSelected(SelectionEvent e) {
275 public void widgetSelected(SelectionEvent e) {
276 Button button= (Button) e.widget;
277 fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
281 private Map fTextFields= new HashMap();
282 private ModifyListener fTextFieldListener= new ModifyListener() {
283 public void modifyText(ModifyEvent e) {
284 Text text= (Text) e.widget;
285 fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
289 private ArrayList fNumberFields= new ArrayList();
290 private ModifyListener fNumberFieldListener= new ModifyListener() {
291 public void modifyText(ModifyEvent e) {
292 numberFieldChanged((Text) e.widget);
296 private WorkbenchChainedTextFontFieldEditor fFontEditor;
297 private List fSyntaxColorList;
298 private List fAppearanceColorList;
299 private List fProblemIndicationList;
300 private ColorEditor fSyntaxForegroundColorEditor;
301 private ColorEditor fAppearanceForegroundColorEditor;
302 private ColorEditor fProblemIndicationForegroundColorEditor;
303 private ColorEditor fBackgroundColorEditor;
304 private Button fBackgroundDefaultRadioButton;
305 private Button fBackgroundCustomRadioButton;
306 private Button fBackgroundColorButton;
307 private Button fBoldCheckBox;
308 // private Button fAddJavaDocTagsButton;
309 private Button fGuessMethodArgumentsButton;
310 private SourceViewer fPreviewViewer;
311 private Color fBackgroundColor;
312 private Control fAutoInsertDelayText;
313 private Control fAutoInsertJavaTriggerText;
314 private Control fAutoInsertJavaDocTriggerText;
315 private Button fShowInTextCheckBox;
316 private Button fShowInOverviewRulerCheckBox;
318 public PHPEditorPreferencePage() {
319 setDescription(PHPUIMessages.getString("PHPEditorPreferencePage.description")); //$NON-NLS-1$
320 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
321 fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys);
325 * @see IWorkbenchPreferencePage#init()
327 public void init(IWorkbench workbench) {
331 * @see PreferencePage#createControl(Composite)
333 public void createControl(Composite parent) {
334 super.createControl(parent);
335 // WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
338 private void handleSyntaxColorListSelection() {
339 int i= fSyntaxColorList.getSelectionIndex();
340 String key= fSyntaxColorListModel[i][1];
341 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
342 fSyntaxForegroundColorEditor.setColorValue(rgb);
343 fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
346 private void handleAppearanceColorListSelection() {
347 int i= fAppearanceColorList.getSelectionIndex();
348 String key= fAppearanceColorListModel[i][1];
349 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
350 fAppearanceForegroundColorEditor.setColorValue(rgb);
353 private void handleProblemIndicationColorListSelection() {
354 int i= fProblemIndicationList.getSelectionIndex();
356 String key= fProblemIndicationColorListModel[i][1];
357 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
358 fProblemIndicationForegroundColorEditor.setColorValue(rgb);
360 key= fProblemIndicationColorListModel[i][2];
361 fShowInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
363 key= fProblemIndicationColorListModel[i][3];
364 fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
367 private Control createSyntaxPage(Composite parent) {
369 Composite colorComposite= new Composite(parent, SWT.NULL);
370 colorComposite.setLayout(new GridLayout());
372 Group backgroundComposite= new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
373 backgroundComposite.setLayout(new RowLayout());
374 backgroundComposite.setText(PHPUIMessages.getString("PHPEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
376 SelectionListener backgroundSelectionListener= new SelectionListener() {
377 public void widgetSelected(SelectionEvent e) {
378 boolean custom= fBackgroundCustomRadioButton.getSelection();
379 fBackgroundColorButton.setEnabled(custom);
380 fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
382 public void widgetDefaultSelected(SelectionEvent e) {}
385 fBackgroundDefaultRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
386 fBackgroundDefaultRadioButton.setText(PHPUIMessages.getString("PHPEditorPreferencePage.systemDefault")); //$NON-NLS-1$
387 fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
389 fBackgroundCustomRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
390 fBackgroundCustomRadioButton.setText(PHPUIMessages.getString("PHPEditorPreferencePage.custom")); //$NON-NLS-1$
391 fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
393 fBackgroundColorEditor= new ColorEditor(backgroundComposite);
394 fBackgroundColorButton= fBackgroundColorEditor.getButton();
396 Label label= new Label(colorComposite, SWT.LEFT);
397 label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.foreground")); //$NON-NLS-1$
398 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
400 Composite editorComposite= new Composite(colorComposite, SWT.NONE);
401 GridLayout layout= new GridLayout();
402 layout.numColumns= 2;
403 layout.marginHeight= 0;
404 layout.marginWidth= 0;
405 editorComposite.setLayout(layout);
406 GridData gd= new GridData(GridData.FILL_BOTH);
407 editorComposite.setLayoutData(gd);
409 fSyntaxColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
410 gd= new GridData(GridData.FILL_BOTH);
411 gd.heightHint= convertHeightInCharsToPixels(5);
412 fSyntaxColorList.setLayoutData(gd);
414 Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
415 layout= new GridLayout();
416 layout.marginHeight= 0;
417 layout.marginWidth= 0;
418 layout.numColumns= 2;
419 stylesComposite.setLayout(layout);
420 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
422 label= new Label(stylesComposite, SWT.LEFT);
423 label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
425 gd.horizontalAlignment= GridData.BEGINNING;
426 label.setLayoutData(gd);
428 fSyntaxForegroundColorEditor= new ColorEditor(stylesComposite);
429 Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton();
430 gd= new GridData(GridData.FILL_HORIZONTAL);
431 gd.horizontalAlignment= GridData.BEGINNING;
432 foregroundColorButton.setLayoutData(gd);
434 fBoldCheckBox= new Button(stylesComposite, SWT.CHECK);
435 fBoldCheckBox.setText(PHPUIMessages.getString("PHPEditorPreferencePage.bold")); //$NON-NLS-1$
436 gd= new GridData(GridData.FILL_HORIZONTAL);
437 gd.horizontalAlignment= GridData.BEGINNING;
438 gd.horizontalSpan= 2;
439 fBoldCheckBox.setLayoutData(gd);
441 label= new Label(colorComposite, SWT.LEFT);
442 label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.preview")); //$NON-NLS-1$
443 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
445 Control previewer= createPreviewer(colorComposite);
446 gd= new GridData(GridData.FILL_BOTH);
447 gd.widthHint= convertWidthInCharsToPixels(20);
448 gd.heightHint= convertHeightInCharsToPixels(5);
449 previewer.setLayoutData(gd);
452 fSyntaxColorList.addSelectionListener(new SelectionListener() {
453 public void widgetDefaultSelected(SelectionEvent e) {
456 public void widgetSelected(SelectionEvent e) {
457 handleSyntaxColorListSelection();
461 foregroundColorButton.addSelectionListener(new SelectionListener() {
462 public void widgetDefaultSelected(SelectionEvent e) {
465 public void widgetSelected(SelectionEvent e) {
466 int i= fSyntaxColorList.getSelectionIndex();
467 String key= fSyntaxColorListModel[i][1];
469 PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
473 fBackgroundColorButton.addSelectionListener(new SelectionListener() {
474 public void widgetDefaultSelected(SelectionEvent e) {
477 public void widgetSelected(SelectionEvent e) {
478 PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor.getColorValue());
482 fBoldCheckBox.addSelectionListener(new SelectionListener() {
483 public void widgetDefaultSelected(SelectionEvent e) {
486 public void widgetSelected(SelectionEvent e) {
487 int i= fSyntaxColorList.getSelectionIndex();
488 String key= fSyntaxColorListModel[i][1];
489 fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
493 return colorComposite;
496 private Control createPreviewer(Composite parent) {
498 fJavaTextTools= new JavaTextTools(fOverlayStore);
500 fPreviewViewer= new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
501 fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools, null));
502 fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
503 fPreviewViewer.setEditable(false);
505 initializeViewerColors(fPreviewViewer);
507 String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
508 IDocument document= new Document(content);
509 PHPEditorEnvironment pe;
510 IDocumentPartitioner partitioner= fJavaTextTools.createDocumentPartitioner();
511 partitioner.connect(document);
512 document.setDocumentPartitioner(partitioner);
514 fPreviewViewer.setDocument(document);
516 fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() {
517 public void propertyChange(PropertyChangeEvent event) {
518 String p= event.getProperty();
519 if (p.equals(PreferenceConstants.EDITOR_BACKGROUND_COLOR) ||
520 p.equals(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR))
522 initializeViewerColors(fPreviewViewer);
525 fPreviewViewer.invalidateTextPresentation();
529 return fPreviewViewer.getControl();
533 * Initializes the given viewer's colors.
535 * @param viewer the viewer to be initialized
537 private void initializeViewerColors(ISourceViewer viewer) {
539 IPreferenceStore store= fOverlayStore;
542 StyledText styledText= viewer.getTextWidget();
544 // ---------- background color ----------------------
545 Color color= store.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)
547 : createColor(store, PreferenceConstants.EDITOR_BACKGROUND_COLOR, styledText.getDisplay());
548 styledText.setBackground(color);
550 if (fBackgroundColor != null)
551 fBackgroundColor.dispose();
553 fBackgroundColor= color;
558 * Creates a color from the information stored in the given preference store.
559 * Returns <code>null</code> if there is no such information available.
561 private Color createColor(IPreferenceStore store, String key, Display display) {
565 if (store.contains(key)) {
567 if (store.isDefault(key))
568 rgb= PreferenceConverter.getDefaultColor(store, key);
570 rgb= PreferenceConverter.getColor(store, key);
573 return new Color(display, rgb);
579 // sets enabled flag for a control and all its sub-tree
580 private static void setEnabled(Control control, boolean enable) {
581 control.setEnabled(enable);
582 if (control instanceof Composite) {
583 Composite composite= (Composite) control;
584 Control[] children= composite.getChildren();
585 for (int i= 0; i < children.length; i++)
586 setEnabled(children[i], enable);
590 private Control createAppearancePage(Composite parent) {
592 Composite appearanceComposite= new Composite(parent, SWT.NONE);
593 GridLayout layout= new GridLayout(); layout.numColumns= 2;
594 appearanceComposite.setLayout(layout);
596 String label= PHPUIMessages.getString("PHPEditorPreferencePage.textFont"); //$NON-NLS-1$
597 addTextFontEditor(appearanceComposite, label, AbstractTextEditor.PREFERENCE_FONT);
599 label= PHPUIMessages.getString("PHPEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
600 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
602 label= PHPUIMessages.getString("PHPEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
603 addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
605 // label= PHPUIMessages.getString("PHPEditorPreferencePage.synchronizeOnCursor"); //$NON-NLS-1$
606 // addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, 0);
608 label= PHPUIMessages.getString("PHPEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
609 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
611 label= PHPUIMessages.getString("PHPEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
612 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
614 label= PHPUIMessages.getString("PHPEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
615 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
617 label= PHPUIMessages.getString("PHPEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
618 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_CURRENT_LINE, 0);
620 label= PHPUIMessages.getString("PHPEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
621 addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_PRINT_MARGIN, 0);
624 Label l= new Label(appearanceComposite, SWT.LEFT );
625 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
626 gd.horizontalSpan= 2;
627 gd.heightHint= convertHeightInCharsToPixels(1) / 2;
630 l= new Label(appearanceComposite, SWT.LEFT);
631 l.setText(PHPUIMessages.getString("PHPEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
632 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
633 gd.horizontalSpan= 2;
636 Composite editorComposite= new Composite(appearanceComposite, SWT.NONE);
637 layout= new GridLayout();
638 layout.numColumns= 2;
639 layout.marginHeight= 0;
640 layout.marginWidth= 0;
641 editorComposite.setLayout(layout);
642 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
643 gd.horizontalSpan= 2;
644 editorComposite.setLayoutData(gd);
646 fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
647 gd= new GridData(GridData.FILL_BOTH);
648 gd.heightHint= convertHeightInCharsToPixels(5);
649 fAppearanceColorList.setLayoutData(gd);
651 Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
652 layout= new GridLayout();
653 layout.marginHeight= 0;
654 layout.marginWidth= 0;
655 layout.numColumns= 2;
656 stylesComposite.setLayout(layout);
657 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
659 l= new Label(stylesComposite, SWT.LEFT);
660 l.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
662 gd.horizontalAlignment= GridData.BEGINNING;
665 fAppearanceForegroundColorEditor= new ColorEditor(stylesComposite);
666 Button foregroundColorButton= fAppearanceForegroundColorEditor.getButton();
667 gd= new GridData(GridData.FILL_HORIZONTAL);
668 gd.horizontalAlignment= GridData.BEGINNING;
669 foregroundColorButton.setLayoutData(gd);
671 fAppearanceColorList.addSelectionListener(new SelectionListener() {
672 public void widgetDefaultSelected(SelectionEvent e) {
675 public void widgetSelected(SelectionEvent e) {
676 handleAppearanceColorListSelection();
679 foregroundColorButton.addSelectionListener(new SelectionListener() {
680 public void widgetDefaultSelected(SelectionEvent e) {
683 public void widgetSelected(SelectionEvent e) {
684 int i= fAppearanceColorList.getSelectionIndex();
685 String key= fAppearanceColorListModel[i][1];
687 PreferenceConverter.setValue(fOverlayStore, key, fAppearanceForegroundColorEditor.getColorValue());
690 return appearanceComposite;
694 private Control createProblemIndicationPage(Composite parent) {
695 Composite composite= new Composite(parent, SWT.NULL);
696 GridLayout layout= new GridLayout(); layout.numColumns= 2;
697 composite.setLayout(layout);
699 String text= "Analyse &problems while typing";
700 addCheckBox(composite, text, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
702 text= PHPUIMessages.getString("PHPEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
703 addCheckBox(composite, text, PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
705 Label label= new Label(composite, SWT.LEFT );
706 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
707 gd.horizontalSpan= 2;
708 gd.heightHint= convertHeightInCharsToPixels(1) / 2;
709 label.setLayoutData(gd);
711 label= new Label(composite, SWT.LEFT);
712 label.setText("&Marker presentation options:");
713 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
714 gd.horizontalSpan= 2;
715 label.setLayoutData(gd);
717 Composite editorComposite= new Composite(composite, SWT.NONE);
718 layout= new GridLayout();
719 layout.numColumns= 2;
720 layout.marginHeight= 0;
721 layout.marginWidth= 0;
722 editorComposite.setLayout(layout);
723 gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
724 gd.horizontalSpan= 2;
725 editorComposite.setLayoutData(gd);
727 fProblemIndicationList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
728 gd= new GridData(GridData.FILL_BOTH);
729 gd.heightHint= convertHeightInCharsToPixels(5);
730 fProblemIndicationList.setLayoutData(gd);
732 Composite optionsComposite= new Composite(editorComposite, SWT.NONE);
733 layout= new GridLayout();
734 layout.marginHeight= 0;
735 layout.marginWidth= 0;
736 layout.numColumns= 2;
737 optionsComposite.setLayout(layout);
738 optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
740 fShowInTextCheckBox= new Button(optionsComposite, SWT.CHECK);
741 fShowInTextCheckBox.setText("Show in &text");
742 gd= new GridData(GridData.FILL_HORIZONTAL);
743 gd.horizontalAlignment= GridData.BEGINNING;
744 gd.horizontalSpan= 2;
745 fShowInTextCheckBox.setLayoutData(gd);
747 fShowInOverviewRulerCheckBox= new Button(optionsComposite, SWT.CHECK);
748 fShowInOverviewRulerCheckBox.setText("Show in overview &ruler");
749 gd= new GridData(GridData.FILL_HORIZONTAL);
750 gd.horizontalAlignment= GridData.BEGINNING;
751 gd.horizontalSpan= 2;
752 fShowInOverviewRulerCheckBox.setLayoutData(gd);
754 label= new Label(optionsComposite, SWT.LEFT);
755 label.setText("C&olor:");
757 gd.horizontalAlignment= GridData.BEGINNING;
758 label.setLayoutData(gd);
760 fProblemIndicationForegroundColorEditor= new ColorEditor(optionsComposite);
761 Button foregroundColorButton= fProblemIndicationForegroundColorEditor.getButton();
762 gd= new GridData(GridData.FILL_HORIZONTAL);
763 gd.horizontalAlignment= GridData.BEGINNING;
764 foregroundColorButton.setLayoutData(gd);
766 fProblemIndicationList.addSelectionListener(new SelectionListener() {
767 public void widgetDefaultSelected(SelectionEvent e) {
771 public void widgetSelected(SelectionEvent e) {
772 handleProblemIndicationColorListSelection();
776 fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
777 public void widgetDefaultSelected(SelectionEvent e) {
781 public void widgetSelected(SelectionEvent e) {
782 int i= fProblemIndicationList.getSelectionIndex();
783 String key= fProblemIndicationColorListModel[i][2];
784 fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
788 fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
789 public void widgetDefaultSelected(SelectionEvent e) {
793 public void widgetSelected(SelectionEvent e) {
794 int i= fProblemIndicationList.getSelectionIndex();
795 String key= fProblemIndicationColorListModel[i][3];
796 fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection());
800 foregroundColorButton.addSelectionListener(new SelectionListener() {
801 public void widgetDefaultSelected(SelectionEvent e) {
805 public void widgetSelected(SelectionEvent e) {
806 int i= fProblemIndicationList.getSelectionIndex();
807 String key= fProblemIndicationColorListModel[i][1];
808 PreferenceConverter.setValue(fOverlayStore, key, fProblemIndicationForegroundColorEditor.getColorValue());
815 // private Control createBehaviourPage(Composite parent) {
816 // Composite composite= new Composite(parent, SWT.NULL);
817 // GridLayout layout= new GridLayout(); layout.numColumns= 2;
818 // composite.setLayout(layout);
820 // String label= PHPUIMessages.getString("PHPEditorPreferencePage.wrapStrings"); //$NON-NLS-1$
821 // addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
823 // label= PHPUIMessages.getString("PHPEditorPreferencePage.smartHomeEnd"); //$NON-NLS-1$
824 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
826 // label= PHPUIMessages.getString("PHPEditorPreferencePage.smartPaste"); //$NON-NLS-1$
827 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
829 // label= PHPUIMessages.getString("PHPEditorPreferencePage.insertSpaceForTabs"); //$NON-NLS-1$
830 // addCheckBox(composite, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
832 // label= PHPUIMessages.getString("PHPEditorPreferencePage.closeStrings"); //$NON-NLS-1$
833 // addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 1);
835 // label= PHPUIMessages.getString("PHPEditorPreferencePage.closeBrackets"); //$NON-NLS-1$
836 // addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 1);
838 // label= PHPUIMessages.getString("PHPEditorPreferencePage.closeBraces"); //$NON-NLS-1$
839 // addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
841 // label= PHPUIMessages.getString("PHPEditorPreferencePage.closePHPDocs"); //$NON-NLS-1$
842 // Button button= addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
844 // label= PHPUIMessages.getString("PHPEditorPreferencePage.addPHPDocTags"); //$NON-NLS-1$
845 // fAddJavaDocTagsButton= addCheckBox(composite, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
846 // createDependency(button, fAddJavaDocTagsButton);
848 // label= PHPUIMessages.getString("PHPEditorPreferencePage.formatPHPDocs"); //$NON-NLS-1$
849 // addCheckBox(composite, label, PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
854 private static void indent(Control control) {
855 GridData gridData= new GridData();
856 gridData.horizontalIndent= 20;
857 control.setLayoutData(gridData);
860 private static void createDependency(final Button master, final Control slave) {
862 master.addSelectionListener(new SelectionListener() {
863 public void widgetSelected(SelectionEvent e) {
864 slave.setEnabled(master.getSelection());
867 public void widgetDefaultSelected(SelectionEvent e) {}
871 private Control createContentAssistPage(Composite parent) {
873 Composite contentAssistComposite= new Composite(parent, SWT.NULL);
874 GridLayout layout= new GridLayout(); layout.numColumns= 2;
875 contentAssistComposite.setLayout(layout);
877 String label= PHPUIMessages.getString("PHPEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$
878 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOINSERT, 0);
880 label= PHPUIMessages.getString("PHPEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$
881 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0);
883 label= PHPUIMessages.getString("PHPEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$
884 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0);
886 label= PHPUIMessages.getString("PHPEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$
887 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ADDIMPORT, 0);
889 label= PHPUIMessages.getString("PHPEditorPreferencePage.insertCompletion"); //$NON-NLS-1$
890 addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_INSERT_COMPLETION, 0);
892 label= PHPUIMessages.getString("PHPEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
893 Button button= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0);
895 label= PHPUIMessages.getString("PHPEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
896 fGuessMethodArgumentsButton= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0);
897 createDependency(button, fGuessMethodArgumentsButton);
899 label= PHPUIMessages.getString("PHPEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$
900 final Button autoactivation= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0);
902 label= PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$
903 fAutoInsertDelayText= addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true);
905 label= PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationTriggersForPHP"); //$NON-NLS-1$
906 fAutoInsertJavaTriggerText= addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, false);
908 label= PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationTriggersForPHPDoc"); //$NON-NLS-1$
909 fAutoInsertJavaDocTriggerText= addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, false);
911 label= PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForCompletionProposals"); //$NON-NLS-1$
912 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, 0);
914 label= PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForCompletionProposals"); //$NON-NLS-1$
915 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, 0);
917 label= PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForMethodParameters"); //$NON-NLS-1$
918 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, 0);
920 label= PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForMethodParameters"); //$NON-NLS-1$
921 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, 0);
923 label= PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForCompletionReplacement"); //$NON-NLS-1$
924 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, 0);
926 label= PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForCompletionReplacement"); //$NON-NLS-1$
927 addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, 0);
929 autoactivation.addSelectionListener(new SelectionAdapter(){
930 public void widgetSelected(SelectionEvent e) {
931 updateAutoactivationControls();
934 return contentAssistComposite;
938 * @see PreferencePage#createContents(Composite)
940 protected Control createContents(Composite parent) {
942 fOverlayStore.load();
943 fOverlayStore.start();
945 TabFolder folder= new TabFolder(parent, SWT.NONE);
946 folder.setLayout(new TabFolderLayout());
947 folder.setLayoutData(new GridData(GridData.FILL_BOTH));
949 TabItem item= new TabItem(folder, SWT.NONE);
950 item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.general")); //$NON-NLS-1$
951 item.setControl(createAppearancePage(folder));
953 item= new TabItem(folder, SWT.NONE);
954 item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.colors")); //$NON-NLS-1$
955 item.setControl(createSyntaxPage(folder));
957 item= new TabItem(folder, SWT.NONE);
958 item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.codeAssist")); //$NON-NLS-1$
959 item.setControl(createContentAssistPage(folder));
961 item= new TabItem(folder, SWT.NONE);
962 item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.problemIndicationTab.title")); //$NON-NLS-1$
963 item.setControl(createProblemIndicationPage(folder));
965 // item= new TabItem(folder, SWT.NONE);
966 // item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.behaviourTab.title")); //$NON-NLS-1$
967 // item.setControl(createBehaviourPage(folder));
969 // item= new TabItem(folder, SWT.NONE);
970 // item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.hoverTab.title")); //$NON-NLS-1$
971 // fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(fOverlayStore);
972 // item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
979 private void initialize() {
981 fFontEditor.setPreferenceStore(getPreferenceStore());
982 fFontEditor.setPreferencePage(this);
987 for (int i= 0; i < fSyntaxColorListModel.length; i++)
988 fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
990 fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
992 if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
993 fSyntaxColorList.select(0);
994 handleSyntaxColorListSelection();
999 for (int i= 0; i < fAppearanceColorListModel.length; i++)
1000 fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1002 fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1004 if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1005 fAppearanceColorList.select(0);
1006 handleAppearanceColorListSelection();
1011 for (int i= 0; i < fProblemIndicationColorListModel.length; i++)
1012 fProblemIndicationList.add(fProblemIndicationColorListModel[i][0]);
1014 fProblemIndicationList.getDisplay().asyncExec(new Runnable() {
1016 if (fProblemIndicationList != null && !fProblemIndicationList.isDisposed()) {
1017 fProblemIndicationList.select(0);
1018 handleProblemIndicationColorListSelection();
1024 private void initializeFields() {
1026 Iterator e= fColorButtons.keySet().iterator();
1027 while (e.hasNext()) {
1028 ColorEditor c= (ColorEditor) e.next();
1029 String key= (String) fColorButtons.get(c);
1030 RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
1031 c.setColorValue(rgb);
1034 e= fCheckBoxes.keySet().iterator();
1035 while (e.hasNext()) {
1036 Button b= (Button) e.next();
1037 String key= (String) fCheckBoxes.get(b);
1038 b.setSelection(fOverlayStore.getBoolean(key));
1041 e= fTextFields.keySet().iterator();
1042 while (e.hasNext()) {
1043 Text t= (Text) e.next();
1044 String key= (String) fTextFields.get(t);
1045 t.setText(fOverlayStore.getString(key));
1048 RGB rgb= PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1049 fBackgroundColorEditor.setColorValue(rgb);
1051 boolean default_= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1052 fBackgroundDefaultRadioButton.setSelection(default_);
1053 fBackgroundCustomRadioButton.setSelection(!default_);
1054 fBackgroundColorButton.setEnabled(!default_);
1056 // boolean closeJavaDocs= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1057 // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1059 boolean fillMethodArguments= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1060 fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1062 updateAutoactivationControls();
1064 // fJavaEditorHoverConfigurationBlock.initializeFields();
1067 private void updateAutoactivationControls() {
1068 boolean autoactivation= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1069 fAutoInsertDelayText.setEnabled(autoactivation);
1070 fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1071 fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1075 * @see PreferencePage#performOk()
1077 public boolean performOk() {
1078 fFontEditor.store();
1079 // fJavaEditorHoverConfigurationBlock.performOk();
1080 fOverlayStore.propagate();
1081 PHPeclipsePlugin.getDefault().savePluginPreferences();
1086 * @see PreferencePage#performDefaults()
1088 protected void performDefaults() {
1090 fFontEditor.loadDefault();
1092 fOverlayStore.loadDefaults();
1095 handleSyntaxColorListSelection();
1096 handleAppearanceColorListSelection();
1097 handleProblemIndicationColorListSelection();
1098 super.performDefaults();
1100 fPreviewViewer.invalidateTextPresentation();
1104 * @see DialogPage#dispose()
1106 public void dispose() {
1108 if (fJavaTextTools != null) {
1109 fJavaTextTools= null;
1112 fFontEditor.setPreferencePage(null);
1113 fFontEditor.setPreferenceStore(null);
1115 if (fOverlayStore != null) {
1116 fOverlayStore.stop();
1117 fOverlayStore= null;
1123 private Control addColorButton(Composite composite, String label, String key, int indentation) {
1125 Label labelControl= new Label(composite, SWT.NONE);
1126 labelControl.setText(label);
1128 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1129 gd.horizontalIndent= indentation;
1130 labelControl.setLayoutData(gd);
1132 ColorEditor editor= new ColorEditor(composite);
1133 Button button= editor.getButton();
1134 button.setData(editor);
1136 gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1137 button.setLayoutData(gd);
1138 button.addSelectionListener(fColorButtonListener);
1140 fColorButtons.put(editor, key);
1145 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1146 Button checkBox= new Button(parent, SWT.CHECK);
1147 checkBox.setText(label);
1149 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1150 gd.horizontalIndent= indentation;
1151 gd.horizontalSpan= 2;
1152 checkBox.setLayoutData(gd);
1153 checkBox.addSelectionListener(fCheckBoxListener);
1155 fCheckBoxes.put(checkBox, key);
1160 private Control addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1162 Label labelControl= new Label(composite, SWT.NONE);
1163 labelControl.setText(label);
1164 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1165 gd.horizontalIndent= indentation;
1166 labelControl.setLayoutData(gd);
1168 Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE);
1169 gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1170 gd.widthHint= convertWidthInCharsToPixels(textLimit + 1);
1171 textControl.setLayoutData(gd);
1172 textControl.setTextLimit(textLimit);
1173 fTextFields.put(textControl, key);
1175 fNumberFields.add(textControl);
1176 textControl.addModifyListener(fNumberFieldListener);
1178 textControl.addModifyListener(fTextFieldListener);
1184 private void addTextFontEditor(Composite parent, String label, String key) {
1186 Composite editorComposite= new Composite(parent, SWT.NONE);
1187 GridLayout layout= new GridLayout();
1188 layout.numColumns= 3;
1189 editorComposite.setLayout(layout);
1190 fFontEditor= new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
1191 fFontEditor.setChangeButtonText(PHPUIMessages.getString("PHPEditorPreferencePage.change")); //$NON-NLS-1$
1193 GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1194 gd.horizontalSpan= 2;
1195 editorComposite.setLayoutData(gd);
1198 private String loadPreviewContentFromFile(String filename) {
1200 String separator= System.getProperty("line.separator"); //$NON-NLS-1$
1201 StringBuffer buffer= new StringBuffer(512);
1202 BufferedReader reader= null;
1204 reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1205 while ((line= reader.readLine()) != null) {
1206 buffer.append(line);
1207 buffer.append(separator);
1209 } catch (IOException io) {
1210 PHPeclipsePlugin.log(io);
1212 if (reader != null) {
1213 try { reader.close(); } catch (IOException e) {}
1216 return buffer.toString();
1219 private void numberFieldChanged(Text textControl) {
1220 String number= textControl.getText();
1221 IStatus status= validatePositiveNumber(number);
1222 if (!status.matches(IStatus.ERROR))
1223 fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1224 updateStatus(status);
1227 private IStatus validatePositiveNumber(String number) {
1228 StatusInfo status= new StatusInfo();
1229 if (number.length() == 0) {
1230 status.setError(PHPUIMessages.getString("PHPEditorPreferencePage.empty_input")); //$NON-NLS-1$
1233 int value= Integer.parseInt(number);
1235 status.setError(PHPUIMessages.getFormattedString("PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1236 } catch (NumberFormatException e) {
1237 status.setError(PHPUIMessages.getFormattedString("PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1243 private void updateStatus(IStatus status) {
1244 if (!status.matches(IStatus.ERROR)) {
1245 for (int i= 0; i < fNumberFields.size(); i++) {
1246 Text text= (Text) fNumberFields.get(i);
1247 IStatus s= validatePositiveNumber(text.getText());
1248 status= StatusUtil.getMoreSevere(s, status);
1251 setValid(!status.matches(IStatus.ERROR));
1252 StatusUtil.applyToStatusLine(this, status);
1256 * @deprecated Inline to avoid reference to preference page
1258 public static boolean indicateQuixFixableProblems() {
1259 return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
1263 * @deprecated Inline to avoid reference to preference page
1265 // static public boolean synchronizeOutlineOnCursorMove() {
1266 // return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);