KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.objectweb.dolphin.resources.DolphinResourcesManagment;
31
32 /**
33  * This class represents a preference page that
34  * is contributed to the Preferences dialog. By
35  * subclassing <samp>FieldEditorPreferencePage</samp>, we
36  * can use the field support built into JFace that allows
37  * us to create a page that is small and knows how to
38  * save, restore and apply itself.
39  * <p>
40  * This page is used to modify preferences only. They
41  * are stored in the preference store that belongs to
42  * the main plug-in class. That way, preferences can
43  * be accessed directly via the preference store.
44  *
45  * @author Bourgeon Jérôme, Macherel Bruno
46  *
47  */

48 public class DolphinPreferencePage
49     extends FieldEditorPreferencePage
50     implements IWorkbenchPreferencePage {
51
52     DirectoryFieldEditor directory;
53
54     /**
55      * Create a new DolphinPreferencePage
56      */

57     public DolphinPreferencePage() {
58         super(GRID);
59
60         setPreferenceStore(DolphinPlugin.getDefault().getPreferenceStore());
61         setDescription("Switch the current workspace to another one");
62     }
63
64     /**
65      * Creates the field editors. Field editors are abstractions of
66      * the common GUI blocks needed to manipulate various types
67      * of preferences. Each field editor knows how to save and
68      * restore itself.
69      *
70      * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
71      */

72     public void createFieldEditors() {
73         directory = new DirectoryFieldEditor(PreferenceConstants.P_WORKSPACE,"&Switch workspace : ", getFieldEditorParent());
74         directory.setChangeButtonText("Browse");
75         addField(directory);
76
77 // addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH,
78
// "&Directory preference:", getFieldEditorParent()));
79
// addField(
80
// new BooleanFieldEditor(
81
// PreferenceConstants.P_BOOLEAN,
82
// "&An example of a boolean preference",
83
// getFieldEditorParent()));
84
//
85
// addField(new RadioGroupFieldEditor(
86
// PreferenceConstants.P_CHOICE,
87
// "An example of a multiple-choice preference",
88
// 1,
89
// new String[][] { { "&Choice 1", "choice1" }, {
90
// "C&hoice 2", "choice2" }
91
// }, getFieldEditorParent()));
92
// addField(
93
// new StringFieldEditor(PreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent()));
94
}
95
96     /**
97      * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
98      */

99     public void init(IWorkbench workbench) {
100     }
101
102     /**
103      * Save the workspace
104      * @see org.eclipse.jface.preference.IPreferencePage#performOk()
105      */

106     public boolean performOk() {
107         performApply();
108         return super.performOk();
109     }
110
111     /**
112      * Save the workspace
113      * @see org.eclipse.jface.preference.PreferencePage#performApply()
114      */

115     protected void performApply() {
116         DolphinResourcesManagment.setWorkspace(directory.getStringValue());
117     }
118
119     /**
120      * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
121      */

122     public boolean performCancel() {
123         return super.performCancel();
124     }
125
126
127 }
Popular Tags