72ab748fe5fd7c7bf13ccfd17ddc09b58c7b0412
[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 package net.sourceforge.phpdt.internal.ui.preferences;
12 import java.io.BufferedReader;
13 import java.io.IOException;
14 import java.io.InputStreamReader;
15 import java.text.Collator;
16 import java.util.ArrayList;
17 import java.util.Comparator;
18 import java.util.HashMap;
19 import java.util.Iterator;
20 import java.util.Map;
21 import java.util.SortedSet;
22 import java.util.TreeSet;
23
24 import net.sourceforge.phpdt.core.JavaCore;
25 import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
26 import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
27 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
28 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
29 import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
30 import net.sourceforge.phpdt.ui.PreferenceConstants;
31 import net.sourceforge.phpdt.ui.text.JavaTextTools;
32 import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
33 import net.sourceforge.phpeclipse.IPreferenceConstants;
34 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
35 import net.sourceforge.phpeclipse.preferences.ColorEditor;
36
37 import org.eclipse.core.runtime.IStatus;
38 import org.eclipse.core.runtime.Preferences;
39 import org.eclipse.jface.preference.IPreferenceStore;
40 import org.eclipse.jface.preference.PreferenceConverter;
41 import org.eclipse.jface.preference.PreferencePage;
42 import org.eclipse.jface.resource.JFaceResources;
43 import org.eclipse.jface.text.Document;
44 import org.eclipse.jface.text.IDocument;
45 import org.eclipse.jface.text.IDocumentPartitioner;
46 import org.eclipse.jface.text.source.ISourceViewer;
47 import org.eclipse.jface.text.source.SourceViewer;
48 import org.eclipse.jface.util.IPropertyChangeListener;
49 import org.eclipse.jface.util.PropertyChangeEvent;
50 import org.eclipse.swt.SWT;
51 import org.eclipse.swt.custom.StyledText;
52 import org.eclipse.swt.events.ModifyEvent;
53 import org.eclipse.swt.events.ModifyListener;
54 import org.eclipse.swt.events.SelectionAdapter;
55 import org.eclipse.swt.events.SelectionEvent;
56 import org.eclipse.swt.events.SelectionListener;
57 import org.eclipse.swt.graphics.Color;
58 import org.eclipse.swt.graphics.RGB;
59 import org.eclipse.swt.layout.GridData;
60 import org.eclipse.swt.layout.GridLayout;
61 import org.eclipse.swt.layout.RowLayout;
62 import org.eclipse.swt.widgets.Button;
63 import org.eclipse.swt.widgets.Combo;
64 import org.eclipse.swt.widgets.Composite;
65 import org.eclipse.swt.widgets.Control;
66 import org.eclipse.swt.widgets.Display;
67 import org.eclipse.swt.widgets.Group;
68 import org.eclipse.swt.widgets.Label;
69 import org.eclipse.swt.widgets.List;
70 import org.eclipse.swt.widgets.TabFolder;
71 import org.eclipse.swt.widgets.TabItem;
72 import org.eclipse.swt.widgets.Text;
73 import org.eclipse.ui.IWorkbench;
74 import org.eclipse.ui.IWorkbenchPreferencePage;
75 import org.eclipse.ui.texteditor.AnnotationPreference;
76 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
77 import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
78 /*
79  * The page for setting the editor options.
80  */
81 public class PHPEditorPreferencePage extends PreferencePage
82     implements
83       IWorkbenchPreferencePage {
84   private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
85   private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
86 //    public final OverlayPreferenceStore.OverlayKey[] fKeys =
87 //      new OverlayPreferenceStore.OverlayKey[] {
88   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
89   // PreferenceConstants.EDITOR_FOREGROUND_COLOR),
90   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
91   // PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR),
92   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
93   // PreferenceConstants.EDITOR_BACKGROUND_COLOR),
94   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
95   // PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR),
96   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
97   // PreferenceConstants.EDITOR_TAB_WIDTH),
98   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
99   // PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR),
100   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
101   // PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD),
102   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
103   // PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR),
104   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
105   // PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD),
106   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
107   // PreferenceConstants.EDITOR_JAVA_TAG_COLOR),
108   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
109   // PreferenceConstants.EDITOR_JAVA_TAG_BOLD),
110   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
111   // PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR),
112   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
113   // PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD),
114   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
115   // PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR),
116   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
117   // PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD),
118   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
119   // PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR),
120   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
121   // PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD),
122   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
123   // PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR),
124   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
125   // PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD),
126   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
127   // PreferenceConstants.EDITOR_PHP_TYPE_COLOR),
128   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
129   // PreferenceConstants.EDITOR_PHP_TYPE_BOLD),
130   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
131   // PreferenceConstants.EDITOR_STRING_COLOR),
132   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
133   // PreferenceConstants.EDITOR_STRING_BOLD),
134   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
135   // PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR),
136   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
137   // PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD),
138   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
139   // PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR),
140   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
141   // PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD),
142   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
143   // PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR),
144   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
145   // PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD),
146   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
147   // PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR),
148   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
149   // PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD),
150   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
151   // PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR),
152   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
153   // PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD),
154   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
155   // PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR),
156   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
157   // PreferenceConstants.EDITOR_MATCHING_BRACKETS),
158   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
159   // PreferenceConstants.EDITOR_CURRENT_LINE_COLOR),
160   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
161   // PreferenceConstants.EDITOR_CURRENT_LINE),
162   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
163   // PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR),
164   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
165   // PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN),
166   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
167   // PreferenceConstants.EDITOR_PRINT_MARGIN),
168   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
169   // PreferenceConstants.EDITOR_FIND_SCOPE_COLOR),
170   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
171   // PreferenceConstants.EDITOR_LINKED_POSITION_COLOR),
172   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
173   // PreferenceConstants.EDITOR_LINK_COLOR),
174   //// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
175   // PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR),
176   //// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
177   // PreferenceConstants.EDITOR_PROBLEM_INDICATION),
178   //// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
179   // PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR),
180   //// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
181   // PreferenceConstants.EDITOR_WARNING_INDICATION),
182   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
183   // PreferenceConstants.EDITOR_TASK_INDICATION_COLOR),
184   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
185   // PreferenceConstants.EDITOR_TASK_INDICATION),
186   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
187   // PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR),
188   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
189   // PreferenceConstants.EDITOR_BOOKMARK_INDICATION),
190   //      new OverlayPreferenceStore.OverlayKey(
191   //        OverlayPreferenceStore.STRING,
192   //        PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR),
193   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
194   // PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION),
195   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
196   // PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR),
197   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
198   // PreferenceConstants.EDITOR_UNKNOWN_INDICATION),
199   //      new OverlayPreferenceStore.OverlayKey(
200   //        OverlayPreferenceStore.BOOLEAN,
201   //        PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER),
202   //      new OverlayPreferenceStore.OverlayKey(
203   //        OverlayPreferenceStore.BOOLEAN,
204   //        PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER),
205   //      new OverlayPreferenceStore.OverlayKey(
206   //        OverlayPreferenceStore.BOOLEAN,
207   //        PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER),
208   //      new OverlayPreferenceStore.OverlayKey(
209   //        OverlayPreferenceStore.BOOLEAN,
210   //        PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER),
211   //      new OverlayPreferenceStore.OverlayKey(
212   //        OverlayPreferenceStore.BOOLEAN,
213   //        PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER),
214   //      new OverlayPreferenceStore.OverlayKey(
215   //        OverlayPreferenceStore.BOOLEAN,
216   //        PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER),
217   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
218   // PreferenceConstants.EDITOR_CORRECTION_INDICATION),
219   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
220   // PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE),
221   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
222   // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS),
223   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
224   // PreferenceConstants.EDITOR_OVERVIEW_RULER),
225   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
226   // PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR),
227   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
228   // PreferenceConstants.EDITOR_LINE_NUMBER_RULER),
229   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
230   // PreferenceConstants.EDITOR_SPACES_FOR_TABS),
231 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
232 //   PreferenceConstants.CODEASSIST_AUTOACTIVATION),
233 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
234 //   PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY),
235 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
236 //   PreferenceConstants.CODEASSIST_AUTOINSERT),
237 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
238 //   PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND),
239 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
240 //   PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND),
241 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
242 //   PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND),
243 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
244 //   PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND),
245 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
246 //   PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND),
247 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
248 //   PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND),
249 //        new OverlayPreferenceStore.OverlayKey(
250 //          OverlayPreferenceStore.STRING,
251 //          PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA),
252 //        new OverlayPreferenceStore.OverlayKey(
253 //          OverlayPreferenceStore.STRING,
254 //          PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC),
255 //        new OverlayPreferenceStore.OverlayKey(
256 //          OverlayPreferenceStore.STRING,
257 //          PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_HTML),
258 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
259 //   PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS),
260 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
261 //   PreferenceConstants.CODEASSIST_ORDER_PROPOSALS),
262 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
263 //   PreferenceConstants.CODEASSIST_CASE_SENSITIVITY),
264 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
265 //   PreferenceConstants.CODEASSIST_ADDIMPORT),
266 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
267 //   PreferenceConstants.CODEASSIST_INSERT_COMPLETION),
268 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
269 //   PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES),
270 //        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
271 //   PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS),
272   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
273   // PreferenceConstants.EDITOR_SMART_PASTE),
274   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
275   // IPreferenceConstants.PHP_USERDEF_XMLFILE),
276   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
277   // PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP),
278   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
279   // PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP),
280   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
281   // PreferenceConstants.EDITOR_CLOSE_BRACES),
282   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
283   // PreferenceConstants.EDITOR_CLOSE_JAVADOCS),
284   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
285   // PreferenceConstants.EDITOR_WRAP_STRINGS),
286   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
287   // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS),
288   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
289   // PreferenceConstants.EDITOR_FORMAT_JAVADOCS),
290   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
291   // PreferenceConstants.EDITOR_SMART_HOME_END),
292   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
293   // PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML),
294   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
295   // PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML),
296   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
297   // PreferenceConstants.EDITOR_DEFAULT_HOVER),
298   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
299   // PreferenceConstants.EDITOR_NONE_HOVER),
300   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
301   // PreferenceConstants.EDITOR_CTRL_HOVER),
302   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
303   // PreferenceConstants.EDITOR_SHIFT_HOVER),
304   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
305   // PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
306   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
307   // PreferenceConstants.EDITOR_CTRL_ALT_HOVER),
308   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
309   // PreferenceConstants.EDITOR_CTRL_ALT_SHIFT_HOVER),
310   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
311   // PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
312   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
313   // PreferenceConstants.EDITOR_ALT_SHIFT_HOVER),
314 //        };
315   /** The keys of the overlay store. */
316   public final OverlayPreferenceStore.OverlayKey[] fKeys;
317   private final String[][] fSyntaxColorListModel = new String[][]{
318       {PHPUIMessages.getString("PHPEditorPreferencePage.multiLineComment"),
319           PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR},
320       //$NON-NLS-1$
321       {PHPUIMessages.getString("PHPEditorPreferencePage.singleLineComment"),
322           PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR},
323       //$NON-NLS-1$
324       {PHPUIMessages.getString("PHPEditorPreferencePage.tags"),
325           PreferenceConstants.EDITOR_PHP_TAG_COLOR},
326       //$NON-NLS-1$
327       {PHPUIMessages.getString("PHPEditorPreferencePage.keywords"),
328           PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR},
329       //$NON-NLS-1$
330       {PHPUIMessages.getString("PHPEditorPreferencePage.functionNames"),
331           PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR},
332       //$NON-NLS-1$
333       {PHPUIMessages.getString("PHPEditorPreferencePage.variables"),
334           PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR},
335       //$NON-NLS-1$
336       {PHPUIMessages.getString("PHPEditorPreferencePage.constants"),
337           PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR},
338       //$NON-NLS-1$
339       {PHPUIMessages.getString("PHPEditorPreferencePage.types"),
340           PreferenceConstants.EDITOR_PHP_TYPE_COLOR},
341       //$NON-NLS-1$
342       {PHPUIMessages.getString("PHPEditorPreferencePage.strings"),
343           PreferenceConstants.EDITOR_STRING_COLOR},
344       //$NON-NLS-1$
345       {PHPUIMessages.getString("PHPEditorPreferencePage.others"),
346           PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR},
347       //$NON-NLS-1$
348       {PHPUIMessages.getString("PHPEditorPreferencePage.phpDocKeywords"),
349           PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR},
350       //$NON-NLS-1$
351       {PHPUIMessages.getString("PHPEditorPreferencePage.phpDocHtmlTags"),
352           PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR},
353       //$NON-NLS-1$
354       {PHPUIMessages.getString("PHPEditorPreferencePage.phpDocLinks"),
355           PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR},
356       //$NON-NLS-1$
357       {PHPUIMessages.getString("PHPEditorPreferencePage.phpDocOthers"),
358           PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR} //$NON-NLS-1$
359   };
360   private final String[][] fAppearanceColorListModel = new String[][]{
361       {
362           PHPUIMessages
363               .getString("PHPEditorPreferencePage.lineNumberForegroundColor"),
364           PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR},
365       //$NON-NLS-1$
366       {
367           PHPUIMessages
368               .getString("PHPEditorPreferencePage.matchingBracketsHighlightColor2"),
369           PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR},
370       //$NON-NLS-1$
371       {
372           PHPUIMessages
373               .getString("PHPEditorPreferencePage.currentLineHighlighColor"),
374           PreferenceConstants.EDITOR_CURRENT_LINE_COLOR},
375       //$NON-NLS-1$
376       {PHPUIMessages.getString("PHPEditorPreferencePage.printMarginColor2"),
377           PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR},
378       //$NON-NLS-1$
379       {PHPUIMessages.getString("PHPEditorPreferencePage.findScopeColor2"),
380           PreferenceConstants.EDITOR_FIND_SCOPE_COLOR},
381       //$NON-NLS-1$
382       {PHPUIMessages.getString("PHPEditorPreferencePage.linkedPositionColor2"),
383           PreferenceConstants.EDITOR_LINKED_POSITION_COLOR},
384       //$NON-NLS-1$
385       {PHPUIMessages.getString("PHPEditorPreferencePage.linkColor2"),
386           PreferenceConstants.EDITOR_LINK_COLOR}, //$NON-NLS-1$
387   };
388   //  private final String[][] fProblemIndicationColorListModel =
389   //    new String[][] {
390   //      {
391   //        "Errors",
392   //        PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR,
393   //        PreferenceConstants.EDITOR_PROBLEM_INDICATION,
394   //        PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER },
395   //      {
396   //      "Warnings",
397   //        PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR,
398   //        PreferenceConstants.EDITOR_WARNING_INDICATION,
399   //        PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER },
400   //        {
401   //      "Tasks",
402   //        PreferenceConstants.EDITOR_TASK_INDICATION_COLOR,
403   //        PreferenceConstants.EDITOR_TASK_INDICATION,
404   //        PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER },
405   //        {
406   //      "Search Results",
407   //        PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR,
408   //        PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION,
409   //        PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER },
410   //        {
411   //      "Bookmarks",
412   //        PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR,
413   //        PreferenceConstants.EDITOR_BOOKMARK_INDICATION,
414   //        PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER },
415   //        {
416   //      "Others",
417   //        PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR,
418   //        PreferenceConstants.EDITOR_UNKNOWN_INDICATION,
419   //        PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER }
420   //  };
421   private final String[][] fAnnotationColorListModel;
422   private final String[][] fAnnotationDecorationListModel = new String[][]{
423       {
424           PreferencesMessages
425               .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"),
426           AnnotationPreference.STYLE_NONE},
427       //$NON-NLS-1$
428 //      {
429 //          PreferencesMessages
430 //              .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"),
431 //          AnnotationPreference.STYLE_SQUIGGLIES},
432       //$NON-NLS-1$
433       {
434           PreferencesMessages
435               .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"),
436           AnnotationPreference.STYLE_UNDERLINE},
437       //$NON-NLS-1$
438       {
439           PreferencesMessages
440               .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"),
441           AnnotationPreference.STYLE_BOX},
442       //$NON-NLS-1$
443       {
444           PreferencesMessages
445               .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"),
446           AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
447   };
448   private OverlayPreferenceStore fOverlayStore;
449   private JavaTextTools fJavaTextTools;
450   //    private JavaEditorHoverConfigurationBlock
451   // fJavaEditorHoverConfigurationBlock;
452   private Map fColorButtons = new HashMap();
453   private SelectionListener fColorButtonListener = new SelectionListener() {
454     public void widgetDefaultSelected(SelectionEvent e) {
455     }
456     public void widgetSelected(SelectionEvent e) {
457       ColorEditor editor = (ColorEditor) e.widget.getData();
458       PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons
459           .get(editor), editor.getColorValue());
460     }
461   };
462   private Map fCheckBoxes = new HashMap();
463   private SelectionListener fCheckBoxListener = new SelectionListener() {
464     public void widgetDefaultSelected(SelectionEvent e) {
465     }
466     public void widgetSelected(SelectionEvent e) {
467       Button button = (Button) e.widget;
468       fOverlayStore.setValue((String) fCheckBoxes.get(button), button
469           .getSelection());
470     }
471   };
472   private Map fTextFields = new HashMap();
473   private ModifyListener fTextFieldListener = new ModifyListener() {
474     public void modifyText(ModifyEvent e) {
475       Text text = (Text) e.widget;
476       fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
477     }
478   };
479   private ArrayList fNumberFields = new ArrayList();
480   private ModifyListener fNumberFieldListener = new ModifyListener() {
481     public void modifyText(ModifyEvent e) {
482       numberFieldChanged((Text) e.widget);
483     }
484   };
485   private WorkbenchChainedTextFontFieldEditor fFontEditor;
486   private List fSyntaxColorList;
487   private List fAppearanceColorList;
488   private List fAnnotationList;
489   private ColorEditor fSyntaxForegroundColorEditor;
490   private ColorEditor fAppearanceForegroundColorEditor;
491   private ColorEditor fAnnotationForegroundColorEditor;
492   private ColorEditor fBackgroundColorEditor;
493   private Button fBackgroundDefaultRadioButton;
494   private Button fBackgroundCustomRadioButton;
495   private Button fBackgroundColorButton;
496   private Button fBoldCheckBox;
497   //private Button fAddJavaDocTagsButton;
498   // private Button fGuessMethodArgumentsButton;
499   private SourceViewer fPreviewViewer;
500   private Color fBackgroundColor;
501   private Control fAutoInsertDelayText;
502   private Control fAutoInsertJavaTriggerText;
503   private Control fAutoInsertJavaDocTriggerText;
504   private Control fAutoInsertHTMLTriggerText;
505   private Button fShowInTextCheckBox;
506   private Button fShowInOverviewRulerCheckBox;
507   private Combo fDecorationStyleCombo;
508   private Button fHighlightInTextCheckBox;
509   private Button fShowInVerticalRulerCheckBox;
510   // private FileFieldEditor fUserDefinedPHPSyntaxFileFFE;
511   public PHPEditorPreferencePage() {
512     setDescription(PHPUIMessages
513         .getString("PHPEditorPreferencePage.description")); //$NON-NLS-1$
514     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
515     MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences();
516     fKeys = createOverlayStoreKeys(markerAnnotationPreferences);
517     fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys);
518     fAnnotationColorListModel = createAnnotationTypeListModel(markerAnnotationPreferences);
519   }
520   private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(
521       MarkerAnnotationPreferences preferences) {
522     ArrayList overlayKeys = new ArrayList();
523     Iterator e = preferences.getAnnotationPreferences().iterator();
524     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
525         OverlayPreferenceStore.STRING,
526         PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR));
527     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
528         OverlayPreferenceStore.BOOLEAN,
529         PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_BOLD));
530     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
531         OverlayPreferenceStore.STRING,
532         PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR));
533     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
534         OverlayPreferenceStore.BOOLEAN,
535         PreferenceConstants.EDITOR_PHP_VARIABLE_BOLD));
536     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
537         OverlayPreferenceStore.STRING,
538         PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR));
539     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
540         OverlayPreferenceStore.BOOLEAN,
541         PreferenceConstants.EDITOR_PHP_CONSTANT_BOLD));
542     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
543         OverlayPreferenceStore.STRING,
544         PreferenceConstants.EDITOR_PHP_TYPE_COLOR));
545     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
546         OverlayPreferenceStore.BOOLEAN,
547         PreferenceConstants.EDITOR_PHP_TYPE_BOLD));
548     overlayKeys
549         .add(new OverlayPreferenceStore.OverlayKey(
550             OverlayPreferenceStore.STRING,
551             IPreferenceConstants.PHP_USERDEF_XMLFILE));
552     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
553         OverlayPreferenceStore.BOOLEAN,
554         PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP));
555     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
556         OverlayPreferenceStore.BOOLEAN,
557         PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP));
558     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
559         OverlayPreferenceStore.BOOLEAN,
560         PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML));
561     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
562         OverlayPreferenceStore.BOOLEAN,
563         PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML));
564     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
565         OverlayPreferenceStore.STRING,
566         PreferenceConstants.EDITOR_FOREGROUND_COLOR));
567     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
568         OverlayPreferenceStore.BOOLEAN,
569         PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR));
570     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
571         OverlayPreferenceStore.STRING,
572         PreferenceConstants.EDITOR_BACKGROUND_COLOR));
573     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
574         OverlayPreferenceStore.BOOLEAN,
575         PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR));
576     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
577         OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH));
578     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
579         OverlayPreferenceStore.STRING,
580         PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR));
581     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
582         OverlayPreferenceStore.BOOLEAN,
583         PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD));
584     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
585         OverlayPreferenceStore.STRING,
586         PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR));
587     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
588         OverlayPreferenceStore.BOOLEAN,
589         PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD));
590     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
591         OverlayPreferenceStore.STRING,
592         PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR));
593     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
594         OverlayPreferenceStore.BOOLEAN,
595         PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD));
596     overlayKeys
597         .add(new OverlayPreferenceStore.OverlayKey(
598             OverlayPreferenceStore.STRING,
599             PreferenceConstants.EDITOR_STRING_COLOR));
600     overlayKeys
601         .add(new OverlayPreferenceStore.OverlayKey(
602             OverlayPreferenceStore.BOOLEAN,
603             PreferenceConstants.EDITOR_STRING_BOLD));
604     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
605         OverlayPreferenceStore.STRING,
606         PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR));
607     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
608         OverlayPreferenceStore.BOOLEAN,
609         PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD));
610     //  overlayKeys.add(new
611     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
612     // PreferenceConstants.EDITOR_TASK_TAG_COLOR));
613     //  overlayKeys.add(new
614     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
615     // PreferenceConstants.EDITOR_TASK_TAG_BOLD));
616     //  
617     //  overlayKeys.add(new
618     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
619     // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR));
620     //  overlayKeys.add(new
621     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
622     // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD));
623     //  
624     //  overlayKeys.add(new
625     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
626     // PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR));
627     //  overlayKeys.add(new
628     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
629     // PreferenceConstants.EDITOR_JAVA_OPERATOR_BOLD));
630     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
631         OverlayPreferenceStore.STRING,
632         PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR));
633     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
634         OverlayPreferenceStore.BOOLEAN,
635         PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD));
636     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
637         OverlayPreferenceStore.STRING,
638         PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR));
639     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
640         OverlayPreferenceStore.BOOLEAN,
641         PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD));
642     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
643         OverlayPreferenceStore.STRING,
644         PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR));
645     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
646         OverlayPreferenceStore.BOOLEAN,
647         PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD));
648     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
649         OverlayPreferenceStore.STRING,
650         PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR));
651     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
652         OverlayPreferenceStore.BOOLEAN,
653         PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD));
654     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
655         OverlayPreferenceStore.STRING,
656         PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
657     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
658         OverlayPreferenceStore.BOOLEAN,
659         PreferenceConstants.EDITOR_MATCHING_BRACKETS));
660     //  overlayKeys.add(new
661     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
662     // ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
663     //  overlayKeys.add(new
664     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
665     // ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
666     //  
667     //  overlayKeys.add(new
668     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
669     // ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
670     //  overlayKeys.add(new
671     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
672     // ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
673     //  overlayKeys.add(new
674     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
675     // ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
676     //
677     //  overlayKeys.add(new
678     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
679     // PreferenceConstants.EDITOR_MARK_OCCURRENCES));
680     //  overlayKeys.add(new
681     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
682     // PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
683     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
684         OverlayPreferenceStore.STRING,
685         PreferenceConstants.EDITOR_FIND_SCOPE_COLOR));
686     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
687         OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR));
688     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
689         OverlayPreferenceStore.BOOLEAN,
690         PreferenceConstants.EDITOR_CORRECTION_INDICATION));
691     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
692         OverlayPreferenceStore.BOOLEAN,
693         PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
694     //  overlayKeys.add(new
695     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
696     // ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
697     //  overlayKeys.add(new
698     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
699     // ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
700     //  overlayKeys.add(new
701     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
702     // ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
703     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
704         OverlayPreferenceStore.BOOLEAN,
705         PreferenceConstants.EDITOR_SPACES_FOR_TABS));
706     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
707         OverlayPreferenceStore.BOOLEAN,
708         PreferenceConstants.CODEASSIST_AUTOACTIVATION));
709     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
710         OverlayPreferenceStore.INT,
711         PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
712     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
713         OverlayPreferenceStore.BOOLEAN,
714         PreferenceConstants.CODEASSIST_AUTOINSERT));
715     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
716         OverlayPreferenceStore.STRING, 
717         PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
718     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
719         OverlayPreferenceStore.STRING,
720         PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
721     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
722         OverlayPreferenceStore.STRING,
723         PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
724     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
725         OverlayPreferenceStore.STRING,
726         PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND));
727     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
728         OverlayPreferenceStore.STRING,
729         PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND));
730     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
731         OverlayPreferenceStore.STRING,
732         PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND));
733     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
734         OverlayPreferenceStore.STRING,
735         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA));
736     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
737         OverlayPreferenceStore.STRING,
738         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC));
739     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
740         OverlayPreferenceStore.BOOLEAN,
741         PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS));
742     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
743         OverlayPreferenceStore.BOOLEAN,
744         PreferenceConstants.CODEASSIST_ORDER_PROPOSALS));
745     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
746         OverlayPreferenceStore.BOOLEAN,
747         PreferenceConstants.CODEASSIST_CASE_SENSITIVITY));
748     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
749         OverlayPreferenceStore.BOOLEAN,
750         PreferenceConstants.CODEASSIST_ADDIMPORT));
751     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
752         OverlayPreferenceStore.BOOLEAN,
753         PreferenceConstants.CODEASSIST_INSERT_COMPLETION));
754     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
755         OverlayPreferenceStore.BOOLEAN,
756         PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES));
757     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
758         OverlayPreferenceStore.BOOLEAN,
759         PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS));
760     overlayKeys
761         .add(new OverlayPreferenceStore.OverlayKey(
762             OverlayPreferenceStore.BOOLEAN,
763             PreferenceConstants.EDITOR_SMART_PASTE));
764 //      overlayKeys.add(new
765 //     OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
766 //     PreferenceConstants.EDITOR_CLOSE_STRINGS));
767 //      overlayKeys.add(new
768 //     OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
769 //     PreferenceConstants.EDITOR_CLOSE_BRACKETS));
770     overlayKeys
771         .add(new OverlayPreferenceStore.OverlayKey(
772             OverlayPreferenceStore.BOOLEAN,
773             PreferenceConstants.EDITOR_CLOSE_BRACES));
774     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
775         OverlayPreferenceStore.BOOLEAN,
776         PreferenceConstants.EDITOR_CLOSE_JAVADOCS));
777     overlayKeys
778         .add(new OverlayPreferenceStore.OverlayKey(
779             OverlayPreferenceStore.BOOLEAN,
780             PreferenceConstants.EDITOR_WRAP_STRINGS));
781     //  overlayKeys.add(new
782     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
783     // PreferenceConstants.EDITOR_ESCAPE_STRINGS));
784     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
785         OverlayPreferenceStore.BOOLEAN,
786         PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS));
787     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
788         OverlayPreferenceStore.BOOLEAN,
789         PreferenceConstants.EDITOR_SMART_HOME_END));
790     //  overlayKeys.add(new
791     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
792     // PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION));
793     //  overlayKeys.add(new
794     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
795     // PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE));
796     //  overlayKeys.add(new
797     // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
798     // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
799     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
800         OverlayPreferenceStore.STRING,
801         PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
802     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
803         OverlayPreferenceStore.STRING,
804         PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
805     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
806         OverlayPreferenceStore.BOOLEAN,
807         PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS));
808     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
809         OverlayPreferenceStore.STRING,
810         PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER));
811     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
812         OverlayPreferenceStore.STRING,
813         PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK));
814     while (e.hasNext()) {
815       AnnotationPreference info = (AnnotationPreference) e.next();
816       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
817           OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
818       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
819           OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
820       if (info.getHighlightPreferenceKey() != null)
821         overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
822             OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
823       overlayKeys
824           .add(new OverlayPreferenceStore.OverlayKey(
825               OverlayPreferenceStore.BOOLEAN, info
826                   .getOverviewRulerPreferenceKey()));
827       if (info.getVerticalRulerPreferenceKey() != null)
828         overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
829             OverlayPreferenceStore.BOOLEAN, info
830                 .getVerticalRulerPreferenceKey()));
831       if (info.getTextStylePreferenceKey() != null)
832         overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
833             OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
834     }
835     OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
836         .size()];
837     overlayKeys.toArray(keys);
838     return keys;
839   }
840   /*
841    * @see IWorkbenchPreferencePage#init()
842    */
843   public void init(IWorkbench workbench) {
844   }
845   /*
846    * @see PreferencePage#createControl(Composite)
847    */
848   public void createControl(Composite parent) {
849     super.createControl(parent);
850     //  WorkbenchHelp.setHelp(getControl(),
851     // IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
852   }
853   private void handleSyntaxColorListSelection() {
854     int i = fSyntaxColorList.getSelectionIndex();
855     String key = fSyntaxColorListModel[i][1];
856     RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
857     fSyntaxForegroundColorEditor.setColorValue(rgb);
858     fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
859   }
860   private void handleAppearanceColorListSelection() {
861     int i = fAppearanceColorList.getSelectionIndex();
862     String key = fAppearanceColorListModel[i][1];
863     RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
864     fAppearanceForegroundColorEditor.setColorValue(rgb);
865   }
866   //  private void handleProblemIndicationColorListSelection() {
867   //    int i = fProblemIndicationList.getSelectionIndex();
868   //
869   //    String key = fProblemIndicationColorListModel[i][1];
870   //    RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
871   //    fProblemIndicationForegroundColorEditor.setColorValue(rgb);
872   //
873   //    key = fProblemIndicationColorListModel[i][2];
874   //    fShowInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
875   //
876   //    key = fProblemIndicationColorListModel[i][3];
877   //    fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
878   //  }
879   private void handleAnnotationListSelection() {
880     int i = fAnnotationList.getSelectionIndex();
881     String key = fAnnotationColorListModel[i][1];
882     RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
883     fAnnotationForegroundColorEditor.setColorValue(rgb);
884     key = fAnnotationColorListModel[i][2];
885     boolean showInText = fOverlayStore.getBoolean(key);
886     fShowInTextCheckBox.setSelection(showInText);
887     key = fAnnotationColorListModel[i][6];
888     if (key != null) {
889       fDecorationStyleCombo.setEnabled(showInText);
890       for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
891         String value = fOverlayStore.getString(key);
892         if (fAnnotationDecorationListModel[j][1].equals(value)) {
893           fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
894           break;
895         }
896       }
897     } else {
898       fDecorationStyleCombo.setEnabled(false);
899       fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set
900                                                                            // selection
901                                                                            // to
902                                                                            // squigglies
903                                                                            // if
904                                                                            // the
905                                                                            // key
906                                                                            // is
907                                                                            // not
908                                                                            // there
909                                                                            // (legacy
910                                                                            // support)
911     }
912     key = fAnnotationColorListModel[i][3];
913     fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
914     key = fAnnotationColorListModel[i][4];
915     if (key != null) {
916       fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
917       fHighlightInTextCheckBox.setEnabled(true);
918     } else
919       fHighlightInTextCheckBox.setEnabled(false);
920     key = fAnnotationColorListModel[i][5];
921     if (key != null) {
922       fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
923       fShowInVerticalRulerCheckBox.setEnabled(true);
924     } else {
925       fShowInVerticalRulerCheckBox.setSelection(true);
926       fShowInVerticalRulerCheckBox.setEnabled(false);
927     }
928   }
929   private Control createSyntaxPage(Composite parent) {
930     Composite colorComposite = new Composite(parent, SWT.NULL);
931     colorComposite.setLayout(new GridLayout());
932     Group backgroundComposite = new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
933     backgroundComposite.setLayout(new RowLayout());
934     backgroundComposite.setText(PHPUIMessages
935         .getString("PHPEditorPreferencePage.backgroundColor")); //$NON-NLS-1$
936     SelectionListener backgroundSelectionListener = new SelectionListener() {
937       public void widgetSelected(SelectionEvent e) {
938         boolean custom = fBackgroundCustomRadioButton.getSelection();
939         fBackgroundColorButton.setEnabled(custom);
940         fOverlayStore.setValue(
941             PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
942       }
943       public void widgetDefaultSelected(SelectionEvent e) {
944       }
945     };
946     fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO
947         | SWT.LEFT);
948     fBackgroundDefaultRadioButton.setText(PHPUIMessages
949         .getString("PHPEditorPreferencePage.systemDefault")); //$NON-NLS-1$
950     fBackgroundDefaultRadioButton
951         .addSelectionListener(backgroundSelectionListener);
952     fBackgroundCustomRadioButton = new Button(backgroundComposite, SWT.RADIO
953         | SWT.LEFT);
954     fBackgroundCustomRadioButton.setText(PHPUIMessages
955         .getString("PHPEditorPreferencePage.custom")); //$NON-NLS-1$
956     fBackgroundCustomRadioButton
957         .addSelectionListener(backgroundSelectionListener);
958     fBackgroundColorEditor = new ColorEditor(backgroundComposite);
959     fBackgroundColorButton = fBackgroundColorEditor.getButton();
960     //    fUserDefinedPHPSyntaxFileFFE =
961     //      new FileFieldEditor(
962     //        IPreferenceConstants.PHP_USERDEF_XMLFILE,
963     //        PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntaxdialog"),
964     //        colorComposite);
965     //    fUserDefinedPHPSyntaxFileFFE.setPreferencePage(this);
966     //    fUserDefinedPHPSyntaxFileFFE.setPreferenceStore(getPreferenceStore());
967     //    fUserDefinedPHPSyntaxFileFFE.load();
968     Label label = new Label(colorComposite, SWT.LEFT);
969     label
970         .setText(PHPUIMessages.getString("PHPEditorPreferencePage.foreground")); //$NON-NLS-1$
971     label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
972     Composite editorComposite = new Composite(colorComposite, SWT.NONE);
973     GridLayout layout = new GridLayout();
974     layout.numColumns = 2;
975     layout.marginHeight = 0;
976     layout.marginWidth = 0;
977     editorComposite.setLayout(layout);
978     GridData gd = new GridData(GridData.FILL_BOTH);
979     editorComposite.setLayoutData(gd);
980     fSyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
981         | SWT.BORDER);
982     gd = new GridData(GridData.FILL_BOTH);
983     gd.heightHint = convertHeightInCharsToPixels(5);
984     fSyntaxColorList.setLayoutData(gd);
985     Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
986     layout = new GridLayout();
987     layout.marginHeight = 0;
988     layout.marginWidth = 0;
989     layout.numColumns = 2;
990     stylesComposite.setLayout(layout);
991     stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
992     label = new Label(stylesComposite, SWT.LEFT);
993     label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
994     gd = new GridData();
995     gd.horizontalAlignment = GridData.BEGINNING;
996     label.setLayoutData(gd);
997     fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
998     Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
999     gd = new GridData(GridData.FILL_HORIZONTAL);
1000     gd.horizontalAlignment = GridData.BEGINNING;
1001     foregroundColorButton.setLayoutData(gd);
1002     fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
1003     fBoldCheckBox.setText(PHPUIMessages
1004         .getString("PHPEditorPreferencePage.bold")); //$NON-NLS-1$
1005     gd = new GridData(GridData.FILL_HORIZONTAL);
1006     gd.horizontalAlignment = GridData.BEGINNING;
1007     gd.horizontalSpan = 2;
1008     fBoldCheckBox.setLayoutData(gd);
1009     label = new Label(colorComposite, SWT.LEFT);
1010     label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.preview")); //$NON-NLS-1$
1011     label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
1012     Control previewer = createPreviewer(colorComposite);
1013     gd = new GridData(GridData.FILL_BOTH);
1014     gd.widthHint = convertWidthInCharsToPixels(20);
1015     gd.heightHint = convertHeightInCharsToPixels(5);
1016     previewer.setLayoutData(gd);
1017     fSyntaxColorList.addSelectionListener(new SelectionListener() {
1018       public void widgetDefaultSelected(SelectionEvent e) {
1019         // do nothing
1020       }
1021       public void widgetSelected(SelectionEvent e) {
1022         handleSyntaxColorListSelection();
1023       }
1024     });
1025     foregroundColorButton.addSelectionListener(new SelectionListener() {
1026       public void widgetDefaultSelected(SelectionEvent e) {
1027         // do nothing
1028       }
1029       public void widgetSelected(SelectionEvent e) {
1030         int i = fSyntaxColorList.getSelectionIndex();
1031         String key = fSyntaxColorListModel[i][1];
1032         PreferenceConverter.setValue(fOverlayStore, key,
1033             fSyntaxForegroundColorEditor.getColorValue());
1034       }
1035     });
1036     fBackgroundColorButton.addSelectionListener(new SelectionListener() {
1037       public void widgetDefaultSelected(SelectionEvent e) {
1038         // do nothing
1039       }
1040       public void widgetSelected(SelectionEvent e) {
1041         PreferenceConverter.setValue(fOverlayStore,
1042             PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor
1043                 .getColorValue());
1044       }
1045     });
1046     fBoldCheckBox.addSelectionListener(new SelectionListener() {
1047       public void widgetDefaultSelected(SelectionEvent e) {
1048         // do nothing
1049       }
1050       public void widgetSelected(SelectionEvent e) {
1051         int i = fSyntaxColorList.getSelectionIndex();
1052         String key = fSyntaxColorListModel[i][1];
1053         fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
1054       }
1055     });
1056     return colorComposite;
1057   }
1058   private Control createPreviewer(Composite parent) {
1059     Preferences coreStore = createTemporaryCorePreferenceStore();
1060     fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false);
1061     fPreviewViewer = new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL
1062         | SWT.BORDER);
1063     fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools,
1064         null, IPHPPartitions.PHP_PARTITIONING));
1065     fPreviewViewer.getTextWidget().setFont(
1066         JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
1067     fPreviewViewer.setEditable(false);
1068     initializeViewerColors(fPreviewViewer);
1069     String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
1070     IDocument document = new Document(content);
1071     //  PHPEditorEnvironment pe;
1072     IDocumentPartitioner partitioner = fJavaTextTools
1073         .createDocumentPartitioner();
1074     partitioner.connect(document);
1075     document.setDocumentPartitioner(partitioner);
1076     fPreviewViewer.setDocument(document);
1077     fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() {
1078       public void propertyChange(PropertyChangeEvent event) {
1079         String p = event.getProperty();
1080         if (p.equals(PreferenceConstants.EDITOR_BACKGROUND_COLOR)
1081             || p.equals(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)) {
1082           initializeViewerColors(fPreviewViewer);
1083         }
1084         fPreviewViewer.invalidateTextPresentation();
1085       }
1086     });
1087     return fPreviewViewer.getControl();
1088   }
1089   private Preferences createTemporaryCorePreferenceStore() {
1090     Preferences result = new Preferences();
1091     result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$
1092     return result;
1093   }
1094   /**
1095    * Initializes the given viewer's colors.
1096    * 
1097    * @param viewer
1098    *            the viewer to be initialized
1099    */
1100   private void initializeViewerColors(ISourceViewer viewer) {
1101     IPreferenceStore store = fOverlayStore;
1102     if (store != null) {
1103       StyledText styledText = viewer.getTextWidget();
1104       // ---------- background color ----------------------
1105       Color color = store
1106           .getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)
1107           ? null
1108           : createColor(store, PreferenceConstants.EDITOR_BACKGROUND_COLOR,
1109               styledText.getDisplay());
1110       styledText.setBackground(color);
1111       if (fBackgroundColor != null)
1112         fBackgroundColor.dispose();
1113       fBackgroundColor = color;
1114     }
1115   }
1116   /**
1117    * Creates a color from the information stored in the given preference store.
1118    * Returns <code>null</code> if there is no such information available.
1119    */
1120   private Color createColor(IPreferenceStore store, String key, Display display) {
1121     RGB rgb = null;
1122     if (store.contains(key)) {
1123       if (store.isDefault(key))
1124         rgb = PreferenceConverter.getDefaultColor(store, key);
1125       else
1126         rgb = PreferenceConverter.getColor(store, key);
1127       if (rgb != null)
1128         return new Color(display, rgb);
1129     }
1130     return null;
1131   }
1132   // sets enabled flag for a control and all its sub-tree
1133   private static void setEnabled(Control control, boolean enable) {
1134     control.setEnabled(enable);
1135     if (control instanceof Composite) {
1136       Composite composite = (Composite) control;
1137       Control[] children = composite.getChildren();
1138       for (int i = 0; i < children.length; i++)
1139         setEnabled(children[i], enable);
1140     }
1141   }
1142   private Control createAppearancePage(Composite parent) {
1143     Composite appearanceComposite = new Composite(parent, SWT.NONE);
1144     GridLayout layout = new GridLayout();
1145     layout.numColumns = 2;
1146     appearanceComposite.setLayout(layout);
1147     String label = PHPUIMessages.getString("PHPEditorPreferencePage.textFont"); //$NON-NLS-1$
1148     addTextFontEditor(appearanceComposite, label, JFaceResources.TEXT_FONT);
1149     label = PHPUIMessages
1150         .getString("PHPEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
1151     addTextField(appearanceComposite, label,
1152         PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
1153     label = PHPUIMessages
1154         .getString("PHPEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
1155     addTextField(appearanceComposite, label,
1156         PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
1157     //  label=
1158     // PHPUIMessages.getString("PHPEditorPreferencePage.synchronizeOnCursor");
1159     // //$NON-NLS-1$
1160     //  addCheckBox(appearanceComposite, label,
1161     // PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, 0);
1162     label = PHPUIMessages
1163         .getString("PHPEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
1164     addCheckBox(appearanceComposite, label,
1165         PreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
1166     label = PHPUIMessages.getString("PHPEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
1167     addCheckBox(appearanceComposite, label,
1168         PreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
1169     label = PHPUIMessages
1170         .getString("PHPEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
1171     addCheckBox(appearanceComposite, label,
1172         PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
1173     label = PHPUIMessages
1174         .getString("PHPEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
1175     addCheckBox(appearanceComposite, label,
1176         PreferenceConstants.EDITOR_CURRENT_LINE, 0);
1177     label = PHPUIMessages.getString("PHPEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
1178     addCheckBox(appearanceComposite, label,
1179         PreferenceConstants.EDITOR_PRINT_MARGIN, 0);
1180     Label l = new Label(appearanceComposite, SWT.LEFT);
1181     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1182     gd.horizontalSpan = 2;
1183     gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1184     l.setLayoutData(gd);
1185     l = new Label(appearanceComposite, SWT.LEFT);
1186     l.setText(PHPUIMessages
1187         .getString("PHPEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
1188     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1189     gd.horizontalSpan = 2;
1190     l.setLayoutData(gd);
1191     Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
1192     layout = new GridLayout();
1193     layout.numColumns = 2;
1194     layout.marginHeight = 0;
1195     layout.marginWidth = 0;
1196     editorComposite.setLayout(layout);
1197     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
1198     gd.horizontalSpan = 2;
1199     editorComposite.setLayoutData(gd);
1200     fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
1201         | SWT.BORDER);
1202     gd = new GridData(GridData.FILL_BOTH);
1203     gd.heightHint = convertHeightInCharsToPixels(5);
1204     fAppearanceColorList.setLayoutData(gd);
1205     Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
1206     layout = new GridLayout();
1207     layout.marginHeight = 0;
1208     layout.marginWidth = 0;
1209     layout.numColumns = 2;
1210     stylesComposite.setLayout(layout);
1211     stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1212     l = new Label(stylesComposite, SWT.LEFT);
1213     l.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
1214     gd = new GridData();
1215     gd.horizontalAlignment = GridData.BEGINNING;
1216     l.setLayoutData(gd);
1217     fAppearanceForegroundColorEditor = new ColorEditor(stylesComposite);
1218     Button foregroundColorButton = fAppearanceForegroundColorEditor.getButton();
1219     gd = new GridData(GridData.FILL_HORIZONTAL);
1220     gd.horizontalAlignment = GridData.BEGINNING;
1221     foregroundColorButton.setLayoutData(gd);
1222     fAppearanceColorList.addSelectionListener(new SelectionListener() {
1223       public void widgetDefaultSelected(SelectionEvent e) {
1224         // do nothing
1225       }
1226       public void widgetSelected(SelectionEvent e) {
1227         handleAppearanceColorListSelection();
1228       }
1229     });
1230     foregroundColorButton.addSelectionListener(new SelectionListener() {
1231       public void widgetDefaultSelected(SelectionEvent e) {
1232         // do nothing
1233       }
1234       public void widgetSelected(SelectionEvent e) {
1235         int i = fAppearanceColorList.getSelectionIndex();
1236         String key = fAppearanceColorListModel[i][1];
1237         PreferenceConverter.setValue(fOverlayStore, key,
1238             fAppearanceForegroundColorEditor.getColorValue());
1239       }
1240     });
1241     return appearanceComposite;
1242   }
1243   private Control createAnnotationsPage(Composite parent) {
1244     Composite composite = new Composite(parent, SWT.NULL);
1245     GridLayout layout = new GridLayout();
1246     layout.numColumns = 2;
1247     composite.setLayout(layout);
1248     String text = PreferencesMessages
1249         .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping"); //$NON-NLS-1$
1250     addCheckBox(composite, text,
1251         PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
1252     text = PreferencesMessages
1253         .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
1254     addCheckBox(composite, text,
1255         PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
1256     addFiller(composite);
1257     Label label = new Label(composite, SWT.LEFT);
1258     label.setText(PreferencesMessages
1259         .getString("JavaEditorPreferencePage.annotationPresentationOptions")); //$NON-NLS-1$
1260     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1261     gd.horizontalSpan = 2;
1262     label.setLayoutData(gd);
1263     Composite editorComposite = new Composite(composite, SWT.NONE);
1264     layout = new GridLayout();
1265     layout.numColumns = 2;
1266     layout.marginHeight = 0;
1267     layout.marginWidth = 0;
1268     editorComposite.setLayout(layout);
1269     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
1270     gd.horizontalSpan = 2;
1271     editorComposite.setLayoutData(gd);
1272     fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL
1273         | SWT.BORDER);
1274     gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
1275         | GridData.FILL_HORIZONTAL);
1276     gd.heightHint = convertHeightInCharsToPixels(10);
1277     fAnnotationList.setLayoutData(gd);
1278     Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
1279     layout = new GridLayout();
1280     layout.marginHeight = 0;
1281     layout.marginWidth = 0;
1282     layout.numColumns = 2;
1283     optionsComposite.setLayout(layout);
1284     optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
1285     fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1286     fShowInTextCheckBox.setText(PreferencesMessages
1287         .getString("JavaEditorPreferencePage.annotations.showInText")); //$NON-NLS-1$
1288     gd = new GridData(GridData.FILL_HORIZONTAL);
1289     gd.horizontalAlignment = GridData.BEGINNING;
1290     gd.horizontalSpan = 2;
1291     fShowInTextCheckBox.setLayoutData(gd);
1292     fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY);
1293     for (int i = 0; i < fAnnotationDecorationListModel.length; i++)
1294       fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
1295     gd = new GridData(GridData.FILL_HORIZONTAL);
1296     gd.horizontalAlignment = GridData.BEGINNING;
1297     gd.horizontalSpan = 2;
1298     gd.horizontalIndent = 20;
1299     fDecorationStyleCombo.setLayoutData(gd);
1300     fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
1301     fHighlightInTextCheckBox.setText(PreferencesMessages
1302         .getString("TextEditorPreferencePage.annotations.highlightInText")); //$NON-NLS-1$
1303     gd = new GridData(GridData.FILL_HORIZONTAL);
1304     gd.horizontalAlignment = GridData.BEGINNING;
1305     gd.horizontalSpan = 2;
1306     fHighlightInTextCheckBox.setLayoutData(gd);
1307     fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1308     fShowInOverviewRulerCheckBox.setText(PreferencesMessages
1309         .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler")); //$NON-NLS-1$
1310     gd = new GridData(GridData.FILL_HORIZONTAL);
1311     gd.horizontalAlignment = GridData.BEGINNING;
1312     gd.horizontalSpan = 2;
1313     fShowInOverviewRulerCheckBox.setLayoutData(gd);
1314     fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
1315     fShowInVerticalRulerCheckBox.setText(PreferencesMessages
1316         .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler")); //$NON-NLS-1$
1317     gd = new GridData(GridData.FILL_HORIZONTAL);
1318     gd.horizontalAlignment = GridData.BEGINNING;
1319     gd.horizontalSpan = 2;
1320     fShowInVerticalRulerCheckBox.setLayoutData(gd);
1321     label = new Label(optionsComposite, SWT.LEFT);
1322     label.setText(PreferencesMessages
1323         .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$
1324     gd = new GridData();
1325     gd.horizontalAlignment = GridData.BEGINNING;
1326     label.setLayoutData(gd);
1327     fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
1328     Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton();
1329     gd = new GridData(GridData.FILL_HORIZONTAL);
1330     gd.horizontalAlignment = GridData.BEGINNING;
1331     foregroundColorButton.setLayoutData(gd);
1332     fAnnotationList.addSelectionListener(new SelectionListener() {
1333       public void widgetDefaultSelected(SelectionEvent e) {
1334         // do nothing
1335       }
1336       public void widgetSelected(SelectionEvent e) {
1337         handleAnnotationListSelection();
1338       }
1339     });
1340     fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
1341       public void widgetDefaultSelected(SelectionEvent e) {
1342         // do nothing
1343       }
1344       public void widgetSelected(SelectionEvent e) {
1345         int i = fAnnotationList.getSelectionIndex();
1346         String key = fAnnotationColorListModel[i][2];
1347         fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
1348         String decorationKey = fAnnotationColorListModel[i][6];
1349         fDecorationStyleCombo.setEnabled(decorationKey != null
1350             && fShowInTextCheckBox.getSelection());
1351       }
1352     });
1353     fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
1354       public void widgetDefaultSelected(SelectionEvent e) {
1355         // do nothing
1356       }
1357       public void widgetSelected(SelectionEvent e) {
1358         int i = fAnnotationList.getSelectionIndex();
1359         String key = fAnnotationColorListModel[i][4];
1360         fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection());
1361       }
1362     });
1363     fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
1364       public void widgetDefaultSelected(SelectionEvent e) {
1365         // do nothing
1366       }
1367       public void widgetSelected(SelectionEvent e) {
1368         int i = fAnnotationList.getSelectionIndex();
1369         String key = fAnnotationColorListModel[i][3];
1370         fOverlayStore
1371             .setValue(key, fShowInOverviewRulerCheckBox.getSelection());
1372       }
1373     });
1374     fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
1375       public void widgetDefaultSelected(SelectionEvent e) {
1376         // do nothing
1377       }
1378       public void widgetSelected(SelectionEvent e) {
1379         int i = fAnnotationList.getSelectionIndex();
1380         String key = fAnnotationColorListModel[i][5];
1381         fOverlayStore
1382             .setValue(key, fShowInVerticalRulerCheckBox.getSelection());
1383       }
1384     });
1385     foregroundColorButton.addSelectionListener(new SelectionListener() {
1386       public void widgetDefaultSelected(SelectionEvent e) {
1387         // do nothing
1388       }
1389       public void widgetSelected(SelectionEvent e) {
1390         int i = fAnnotationList.getSelectionIndex();
1391         String key = fAnnotationColorListModel[i][1];
1392         PreferenceConverter.setValue(fOverlayStore, key,
1393             fAnnotationForegroundColorEditor.getColorValue());
1394       }
1395     });
1396     fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
1397       /**
1398        * {@inheritdoc}
1399        */
1400       public void widgetDefaultSelected(SelectionEvent e) {
1401         // do nothing
1402       }
1403       /**
1404        * {@inheritdoc}
1405        */
1406       public void widgetSelected(SelectionEvent e) {
1407         int i = fAnnotationList.getSelectionIndex();
1408         String key = fAnnotationColorListModel[i][6];
1409         if (key != null) {
1410           for (int j = 0; j < fAnnotationDecorationListModel.length; j++) {
1411             if (fAnnotationDecorationListModel[j][0]
1412                 .equals(fDecorationStyleCombo.getText())) {
1413               fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]);
1414               break;
1415             }
1416           }
1417         }
1418       }
1419     });
1420     return composite;
1421   }
1422   private String[][] createAnnotationTypeListModel(
1423       MarkerAnnotationPreferences preferences) {
1424     ArrayList listModelItems = new ArrayList();
1425     SortedSet sortedPreferences = new TreeSet(new Comparator() {
1426       /*
1427        * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
1428        */
1429       public int compare(Object o1, Object o2) {
1430         if (!(o2 instanceof AnnotationPreference))
1431           return -1;
1432         if (!(o1 instanceof AnnotationPreference))
1433           return 1;
1434         AnnotationPreference a1 = (AnnotationPreference) o1;
1435         AnnotationPreference a2 = (AnnotationPreference) o2;
1436         return Collator.getInstance().compare(a1.getPreferenceLabel(),
1437             a2.getPreferenceLabel());
1438       }
1439     });
1440     sortedPreferences.addAll(preferences.getAnnotationPreferences());
1441     Iterator e = sortedPreferences.iterator();
1442     while (e.hasNext()) {
1443       AnnotationPreference info = (AnnotationPreference) e.next();
1444       listModelItems.add(new String[]{info.getPreferenceLabel(),
1445           info.getColorPreferenceKey(), info.getTextPreferenceKey(),
1446           info.getOverviewRulerPreferenceKey(),
1447           info.getHighlightPreferenceKey(),
1448           info.getVerticalRulerPreferenceKey(),
1449           info.getTextStylePreferenceKey()});
1450     }
1451     String[][] items = new String[listModelItems.size()][];
1452     listModelItems.toArray(items);
1453     return items;
1454   }
1455   private Control createBehaviourPage(Composite parent) {
1456     Composite composite = new Composite(parent, SWT.NULL);
1457     GridLayout layout = new GridLayout();
1458     layout.numColumns = 2;
1459     composite.setLayout(layout);
1460     String label;
1461     //                  String label=
1462     // PHPUIMessages.getString("PHPEditorPreferencePage.wrapStrings");
1463     // //$NON-NLS-1$
1464     //                  addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS,
1465     // 1);
1466     //                  label= PHPUIMessages.getString("PHPEditorPreferencePage.smartHomeEnd");
1467     // //$NON-NLS-1$
1468     //                  addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END,
1469     // 1);
1470     //  
1471     //                  label= PHPUIMessages.getString("PHPEditorPreferencePage.smartPaste");
1472     // //$NON-NLS-1$
1473     //                  addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_PASTE,
1474     // 1);
1475     label = PHPUIMessages
1476         .getString("PHPEditorPreferencePage.insertSpaceForTabs"); //$NON-NLS-1$
1477     addCheckBox(composite, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
1478     label = PHPUIMessages.getString("PHPEditorPreferencePage.closeStringsPHP"); //$NON-NLS-1$
1479     addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP,
1480         1);
1481     label = PHPUIMessages.getString("PHPEditorPreferencePage.closeBracketsPHP"); //$NON-NLS-1$
1482     addCheckBox(composite, label,
1483         PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1);
1484     //                  label= PHPUIMessages.getString("PHPEditorPreferencePage.closeBraces");
1485     // //$NON-NLS-1$
1486     //                  addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES,
1487     // 1);
1488     //  
1489     //                  label= PHPUIMessages.getString("PHPEditorPreferencePage.closePHPDocs");
1490     // //$NON-NLS-1$
1491     //                  Button button= addCheckBox(composite, label,
1492     // PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
1493     //  
1494     //                  label= PHPUIMessages.getString("PHPEditorPreferencePage.addPHPDocTags");
1495     // //$NON-NLS-1$
1496     //                  fAddJavaDocTagsButton= addCheckBox(composite, label,
1497     // PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
1498     //                  createDependency(button, fAddJavaDocTagsButton);
1499     //                  label= PHPUIMessages.getString("PHPEditorPreferencePage.formatPHPDocs");
1500     // //$NON-NLS-1$
1501     //                  addCheckBox(composite, label,
1502     // PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
1503     //          
1504     label = PHPUIMessages.getString("PHPEditorPreferencePage.closeStringsHTML"); //$NON-NLS-1$
1505     addCheckBox(composite, label,
1506         PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML, 1);
1507     label = PHPUIMessages
1508         .getString("PHPEditorPreferencePage.closeBracketsHTML"); //$NON-NLS-1$
1509     addCheckBox(composite, label,
1510         PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML, 1);
1511     return composite;
1512   }
1513   
1514   private static void indent(Control control) {
1515     GridData gridData = new GridData();
1516     gridData.horizontalIndent = 20;
1517     control.setLayoutData(gridData);
1518   }
1519   private static void createDependency(final Button master, final Control slave) {
1520     indent(slave);
1521     master.addSelectionListener(new SelectionListener() {
1522       public void widgetSelected(SelectionEvent e) {
1523         slave.setEnabled(master.getSelection());
1524       }
1525       public void widgetDefaultSelected(SelectionEvent e) {
1526       }
1527     });
1528   }
1529   private Control createContentAssistPage(Composite parent) {
1530     Composite contentAssistComposite = new Composite(parent, SWT.NULL);
1531     GridLayout layout = new GridLayout();
1532     layout.numColumns = 2;
1533     contentAssistComposite.setLayout(layout);
1534     String label;
1535     //    String label =
1536     // PHPUIMessages.getString("PHPEditorPreferencePage.insertSingleProposalsAutomatically");
1537     // //$NON-NLS-1$
1538     //    addCheckBox(contentAssistComposite, label,
1539     // PreferenceConstants.CODEASSIST_AUTOINSERT, 0);
1540     //
1541     //    label =
1542     // PHPUIMessages.getString("PHPEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext");
1543     // //$NON-NLS-1$
1544     //    addCheckBox(contentAssistComposite, label,
1545     // PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0);
1546     //
1547     //    label =
1548     // PHPUIMessages.getString("PHPEditorPreferencePage.presentProposalsInAlphabeticalOrder");
1549     // //$NON-NLS-1$
1550     //    addCheckBox(contentAssistComposite, label,
1551     // PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0);
1552     //
1553     //    label =
1554     // PHPUIMessages.getString("PHPEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName");
1555     // //$NON-NLS-1$
1556     //    addCheckBox(contentAssistComposite, label,
1557     // PreferenceConstants.CODEASSIST_ADDIMPORT, 0);
1558     //
1559     //    label =
1560     // PHPUIMessages.getString("PHPEditorPreferencePage.insertCompletion");
1561     // //$NON-NLS-1$
1562     //    addCheckBox(contentAssistComposite, label,
1563     // PreferenceConstants.CODEASSIST_INSERT_COMPLETION, 0);
1564     //
1565     //    label =
1566     // PHPUIMessages.getString("PHPEditorPreferencePage.fillArgumentNamesOnMethodCompletion");
1567     // //$NON-NLS-1$
1568     //    Button button = addCheckBox(contentAssistComposite, label,
1569     // PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0);
1570     //
1571     //    label =
1572     // PHPUIMessages.getString("PHPEditorPreferencePage.guessArgumentNamesOnMethodCompletion");
1573     // //$NON-NLS-1$
1574     //    fGuessMethodArgumentsButton =
1575     //      addCheckBox(contentAssistComposite, label,
1576     // PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0);
1577     //    createDependency(button, fGuessMethodArgumentsButton);
1578     label = PHPUIMessages
1579         .getString("PHPEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$
1580     final Button autoactivation = addCheckBox(contentAssistComposite, label,
1581         PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0);
1582     label = PHPUIMessages
1583         .getString("PHPEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$
1584     fAutoInsertDelayText = addTextField(contentAssistComposite, label,
1585         PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true);
1586     label = PHPUIMessages
1587         .getString("PHPEditorPreferencePage.autoActivationTriggersForPHP"); //$NON-NLS-1$
1588     fAutoInsertJavaTriggerText = addTextField(contentAssistComposite, label,
1589         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0,
1590         false);
1591     label = PHPUIMessages
1592         .getString("PHPEditorPreferencePage.autoActivationTriggersForPHPDoc"); //$NON-NLS-1$
1593     fAutoInsertJavaDocTriggerText = addTextField(contentAssistComposite, label,
1594         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0,
1595         false);
1596     label = PHPUIMessages
1597         .getString("PHPEditorPreferencePage.autoActivationTriggersForHTML"); //$NON-NLS-1$
1598     fAutoInsertHTMLTriggerText = addTextField(contentAssistComposite, label,
1599         PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_HTML, 4, 0,
1600         false);
1601     label = PHPUIMessages
1602         .getString("PHPEditorPreferencePage.backgroundForCompletionProposals"); //$NON-NLS-1$
1603     addColorButton(contentAssistComposite, label,
1604         PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, 0);
1605     label = PHPUIMessages
1606         .getString("PHPEditorPreferencePage.foregroundForCompletionProposals"); //$NON-NLS-1$
1607     addColorButton(contentAssistComposite, label,
1608         PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, 0);
1609     //    label =
1610     // PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForMethodParameters");
1611     // //$NON-NLS-1$
1612     //    addColorButton(contentAssistComposite, label,
1613     // PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, 0);
1614     //
1615     //    label =
1616     // PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForMethodParameters");
1617     // //$NON-NLS-1$
1618     //    addColorButton(contentAssistComposite, label,
1619     // PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, 0);
1620     //    label =
1621     // PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForCompletionReplacement");
1622     // //$NON-NLS-1$
1623     //    addColorButton(contentAssistComposite, label,
1624     // PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, 0);
1625     //
1626     //    label =
1627     // PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForCompletionReplacement");
1628     // //$NON-NLS-1$
1629     //    addColorButton(contentAssistComposite, label,
1630     // PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, 0);
1631     autoactivation.addSelectionListener(new SelectionAdapter() {
1632       public void widgetSelected(SelectionEvent e) {
1633         updateAutoactivationControls();
1634       }
1635     });
1636     return contentAssistComposite;
1637   }
1638   /*
1639    * @see PreferencePage#createContents(Composite)
1640    */
1641   protected Control createContents(Composite parent) {
1642     initializeDefaultColors();
1643     fOverlayStore.load();
1644     fOverlayStore.start();
1645     TabFolder folder = new TabFolder(parent, SWT.NONE);
1646     folder.setLayout(new TabFolderLayout());
1647     folder.setLayoutData(new GridData(GridData.FILL_BOTH));
1648     TabItem item = new TabItem(folder, SWT.NONE);
1649     item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.general")); //$NON-NLS-1$
1650     item.setControl(createAppearancePage(folder));
1651     item = new TabItem(folder, SWT.NONE);
1652     item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.colors")); //$NON-NLS-1$
1653     item.setControl(createSyntaxPage(folder));
1654     item = new TabItem(folder, SWT.NONE);
1655     item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.codeAssist")); //$NON-NLS-1$
1656     item.setControl(createContentAssistPage(folder));
1657     item = new TabItem(folder, SWT.NONE);
1658     item.setText(PHPUIMessages
1659         .getString("PHPEditorPreferencePage.annotationsTab.title")); //$NON-NLS-1$
1660     item.setControl(createAnnotationsPage(folder));
1661     item = new TabItem(folder, SWT.NONE);
1662     item.setText(PHPUIMessages
1663         .getString("PHPEditorPreferencePage.behaviourTab.title")); //$NON-NLS-1$
1664     item.setControl(createBehaviourPage(folder));
1665                 item= new TabItem(folder, SWT.NONE);
1666                 item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.hoverTab.title"));
1667      //$NON-NLS-1$
1668 //              fJavaEditorHoverConfigurationBlock= new
1669 //     JavaEditorHoverConfigurationBlock(fOverlayStore);
1670 //              item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
1671     initialize();
1672     return folder;
1673   }
1674   private void initialize() {
1675     fFontEditor.setPreferenceStore(getPreferenceStore());
1676     fFontEditor.setPreferencePage(this);
1677     fFontEditor.load();
1678     initializeFields();
1679     for (int i = 0; i < fSyntaxColorListModel.length; i++)
1680       fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
1681     fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
1682       public void run() {
1683         if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
1684           fSyntaxColorList.select(0);
1685           handleSyntaxColorListSelection();
1686         }
1687       }
1688     });
1689     for (int i = 0; i < fAppearanceColorListModel.length; i++)
1690       fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
1691     fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
1692       public void run() {
1693         if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
1694           fAppearanceColorList.select(0);
1695           handleAppearanceColorListSelection();
1696         }
1697       }
1698     });
1699     for (int i = 0; i < fAnnotationColorListModel.length; i++)
1700       fAnnotationList.add(fAnnotationColorListModel[i][0]);
1701     fAnnotationList.getDisplay().asyncExec(new Runnable() {
1702       public void run() {
1703         if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
1704           fAnnotationList.select(0);
1705           handleAnnotationListSelection();
1706         }
1707       }
1708     });
1709 //      for (int i= 0; i < fContentAssistColorListModel.length; i++)
1710 //              fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
1711 //      fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
1712 //              public void run() {
1713 //                      if (fContentAssistColorList != null &&
1714 //     !fContentAssistColorList.isDisposed()) {
1715 //                              fContentAssistColorList.select(0);
1716 //                              handleContentAssistColorListSelection();
1717 //                      }
1718 //              }
1719 //      });
1720   }
1721   private void initializeFields() {
1722     Iterator e = fColorButtons.keySet().iterator();
1723     while (e.hasNext()) {
1724       ColorEditor c = (ColorEditor) e.next();
1725       String key = (String) fColorButtons.get(c);
1726       RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
1727       c.setColorValue(rgb);
1728     }
1729     e = fCheckBoxes.keySet().iterator();
1730     while (e.hasNext()) {
1731       Button b = (Button) e.next();
1732       String key = (String) fCheckBoxes.get(b);
1733       b.setSelection(fOverlayStore.getBoolean(key));
1734     }
1735     e = fTextFields.keySet().iterator();
1736     while (e.hasNext()) {
1737       Text t = (Text) e.next();
1738       String key = (String) fTextFields.get(t);
1739       t.setText(fOverlayStore.getString(key));
1740     }
1741     RGB rgb = PreferenceConverter.getColor(fOverlayStore,
1742         PreferenceConstants.EDITOR_BACKGROUND_COLOR);
1743     fBackgroundColorEditor.setColorValue(rgb);
1744     boolean default_ = fOverlayStore
1745         .getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
1746     fBackgroundDefaultRadioButton.setSelection(default_);
1747     fBackgroundCustomRadioButton.setSelection(!default_);
1748     fBackgroundColorButton.setEnabled(!default_);
1749     //    boolean closeJavaDocs=
1750     // fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
1751     //    fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
1752     //    boolean fillMethodArguments =
1753     // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
1754     //    fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
1755     updateAutoactivationControls();
1756     //  fJavaEditorHoverConfigurationBlock.initializeFields();
1757   }
1758   
1759   private void initializeDefaultColors() {      
1760                 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) {
1761                         RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
1762                         PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1763                         PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb);
1764                 }
1765                 if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) {
1766                         RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB();
1767                         PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1768                         PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb);
1769                 }
1770   }
1771   
1772   private void updateAutoactivationControls() {
1773     boolean autoactivation = fOverlayStore
1774         .getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
1775     fAutoInsertDelayText.setEnabled(autoactivation);
1776     fAutoInsertJavaTriggerText.setEnabled(autoactivation);
1777     fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
1778     fAutoInsertHTMLTriggerText.setEnabled(autoactivation);
1779   }
1780   /*
1781    * @see PreferencePage#performOk()
1782    */
1783   public boolean performOk() {
1784     fFontEditor.store();
1785     //  fJavaEditorHoverConfigurationBlock.performOk();
1786     fOverlayStore.propagate();
1787     // fUserDefinedPHPSyntaxFileFFE.store();
1788     PHPeclipsePlugin.getDefault().savePluginPreferences();
1789     return true;
1790   }
1791   /*
1792    * @see PreferencePage#performDefaults()
1793    */
1794   protected void performDefaults() {
1795     fFontEditor.loadDefault();
1796     fOverlayStore.loadDefaults();
1797     initializeFields();
1798     //  fUserDefinedPHPSyntaxFileFFE.loadDefault();
1799     handleSyntaxColorListSelection();
1800     handleAppearanceColorListSelection();
1801     handleAnnotationListSelection();
1802     //  handleContentAssistColorListSelection();
1803     super.performDefaults();
1804     fPreviewViewer.invalidateTextPresentation();
1805   }
1806   /*
1807    * @see DialogPage#dispose()
1808    */
1809   public void dispose() {
1810     if (fJavaTextTools != null) {
1811       fJavaTextTools = null;
1812     }
1813     fFontEditor.setPreferencePage(null);
1814     fFontEditor.setPreferenceStore(null);
1815     if (fOverlayStore != null) {
1816       fOverlayStore.stop();
1817       fOverlayStore = null;
1818     }
1819     super.dispose();
1820   }
1821   private Control addColorButton(Composite composite, String label, String key,
1822       int indentation) {
1823     Label labelControl = new Label(composite, SWT.NONE);
1824     labelControl.setText(label);
1825     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1826     gd.horizontalIndent = indentation;
1827     labelControl.setLayoutData(gd);
1828     ColorEditor editor = new ColorEditor(composite);
1829     Button button = editor.getButton();
1830     button.setData(editor);
1831     gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1832     button.setLayoutData(gd);
1833     button.addSelectionListener(fColorButtonListener);
1834     fColorButtons.put(editor, key);
1835     return composite;
1836   }
1837   private void addFiller(Composite composite) {
1838     Label filler = new Label(composite, SWT.LEFT);
1839     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1840     gd.horizontalSpan = 2;
1841     gd.heightHint = convertHeightInCharsToPixels(1) / 2;
1842     filler.setLayoutData(gd);
1843   }
1844   private Button addCheckBox(Composite parent, String label, String key,
1845       int indentation) {
1846     Button checkBox = new Button(parent, SWT.CHECK);
1847     checkBox.setText(label);
1848     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1849     gd.horizontalIndent = indentation;
1850     gd.horizontalSpan = 2;
1851     checkBox.setLayoutData(gd);
1852     checkBox.addSelectionListener(fCheckBoxListener);
1853     fCheckBoxes.put(checkBox, key);
1854     return checkBox;
1855   }
1856   private Control addTextField(Composite composite, String label, String key,
1857       int textLimit, int indentation, boolean isNumber) {
1858     Label labelControl = new Label(composite, SWT.NONE);
1859     labelControl.setText(label);
1860     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1861     gd.horizontalIndent = indentation;
1862     labelControl.setLayoutData(gd);
1863     Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
1864     gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
1865     gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
1866     textControl.setLayoutData(gd);
1867     textControl.setTextLimit(textLimit);
1868     fTextFields.put(textControl, key);
1869     if (isNumber) {
1870       fNumberFields.add(textControl);
1871       textControl.addModifyListener(fNumberFieldListener);
1872     } else {
1873       textControl.addModifyListener(fTextFieldListener);
1874     }
1875     return textControl;
1876   }
1877   private void addTextFontEditor(Composite parent, String label, String key) {
1878     Composite editorComposite = new Composite(parent, SWT.NONE);
1879     GridLayout layout = new GridLayout();
1880     layout.numColumns = 3;
1881     editorComposite.setLayout(layout);
1882     fFontEditor = new WorkbenchChainedTextFontFieldEditor(key, label,
1883         editorComposite);
1884     fFontEditor.setChangeButtonText(PHPUIMessages
1885         .getString("PHPEditorPreferencePage.change")); //$NON-NLS-1$
1886     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
1887     gd.horizontalSpan = 2;
1888     editorComposite.setLayoutData(gd);
1889   }
1890   private String loadPreviewContentFromFile(String filename) {
1891     String line;
1892     String separator = System.getProperty("line.separator"); //$NON-NLS-1$
1893     StringBuffer buffer = new StringBuffer(512);
1894     BufferedReader reader = null;
1895     try {
1896       reader = new BufferedReader(new InputStreamReader(getClass()
1897           .getResourceAsStream(filename)));
1898       while ((line = reader.readLine()) != null) {
1899         buffer.append(line);
1900         buffer.append(separator);
1901       }
1902     } catch (IOException io) {
1903       PHPeclipsePlugin.log(io);
1904     } finally {
1905       if (reader != null) {
1906         try {
1907           reader.close();
1908         } catch (IOException e) {
1909         }
1910       }
1911     }
1912     return buffer.toString();
1913   }
1914   private void numberFieldChanged(Text textControl) {
1915     String number = textControl.getText();
1916     IStatus status = validatePositiveNumber(number);
1917     if (!status.matches(IStatus.ERROR))
1918       fOverlayStore.setValue((String) fTextFields.get(textControl), number);
1919     updateStatus(status);
1920   }
1921   private IStatus validatePositiveNumber(String number) {
1922     StatusInfo status = new StatusInfo();
1923     if (number.length() == 0) {
1924       status.setError(PHPUIMessages
1925           .getString("PHPEditorPreferencePage.empty_input")); //$NON-NLS-1$
1926     } else {
1927       try {
1928         int value = Integer.parseInt(number);
1929         if (value < 0)
1930           status.setError(PHPUIMessages.getFormattedString(
1931               "PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1932       } catch (NumberFormatException e) {
1933         status.setError(PHPUIMessages.getFormattedString(
1934             "PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
1935       }
1936     }
1937     return status;
1938   }
1939   private void updateStatus(IStatus status) {
1940     if (!status.matches(IStatus.ERROR)) {
1941       for (int i = 0; i < fNumberFields.size(); i++) {
1942         Text text = (Text) fNumberFields.get(i);
1943         IStatus s = validatePositiveNumber(text.getText());
1944         status = StatusUtil.getMoreSevere(s, status);
1945       }
1946     }
1947     setValid(!status.matches(IStatus.ERROR));
1948     StatusUtil.applyToStatusLine(this, status);
1949   }
1950   /**
1951    * @deprecated Inline to avoid reference to preference page
1952    */
1953   public static boolean indicateQuixFixableProblems() {
1954     return PreferenceConstants.getPreferenceStore().getBoolean(
1955         PreferenceConstants.EDITOR_CORRECTION_INDICATION);
1956   }
1957   /**
1958    * @deprecated Inline to avoid reference to preference page
1959    */
1960   //    static public boolean synchronizeOutlineOnCursorMove() {
1961   //            return
1962   // PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
1963   //    }
1964 }