KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dolphin > preferences > SamplePreferencePage


1 /*
2 * Copyright (C) 2005 Bourgeon Jérôme, Macherel Bruno
3 *
4 * This file is part of Dolphin
5 *
6 * Dolphin : An open source J2EE Deployment Tool JSR-88 compliant
7 * Contact: ishmael-dev@objectweb.org
8 *
9 * Dolphin is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or any later version.
13 *
14 * Dolphin is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with Dolphin; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 */

24 package org.objectweb.dolphin.preferences;
25
26 import org.eclipse.jface.preference.*;
27 import org.eclipse.ui.IWorkbenchPreferencePage;
28 import org.eclipse.ui.IWorkbench;
29 import org.objectweb.dolphin.DolphinPlugin;
30
31 /**
32  * This class represents a preference page that
33  * is contributed to the Preferences dialog. By
34  * subclassing <samp>FieldEditorPreferencePage</samp>, we
35  * can use the field support built into JFace that allows
36  * us to create a page that is small and knows how to
37  * save, restore and apply itself.
38  * <p>
39  * This page is used to modify preferences only. They
40  * are stored in the preference store that belongs to
41  * the main plug-in class. That way, preferences can
42  * be accessed directly via the preference store.
43  */

44
45 public class SamplePreferencePage
46     extends FieldEditorPreferencePage
47     implements IWorkbenchPreferencePage {
48
49     /**
50      * Create a new SamplePreferencePage
51      */

52     public SamplePreferencePage() {
53         super(GRID);
54         setPreferenceStore(DolphinPlugin.getDefault().getPreferenceStore());
55         setDescription("A demonstration of a preference page implementation");
56     }
57     
58     /**
59      * Creates the field editors. Field editors are abstractions of
60      * the common GUI blocks needed to manipulate various types
61      * of preferences. Each field editor knows how to save and
62      * restore itself.
63      */

64     public void createFieldEditors() {
65         addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH,
66                 "&Directory preference:", getFieldEditorParent()));
67         addField(
68             new BooleanFieldEditor(
69                 PreferenceConstants.P_BOOLEAN,
70                 "&An example of a boolean preference",
71                 getFieldEditorParent()));
72
73         addField(new RadioGroupFieldEditor(
74                 PreferenceConstants.P_CHOICE,
75             "An example of a multiple-choice preference",
76             1,
77             new String JavaDoc[][] { { "&Choice 1", "choice1" }, {
78                 "C&hoice 2", "choice2" }
79         }, getFieldEditorParent()));
80         addField(
81             new StringFieldEditor(PreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent()));
82     }
83
84     /**
85      * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
86      */

87     public void init(IWorkbench workbench) {
88     }
89     
90 }
Popular Tags