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