Source code: com/port80/eclipse/csharp/preferences/CSharpEditorFormatterPreferencePage.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.ui.IWorkbench;
6 import org.eclipse.ui.IWorkbenchPreferencePage;
7
8 import com.port80.eclipse.editors.EditorsPlugin;
9 import com.port80.eclipse.editors.IConstants;
10 import com.port80.eclipse.util.SeparatorFieldEditor;
11
12 /**
13 * This class represents a preference page that
14 * is contributed to the Preferences dialog. By
15 * subclassing <samp>FieldEditorPreferencePage</samp>, we
16 * can use the field support built into JFace that allows
17 * us to create a page that is small and knows how to
18 * save, restore and apply itself.
19 * <p>
20 * This page is used to modify preferences only. They
21 * are stored in the preference store that belongs to
22 * the main plug-in class. That way, preferences can
23 * be accessed directly via the preference store.
24 */
25
26 public class CSharpEditorFormatterPreferencePage
27 extends FieldEditorPreferencePage
28 implements IWorkbenchPreferencePage, IConstants {
29
30 ////////////////////////////////////////////////////////////////////////
31
32 private static final String NAME = "CSharpEditorFormatterPreferencePage";
33
34 ////////////////////////////////////////////////////////////////////////
35
36 public CSharpEditorFormatterPreferencePage() {
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 indent_preprocessor = EditorsPlugin.getResourceString("IndentPreprocessor");
61 String indent_case = EditorsPlugin.getResourceString("IndentCase");
62 String break_declaration_open_brace = EditorsPlugin.getResourceString("BreakDeclarationOpenBrace");
63 String break_control_open_brace = EditorsPlugin.getResourceString("BreakControlOpenBrace");
64 //
65 addField(
66 new BooleanFieldEditor(
67 PREF_CSHARP_INDENT_PREPROCESSOR,
68 indent_preprocessor,
69 getFieldEditorParent()));
70 addField(new BooleanFieldEditor(PREF_CSHARP_INDENT_CASE, indent_case, getFieldEditorParent()));
71 addField(
72 new BooleanFieldEditor(
73 PREF_CSHARP_BREAK_DECLARATION_OPEN_BRACE,
74 break_declaration_open_brace,
75 getFieldEditorParent()));
76 addField(
77 new BooleanFieldEditor(
78 PREF_CSHARP_BREAK_CONTROL_OPEN_BRACE,
79 break_control_open_brace,
80 getFieldEditorParent()));
81 addField(new SeparatorFieldEditor("", "", getFieldEditorParent()));
82 }
83
84 public void init(IWorkbench workbench) {
85 }
86 }