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