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