Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/port80/eclipse/csharp/preferences/CSharpEditorPreferencePage.java


1   package com.port80.eclipse.csharp.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.CustomFontFieldEditor;
12  import com.port80.eclipse.util.HexColorFieldEditor;
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 CSharpEditorPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IConstants {
30  
31    ////////////////////////////////////////////////////////////////////////
32  
33    private static final String NAME="CSharpEditorPreferencePage";
34    
35    ////////////////////////////////////////////////////////////////////////
36  
37    public CSharpEditorPreferencePage() {
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 sync=EditorsPlugin.getResourceString("SyncSelection");
67      String validate=EditorsPlugin.getResourceString("ValidateAfterAction");
68      String indent_preprocessor=EditorsPlugin.getResourceString("IndentPreprocessor");
69      String indent_case=EditorsPlugin.getResourceString("IndentCase");
70      String warn_unused_token=EditorsPlugin.getResourceString("WarnUnusedToken");
71      String warn_unused_nonterminal=EditorsPlugin.getResourceString("WarnUnusedNonTerminal");
72      //
73      addField(new IntegerFieldEditor(PREF_CSHARP_LINEWIDTH, linewidth, getFieldEditorParent()));
74      addField(new IntegerFieldEditor(PREF_CSHARP_TABWIDTH, tabwidth, getFieldEditorParent()));
75      addField(new BooleanFieldEditor(PREF_CSHARP_INDENT_USE_TAB, usetab, getFieldEditorParent()));
76      addField(new HexColorFieldEditor(PREF_CSHARP_BG, background,getFieldEditorParent()));
77      addField(new CustomFontFieldEditor(PREF_CSHARP_FONT, font, getFieldEditorParent()));
78      addField(new SeparatorFieldEditor("", "", getFieldEditorParent()));
79      addField(new BooleanFieldEditor(PREF_CSHARP_INDENT_PREPROCESSOR, indent_preprocessor, getFieldEditorParent()));
80      addField(new BooleanFieldEditor(PREF_CSHARP_INDENT_CASE, indent_case, getFieldEditorParent()));
81      addField(new BooleanFieldEditor(PREF_CSHARP_WARN_UNUSED_TOKEN, warn_unused_token, getFieldEditorParent()));
82      addField(new BooleanFieldEditor(PREF_CSHARP_WARN_UNUSED_NONTERMINAL, warn_unused_nonterminal, getFieldEditorParent()));
83      addField(new BooleanFieldEditor(PREF_CSHARP_VALIDATE_AFTER_ACTION, validate, getFieldEditorParent()));
84      addField(new SeparatorFieldEditor("", "", getFieldEditorParent()));
85      addField(new BooleanFieldEditor(PREF_CSHARP_SYNC_SELECTION, sync, getFieldEditorParent()));
86      addField(new SeparatorFieldEditor("", "", getFieldEditorParent()));
87    }
88  
89    public void init(IWorkbench workbench) {
90    }
91  }