1 package org.simantics.ui.workspace.tracker.internal.preferences;
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;
15 * @author Tuukka Lehtonen
18 public class WorkspaceSizeTrackingPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
20 private BooleanFieldEditor fShowSizeMonitor;
21 private IntegerFieldEditor fUpdateInterval;
22 private BooleanFieldEditor fHighlightLowSpace;
23 private IntegerFieldEditor fLowSpaceThreshold;
26 * Create the console page.
28 public WorkspaceSizeTrackingPreferencePage() {
30 setDescription(Messages.WorkspaceSizeTrackingPreferencePage_Workspace_Size_Tracking_Settings);
31 setPreferenceStore(Activator.getDefault().getPreferenceStore());
35 * @see org.eclipse.jface.preference.PreferencePage#createControl(Composite)
38 public void createControl(Composite parent) {
39 super.createControl(parent);
43 * Create all field editors for this page
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, 500000);
56 addField(fLowSpaceThreshold);
60 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
63 public void init(IWorkbench workbench) {
67 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
70 public boolean performOk() {
71 boolean show = fShowSizeMonitor.getBooleanValue();
72 WorkspaceSizeTrackerContribution.showTracker(show);
73 return super.performOk();