d0f927750eb65b8ea4ec6ba76a02837a1fd4fe96
[phpeclipse.git] /
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
7
8 Contributors:
9     IBM Corporation - Initial implementation
10 **********************************************************************/
11
12 package net.sourceforge.phpdt.internal.ui.preferences;
13
14 import java.io.BufferedReader;
15 import java.io.IOException;
16 import java.io.InputStreamReader;
17 import java.util.ArrayList;
18 import java.util.HashMap;
19 import java.util.Iterator;
20 import java.util.Map;
21
22 import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
23 import net.sourceforge.phpdt.internal.ui.dialog.StatusInfo;
24 import net.sourceforge.phpdt.internal.ui.dialog.StatusUtil;
25 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
26 import net.sourceforge.phpdt.ui.PreferenceConstants;
27 import net.sourceforge.phpdt.ui.text.JavaTextTools;
28 import net.sourceforge.phpeclipse.IPreferenceConstants;
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;
33 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
34
35 import org.eclipse.core.runtime.IStatus;
36 import org.eclipse.jface.preference.FileFieldEditor;
37 import org.eclipse.jface.preference.IPreferenceStore;
38 import org.eclipse.jface.preference.PreferenceConverter;
39 import org.eclipse.jface.preference.PreferencePage;
40 import org.eclipse.jface.resource.JFaceResources;
41 import org.eclipse.jface.text.Document;
42 import org.eclipse.jface.text.IDocument;
43 import org.eclipse.jface.text.IDocumentPartitioner;
44 import org.eclipse.jface.text.source.ISourceViewer;
45 import org.eclipse.jface.text.source.SourceViewer;
46 import org.eclipse.jface.util.IPropertyChangeListener;
47 import org.eclipse.jface.util.PropertyChangeEvent;
48 import org.eclipse.swt.SWT;
49 import org.eclipse.swt.custom.StyledText;
50 import org.eclipse.swt.events.ModifyEvent;
51 import org.eclipse.swt.events.ModifyListener;
52 import org.eclipse.swt.events.SelectionAdapter;
53 import org.eclipse.swt.events.SelectionEvent;
54 import org.eclipse.swt.events.SelectionListener;
55 import org.eclipse.swt.graphics.Color;
56 import org.eclipse.swt.graphics.RGB;
57 import org.eclipse.swt.layout.GridData;
58 import org.eclipse.swt.layout.GridLayout;
59 import org.eclipse.swt.layout.RowLayout;
60 import org.eclipse.swt.widgets.Button;
61 import org.eclipse.swt.widgets.Composite;
62 import org.eclipse.swt.widgets.Control;
63 import org.eclipse.swt.widgets.Display;
64 import org.eclipse.swt.widgets.Group;
65 import org.eclipse.swt.widgets.Label;
66 import org.eclipse.swt.widgets.List;
67 import org.eclipse.swt.widgets.TabFolder;
68 import org.eclipse.swt.widgets.TabItem;
69 import org.eclipse.swt.widgets.Text;
70 import org.eclipse.ui.IWorkbench;
71 import org.eclipse.ui.IWorkbenchPreferencePage;
72 import org.eclipse.ui.texteditor.AbstractTextEditor;
73 import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
74
75 /*
76  * The page for setting the editor options.
77  */
78 public class PHPEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
79
80   private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
81
82   public final OverlayPreferenceStore.OverlayKey[] fKeys =
83     new OverlayPreferenceStore.OverlayKey[] {
84       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOREGROUND_COLOR),
85       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR),
86       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BACKGROUND_COLOR),
87       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR),
88       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH),
89       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR),
90       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD),
91       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR),
92       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD),
93       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR),
94       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD),
95       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR),
96       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD),
97       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR),
98       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD),
99       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR),
100       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD),
101       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_TYPE_COLOR),
102       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD),
103       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR),
104       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD),
105       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR),
106       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD),
107       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR),
108       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD),
109       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD),
110       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),
113       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR),
114       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD),
115       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR),
116       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS),
117       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CURRENT_LINE_COLOR),
118       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CURRENT_LINE),
119       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR),
120       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN),
121       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PRINT_MARGIN),
122       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR),
123       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINKED_POSITION_COLOR),
124       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR),
125       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR),
126       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PROBLEM_INDICATION),
127       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR),
128       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WARNING_INDICATION),
129       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR),
130       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION),
131       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR),
132       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BOOKMARK_INDICATION),
133       new OverlayPreferenceStore.OverlayKey(
134         OverlayPreferenceStore.STRING,
135         PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR),
136       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION),
137       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR),
138       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_UNKNOWN_INDICATION),
139       new OverlayPreferenceStore.OverlayKey(
140         OverlayPreferenceStore.BOOLEAN,
141         PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER),
142       new OverlayPreferenceStore.OverlayKey(
143         OverlayPreferenceStore.BOOLEAN,
144         PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER),
145       new OverlayPreferenceStore.OverlayKey(
146         OverlayPreferenceStore.BOOLEAN,
147         PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER),
148       new OverlayPreferenceStore.OverlayKey(
149         OverlayPreferenceStore.BOOLEAN,
150         PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER),
151       new OverlayPreferenceStore.OverlayKey(
152         OverlayPreferenceStore.BOOLEAN,
153         PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER),
154       new OverlayPreferenceStore.OverlayKey(
155         OverlayPreferenceStore.BOOLEAN,
156         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),
159       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS),
160       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_OVERVIEW_RULER),
161       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR),
162       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_LINE_NUMBER_RULER),
163       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SPACES_FOR_TABS),
164       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOACTIVATION),
165       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY),
166       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT),
167       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND),
168       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND),
169       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND),
170       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND),
171       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND),
172       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND),
173       new OverlayPreferenceStore.OverlayKey(
174         OverlayPreferenceStore.STRING,
175         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA),
176       new OverlayPreferenceStore.OverlayKey(
177         OverlayPreferenceStore.STRING,
178         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC),
179       new OverlayPreferenceStore.OverlayKey(
180         OverlayPreferenceStore.STRING,
181         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_HTML),
182       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS),
183       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS),
184       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_CASE_SENSITIVITY),
185       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT),
186       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_INSERT_COMPLETION),
187       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES),
188       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS),
189       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE),
190       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS),
191       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS),
192       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES),
193       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_JAVADOCS),
194       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS),
195       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS),
196       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FORMAT_JAVADOCS),
197       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END),
198       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_DEFAULT_HOVER),
199       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_NONE_HOVER),
200       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_HOVER),
201       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SHIFT_HOVER),
202       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
203       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_ALT_HOVER),
204       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_ALT_SHIFT_HOVER),
205       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
206       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_ALT_SHIFT_HOVER),
207       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_USERDEF_XMLFILE),
208       };
209
210   private final String[][] fSyntaxColorListModel = new String[][] { { PHPUIMessages.getString("PHPEditorPreferencePage.multiLineComment"), PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$
211     {
212       PHPUIMessages.getString("PHPEditorPreferencePage.singleLineComment"), PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$
213     {
214       PHPUIMessages.getString("PHPEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$
215     {
216       PHPUIMessages.getString("PHPEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR }, //$NON-NLS-1$
217     {
218       PHPUIMessages.getString("PHPEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR }, //$NON-NLS-1$
219     {
220       PHPUIMessages.getString("PHPEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR }, //$NON-NLS-1$
221     {
222       PHPUIMessages.getString("PHPEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR }, //$NON-NLS-1$
223     {
224       PHPUIMessages.getString("PHPEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$
225     {
226       PHPUIMessages.getString("PHPEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
227     {
228       PHPUIMessages.getString("PHPEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$
229     {
230       PHPUIMessages.getString("PHPEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD }, //$NON-NLS-1$
231     {
232       PHPUIMessages.getString("PHPEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$
233     {
234       PHPUIMessages.getString("PHPEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
235   };
236
237   private final String[][] fAppearanceColorListModel = new String[][] { { PHPUIMessages.getString("PHPEditorPreferencePage.lineNumberForegroundColor"), PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR }, //$NON-NLS-1$
238     {
239       PHPUIMessages.getString("PHPEditorPreferencePage.matchingBracketsHighlightColor2"), PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR }, //$NON-NLS-1$
240     {
241       PHPUIMessages.getString("PHPEditorPreferencePage.currentLineHighlighColor"), PreferenceConstants.EDITOR_CURRENT_LINE_COLOR }, //$NON-NLS-1$
242     {
243       PHPUIMessages.getString("PHPEditorPreferencePage.printMarginColor2"), PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR }, //$NON-NLS-1$
244     {
245       PHPUIMessages.getString("PHPEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR }, //$NON-NLS-1$
246     {
247       PHPUIMessages.getString("PHPEditorPreferencePage.linkedPositionColor2"), PreferenceConstants.EDITOR_LINKED_POSITION_COLOR }, //$NON-NLS-1$
248     {
249       PHPUIMessages.getString("PHPEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$
250   };
251
252   private final String[][] fProblemIndicationColorListModel =
253     new String[][] {
254       {
255         "Errors",
256         PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR,
257         PreferenceConstants.EDITOR_PROBLEM_INDICATION,
258         PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER },
259       {
260       "Warnings",
261         PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR,
262         PreferenceConstants.EDITOR_WARNING_INDICATION,
263         PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER },
264         {
265       "Tasks",
266         PreferenceConstants.EDITOR_TASK_INDICATION_COLOR,
267         PreferenceConstants.EDITOR_TASK_INDICATION,
268         PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER },
269         {
270       "Search Results",
271         PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR,
272         PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION,
273         PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER },
274         {
275       "Bookmarks",
276         PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR,
277         PreferenceConstants.EDITOR_BOOKMARK_INDICATION,
278         PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER },
279         {
280       "Others",
281         PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR,
282         PreferenceConstants.EDITOR_UNKNOWN_INDICATION,
283         PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER }
284   };
285
286   private OverlayPreferenceStore fOverlayStore;
287   private JavaTextTools fJavaTextTools;
288   //    private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
289
290   private Map fColorButtons = new HashMap();
291   private SelectionListener fColorButtonListener = new SelectionListener() {
292     public void widgetDefaultSelected(SelectionEvent e) {
293     }
294     public void widgetSelected(SelectionEvent e) {
295       ColorEditor editor = (ColorEditor) e.widget.getData();
296       PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue());
297     }
298   };
299
300   private Map fCheckBoxes = new HashMap();
301   private SelectionListener fCheckBoxListener = new SelectionListener() {
302     public void widgetDefaultSelected(SelectionEvent e) {
303     }
304     public void widgetSelected(SelectionEvent e) {
305       Button button = (Button) e.widget;
306       fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
307     }
308   };
309
310   private Map fTextFields = new HashMap();
311   private ModifyListener fTextFieldListener = new ModifyListener() {
312     public void modifyText(ModifyEvent e) {
313       Text text = (Text) e.widget;
314       fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
315     }
316   };
317
318   private ArrayList fNumberFields = new ArrayList();
319   private ModifyListener fNumberFieldListener = new ModifyListener() {
320     public void modifyText(ModifyEvent e) {
321       numberFieldChanged((Text) e.widget);
322     }
323   };
324
325   private WorkbenchChainedTextFontFieldEditor fFontEditor;
326   private List fSyntaxColorList;
327   private List fAppearanceColorList;
328   private List fProblemIndicationList;
329   private ColorEditor fSyntaxForegroundColorEditor;
330   private ColorEditor fAppearanceForegroundColorEditor;
331   private ColorEditor fProblemIndicationForegroundColorEditor;
332   private ColorEditor fBackgroundColorEditor;
333   private Button fBackgroundDefaultRadioButton;
334   private Button fBackgroundCustomRadioButton;
335   private Button fBackgroundColorButton;
336   private Button fBoldCheckBox;
337   // private Button fAddJavaDocTagsButton;
338   private Button fGuessMethodArgumentsButton;
339   private SourceViewer fPreviewViewer;
340   private Color fBackgroundColor;
341   private Control fAutoInsertDelayText;
342   private Control fAutoInsertJavaTriggerText;
343   private Control fAutoInsertJavaDocTriggerText;
344   private Control fAutoInsertHTMLTriggerText;
345   private Button fShowInTextCheckBox;
346   private Button fShowInOverviewRulerCheckBox;
347   // private FileFieldEditor fUserDefinedPHPSyntaxFileFFE;
348
349   public PHPEditorPreferencePage() {
350     setDescription(PHPUIMessages.getString("PHPEditorPreferencePage.description")); //$NON-NLS-1$
351     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
352     fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
353   }
354
355   /*
356    * @see IWorkbenchPreferencePage#init()
357    */
358   public void init(IWorkbench workbench) {
359   }
360
361   /*
362    * @see PreferencePage#createControl(Composite)
363    */
364   public void createControl(Composite parent) {
365     super.createControl(parent);
366     //  WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
367   }
368
369   private void handleSyntaxColorListSelection() {
370     int i = fSyntaxColorList.getSelectionIndex();
371     String key = fSyntaxColorListModel[i][1];
372     RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
373     fSyntaxForegroundColorEditor.setColorValue(rgb);
374     fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
375   }
376
377   private void handleAppearanceColorListSelection() {
378     int i = fAppearanceColorList.getSelectionIndex();
379     String key = fAppearanceColorListModel[i][1];
380     RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
381     fAppearanceForegroundColorEditor.setColorValue(rgb);
382   }
383
384   private void handleProblemIndicationColorListSelection() {
385     int i = fProblemIndicationList.getSelectionIndex();
386
387     String key = fProblemIndicationColorListModel[i][1];
388     RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
389     fProblemIndicationForegroundColorEditor.setColorValue(rgb);
390
391     key = fProblemIndicationColorListModel[i][2];
392     fShowInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
393
394     key = fProblemIndicationColorListModel[i][3];
395     fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
396   }
397
398   private Control createSyntaxPage(Composite parent) {
399
400     Composite colorComposite = new Composite(parent, SWT.NULL);
401     colorComposite.setLayout(new GridLayout());
402
403     Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
404     backgroundComposite.setLayout(new RowLayout());
405     backgroundComposite.setText(PHPUIMessages.getString("PHPEditorPreferencePage.backgroundColor")); //$NON-NLS-1$
406
407     SelectionListener backgroundSelectionListener = new SelectionListener() {
408       public void widgetSelected(SelectionEvent e) {
409         boolean custom = fBackgroundCustomRadioButton.getSelection();
410         fBackgroundColorButton.setEnabled(custom);
411         fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
412       }
413       public void widgetDefaultSelected(SelectionEvent e) {
414       }
415     };
416
417     fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
418     fBackgroundDefaultRadioButton.setText(PHPUIMessages.getString("PHPEditorPreferencePage.systemDefault")); //$NON-NLS-1$
419     fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
420
421     fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
422     fBackgroundCustomRadioButton.setText(PHPUIMessages.getString("PHPEditorPreferencePage.custom")); //$NON-NLS-1$
423     fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
424
425     fBackgroundColorEditor = new ColorEditor(backgroundComposite);
426     fBackgroundColorButton = fBackgroundColorEditor.getButton();
427
428     //    fUserDefinedPHPSyntaxFileFFE =
429     //      new FileFieldEditor(
430     //        IPreferenceConstants.PHP_USERDEF_XMLFILE,
431     //        PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntaxdialog"),
432     //        colorComposite);
433     //    fUserDefinedPHPSyntaxFileFFE.setPreferencePage(this);
434     //    fUserDefinedPHPSyntaxFileFFE.setPreferenceStore(getPreferenceStore());
435     //    fUserDefinedPHPSyntaxFileFFE.load();
436
437     Label label = new Label(colorComposite, SWT.LEFT);
438     label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.foreground")); //$NON-NLS-1$
439     label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
440
441     Composite editorComposite = new Composite(colorComposite, SWT.NONE);
442     GridLayout layout = new GridLayout();
443     layout.numColumns = 2;
444     layout.marginHeight = 0;
445     layout.marginWidth = 0;
446     editorComposite.setLayout(layout);
447     GridData gd = new GridData(GridData.FILL_BOTH);
448     editorComposite.setLayoutData(gd);
449
450     fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
451     gd = new GridData(GridData.FILL_BOTH);
452     gd.heightHint = convertHeightInCharsToPixels(5);
453     fSyntaxColorList.setLayoutData(gd);
454
455     Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
456     layout = new GridLayout();
457     layout.marginHeight = 0;
458     layout.marginWidth = 0;
459     layout.numColumns = 2;
460     stylesComposite.setLayout(layout);
461     stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
462
463     label = new Label(stylesComposite, SWT.LEFT);
464     label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
465     gd = new GridData();
466     gd.horizontalAlignment = GridData.BEGINNING;
467     label.setLayoutData(gd);
468
469     fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
470     Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
471     gd = new GridData(GridData.FILL_HORIZONTAL);
472     gd.horizontalAlignment = GridData.BEGINNING;
473     foregroundColorButton.setLayoutData(gd);
474
475     fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
476     fBoldCheckBox.setText(PHPUIMessages.getString("PHPEditorPreferencePage.bold")); //$NON-NLS-1$
477     gd = new GridData(GridData.FILL_HORIZONTAL);
478     gd.horizontalAlignment = GridData.BEGINNING;
479     gd.horizontalSpan = 2;
480     fBoldCheckBox.setLayoutData(gd);
481
482     label = new Label(colorComposite, SWT.LEFT);
483     label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.preview")); //$NON-NLS-1$
484     label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
485
486     Control previewer = createPreviewer(colorComposite);
487     gd = new GridData(GridData.FILL_BOTH);
488     gd.widthHint = convertWidthInCharsToPixels(20);
489     gd.heightHint = convertHeightInCharsToPixels(5);
490     previewer.setLayoutData(gd);
491
492     fSyntaxColorList.addSelectionListener(new SelectionListener() {
493       public void widgetDefaultSelected(SelectionEvent e) {
494         // do nothing
495       }
496       public void widgetSelected(SelectionEvent e) {
497         handleSyntaxColorListSelection();
498       }
499     });
500
501     foregroundColorButton.addSelectionListener(new SelectionListener() {
502       public void widgetDefaultSelected(SelectionEvent e) {
503         // do nothing
504       }
505       public void widgetSelected(SelectionEvent e) {
506         int i = fSyntaxColorList.getSelectionIndex();
507         String key = fSyntaxColorListModel[i][1];
508
509         PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
510       }
511     });
512
513     fBackgroundColorButton.addSelectionListener(new SelectionListener() {
514       public void widgetDefaultSelected(SelectionEvent e) {
515         // do nothing
516       }
517       public void widgetSelected(SelectionEvent e) {
518         PreferenceConverter.setValue(
519           fOverlayStore,
520           PreferenceConstants.EDITOR_BACKGROUND_COLOR,
521           fBackgroundColorEditor.getColorValue());
522       }
523     });
524
525     fBoldCheckBox.addSelectionListener(new SelectionListener() {
526       public void widgetDefaultSelected(SelectionEvent e) {
527         // do nothing
528       }
529       public void widgetSelected(SelectionEvent e) {
530         int i = fSyntaxColorList.getSelectionIndex();
531         String key = fSyntaxColorListModel[i][1];
532         fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
533       }
534     });
535
536     return colorComposite;
537   }
538
539   private Control createPreviewer(Composite parent) {
540
541     fJavaTextTools = new JavaTextTools(fOverlayStore);
542
543     fPreviewViewer = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
544     fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools, null));
545     fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
546     fPreviewViewer.setEditable(false);
547
548     initializeViewerColors(fPreviewViewer);
549
550     String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
551     IDocument document = new Document(content);
552     PHPEditorEnvironment pe;
553     IDocumentPartitioner partitioner = fJavaTextTools.createDocumentPartitioner();
554     partitioner.connect(document);
555     document.setDocumentPartitioner(partitioner);
556
557     fPreviewViewer.setDocument(document);
558
559     fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() {
560       public void propertyChange(PropertyChangeEvent event) {
561         String p = event.getProperty();
562         if (p.equals(PreferenceConstants.EDITOR_BACKGROUND_COLOR)
563           || p.equals(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)) {
564           initializeViewerColors(fPreviewViewer);
565         }
566
567         fPreviewViewer.invalidateTextPresentation();
568       }
569     });
570
571     return fPreviewViewer.getControl();
572   }
573
574   /**
575    * Initializes the given viewer's colors.
576    * 
577    * @param viewer the viewer to be initialized
578    */
579   private void initializeViewerColors(ISourceViewer viewer) {
580
581     IPreferenceStore store = fOverlayStore;
582     if (store != null) {
583
584       StyledText styledText = viewer.getTextWidget();
585
586       // ---------- background color ----------------------
587       Color color =
588         store.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)
589           ? null
590           : createColor(store, PreferenceConstants.EDITOR_BACKGROUND_COLOR, styledText.getDisplay());
591       styledText.setBackground(color);
592
593       if (fBackgroundColor != null)
594         fBackgroundColor.dispose();
595
596       fBackgroundColor = color;
597     }
598   }
599
600   /**
601    * Creates a color from the information stored in the given preference store.
602    * Returns <code>null</code> if there is no such information available.
603    */
604   private Color createColor(IPreferenceStore store, String key, Display display) {
605
606     RGB rgb = null;
607
608     if (store.contains(key)) {
609
610       if (store.isDefault(key))
611         rgb = PreferenceConverter.getDefaultColor(store, key);
612       else
613         rgb = PreferenceConverter.getColor(store, key);
614
615       if (rgb != null)
616         return new Color(display, rgb);
617     }
618
619     return null;
620   }
621
622   // sets enabled flag for a control and all its sub-tree
623   private static void setEnabled(Control control, boolean enable) {
624     control.setEnabled(enable);
625     if (control instanceof Composite) {
626       Composite composite = (Composite) control;
627       Control[] children = composite.getChildren();
628       for (int i = 0; i < children.length; i++)
629         setEnabled(children[i], enable);
630     }
631   }
632
633   private Control createAppearancePage(Composite parent) {
634
635     Composite appearanceComposite = new Composite(parent, SWT.NONE);
636     GridLayout layout = new GridLayout();
637     layout.numColumns = 2;
638     appearanceComposite.setLayout(layout);
639
640     String label = PHPUIMessages.getString("PHPEditorPreferencePage.textFont"); //$NON-NLS-1$
641     addTextFontEditor(appearanceComposite, label, AbstractTextEditor.PREFERENCE_FONT);
642
643     label = PHPUIMessages.getString("PHPEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
644     addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
645
646     label = PHPUIMessages.getString("PHPEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
647     addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
648
649     //  label= PHPUIMessages.getString("PHPEditorPreferencePage.synchronizeOnCursor"); //$NON-NLS-1$
650     //  addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, 0);
651
652     label = PHPUIMessages.getString("PHPEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
653     addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
654
655     label = PHPUIMessages.getString("PHPEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
656     addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
657
658     label = PHPUIMessages.getString("PHPEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
659     addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
660
661     label = PHPUIMessages.getString("PHPEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
662     addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_CURRENT_LINE, 0);
663
664     label = PHPUIMessages.getString("PHPEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
665     addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_PRINT_MARGIN, 0);
666
667     Label l = new Label(appearanceComposite, SWT.LEFT);
668     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
669     gd.horizontalSpan = 2;
670     gd.heightHint = convertHeightInCharsToPixels(1) / 2;
671     l.setLayoutData(gd);
672
673     l = new Label(appearanceComposite, SWT.LEFT);
674     l.setText(PHPUIMessages.getString("PHPEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
675     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
676     gd.horizontalSpan = 2;
677     l.setLayoutData(gd);
678
679     Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
680     layout = new GridLayout();
681     layout.numColumns = 2;
682     layout.marginHeight = 0;
683     layout.marginWidth = 0;
684     editorComposite.setLayout(layout);
685     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
686     gd.horizontalSpan = 2;
687     editorComposite.setLayoutData(gd);
688
689     fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
690     gd = new GridData(GridData.FILL_BOTH);
691     gd.heightHint = convertHeightInCharsToPixels(5);
692     fAppearanceColorList.setLayoutData(gd);
693
694     Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
695     layout = new GridLayout();
696     layout.marginHeight = 0;
697     layout.marginWidth = 0;
698     layout.numColumns = 2;
699     stylesComposite.setLayout(layout);
700     stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
701
702     l = new Label(stylesComposite, SWT.LEFT);
703     l.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
704     gd = new GridData();
705     gd.horizontalAlignment = GridData.BEGINNING;
706     l.setLayoutData(gd);
707
708     fAppearanceForegroundColorEditor = new ColorEditor(stylesComposite);
709     Button foregroundColorButton = fAppearanceForegroundColorEditor.getButton();
710     gd = new GridData(GridData.FILL_HORIZONTAL);
711     gd.horizontalAlignment = GridData.BEGINNING;
712     foregroundColorButton.setLayoutData(gd);
713
714     fAppearanceColorList.addSelectionListener(new SelectionListener() {
715       public void widgetDefaultSelected(SelectionEvent e) {
716         // do nothing
717       }
718       public void widgetSelected(SelectionEvent e) {
719         handleAppearanceColorListSelection();
720       }
721     });
722     foregroundColorButton.addSelectionListener(new SelectionListener() {
723       public void widgetDefaultSelected(SelectionEvent e) {
724         // do nothing
725       }
726       public void widgetSelected(SelectionEvent e) {
727         int i = fAppearanceColorList.getSelectionIndex();
728         String key = fAppearanceColorListModel[i][1];
729
730         PreferenceConverter.setValue(fOverlayStore, key, fAppearanceForegroundColorEditor.getColorValue());
731       }
732     });
733     return appearanceComposite;
734   }
735
736   private Control createProblemIndicationPage(Composite parent) {
737     Composite composite = new Composite(parent, SWT.NULL);
738     GridLayout layout = new GridLayout();
739     layout.numColumns = 2;
740     composite.setLayout(layout);
741
742     String text = "Analyse &problems while typing";
743     addCheckBox(composite, text, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
744
745     text = PHPUIMessages.getString("PHPEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
746     addCheckBox(composite, text, PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
747
748     Label label = new Label(composite, SWT.LEFT);
749     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
750     gd.horizontalSpan = 2;
751     gd.heightHint = convertHeightInCharsToPixels(1) / 2;
752     label.setLayoutData(gd);
753
754     label = new Label(composite, SWT.LEFT);
755     label.setText("&Marker presentation options:");
756     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
757     gd.horizontalSpan = 2;
758     label.setLayoutData(gd);
759
760     Composite editorComposite = new Composite(composite, SWT.NONE);
761     layout = new GridLayout();
762     layout.numColumns = 2;
763     layout.marginHeight = 0;
764     layout.marginWidth = 0;
765     editorComposite.setLayout(layout);
766     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
767     gd.horizontalSpan = 2;
768     editorComposite.setLayoutData(gd);
769
770     fProblemIndicationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
771     gd = new GridData(GridData.FILL_BOTH);
772     gd.heightHint = convertHeightInCharsToPixels(5);
773     fProblemIndicationList.setLayoutData(gd);
774
775     Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
776     layout = new GridLayout();
777     layout.marginHeight = 0;
778     layout.marginWidth = 0;
779     layout.numColumns = 2;
780     optionsComposite.setLayout(layout);
781     optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
782
783     fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
784     fShowInTextCheckBox.setText("Show in &text");
785     gd = new GridData(GridData.FILL_HORIZONTAL);
786     gd.horizontalAlignment = GridData.BEGINNING;
787     gd.horizontalSpan = 2;
788     fShowInTextCheckBox.setLayoutData(gd);
789
790     fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
791     fShowInOverviewRulerCheckBox.setText("Show in overview &ruler");
792     gd = new GridData(GridData.FILL_HORIZONTAL);
793     gd.horizontalAlignment = GridData.BEGINNING;
794     gd.horizontalSpan = 2;
795     fShowInOverviewRulerCheckBox.setLayoutData(gd);
796
797     label = new Label(optionsComposite, SWT.LEFT);
798     label.setText("C&olor:");
799     gd = new GridData();
800     gd.horizontalAlignment = GridData.BEGINNING;
801     label.setLayoutData(gd);
802
803     fProblemIndicationForegroundColorEditor = new ColorEditor(optionsComposite);
804     Button foregroundColorButton = fProblemIndicationForegroundColorEditor.getButton();
805     gd = new GridData(GridData.FILL_HORIZONTAL);
806     gd.horizontalAlignment = GridData.BEGINNING;
807     foregroundColorButton.setLayoutData(gd);
808
809     fProblemIndicationList.addSelectionListener(new SelectionListener() {
810       public void widgetDefaultSelected(SelectionEvent e) {
811         // do nothing
812       }
813
814       public void widgetSelected(SelectionEvent e) {
815         handleProblemIndicationColorListSelection();
816       }
817     });
818
819     fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
820       public void widgetDefaultSelected(SelectionEvent e) {
821         // do nothing
822       }
823
824       public void widgetSelected(SelectionEvent e) {
825         int i = fProblemIndicationList.getSelectionIndex();
826         String key = fProblemIndicationColorListModel[i][2];
827         fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
828       }
829     });
830
831     fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
832       public void widgetDefaultSelected(SelectionEvent e) {
833         // do nothing
834       }
835
836       public void widgetSelected(SelectionEvent e) {
837         int i = fProblemIndicationList.getSelectionIndex();
838         String key = fProblemIndicationColorListModel[i][3];
839         fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection());
840       }
841     });
842
843     foregroundColorButton.addSelectionListener(new SelectionListener() {
844       public void widgetDefaultSelected(SelectionEvent e) {
845         // do nothing
846       }
847
848       public void widgetSelected(SelectionEvent e) {
849         int i = fProblemIndicationList.getSelectionIndex();
850         String key = fProblemIndicationColorListModel[i][1];
851         PreferenceConverter.setValue(fOverlayStore, key, fProblemIndicationForegroundColorEditor.getColorValue());
852       }
853     });
854
855     return composite;
856   }
857
858   //    private Control createBehaviourPage(Composite parent) {
859   //            Composite composite= new Composite(parent, SWT.NULL);
860   //            GridLayout layout= new GridLayout(); layout.numColumns= 2;
861   //            composite.setLayout(layout);
862   //
863   //            String label= PHPUIMessages.getString("PHPEditorPreferencePage.wrapStrings"); //$NON-NLS-1$
864   //            addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
865   //            
866   //            label= PHPUIMessages.getString("PHPEditorPreferencePage.smartHomeEnd"); //$NON-NLS-1$
867   //            addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
868   //
869   //            label= PHPUIMessages.getString("PHPEditorPreferencePage.smartPaste"); //$NON-NLS-1$
870   //            addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
871   //
872   //            label= PHPUIMessages.getString("PHPEditorPreferencePage.insertSpaceForTabs"); //$NON-NLS-1$
873   //            addCheckBox(composite, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
874   //
875   //            label= PHPUIMessages.getString("PHPEditorPreferencePage.closeStrings"); //$NON-NLS-1$
876   //            addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 1);
877   //
878   //            label= PHPUIMessages.getString("PHPEditorPreferencePage.closeBrackets"); //$NON-NLS-1$
879   //            addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 1);
880   //
881   //            label= PHPUIMessages.getString("PHPEditorPreferencePage.closeBraces"); //$NON-NLS-1$
882   //            addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
883   //
884   //            label= PHPUIMessages.getString("PHPEditorPreferencePage.closePHPDocs"); //$NON-NLS-1$
885   //            Button button= addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
886   //
887   //            label= PHPUIMessages.getString("PHPEditorPreferencePage.addPHPDocTags"); //$NON-NLS-1$
888   //            fAddJavaDocTagsButton= addCheckBox(composite, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
889   //            createDependency(button, fAddJavaDocTagsButton);
890   //
891   //            label= PHPUIMessages.getString("PHPEditorPreferencePage.formatPHPDocs"); //$NON-NLS-1$
892   //            addCheckBox(composite, label, PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
893   //    
894   //            return composite;
895   //    }
896
897   private static void indent(Control control) {
898     GridData gridData = new GridData();
899     gridData.horizontalIndent = 20;
900     control.setLayoutData(gridData);
901   }
902
903   private static void createDependency(final Button master, final Control slave) {
904     indent(slave);
905     master.addSelectionListener(new SelectionListener() {
906       public void widgetSelected(SelectionEvent e) {
907         slave.setEnabled(master.getSelection());
908       }
909
910       public void widgetDefaultSelected(SelectionEvent e) {
911       }
912     });
913   }
914
915   private Control createContentAssistPage(Composite parent) {
916
917     Composite contentAssistComposite = new Composite(parent, SWT.NULL);
918     GridLayout layout = new GridLayout();
919     layout.numColumns = 2;
920     contentAssistComposite.setLayout(layout);
921
922     String label = PHPUIMessages.getString("PHPEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$
923     addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOINSERT, 0);
924
925     label = PHPUIMessages.getString("PHPEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$
926     addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0);
927
928     label = PHPUIMessages.getString("PHPEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$
929     addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0);
930
931     label = PHPUIMessages.getString("PHPEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$
932     addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ADDIMPORT, 0);
933
934     label = PHPUIMessages.getString("PHPEditorPreferencePage.insertCompletion"); //$NON-NLS-1$
935     addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_INSERT_COMPLETION, 0);
936
937     label = PHPUIMessages.getString("PHPEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
938     Button button = addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0);
939
940     label = PHPUIMessages.getString("PHPEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
941     fGuessMethodArgumentsButton =
942       addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0);
943     createDependency(button, fGuessMethodArgumentsButton);
944
945     label = PHPUIMessages.getString("PHPEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$
946     final Button autoactivation = addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0);
947
948     label = PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$
949     fAutoInsertDelayText =
950       addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true);
951
952     label = PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationTriggersForPHP"); //$NON-NLS-1$
953     fAutoInsertJavaTriggerText =
954       addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, false);
955
956     label = PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationTriggersForPHPDoc"); //$NON-NLS-1$
957     fAutoInsertJavaDocTriggerText =
958       addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, false);
959
960     label = PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationTriggersForHTML"); //$NON-NLS-1$
961     fAutoInsertHTMLTriggerText =
962       addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_HTML, 4, 0, false);
963
964     label = PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForCompletionProposals"); //$NON-NLS-1$
965     addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, 0);
966
967     label = PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForCompletionProposals"); //$NON-NLS-1$
968     addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, 0);
969
970     //    label = PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForMethodParameters"); //$NON-NLS-1$
971     //    addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, 0);
972     //
973     //    label = PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForMethodParameters"); //$NON-NLS-1$
974     //    addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, 0);
975
976     //    label = PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForCompletionReplacement"); //$NON-NLS-1$
977     //    addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, 0);
978     //
979     //    label = PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForCompletionReplacement"); //$NON-NLS-1$
980     //    addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, 0);
981
982     autoactivation.addSelectionListener(new SelectionAdapter() {
983       public void widgetSelected(SelectionEvent e) {
984         updateAutoactivationControls();
985       }
986     });
987     return contentAssistComposite;
988   }
989
990   /*
991    * @see PreferencePage#createContents(Composite)
992    */
993   protected Control createContents(Composite parent) {
994
995     fOverlayStore.load();
996     fOverlayStore.start();
997
998     TabFolder folder = new TabFolder(parent, SWT.NONE);
999     folder.setLayout(new TabFolderLayout());
1000     folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1001
1002     TabItem item = new TabItem(folder, SWT.NONE);
1003     item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.general")); //$NON-NLS-1$
1004     item.setControl(createAppearancePage(folder));
1005
1006     item = new TabItem(folder, SWT.NONE);
1007     item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.colors")); //$NON-NLS-1$
1008     item.setControl(createSyntaxPage(folder));
1009
1010     item = new TabItem(folder, SWT.NONE);
1011     item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.codeAssist")); //$NON-NLS-1$
1012     item.setControl(createContentAssistPage(folder));
1013
1014     item = new TabItem(folder, SWT.NONE);
1015     item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.problemIndicationTab.title")); //$NON-NLS-1$
1016     item.setControl(createProblemIndicationPage(folder));
1017
1018     //          item= new TabItem(folder, SWT.NONE);
1019     //          item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.behaviourTab.title")); //$NON-NLS-1$
1020     //          item.setControl(createBehaviourPage(folder));
1021
1022     //          item= new TabItem(folder, SWT.NONE);
1023     //          item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.hoverTab.title")); //$NON-NLS-1$
1024     //          fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(fOverlayStore);
1025     //          item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1026
1027     initialize();
1028
1029     return folder;
1030   }
1031
1032   private void initialize() {
1033
1034     fFontEditor.setPreferenceStore(getPreferenceStore());
1035     fFontEditor.setPreferencePage(this);
1036     fFontEditor.load();
1037
1038     initializeFields();
1039
1040     for (int i = 0; i < fSyntaxColorListModel.length; i++)
1041       fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1042
1043     fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1044       public void run() {
1045         if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1046           fSyntaxColorList.select(0);
1047           handleSyntaxColorListSelection();
1048         }
1049       }
1050     });
1051
1052     for (int i = 0; i < fAppearanceColorListModel.length; i++)
1053       fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1054
1055     fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1056       public void run() {
1057         if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1058           fAppearanceColorList.select(0);
1059           handleAppearanceColorListSelection();
1060         }
1061       }
1062     });
1063
1064     for (int i = 0; i < fProblemIndicationColorListModel.length; i++)
1065       fProblemIndicationList.add(fProblemIndicationColorListModel[i][0]);
1066
1067     fProblemIndicationList.getDisplay().asyncExec(new Runnable() {
1068       public void run() {
1069         if (fProblemIndicationList != null && !fProblemIndicationList.isDisposed()) {
1070           fProblemIndicationList.select(0);
1071           handleProblemIndicationColorListSelection();
1072         }
1073       }
1074     });
1075   }
1076
1077   private void initializeFields() {
1078
1079     Iterator e = fColorButtons.keySet().iterator();
1080     while (e.hasNext()) {
1081       ColorEditor c = (ColorEditor) e.next();
1082       String key = (String) fColorButtons.get(c);
1083       RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1084       c.setColorValue(rgb);
1085     }
1086
1087     e = fCheckBoxes.keySet().iterator();
1088     while (e.hasNext()) {
1089       Button b = (Button) e.next();
1090       String key = (String) fCheckBoxes.get(b);
1091       b.setSelection(fOverlayStore.getBoolean(key));
1092     }
1093
1094     e = fTextFields.keySet().iterator();
1095     while (e.hasNext()) {
1096       Text t = (Text) e.next();
1097       String key = (String) fTextFields.get(t);
1098       t.setText(fOverlayStore.getString(key));
1099     }
1100
1101     RGB rgb = PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1102     fBackgroundColorEditor.setColorValue(rgb);
1103
1104     boolean default_ = fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1105     fBackgroundDefaultRadioButton.setSelection(default_);
1106     fBackgroundCustomRadioButton.setSelection(!default_);
1107     fBackgroundColorButton.setEnabled(!default_);
1108
1109     //  boolean closeJavaDocs= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1110     //  fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1111
1112     boolean fillMethodArguments = fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1113     fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1114
1115     updateAutoactivationControls();
1116
1117     //  fJavaEditorHoverConfigurationBlock.initializeFields();
1118   }
1119
1120   private void updateAutoactivationControls() {
1121     boolean autoactivation = fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1122     fAutoInsertDelayText.setEnabled(autoactivation);
1123     fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1124     fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1125     fAutoInsertHTMLTriggerText.setEnabled(autoactivation);
1126   }
1127
1128   /*
1129    * @see PreferencePage#performOk()
1130    */
1131   public boolean performOk() {
1132     fFontEditor.store();
1133     //  fJavaEditorHoverConfigurationBlock.performOk();
1134     fOverlayStore.propagate();
1135     // fUserDefinedPHPSyntaxFileFFE.store();
1136     PHPeclipsePlugin.getDefault().savePluginPreferences();
1137     return true;
1138   }
1139
1140   /*
1141    * @see PreferencePage#performDefaults()
1142    */
1143   protected void performDefaults() {
1144
1145     fFontEditor.loadDefault();
1146
1147     fOverlayStore.loadDefaults();
1148     initializeFields();
1149
1150     //  fUserDefinedPHPSyntaxFileFFE.loadDefault();
1151     handleSyntaxColorListSelection();
1152     handleAppearanceColorListSelection();
1153     handleProblemIndicationColorListSelection();
1154     super.performDefaults();
1155
1156     fPreviewViewer.invalidateTextPresentation();
1157   }
1158
1159   /*
1160    * @see DialogPage#dispose()
1161    */
1162   public void dispose() {
1163
1164     if (fJavaTextTools != null) {
1165       fJavaTextTools = null;
1166     }
1167
1168     fFontEditor.setPreferencePage(null);
1169     fFontEditor.setPreferenceStore(null);
1170
1171     if (fOverlayStore != null) {
1172       fOverlayStore.stop();
1173       fOverlayStore = null;
1174     }
1175
1176     super.dispose();
1177   }
1178
1179   private Control addColorButton(Composite composite, String label, String key, int indentation) {
1180
1181     Label labelControl = new Label(composite, SWT.NONE);
1182     labelControl.setText(label);
1183
1184     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1185     gd.horizontalIndent = indentation;
1186     labelControl.setLayoutData(gd);
1187
1188     ColorEditor editor = new ColorEditor(composite);
1189     Button button = editor.getButton();
1190     button.setData(editor);
1191
1192     gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1193     button.setLayoutData(gd);
1194     button.addSelectionListener(fColorButtonListener);
1195
1196     fColorButtons.put(editor, key);
1197
1198     return composite;
1199   }
1200
1201   private Button addCheckBox(Composite parent, String label, String key, int indentation) {
1202     Button checkBox = new Button(parent, SWT.CHECK);
1203     checkBox.setText(label);
1204
1205     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1206     gd.horizontalIndent = indentation;
1207     gd.horizontalSpan = 2;
1208     checkBox.setLayoutData(gd);
1209     checkBox.addSelectionListener(fCheckBoxListener);
1210
1211     fCheckBoxes.put(checkBox, key);
1212
1213     return checkBox;
1214   }
1215
1216   private Control addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
1217
1218     Label labelControl = new Label(composite, SWT.NONE);
1219     labelControl.setText(label);
1220     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1221     gd.horizontalIndent = indentation;
1222     labelControl.setLayoutData(gd);
1223
1224     Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1225     gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1226     gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1227     textControl.setLayoutData(gd);
1228     textControl.setTextLimit(textLimit);
1229     fTextFields.put(textControl, key);
1230     if (isNumber) {
1231       fNumberFields.add(textControl);
1232       textControl.addModifyListener(fNumberFieldListener);
1233     } else {
1234       textControl.addModifyListener(fTextFieldListener);
1235     }
1236
1237     return textControl;
1238   }
1239
1240   private void addTextFontEditor(Composite parent, String label, String key) {
1241
1242     Composite editorComposite = new Composite(parent, SWT.NONE);
1243     GridLayout layout = new GridLayout();
1244     layout.numColumns = 3;
1245     editorComposite.setLayout(layout);
1246     fFontEditor = new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
1247     fFontEditor.setChangeButtonText(PHPUIMessages.getString("PHPEditorPreferencePage.change")); //$NON-NLS-1$
1248
1249     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1250     gd.horizontalSpan = 2;
1251     editorComposite.setLayoutData(gd);
1252   }
1253
1254   private String loadPreviewContentFromFile(String filename) {
1255     String line;
1256     String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1257     StringBuffer buffer = new StringBuffer(512);
1258     BufferedReader reader = null;
1259     try {
1260       reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
1261       while ((line = reader.readLine()) != null) {
1262         buffer.append(line);
1263         buffer.append(separator);
1264       }
1265     } catch (IOException io) {
1266       PHPeclipsePlugin.log(io);
1267     } finally {
1268       if (reader != null) {
1269         try {
1270           reader.close();
1271         } catch (IOException e) {
1272         }
1273       }
1274     }
1275     return buffer.toString();
1276   }
1277
1278   private void numberFieldChanged(Text textControl) {
1279     String number = textControl.getText();
1280     IStatus status = validatePositiveNumber(number);
1281     if (!status.matches(IStatus.ERROR))
1282       fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1283     updateStatus(status);
1284   }
1285
1286   private IStatus validatePositiveNumber(String number) {
1287     StatusInfo status = new StatusInfo();
1288     if (number.length() == 0) {
1289       status.setError(PHPUIMessages.getString("PHPEditorPreferencePage.empty_input")); //$NON-NLS-1$
1290     } else {
1291       try {
1292         int value = Integer.parseInt(number);
1293         if (value < 0)
1294           status.setError(PHPUIMessages.getFormattedString("PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1295       } catch (NumberFormatException e) {
1296         status.setError(PHPUIMessages.getFormattedString("PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1297       }
1298     }
1299     return status;
1300   }
1301
1302   private void updateStatus(IStatus status) {
1303     if (!status.matches(IStatus.ERROR)) {
1304       for (int i = 0; i < fNumberFields.size(); i++) {
1305         Text text = (Text) fNumberFields.get(i);
1306         IStatus s = validatePositiveNumber(text.getText());
1307         status = StatusUtil.getMoreSevere(s, status);
1308       }
1309     }
1310     setValid(!status.matches(IStatus.ERROR));
1311     StatusUtil.applyToStatusLine(this, status);
1312   }
1313
1314   /**
1315    * @deprecated Inline to avoid reference to preference page
1316    */
1317   public static boolean indicateQuixFixableProblems() {
1318     return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
1319   }
1320
1321   /**
1322    * @deprecated Inline to avoid reference to preference page
1323    */
1324   //    static public boolean synchronizeOutlineOnCursorMove() {
1325   //            return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
1326   //    }
1327
1328 }