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