Source code: com/port80/eclipse/editors/preferences/CSSEditorPreferencePage.java
1 package com.port80.eclipse.editors.preferences;
2
3 import org.eclipse.jface.preference.BooleanFieldEditor;
4 import org.eclipse.jface.preference.FieldEditorPreferencePage;
5 import org.eclipse.jface.preference.IntegerFieldEditor;
6 import org.eclipse.ui.IWorkbench;
7 import org.eclipse.ui.IWorkbenchPreferencePage;
8
9 import com.port80.eclipse.editors.EditorsPlugin;
10 import com.port80.eclipse.editors.IConstants;
11 import com.port80.eclipse.util.*;
12 import com.port80.eclipse.util.SeparatorFieldEditor;
13
14 /**
15 * This class represents a preference page that
16 * is contributed to the Preferences dialog. By
17 * subclassing <samp>FieldEditorPreferencePage</samp>, we
18 * can use the field support built into JFace that allows
19 * us to create a page that is small and knows how to
20 * save, restore and apply itself.
21 * <p>
22 * This page is used to modify preferences only. They
23 * are stored in the preference store that belongs to
24 * the main plug-in class. That way, preferences can
25 * be accessed directly via the preference store.
26 */
27
28 public class CSSEditorPreferencePage
29 extends FieldEditorPreferencePage
30 implements IWorkbenchPreferencePage, IConstants {
31
32 ////////////////////////////////////////////////////////////////////////
33
34 private static final String NAME = "CSSEditorPreferencePage";
35
36 ////////////////////////////////////////////////////////////////////////
37
38 public CSSEditorPreferencePage() {
39 super(GRID);
40 setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore());
41 // setDescription(EditorsPlugin.getResourceString(NAME + ".description"));
42 initializeDefaults();
43 }
44
45 ////////////////////////////////////////////////////////////////////////
46
47 /**
48 * Sets the default values of the preferences.
49 */
50 private void initializeDefaults() {
51 // Dummy to ensure preference store loaded and initialized.
52 getPreferenceStore();
53 }
54
55 /**
56 * Creates the field editors. Field editors are abstractions of
57 * the common GUI blocks needed to manipulate various types
58 * of preferences. Each field editor knows how to save and
59 * restore itself.
60 */
61
62 public void createFieldEditors() {
63 String linewidth = EditorsPlugin.getResourceString("LineWidth");
64 String tabwidth = EditorsPlugin.getResourceString("TabWidth");
65 String usetab = EditorsPlugin.getResourceString("UseTab");
66 String background = EditorsPlugin.getResourceString("Background");
67 String font = EditorsPlugin.getResourceString("Font");
68 addField(new IntegerFieldEditor(PREF_CSS_LINEWIDTH, linewidth, getFieldEditorParent()));
69 addField(new IntegerFieldEditor(PREF_CSS_TABWIDTH, tabwidth, getFieldEditorParent()));
70 addField(new BooleanFieldEditor(PREF_CSS_INDENT_USE_TAB, usetab, getFieldEditorParent()));
71 addField(new HexColorFieldEditor(PREF_CSS_BG, background, getFieldEditorParent()));
72 addField(new CustomFontFieldEditor(PREF_CSS_FONT, font, getFieldEditorParent()));
73 addField(new SeparatorFieldEditor("", "", getFieldEditorParent()));
74 }
75
76 public void init(IWorkbench workbench) {
77 }
78 }