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