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