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