KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > viewer > preferences > AutoScrollPreferencePage


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * *
5  * This library is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or (at your option) any later version. *
9  * *
10  * This library is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13  * Lesser General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Lesser General Public *
16  * License along with this library; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin St, Fifth Floor, *
19  * Boston, MA 02110-1301 USA *
20  * *
21  * Or get it online : *
22  * http://www.gnu.org/copyleft/lesser.html *
23  * *
24  * *
25  ******************************************************************************/

26
27 package org.nightlabs.editor2d.viewer.preferences;
28
29 import org.eclipse.jface.preference.FieldEditorPreferencePage;
30 import org.eclipse.jface.preference.IntegerFieldEditor;
31 import org.eclipse.ui.IWorkbench;
32 import org.eclipse.ui.IWorkbenchPreferencePage;
33
34 import org.nightlabs.editor2d.viewer.BufferManager;
35 import org.nightlabs.editor2d.viewer.ViewerPlugin;
36
37 public class AutoScrollPreferencePage
38 //extends PreferencePage
39
extends FieldEditorPreferencePage
40 implements IWorkbenchPreferencePage
41 {
42     public AutoScrollPreferencePage()
43     {
44         super(GRID);
45         setPreferenceStore(ViewerPlugin.getDefault().getPreferenceStore());
46         setTitle(ViewerPlugin.getResourceString("preferences.autoScroll.title"));
47     }
48             
49     protected IntegerFieldEditor scrollStep;
50     protected IntegerFieldEditor timerDelay;
51     protected IntegerFieldEditor scrollTolerance;
52 //protected IntegerFieldEditor bufferScale;
53

54     protected void createFieldEditors()
55     {
56         scrollStep = new IntegerFieldEditor(Preferences.PREFERENCE_SCROLL_STEP,
57                 ViewerPlugin.getResourceString("preferences.autoScroll.label.scrollStep"),
58                 getFieldEditorParent());
59         scrollStep.setValidRange(1, 25);
60         scrollStep.setTextLimit(2);
61
62         scrollTolerance = new IntegerFieldEditor(Preferences.PREFERENCE_SCROLL_TOLERANCE,
63                 ViewerPlugin.getResourceString("preferences.autoScroll.label.scrollTolerance"),
64                 getFieldEditorParent());
65         scrollTolerance.setValidRange(1, 100);
66         scrollTolerance.setTextLimit(3);
67         
68         timerDelay = new IntegerFieldEditor(Preferences.PREFERENCE_TIMER_DELAY,
69                 ViewerPlugin.getResourceString("preferences.autoScroll.label.timerDelay"),
70                 getFieldEditorParent());
71         timerDelay.setValidRange(1, 100);
72         timerDelay.setTextLimit(3);
73         
74 // bufferScale = new IntegerFieldEditor(Preferences.PREFERENCE_BUFFER_SCALE,
75
// ViewerPlugin.getResourceString("preferences.buffer.label.scaleFactor"),
76
// getFieldEditorParent());
77
// bufferScale.setValidRange(1, 5);
78
// bufferScale.setTextLimit(1);
79

80         addField(scrollStep);
81         addField(scrollTolerance);
82         addField(timerDelay);
83         
84 // scrollStep.setStringValue("25");
85
// scrollTolerance.setStringValue("10");
86
// timerDelay.setStringValue("10");
87
}
88     
89     protected void performDefaults() {
90         Preferences.initDefaultValues(Preferences.getPreferenceStore());
91         super.performDefaults();
92     }
93
94     public boolean performOk()
95     {
96         getPreferenceStore().setValue(Preferences.PREFERENCE_SCROLL_STEP, scrollStep.getIntValue());
97         getPreferenceStore().setValue(Preferences.PREFERENCE_SCROLL_TOLERANCE, scrollTolerance.getIntValue());
98         getPreferenceStore().setValue(Preferences.PREFERENCE_TIMER_DELAY, timerDelay.getIntValue());
99 // return super.performOk();
100
return true;
101     }
102     
103     public void init(IWorkbench workbench) {}
104 }
105
Popular Tags