Codeformatter preferences should work now
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPSyntaxEditorPreferencePage.java
1 package net.sourceforge.phpeclipse;
2
3 import java.util.HashMap;
4 import java.util.Iterator;
5 import java.util.Map;
6
7 import net.sourceforge.phpeclipse.preferences.ColorEditor;
8 import net.sourceforge.phpeclipse.preferences.OverlayPreferenceStore;
9 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
10
11 import org.eclipse.core.runtime.IStatus;
12 import org.eclipse.jface.preference.BooleanFieldEditor;
13 import org.eclipse.jface.preference.FileFieldEditor;
14 import org.eclipse.jface.preference.IPreferenceStore;
15 import org.eclipse.jface.preference.IntegerFieldEditor;
16 import org.eclipse.jface.preference.PreferenceConverter;
17 import org.eclipse.jface.preference.PreferencePage;
18 import org.eclipse.jface.text.source.ISourceViewer;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.custom.StyledText;
21 import org.eclipse.swt.events.SelectionEvent;
22 import org.eclipse.swt.events.SelectionListener;
23 import org.eclipse.swt.graphics.Color;
24 import org.eclipse.swt.graphics.RGB;
25 import org.eclipse.swt.layout.GridData;
26 import org.eclipse.swt.layout.GridLayout;
27 import org.eclipse.swt.widgets.Button;
28 import org.eclipse.swt.widgets.Composite;
29 import org.eclipse.swt.widgets.Control;
30 import org.eclipse.swt.widgets.Display;
31 import org.eclipse.swt.widgets.Group;
32 import org.eclipse.swt.widgets.Label;
33 import org.eclipse.swt.widgets.List;
34 import org.eclipse.ui.IWorkbench;
35 import org.eclipse.ui.IWorkbenchPreferencePage;
36
37 /*
38  * The preference page for setting the PHP Editor options.
39  */
40 public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
41
42   public final OverlayPreferenceStore.OverlayKey[] Keys =
43     new OverlayPreferenceStore.OverlayKey[] {
44       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_MULTILINE_COMMENT),
45       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_MULTILINE_COMMENT_BOLD),
46       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_MULTILINE_COMMENT_ITALIC),
47       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_MULTILINE_COMMENT_UNDERLINE),
48       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_SINGLELINE_COMMENT),
49       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_SINGLELINE_COMMENT_BOLD),
50       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_SINGLELINE_COMMENT_ITALIC),
51       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_SINGLELINE_COMMENT_UNDERLINE),
52       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_KEYWORD),
53       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_KEYWORD_BOLD),
54       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_KEYWORD_ITALIC),
55       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_KEYWORD_UNDERLINE),
56       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_VARIABLE),
57       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_VARIABLE_BOLD),
58       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_VARIABLE_ITALIC),
59       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_VARIABLE_UNDERLINE),
60       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_TYPE),
61       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_TYPE_BOLD),
62       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_TYPE_ITALIC),
63       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_TYPE_UNDERLINE),
64       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_CONSTANT),
65       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_CONSTANT_BOLD),
66       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_CONSTANT_ITALIC),
67       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_CONSTANT_UNDERLINE),
68       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_FUNCTIONNAME),
69       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_FUNCTIONNAME_BOLD),
70       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_FUNCTIONNAME_ITALIC),
71       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_FUNCTIONNAME_UNDERLINE),
72       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_STRING),
73       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_BOLD),
74       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_ITALIC),
75       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_UNDERLINE),
76       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_DEFAULT),
77       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_BOLD),
78       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_ITALIC),
79       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_UNDERLINE),
80       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_USERDEF_XMLFILE),
81       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_EDITOR_BACKGROUND)};
82
83   private final String[][] SyntaxColorListModel =
84     new String[][] {
85       {
86         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.multiLineComment"),
87         IPreferenceConstants.PHP_MULTILINE_COMMENT },
88       {
89       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.singleLineComment"),
90         IPreferenceConstants.PHP_SINGLELINE_COMMENT },
91         {
92       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.keywords"), IPreferenceConstants.PHP_KEYWORD }, {
93       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.variables"), IPreferenceConstants.PHP_VARIABLE }, {
94       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.types"), IPreferenceConstants.PHP_TYPE }, {
95       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.functions"), IPreferenceConstants.PHP_FUNCTIONNAME }, {
96       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.constants"), IPreferenceConstants.PHP_CONSTANT }, {
97       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.strings"), IPreferenceConstants.PHP_STRING }, {
98       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.others"), IPreferenceConstants.PHP_DEFAULT }
99   };
100
101   private OverlayPreferenceStore OverlayStore;
102
103   private Map ColorButtons = new HashMap();
104   private SelectionListener ColorButtonListener = new SelectionListener() {
105     public void widgetDefaultSelected(SelectionEvent e) {
106     }
107     public void widgetSelected(SelectionEvent e) {
108       ColorEditor editor = (ColorEditor) e.widget.getData();
109       PreferenceConverter.setValue(OverlayStore, (String) ColorButtons.get(editor), editor.getColorValue());
110     }
111   };
112
113   private Map CheckBoxes = new HashMap();
114   private SelectionListener CheckBoxListener = new SelectionListener() {
115     public void widgetDefaultSelected(SelectionEvent e) {
116     }
117     public void widgetSelected(SelectionEvent e) {
118       Button button = (Button) e.widget;
119       OverlayStore.setValue((String) CheckBoxes.get(button), button.getSelection());
120     }
121   };
122
123   private List SyntaxColorList;
124   /** The ColorEditor that choose the foreground color. */
125   private ColorEditor SyntaxForegroundColorEditor;
126   private Button BoldCheckBox;
127   private Button ItalicCheckBox;
128   private Button UnderlineCheckBox;
129   private FileFieldEditor userdefPHPSyntaxFileFFE;
130   private BooleanFieldEditor showLineNumber;
131   private IntegerFieldEditor formatterTabSize;
132   private BooleanFieldEditor spacesForTabs;
133
134   public PHPSyntaxEditorPreferencePage() {
135     setDescription(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.description")); //$NON-NLS-1$
136     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
137     OverlayStore = new OverlayPreferenceStore(getPreferenceStore(), Keys);
138   }
139
140   public void init(IWorkbench workbench) {
141   }
142
143   public void createControl(Composite parent) {
144     super.createControl(parent);
145   }
146
147   private void handleSyntaxColorListSelection() {
148     int i = SyntaxColorList.getSelectionIndex();
149     String key = SyntaxColorListModel[i][1];
150     RGB rgb = PreferenceConverter.getColor(OverlayStore, key);
151     SyntaxForegroundColorEditor.setColorValue(rgb);
152     BoldCheckBox.setSelection(OverlayStore.getBoolean(key + "_bold"));
153     ItalicCheckBox.setSelection(OverlayStore.getBoolean(key + "_italic"));
154     UnderlineCheckBox.setSelection(OverlayStore.getBoolean(key + "_underline"));
155   }
156
157   /**
158    * Create the group of options for other parameters (background color for example).
159    * @param parent the parent component
160    */
161   private void backgroundOptionPage(Composite parent) {
162     Label label = new Label(parent, SWT.LEFT);
163     label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.color")); //$NON-NLS-1$
164     GridData gd = new GridData();
165     gd.horizontalAlignment = GridData.BEGINNING;
166     label.setLayoutData(gd);
167     final ColorEditor syntaxBackgroundColorEditor = new ColorEditor(parent);
168     RGB rgb = PreferenceConverter.getColor(OverlayStore, IPreferenceConstants.PHP_EDITOR_BACKGROUND);
169     syntaxBackgroundColorEditor.setColorValue(rgb);
170     Button backgroundColorButton = syntaxBackgroundColorEditor.getButton();
171     gd = new GridData(GridData.FILL_HORIZONTAL);
172     gd.horizontalAlignment = GridData.BEGINNING;
173     backgroundColorButton.setLayoutData(gd);
174     backgroundColorButton.addSelectionListener(new SelectionListener() {
175       public void widgetDefaultSelected(SelectionEvent e) {
176         // do nothing
177       }
178       public void widgetSelected(SelectionEvent e) {
179         PreferenceConverter.setValue(OverlayStore, IPreferenceConstants.PHP_EDITOR_BACKGROUND, syntaxBackgroundColorEditor.getColorValue());
180       }
181     });
182   }
183
184   /**
185    * Create the group of options for the syntax parameters.
186    * @param parent the parent component
187    * @return
188    */
189   private Control createSyntaxPage(Composite parent) {
190
191     Composite colorComposite = new Composite(parent, SWT.NULL);
192     colorComposite.setLayout(new GridLayout());
193
194     Label label = new Label(colorComposite, SWT.LEFT);
195     label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntax")); //$NON-NLS-1$
196     label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
197
198     Composite editorComposite = new Composite(colorComposite, SWT.NONE);
199     GridLayout layout = new GridLayout();
200     layout.numColumns = 2;
201     layout.marginHeight = 0;
202     layout.marginWidth = 0;
203     editorComposite.setLayout(layout);
204     GridData gd = new GridData(GridData.FILL_BOTH);
205     editorComposite.setLayoutData(gd);
206
207     SyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
208     gd = new GridData(GridData.FILL_BOTH);
209     gd.heightHint = convertHeightInCharsToPixels(5);
210     SyntaxColorList.setLayoutData(gd);
211
212     Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
213     layout = new GridLayout();
214     layout.marginHeight = 0;
215     layout.marginWidth = 0;
216     layout.numColumns = 2;
217     stylesComposite.setLayout(layout);
218     stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
219
220     label = new Label(stylesComposite, SWT.LEFT);
221     label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.color")); //$NON-NLS-1$
222     gd = new GridData();
223     gd.horizontalAlignment = GridData.BEGINNING;
224     label.setLayoutData(gd);
225
226     SyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
227     Button foregroundColorButton = SyntaxForegroundColorEditor.getButton();
228     gd = new GridData(GridData.FILL_HORIZONTAL);
229     gd.horizontalAlignment = GridData.BEGINNING;
230     foregroundColorButton.setLayoutData(gd);
231
232     BoldCheckBox = new Button(stylesComposite, SWT.CHECK);
233     BoldCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.bold")); //$NON-NLS-1$
234     gd = new GridData(GridData.FILL_HORIZONTAL);
235     gd.horizontalAlignment = GridData.BEGINNING;
236     gd.horizontalSpan = 2;
237     BoldCheckBox.setLayoutData(gd);
238
239     ItalicCheckBox = new Button(stylesComposite, SWT.CHECK);
240     ItalicCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.italic")); //$NON-NLS-1$
241     ItalicCheckBox.setEnabled(false);
242     gd = new GridData(GridData.FILL_HORIZONTAL);
243     gd.horizontalAlignment = GridData.BEGINNING;
244     gd.horizontalSpan = 2;
245     ItalicCheckBox.setLayoutData(gd);
246
247     UnderlineCheckBox = new Button(stylesComposite, SWT.CHECK);
248     UnderlineCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.underline")); //$NON-NLS-1$
249     UnderlineCheckBox.setEnabled(false);
250     gd = new GridData(GridData.FILL_HORIZONTAL);
251     gd.horizontalAlignment = GridData.BEGINNING;
252     gd.horizontalSpan = 2;
253     UnderlineCheckBox.setLayoutData(gd);
254
255     Composite customSyntaxComposite = new Composite(colorComposite, SWT.NONE);
256     layout = new GridLayout();
257     layout.marginHeight = 0;
258     layout.marginWidth = 0;
259     layout.numColumns = 3;
260     stylesComposite.setLayout(layout);
261     stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
262
263     userdefPHPSyntaxFileFFE =
264       new FileFieldEditor(
265         IPreferenceConstants.PHP_USERDEF_XMLFILE,
266         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntaxdialog"),
267         colorComposite);
268     userdefPHPSyntaxFileFFE.setPreferencePage(this);
269     userdefPHPSyntaxFileFFE.setPreferenceStore(getPreferenceStore());
270     userdefPHPSyntaxFileFFE.load();
271
272     SyntaxColorList.addSelectionListener(new SelectionListener() {
273       public void widgetDefaultSelected(SelectionEvent e) {
274         // do nothing
275       }
276       public void widgetSelected(SelectionEvent e) {
277         handleSyntaxColorListSelection();
278       }
279     });
280
281     foregroundColorButton.addSelectionListener(new SelectionListener() {
282       public void widgetDefaultSelected(SelectionEvent e) {
283         // do nothing
284       }
285       public void widgetSelected(SelectionEvent e) {
286         int i = SyntaxColorList.getSelectionIndex();
287         String key = SyntaxColorListModel[i][1];
288
289         PreferenceConverter.setValue(OverlayStore, key, SyntaxForegroundColorEditor.getColorValue());
290       }
291     });
292     BoldCheckBox.addSelectionListener(new SelectionListener() {
293       public void widgetDefaultSelected(SelectionEvent e) {
294         // do nothing
295       }
296       public void widgetSelected(SelectionEvent e) {
297         int i = SyntaxColorList.getSelectionIndex();
298         String key = SyntaxColorListModel[i][1];
299         OverlayStore.setValue(key + "_bold", BoldCheckBox.getSelection());
300       }
301     });
302
303     ItalicCheckBox.addSelectionListener(new SelectionListener() {
304       public void widgetDefaultSelected(SelectionEvent e) {
305         // do nothing
306       }
307       public void widgetSelected(SelectionEvent e) {
308         int i = SyntaxColorList.getSelectionIndex();
309         String key = SyntaxColorListModel[i][1];
310         OverlayStore.setValue(key + "_italic", ItalicCheckBox.getSelection());
311       }
312     });
313
314     UnderlineCheckBox.addSelectionListener(new SelectionListener() {
315       public void widgetDefaultSelected(SelectionEvent e) {
316         // do nothing
317       }
318       public void widgetSelected(SelectionEvent e) {
319         int i = SyntaxColorList.getSelectionIndex();
320         String key = SyntaxColorListModel[i][1];
321         OverlayStore.setValue(key + "_underline", UnderlineCheckBox.getSelection());
322       }
323     });
324     return colorComposite;
325   }
326
327   private void initializeViewerColors(ISourceViewer viewer) {
328
329     IPreferenceStore store = OverlayStore;
330     if (store != null) {
331
332       StyledText styledText = viewer.getTextWidget();
333     }
334   }
335
336   private Color createColor(IPreferenceStore store, String key, Display display) {
337     RGB rgb = null;
338     if (store.contains(key)) {
339       if (store.isDefault(key))
340         rgb = PreferenceConverter.getDefaultColor(store, key);
341       else
342         rgb = PreferenceConverter.getColor(store, key);
343       if (rgb != null)
344         return new Color(display, rgb);
345     }
346     return null;
347   }
348
349   private static void setEnabled(Control control, boolean enable) {
350     control.setEnabled(enable);
351     if (control instanceof Composite) {
352       Composite composite = (Composite) control;
353       Control[] children = composite.getChildren();
354       for (int i = 0; i < children.length; i++)
355         setEnabled(children[i], enable);
356     }
357   }
358
359   private static void indent(Control control) {
360     GridData gridData = new GridData();
361     gridData.horizontalIndent = 20;
362     control.setLayoutData(gridData);
363   }
364
365   private static void createDependency(final Button master, final Control slave) {
366     indent(slave);
367     master.addSelectionListener(new SelectionListener() {
368       public void widgetSelected(SelectionEvent e) {
369         slave.setEnabled(master.getSelection());
370       }
371
372       public void widgetDefaultSelected(SelectionEvent e) {
373       }
374     });
375   }
376
377   protected Control createContents(Composite parent) {
378     OverlayStore.load();
379     OverlayStore.start();
380     //Create overall composite
381     Composite composite = new Composite(parent, SWT.NONE);
382     GridLayout layout = new GridLayout();
383     layout.marginHeight = 0;
384     layout.marginWidth = 0;
385     composite.setLayout(layout);
386     Composite syntaxComposite = new Composite(composite, SWT.NULL);
387     syntaxComposite.setLayout(new GridLayout());
388     layout = new GridLayout();
389     layout.numColumns = 3;
390     Group syntaxGroup = new Group(syntaxComposite, SWT.NONE);
391     syntaxGroup.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.foreground"));
392     syntaxGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
393     syntaxGroup.setLayout(layout);
394     createSyntaxPage(syntaxGroup);
395
396     Composite backgroundOptions = new Composite(composite,SWT.NULL);
397     backgroundOptions.setLayout(new GridLayout());
398     layout = new GridLayout();
399     layout.numColumns = 3;
400     Group backgroundOptionsGroup = new Group(backgroundOptions,SWT.NONE);
401     backgroundOptionsGroup.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.background"));
402     backgroundOptionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
403     backgroundOptionsGroup.setLayout(layout);
404     backgroundOptionPage(backgroundOptionsGroup);
405
406     initialize();
407     
408    
409     showLineNumber = new BooleanFieldEditor(PHPeclipsePlugin.LINE_NUMBER_RULER, 
410     "Show line numbers", composite);
411     showLineNumber.setPreferencePage(this);
412     showLineNumber.setPreferenceStore(getPreferenceStore());
413     showLineNumber.load();
414     
415 //    formatterTabSize = new IntegerFieldEditor(PHPeclipsePlugin.FORMATTER_TAB_SIZE, 
416 //    "Displayed tab width", composite, 3);
417 //    formatterTabSize.setPreferencePage(this);
418 //    formatterTabSize.setPreferenceStore(getPreferenceStore());
419 //    formatterTabSize.load();
420 //    
421 //    spacesForTabs = new BooleanFieldEditor(PHPeclipsePlugin.SPACES_FOR_TABS, 
422 //    "Spaces for Tabs", composite);
423 //    spacesForTabs.setPreferencePage(this);
424 //    spacesForTabs.setPreferenceStore(getPreferenceStore());
425 //    spacesForTabs.load();
426     return composite;
427   }
428
429   private void initialize() {
430     initializeFields();
431     for (int i = 0; i < SyntaxColorListModel.length; i++)
432       SyntaxColorList.add(SyntaxColorListModel[i][0]);
433     SyntaxColorList.getDisplay().asyncExec(new Runnable() {
434       public void run() {
435         if (SyntaxColorList != null && !SyntaxColorList.isDisposed()) {
436           SyntaxColorList.select(0);
437           handleSyntaxColorListSelection();
438         }
439       }
440     });
441   }
442
443   private void initializeFields() {
444
445     Iterator e = ColorButtons.keySet().iterator();
446     while (e.hasNext()) {
447       ColorEditor c = (ColorEditor) e.next();
448       String key = (String) ColorButtons.get(c);
449       RGB rgb = PreferenceConverter.getColor(OverlayStore, key);
450       c.setColorValue(rgb);
451     }
452
453     e = CheckBoxes.keySet().iterator();
454     while (e.hasNext()) {
455       Button b = (Button) e.next();
456       String key = (String) CheckBoxes.get(b);
457       b.setSelection(OverlayStore.getBoolean(key));
458     }
459   }
460
461   public boolean performOk() {
462     OverlayStore.propagate();
463     IPreferenceStore store = getPreferenceStore();
464     PHPeclipsePlugin.getDefault().savePluginPreferences();
465     userdefPHPSyntaxFileFFE.store();
466     showLineNumber.store();
467     spacesForTabs.store();
468     formatterTabSize.store();
469     return true;
470   }
471
472   protected void performDefaults() {
473     OverlayStore.loadDefaults();
474     initializeFields();
475     handleSyntaxColorListSelection();
476     userdefPHPSyntaxFileFFE.loadDefault();
477     showLineNumber.loadDefault();
478     spacesForTabs.loadDefault();
479     showLineNumber.loadDefault();
480     formatterTabSize.loadDefault();
481     super.performDefaults();
482   }
483
484   public void dispose() {
485     if (OverlayStore != null) {
486       OverlayStore.stop();
487       OverlayStore = null;
488     }
489     super.dispose();
490   }
491
492   private Control addColorButton(Composite composite, String label, String key, int indentation) {
493     Label labelControl = new Label(composite, SWT.NONE);
494     labelControl.setText(label);
495     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
496     gd.horizontalIndent = indentation;
497     labelControl.setLayoutData(gd);
498     ColorEditor editor = new ColorEditor(composite);
499     Button button = editor.getButton();
500     button.setData(editor);
501     gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
502     button.setLayoutData(gd);
503     button.addSelectionListener(ColorButtonListener);
504     ColorButtons.put(editor, key);
505     return composite;
506   }
507
508   private Button addCheckBox(Composite parent, String label, String key, int indentation) {
509     Button checkBox = new Button(parent, SWT.CHECK);
510     checkBox.setText(label);
511     GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
512     gd.horizontalIndent = indentation;
513     gd.horizontalSpan = 2;
514     checkBox.setLayoutData(gd);
515     checkBox.addSelectionListener(CheckBoxListener);
516     CheckBoxes.put(checkBox, key);
517     return checkBox;
518   }
519
520   private void updateStatus(IStatus status) {
521   }
522
523   /**
524    * @deprecated Inline to avoid reference to preference page
525    */
526   public static boolean indicateQuixFixableProblems() {
527     //          return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
528     return false;
529   }
530
531   /**
532    * @deprecated Inline to avoid reference to preference page
533    */
534   static public boolean synchronizeOutlineOnCursorMove() {
535     //          return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
536     return false;
537   }
538
539 }