KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > console > preferences > HibernateConsolePreferencePage


1 package org.hibernate.eclipse.console.preferences;
2
3 import org.eclipse.jface.preference.*;
4 import org.eclipse.ui.IWorkbenchPreferencePage;
5 import org.eclipse.ui.IWorkbench;
6 import org.hibernate.eclipse.console.HibernateConsolePlugin;
7 import org.eclipse.jface.preference.IPreferenceStore;
8
9 /**
10  * This class represents a preference page that
11  * is contributed to the Preferences dialog. By
12  * subclassing <samp>FieldEditorPreferencePage</samp>, we
13  * can use the field support built into JFace that allows
14  * us to create a page that is small and knows how to
15  * save, restore and apply itself.
16  * <p>
17  * This page is used to modify preferences only. They
18  * are stored in the preference store that belongs to
19  * the main plug-in class. That way, preferences can
20  * be accessed directly via the preference store.
21  */

22
23
24 public class HibernateConsolePreferencePage
25     extends FieldEditorPreferencePage
26     implements IWorkbenchPreferencePage {
27     public static final String JavaDoc P_PATH = "pathPreference";
28     public static final String JavaDoc P_BOOLEAN = "booleanPreference";
29     public static final String JavaDoc P_CHOICE = "choicePreference";
30     public static final String JavaDoc P_STRING = "stringPreference";
31
32     public HibernateConsolePreferencePage() {
33         super(GRID);
34         setPreferenceStore(HibernateConsolePlugin.getDefault().getPreferenceStore());
35         setDescription("A demonstration of a preference page implementation");
36         initializeDefaults();
37     }
38 /**
39  * Sets the default values of the preferences.
40  */

41     private void initializeDefaults() {
42         IPreferenceStore store = getPreferenceStore();
43         store.setDefault(P_BOOLEAN, true);
44         store.setDefault(P_CHOICE, "choice2");
45         store.setDefault(P_STRING, "Default value");
46     }
47     
48 /**
49  * Creates the field editors. Field editors are abstractions of
50  * the common GUI blocks needed to manipulate various types
51  * of preferences. Each field editor knows how to save and
52  * restore itself.
53  */

54
55     public void createFieldEditors() {
56         addField(new DirectoryFieldEditor(P_PATH,
57                 "&Directory preference:", getFieldEditorParent()));
58         addField(
59             new BooleanFieldEditor(
60                 P_BOOLEAN,
61                 "&An example of a boolean preference",
62                 getFieldEditorParent()));
63
64         addField(new RadioGroupFieldEditor(
65             P_CHOICE,
66             "An example of a multiple-choice preference",
67             1,
68             new String JavaDoc[][] { { "&Choice 1", "choice1" }, {
69                 "C&hoice 2", "choice2" }
70         }, getFieldEditorParent()));
71         addField(
72             new StringFieldEditor(P_STRING, "A &text preference:", getFieldEditorParent()));
73     }
74     
75     public void init(IWorkbench workbench) {
76     }
77 }
Popular Tags