]> gerrit.simantics Code Review - simantics/platform.git/blob
54cd0fc73965557158c3f29fa1fd3e8b04300f4a
[simantics/platform.git] /
1 package org.simantics.ui.workspace.tracker.internal.preferences;
2
3 import org.eclipse.jface.preference.BooleanFieldEditor;
4 import org.eclipse.jface.preference.FieldEditorPreferencePage;
5 import org.eclipse.jface.preference.IntegerFieldEditor;
6 import org.eclipse.swt.SWT;
7 import org.eclipse.swt.widgets.Composite;
8 import org.eclipse.ui.IWorkbench;
9 import org.eclipse.ui.IWorkbenchPreferencePage;
10 import org.simantics.ui.workspace.tracker.internal.Activator;
11 import org.simantics.ui.workspace.tracker.internal.contributions.IWorkspaceSizeTrackerConstants;
12 import org.simantics.ui.workspace.tracker.internal.contributions.WorkspaceSizeTrackerContribution;
13
14 /**
15  * @author Tuukka Lehtonen
16  * @since 1.31.0
17  */
18 public class WorkspaceSizeTrackingPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
19
20         private BooleanFieldEditor fShowSizeMonitor;
21         private IntegerFieldEditor fUpdateInterval;
22         private BooleanFieldEditor fHighlightLowSpace;
23         private IntegerFieldEditor fLowSpaceThreshold;
24
25         /**
26          * Create the console page.
27          */
28         public WorkspaceSizeTrackingPreferencePage() {
29                 super(GRID);
30                 setDescription(Messages.WorkspaceSizeTrackingPreferencePage_Workspace_Size_Tracking_Settings);
31                 setPreferenceStore(Activator.getDefault().getPreferenceStore());
32         }
33
34         /* (non-Javadoc)
35          * @see org.eclipse.jface.preference.PreferencePage#createControl(Composite)
36          */
37         @Override
38         public void createControl(Composite parent) {
39                 super.createControl(parent);
40         }
41
42         /**
43          * Create all field editors for this page
44          */
45         @Override
46         public void createFieldEditors() {
47                 fShowSizeMonitor = new BooleanFieldEditor(IWorkspaceSizeTrackerConstants.PREF_SHOW_MONITOR, Messages.WorkspaceSizeTrackingPreferencePage_Show_Monitor, SWT.NONE, getFieldEditorParent());
48                 addField(fShowSizeMonitor);
49                 fUpdateInterval = new IntegerFieldEditor(IWorkspaceSizeTrackerConstants.PREF_UPDATE_INTERVAL, Messages.WorkspaceSizeTrackingPreferencePage_Update_Interval, getFieldEditorParent());
50                 fUpdateInterval.setValidRange(100, 10000);
51                 addField(fUpdateInterval);
52                 fHighlightLowSpace = new BooleanFieldEditor(IWorkspaceSizeTrackerConstants.PREF_HIGHLIGHT_LOW_SPACE, Messages.WorkspaceSizeTrackingPreferencePage_Highlight_Low_Space, SWT.NONE, getFieldEditorParent());
53                 addField(fHighlightLowSpace);
54                 fLowSpaceThreshold = new IntegerFieldEditor(IWorkspaceSizeTrackerConstants.PREF_LOW_SPACE_THRESHOLD, Messages.WorkspaceSizeTrackingPreferencePage_Low_Space_Threshold, getFieldEditorParent());
55                 fLowSpaceThreshold.setValidRange(100, 100000000);
56                 addField(fLowSpaceThreshold);
57         }
58
59         /* (non-Javadoc)
60          * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
61          */
62         @Override
63         public void init(IWorkbench workbench) {
64         }
65
66         /* (non-Javadoc)
67          * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
68          */
69         @Override
70         public boolean performOk() {
71                 boolean show = fShowSizeMonitor.getBooleanValue();
72                 WorkspaceSizeTrackerContribution.showTracker(show);
73                 return super.performOk();
74         }
75
76 }