Source code: com/port80/eclipse/editors/preferences/JavaccEditorPreferencePage.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 JavaccEditorPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IConstants {
29
30 ////////////////////////////////////////////////////////////////////////
31
32 private static final String NAME="JavaccEditorPreferencePage";
33
34 ////////////////////////////////////////////////////////////////////////
35
36 public JavaccEditorPreferencePage() {
37 super(GRID);
38 setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore());
39 // setDescription(EditorsPlugin.getResourceString(NAME+".description"));
40 initializeDefaults();
41 }
42
43 ////////////////////////////////////////////////////////////////////////
44
45 /**
46 * Sets the default values of the preferences.
47 */
48 private void initializeDefaults() {
49 getPreferenceStore();
50 }
51
52 /**
53 * Creates the field editors. Field editors are abstractions of
54 * the common GUI blocks needed to manipulate various types
55 * of preferences. Each field editor knows how to save and
56 * restore itself.
57 */
58
59 public void createFieldEditors() {
60 String linewidth=EditorsPlugin.getResourceString("LineWidth");
61 String tabwidth=EditorsPlugin.getResourceString("TabWidth");
62 String usetab=EditorsPlugin.getResourceString("UseTab");
63 String background=EditorsPlugin.getResourceString("Background");
64 String font=EditorsPlugin.getResourceString("Font");
65 String sync=EditorsPlugin.getResourceString("SyncSelection");
66 String validate=EditorsPlugin.getResourceString("ValidateAfterAction");
67 String codecolumn=EditorsPlugin.getResourceString("CodeColumn");
68 String warn_unused_token=EditorsPlugin.getResourceString("WarnUnusedToken");
69 String warn_unused_nonterminal=EditorsPlugin.getResourceString("WarnUnusedNonTerminal");
70 //
71 addField(new IntegerFieldEditor(PREF_JAVACC_LINEWIDTH, linewidth, getFieldEditorParent()));
72 addField(new IntegerFieldEditor(PREF_JAVACC_TABWIDTH, tabwidth, getFieldEditorParent()));
73 addField(new BooleanFieldEditor(PREF_JAVACC_INDENT_USE_TAB, usetab, getFieldEditorParent()));
74 addField(new HexColorFieldEditor(PREF_JAVACC_BG, background,getFieldEditorParent()));
75 addField(new CustomFontFieldEditor(PREF_JAVACC_FONT, font, getFieldEditorParent()));
76 addField(new SeparatorFieldEditor("", "", getFieldEditorParent()));
77 addField(new IntegerFieldEditor(PREF_JAVACC_CODE_COLUMN, codecolumn, getFieldEditorParent()));
78 addField(new BooleanFieldEditor(PREF_JAVACC_WARN_UNUSED_TOKEN, warn_unused_token, getFieldEditorParent()));
79 addField(new BooleanFieldEditor(PREF_JAVACC_WARN_UNUSED_NONTERMINAL, warn_unused_nonterminal, getFieldEditorParent()));
80 addField(new BooleanFieldEditor(PREF_JAVACC_VALIDATE_AFTER_ACTION, validate, getFieldEditorParent()));
81 addField(new SeparatorFieldEditor("", "", getFieldEditorParent()));
82 addField(new BooleanFieldEditor(PREF_JAVACC_SYNC_SELECTION, sync, getFieldEditorParent()));
83 addField(new SeparatorFieldEditor("", "", getFieldEditorParent()));
84 }
85
86 public void init(IWorkbench workbench) {
87 }
88 }