View Javadoc

1   /* ======================================
2    * Copyright (c) 2004-2005 Achim Nierbeck
3    * All rights reserved.
4    *
5    * You may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *       http://www.gnu.org/licenses/lgpl.html
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   * ======================================
16   */
17  
18  /*
19   * TimeTrackPreferencePage.java
20   * $Revision: 1.5 $
21   * Date 14.12.2005
22   * 
23   * $Author: nierbeck $ 
24   * $Date: 2006/02/02 21:31:31 $ 
25   * 
26   */
27  
28  package de.nierbeck.timeTrack.preferences;
29  
30  import org.eclipse.jface.preference.*;
31  import org.eclipse.ui.IWorkbenchPreferencePage;
32  import org.eclipse.ui.IWorkbench;
33  import de.nierbeck.timeTrack.TimeTrackPlugin;
34  
35  /***
36   * This class represents a preference page that is contributed to the
37   * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>,
38   * we can use the field support built into JFace that allows us to create a page
39   * that is small and knows how to save, restore and apply itself.
40   * <p>
41   * This page is used to modify preferences only. They are stored in the
42   * preference store that belongs to the main plug-in class. That way,
43   * preferences can be accessed directly via the preference store.
44   */
45  
46  public class TimeTrackPreferencePage extends FieldEditorPreferencePage
47  		implements IWorkbenchPreferencePage {
48  
49  	/***
50  	 * Constructor
51  	 *
52  	 */
53  	public TimeTrackPreferencePage() {
54  		super(GRID);
55  		setPreferenceStore(TimeTrackPlugin.getDefault().getPreferenceStore());
56  		// setDescription("A demonstration of a preference page
57  		// implementation");
58  		setDescription("Initializes the TimeTrack Plugin. Here you can set where "
59  				+ "to look for the xml file containing the data and the preferences "
60  				+ "for the Report");
61  	}
62  
63  	/***
64  	 * Creates the field editors. Field editors are abstractions of the common
65  	 * GUI blocks needed to manipulate various types of preferences. Each field
66  	 * editor knows how to save and restore itself.
67  	 */
68  	public final void createFieldEditors() {
69  		addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH,
70  				"&Directory to look for\nthe xml-files:",
71  				getFieldEditorParent()));
72  
73  		StringFieldEditor editor = new StringFieldEditor(
74  				PreferenceConstants.P_FILE, "The &xml-file name:",
75  				getFieldEditorParent());
76  
77  		editor.setEmptyStringAllowed(false);
78  
79  		addField(editor);
80  
81  		IntegerFieldEditor updateEditor = new IntegerFieldEditor(
82  				PreferenceConstants.P_UPDATE_INTERVALL, "The &update intervall:",
83  				getFieldEditorParent());
84  		updateEditor.setEmptyStringAllowed(false);
85  		updateEditor.load();
86  
87  		addField(updateEditor);
88  
89  		// addField(new DirectoryFieldEditor(PreferenceConstants.P_PATH,
90  		// "&Directory preference:", getFieldEditorParent()));
91  		// addField(
92  		// new BooleanFieldEditor(
93  		// PreferenceConstants.P_BOOLEAN,
94  		// "&An example of a boolean preference",
95  		// getFieldEditorParent()));
96  		//
97  		// addField(new RadioGroupFieldEditor(
98  		// PreferenceConstants.P_CHOICE,
99  		// "An example of a multiple-choice preference",
100 		// 1,
101 		// new String[][] { { "&Choice 1", "choice1" }, {
102 		// "C&hoice 2", "choice2" }
103 		// }, getFieldEditorParent()));
104 		// addField(
105 		// new StringFieldEditor(PreferenceConstants.P_STRING, "A &text
106 		// preference:", getFieldEditorParent()));
107 	}
108 
109 	/***
110 	 * @param workbench - the parent
111 	 * 
112 	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
113 	 */
114 	public void init(IWorkbench workbench) {
115 	}
116 
117 	/***
118 	 * @return returns the super.performOK()
119 	 * 
120 	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
121 	 */
122 	public final boolean performOk() {
123 		boolean b = super.performOk();
124 		TimeTrackPlugin.getTimeTrackManager().reloadState();
125 		return b;
126 	}
127 
128 }