1 package net.sourceforge.phpeclipse;
3 import java.util.HashMap;
4 import java.util.Iterator;
7 import net.sourceforge.phpeclipse.preferences.ColorEditor;
8 import net.sourceforge.phpeclipse.preferences.OverlayPreferenceStore;
9 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
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;
38 * The preference page for setting the PHP Editor options.
40 public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
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),
81 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_KEYWORD),
82 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_KEYWORD_BOLD),
83 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_KEYWORD_ITALIC),
84 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_KEYWORD_UNDERLINE),
85 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_TAG),
86 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_TAG_BOLD),
87 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_TAG_ITALIC),
88 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_TAG_UNDERLINE),
89 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_LINK),
90 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_LINK_BOLD),
91 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_LINK_ITALIC),
92 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_LINK_UNDERLINE),
93 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_DEFAULT),
94 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_DEFAULT_BOLD),
95 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_DEFAULT_ITALIC),
96 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_DEFAULT_UNDERLINE),
98 new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_USERDEF_XMLFILE),
99 // new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_EDITOR_BACKGROUND)
102 private final String[][] SyntaxColorListModel =
105 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.multiLineComment"),
106 IPreferenceConstants.PHP_MULTILINE_COMMENT },
108 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.singleLineComment"),
109 IPreferenceConstants.PHP_SINGLELINE_COMMENT },
111 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.keywords"), IPreferenceConstants.PHP_KEYWORD }, {
112 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.variables"), IPreferenceConstants.PHP_VARIABLE }, {
113 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.types"), IPreferenceConstants.PHP_TYPE }, {
114 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.functions"), IPreferenceConstants.PHP_FUNCTIONNAME }, {
115 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.constants"), IPreferenceConstants.PHP_CONSTANT }, {
116 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.strings"), IPreferenceConstants.PHP_STRING }, {
117 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.others"), IPreferenceConstants.PHP_DEFAULT }, {
118 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_keywords"), IPreferenceConstants.PHPDOC_KEYWORD }, {
119 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_tags"), IPreferenceConstants.PHPDOC_TAG }, {
120 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_links"), IPreferenceConstants.PHPDOC_LINK }, {
121 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_others"), IPreferenceConstants.PHPDOC_DEFAULT }
124 private OverlayPreferenceStore OverlayStore;
126 private Map ColorButtons = new HashMap();
127 private SelectionListener ColorButtonListener = new SelectionListener() {
128 public void widgetDefaultSelected(SelectionEvent e) {
130 public void widgetSelected(SelectionEvent e) {
131 ColorEditor editor = (ColorEditor) e.widget.getData();
132 PreferenceConverter.setValue(OverlayStore, (String) ColorButtons.get(editor), editor.getColorValue());
136 private Map CheckBoxes = new HashMap();
137 private SelectionListener CheckBoxListener = new SelectionListener() {
138 public void widgetDefaultSelected(SelectionEvent e) {
140 public void widgetSelected(SelectionEvent e) {
141 Button button = (Button) e.widget;
142 OverlayStore.setValue((String) CheckBoxes.get(button), button.getSelection());
146 private List SyntaxColorList;
147 /** The ColorEditor that choose the foreground color. */
148 private ColorEditor SyntaxForegroundColorEditor;
149 private Button BoldCheckBox;
150 private Button ItalicCheckBox;
151 private Button UnderlineCheckBox;
152 private FileFieldEditor userdefPHPSyntaxFileFFE;
153 // private BooleanFieldEditor showLineNumber;
154 // private IntegerFieldEditor formatterTabSize;
155 // private BooleanFieldEditor spacesForTabs;
157 public PHPSyntaxEditorPreferencePage() {
158 setDescription(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.description")); //$NON-NLS-1$
159 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
160 OverlayStore = new OverlayPreferenceStore(getPreferenceStore(), Keys);
163 public void init(IWorkbench workbench) {
166 public void createControl(Composite parent) {
167 super.createControl(parent);
170 private void handleSyntaxColorListSelection() {
171 int i = SyntaxColorList.getSelectionIndex();
172 String key = SyntaxColorListModel[i][1];
173 RGB rgb = PreferenceConverter.getColor(OverlayStore, key);
174 SyntaxForegroundColorEditor.setColorValue(rgb);
175 BoldCheckBox.setSelection(OverlayStore.getBoolean(key + "_bold"));
176 ItalicCheckBox.setSelection(OverlayStore.getBoolean(key + "_italic"));
177 UnderlineCheckBox.setSelection(OverlayStore.getBoolean(key + "_underline"));
181 * Create the group of options for other parameters (background color for example).
182 * @param parent the parent component
184 private void backgroundOptionPage(Composite parent) {
185 Label label = new Label(parent, SWT.LEFT);
186 label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.color")); //$NON-NLS-1$
187 GridData gd = new GridData();
188 gd.horizontalAlignment = GridData.BEGINNING;
189 label.setLayoutData(gd);
190 // final ColorEditor syntaxBackgroundColorEditor = new ColorEditor(parent);
191 // RGB rgb = PreferenceConverter.getColor(OverlayStore, IPreferenceConstants.PHP_EDITOR_BACKGROUND);
192 // syntaxBackgroundColorEditor.setColorValue(rgb);
193 // Button backgroundColorButton = syntaxBackgroundColorEditor.getButton();
194 // gd = new GridData(GridData.FILL_HORIZONTAL);
195 // gd.horizontalAlignment = GridData.BEGINNING;
196 // backgroundColorButton.setLayoutData(gd);
197 // backgroundColorButton.addSelectionListener(new SelectionListener() {
198 // public void widgetDefaultSelected(SelectionEvent e) {
201 // public void widgetSelected(SelectionEvent e) {
202 // PreferenceConverter.setValue(OverlayStore, IPreferenceConstants.PHP_EDITOR_BACKGROUND, syntaxBackgroundColorEditor.getColorValue());
208 * Create the group of options for the syntax parameters.
209 * @param parent the parent component
212 private Control createSyntaxPage(Composite parent) {
214 Composite colorComposite = new Composite(parent, SWT.NULL);
215 colorComposite.setLayout(new GridLayout());
217 Label label = new Label(colorComposite, SWT.LEFT);
218 label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntax")); //$NON-NLS-1$
219 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
221 Composite editorComposite = new Composite(colorComposite, SWT.NONE);
222 GridLayout layout = new GridLayout();
223 layout.numColumns = 2;
224 layout.marginHeight = 0;
225 layout.marginWidth = 0;
226 editorComposite.setLayout(layout);
227 GridData gd = new GridData(GridData.FILL_BOTH);
228 editorComposite.setLayoutData(gd);
230 SyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
231 gd = new GridData(GridData.FILL_BOTH);
232 gd.heightHint = convertHeightInCharsToPixels(5);
233 SyntaxColorList.setLayoutData(gd);
235 Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
236 layout = new GridLayout();
237 layout.marginHeight = 0;
238 layout.marginWidth = 0;
239 layout.numColumns = 2;
240 stylesComposite.setLayout(layout);
241 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
243 label = new Label(stylesComposite, SWT.LEFT);
244 label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.color")); //$NON-NLS-1$
246 gd.horizontalAlignment = GridData.BEGINNING;
247 label.setLayoutData(gd);
249 SyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
250 Button foregroundColorButton = SyntaxForegroundColorEditor.getButton();
251 gd = new GridData(GridData.FILL_HORIZONTAL);
252 gd.horizontalAlignment = GridData.BEGINNING;
253 foregroundColorButton.setLayoutData(gd);
255 BoldCheckBox = new Button(stylesComposite, SWT.CHECK);
256 BoldCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.bold")); //$NON-NLS-1$
257 gd = new GridData(GridData.FILL_HORIZONTAL);
258 gd.horizontalAlignment = GridData.BEGINNING;
259 gd.horizontalSpan = 2;
260 BoldCheckBox.setLayoutData(gd);
262 ItalicCheckBox = new Button(stylesComposite, SWT.CHECK);
263 ItalicCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.italic")); //$NON-NLS-1$
264 ItalicCheckBox.setEnabled(false);
265 gd = new GridData(GridData.FILL_HORIZONTAL);
266 gd.horizontalAlignment = GridData.BEGINNING;
267 gd.horizontalSpan = 2;
268 ItalicCheckBox.setLayoutData(gd);
270 UnderlineCheckBox = new Button(stylesComposite, SWT.CHECK);
271 UnderlineCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.underline")); //$NON-NLS-1$
272 UnderlineCheckBox.setEnabled(false);
273 gd = new GridData(GridData.FILL_HORIZONTAL);
274 gd.horizontalAlignment = GridData.BEGINNING;
275 gd.horizontalSpan = 2;
276 UnderlineCheckBox.setLayoutData(gd);
278 Composite customSyntaxComposite = new Composite(colorComposite, SWT.NONE);
279 layout = new GridLayout();
280 layout.marginHeight = 0;
281 layout.marginWidth = 0;
282 layout.numColumns = 3;
283 stylesComposite.setLayout(layout);
284 stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
286 userdefPHPSyntaxFileFFE =
288 IPreferenceConstants.PHP_USERDEF_XMLFILE,
289 PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntaxdialog"),
291 userdefPHPSyntaxFileFFE.setPreferencePage(this);
292 userdefPHPSyntaxFileFFE.setPreferenceStore(getPreferenceStore());
293 userdefPHPSyntaxFileFFE.load();
295 SyntaxColorList.addSelectionListener(new SelectionListener() {
296 public void widgetDefaultSelected(SelectionEvent e) {
299 public void widgetSelected(SelectionEvent e) {
300 handleSyntaxColorListSelection();
304 foregroundColorButton.addSelectionListener(new SelectionListener() {
305 public void widgetDefaultSelected(SelectionEvent e) {
308 public void widgetSelected(SelectionEvent e) {
309 int i = SyntaxColorList.getSelectionIndex();
310 String key = SyntaxColorListModel[i][1];
312 PreferenceConverter.setValue(OverlayStore, key, SyntaxForegroundColorEditor.getColorValue());
315 BoldCheckBox.addSelectionListener(new SelectionListener() {
316 public void widgetDefaultSelected(SelectionEvent e) {
319 public void widgetSelected(SelectionEvent e) {
320 int i = SyntaxColorList.getSelectionIndex();
321 String key = SyntaxColorListModel[i][1];
322 OverlayStore.setValue(key + "_bold", BoldCheckBox.getSelection());
326 ItalicCheckBox.addSelectionListener(new SelectionListener() {
327 public void widgetDefaultSelected(SelectionEvent e) {
330 public void widgetSelected(SelectionEvent e) {
331 int i = SyntaxColorList.getSelectionIndex();
332 String key = SyntaxColorListModel[i][1];
333 OverlayStore.setValue(key + "_italic", ItalicCheckBox.getSelection());
337 UnderlineCheckBox.addSelectionListener(new SelectionListener() {
338 public void widgetDefaultSelected(SelectionEvent e) {
341 public void widgetSelected(SelectionEvent e) {
342 int i = SyntaxColorList.getSelectionIndex();
343 String key = SyntaxColorListModel[i][1];
344 OverlayStore.setValue(key + "_underline", UnderlineCheckBox.getSelection());
347 return colorComposite;
350 private void initializeViewerColors(ISourceViewer viewer) {
352 IPreferenceStore store = OverlayStore;
355 StyledText styledText = viewer.getTextWidget();
359 private Color createColor(IPreferenceStore store, String key, Display display) {
361 if (store.contains(key)) {
362 if (store.isDefault(key))
363 rgb = PreferenceConverter.getDefaultColor(store, key);
365 rgb = PreferenceConverter.getColor(store, key);
367 return new Color(display, rgb);
372 private static void setEnabled(Control control, boolean enable) {
373 control.setEnabled(enable);
374 if (control instanceof Composite) {
375 Composite composite = (Composite) control;
376 Control[] children = composite.getChildren();
377 for (int i = 0; i < children.length; i++)
378 setEnabled(children[i], enable);
382 private static void indent(Control control) {
383 GridData gridData = new GridData();
384 gridData.horizontalIndent = 20;
385 control.setLayoutData(gridData);
388 private static void createDependency(final Button master, final Control slave) {
390 master.addSelectionListener(new SelectionListener() {
391 public void widgetSelected(SelectionEvent e) {
392 slave.setEnabled(master.getSelection());
395 public void widgetDefaultSelected(SelectionEvent e) {
400 protected Control createContents(Composite parent) {
402 OverlayStore.start();
403 //Create overall composite
404 Composite composite = new Composite(parent, SWT.NONE);
405 GridLayout layout = new GridLayout();
406 layout.marginHeight = 0;
407 layout.marginWidth = 0;
408 composite.setLayout(layout);
409 Composite syntaxComposite = new Composite(composite, SWT.NULL);
410 syntaxComposite.setLayout(new GridLayout());
411 layout = new GridLayout();
412 layout.numColumns = 3;
413 Group syntaxGroup = new Group(syntaxComposite, SWT.NONE);
414 syntaxGroup.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.foreground"));
415 syntaxGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
416 syntaxGroup.setLayout(layout);
417 createSyntaxPage(syntaxGroup);
419 Composite backgroundOptions = new Composite(composite,SWT.NULL);
420 backgroundOptions.setLayout(new GridLayout());
421 layout = new GridLayout();
422 layout.numColumns = 3;
423 Group backgroundOptionsGroup = new Group(backgroundOptions,SWT.NONE);
424 backgroundOptionsGroup.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.background"));
425 backgroundOptionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
426 backgroundOptionsGroup.setLayout(layout);
427 backgroundOptionPage(backgroundOptionsGroup);
432 // showLineNumber = new BooleanFieldEditor(PHPeclipsePlugin.LINE_NUMBER_RULER,
433 // "Show line numbers", composite);
434 // showLineNumber.setPreferencePage(this);
435 // showLineNumber.setPreferenceStore(getPreferenceStore());
436 // showLineNumber.load();
438 // formatterTabSize = new IntegerFieldEditor(PHPeclipsePlugin.FORMATTER_TAB_SIZE,
439 // "Displayed tab width", composite, 3);
440 // formatterTabSize.setPreferencePage(this);
441 // formatterTabSize.setPreferenceStore(getPreferenceStore());
442 // formatterTabSize.load();
444 // spacesForTabs = new BooleanFieldEditor(PHPeclipsePlugin.SPACES_FOR_TABS,
445 // "Spaces for Tabs", composite);
446 // spacesForTabs.setPreferencePage(this);
447 // spacesForTabs.setPreferenceStore(getPreferenceStore());
448 // spacesForTabs.load();
452 private void initialize() {
454 for (int i = 0; i < SyntaxColorListModel.length; i++)
455 SyntaxColorList.add(SyntaxColorListModel[i][0]);
456 SyntaxColorList.getDisplay().asyncExec(new Runnable() {
458 if (SyntaxColorList != null && !SyntaxColorList.isDisposed()) {
459 SyntaxColorList.select(0);
460 handleSyntaxColorListSelection();
466 private void initializeFields() {
468 Iterator e = ColorButtons.keySet().iterator();
469 while (e.hasNext()) {
470 ColorEditor c = (ColorEditor) e.next();
471 String key = (String) ColorButtons.get(c);
472 RGB rgb = PreferenceConverter.getColor(OverlayStore, key);
473 c.setColorValue(rgb);
476 e = CheckBoxes.keySet().iterator();
477 while (e.hasNext()) {
478 Button b = (Button) e.next();
479 String key = (String) CheckBoxes.get(b);
480 b.setSelection(OverlayStore.getBoolean(key));
484 public boolean performOk() {
485 OverlayStore.propagate();
486 IPreferenceStore store = getPreferenceStore();
487 PHPeclipsePlugin.getDefault().savePluginPreferences();
488 userdefPHPSyntaxFileFFE.store();
489 // showLineNumber.store();
490 // spacesForTabs.store();
491 // formatterTabSize.store();
495 protected void performDefaults() {
496 OverlayStore.loadDefaults();
498 handleSyntaxColorListSelection();
499 userdefPHPSyntaxFileFFE.loadDefault();
500 // showLineNumber.loadDefault();
501 // spacesForTabs.loadDefault();
502 // showLineNumber.loadDefault();
503 // formatterTabSize.loadDefault();
504 super.performDefaults();
507 public void dispose() {
508 if (OverlayStore != null) {
515 private Control addColorButton(Composite composite, String label, String key, int indentation) {
516 Label labelControl = new Label(composite, SWT.NONE);
517 labelControl.setText(label);
518 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
519 gd.horizontalIndent = indentation;
520 labelControl.setLayoutData(gd);
521 ColorEditor editor = new ColorEditor(composite);
522 Button button = editor.getButton();
523 button.setData(editor);
524 gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
525 button.setLayoutData(gd);
526 button.addSelectionListener(ColorButtonListener);
527 ColorButtons.put(editor, key);
531 private Button addCheckBox(Composite parent, String label, String key, int indentation) {
532 Button checkBox = new Button(parent, SWT.CHECK);
533 checkBox.setText(label);
534 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
535 gd.horizontalIndent = indentation;
536 gd.horizontalSpan = 2;
537 checkBox.setLayoutData(gd);
538 checkBox.addSelectionListener(CheckBoxListener);
539 CheckBoxes.put(checkBox, key);
543 private void updateStatus(IStatus status) {
547 * @deprecated Inline to avoid reference to preference page
549 public static boolean indicateQuixFixableProblems() {
550 // return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
555 * @deprecated Inline to avoid reference to preference page
557 static public boolean synchronizeOutlineOnCursorMove() {
558 // return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);