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