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