1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
57
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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 }