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