From: Tuukka Lehtonen Date: Wed, 15 Nov 2017 07:52:03 +0000 (+0200) Subject: Minor cleanup for workspace size tracking code. X-Git-Tag: v1.31.0~35 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=b50d1ae1caae9706ebc9e24ce36bf1dfa5d6915f;p=simantics%2Fplatform.git Minor cleanup for workspace size tracking code. refs #7617 refs #7618 Change-Id: I836bf9bcb9bb50115a308ff3487a98772d5d6f11 --- diff --git a/bundles/org.simantics.filesystem.services/META-INF/MANIFEST.MF b/bundles/org.simantics.filesystem.services/META-INF/MANIFEST.MF index 2347ee275..dc608d2c4 100644 --- a/bundles/org.simantics.filesystem.services/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.filesystem.services/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Workspace Size Monitoring Service +Bundle-Name: Simantics File System Services Bundle-SymbolicName: org.simantics.filesystem.services Bundle-Version: 1.0.0.qualifier Bundle-Activator: org.simantics.filesystem.services.internal.Activator diff --git a/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/IWorkspaceSizeTrackerConstants.java b/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/IWorkspaceSizeTrackerConstants.java index d8fe6dc8f..2a83778fe 100644 --- a/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/IWorkspaceSizeTrackerConstants.java +++ b/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/IWorkspaceSizeTrackerConstants.java @@ -8,7 +8,7 @@ package org.simantics.ui.workspace.tracker.internal.contributions; */ public interface IWorkspaceSizeTrackerConstants { - String P_NODE = "org.simantics.ui.workspace.tracker"; + String P_NODE = "org.simantics.ui.workspace.tracker"; //$NON-NLS-1$ /** * Boolean preference key for whether or not to show the status bar workspace @@ -31,4 +31,9 @@ public interface IWorkspaceSizeTrackerConstants { */ String PREF_LOW_SPACE_THRESHOLD = "WorkspaceSizeTracker.lowSpaceThreshold"; //$NON-NLS-1$ + boolean DEFAULT_SHOW_MONITOR = true; + int DEFAULT_UPDATE_INTERVAL = 1000; + boolean DEFAULT_HIGHLIGHT_LOW_SPACE = true; + long DEFAULT_LOW_SPACE_THRESHOLD = 500L; + } diff --git a/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/WorkspaceSizeTrackerTrim.java b/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/WorkspaceSizeTrackerTrim.java index 58dca581a..0e133421b 100644 --- a/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/WorkspaceSizeTrackerTrim.java +++ b/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/WorkspaceSizeTrackerTrim.java @@ -51,12 +51,17 @@ public class WorkspaceSizeTrackerTrim extends Composite { private SizeTracker sizeTracker; private IPreferenceStore prefStore; + /** + * How many MB of free disk space means we are low on disk space? + */ + private long lowSpaceThreshold = IWorkspaceSizeTrackerConstants.DEFAULT_LOW_SPACE_THRESHOLD; + private boolean highlightLowSpace = IWorkspaceSizeTrackerConstants.DEFAULT_HIGHLIGHT_LOW_SPACE; + private int updateInterval = IWorkspaceSizeTrackerConstants.DEFAULT_UPDATE_INTERVAL; + private Color bgCol, usedSpaceCol, lowSpaceCol, topLeftCol, bottomRightCol, sepCol, textCol; @SuppressWarnings("unused") private Color markCol; - private int updateInterval; - private String storeName; private long totalSpace; private long availableSpace; @@ -68,12 +73,6 @@ public class WorkspaceSizeTrackerTrim extends Composite { private boolean hasChanged; private long mark = -1; - /** - * How many MB of free disk space means we are low on disk space? - */ - private long lowSpaceThreshold = 500; - private boolean highlightLowSpace = true; - private boolean updateTooltip = false; private final Runnable timer = new Runnable() { @@ -128,6 +127,8 @@ public class WorkspaceSizeTrackerTrim extends Composite { prefStore.addPropertyChangeListener(prefListener); setUpdateIntervalInMS(prefStore.getInt(IWorkspaceSizeTrackerConstants.PREF_UPDATE_INTERVAL)); + highlightLowSpace = prefStore.getBoolean(IWorkspaceSizeTrackerConstants.PREF_HIGHLIGHT_LOW_SPACE); + lowSpaceThreshold = prefStore.getLong(IWorkspaceSizeTrackerConstants.PREF_LOW_SPACE_THRESHOLD); Display display = getDisplay(); usedSpaceCol = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); diff --git a/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferenceInitializer.java b/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferenceInitializer.java index 27a620e50..f6eb4084e 100644 --- a/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferenceInitializer.java +++ b/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferenceInitializer.java @@ -19,10 +19,10 @@ public class WorkspaceSizeTrackingPreferenceInitializer extends AbstractPreferen public void initializeDefaultPreferences() { IScopeContext context = DefaultScope.INSTANCE; Preferences node = context.getNode(IWorkspaceSizeTrackerConstants.P_NODE); - node.putBoolean(IWorkspaceSizeTrackerConstants.PREF_SHOW_MONITOR, true); - node.putInt(IWorkspaceSizeTrackerConstants.PREF_UPDATE_INTERVAL, 1000); - node.putBoolean(IWorkspaceSizeTrackerConstants.PREF_HIGHLIGHT_LOW_SPACE, true); - node.putLong(IWorkspaceSizeTrackerConstants.PREF_LOW_SPACE_THRESHOLD, 500); + node.putBoolean(IWorkspaceSizeTrackerConstants.PREF_SHOW_MONITOR, IWorkspaceSizeTrackerConstants.DEFAULT_SHOW_MONITOR); + node.putInt(IWorkspaceSizeTrackerConstants.PREF_UPDATE_INTERVAL, IWorkspaceSizeTrackerConstants.DEFAULT_UPDATE_INTERVAL); + node.putBoolean(IWorkspaceSizeTrackerConstants.PREF_HIGHLIGHT_LOW_SPACE, IWorkspaceSizeTrackerConstants.DEFAULT_HIGHLIGHT_LOW_SPACE); + node.putLong(IWorkspaceSizeTrackerConstants.PREF_LOW_SPACE_THRESHOLD, IWorkspaceSizeTrackerConstants.DEFAULT_LOW_SPACE_THRESHOLD); } } diff --git a/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferencePage.java b/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferencePage.java index 447bd543b..54cd0fc73 100644 --- a/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferencePage.java +++ b/bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferencePage.java @@ -52,7 +52,7 @@ public class WorkspaceSizeTrackingPreferencePage extends FieldEditorPreferencePa fHighlightLowSpace = new BooleanFieldEditor(IWorkspaceSizeTrackerConstants.PREF_HIGHLIGHT_LOW_SPACE, Messages.WorkspaceSizeTrackingPreferencePage_Highlight_Low_Space, SWT.NONE, getFieldEditorParent()); addField(fHighlightLowSpace); fLowSpaceThreshold = new IntegerFieldEditor(IWorkspaceSizeTrackerConstants.PREF_LOW_SPACE_THRESHOLD, Messages.WorkspaceSizeTrackingPreferencePage_Low_Space_Threshold, getFieldEditorParent()); - fLowSpaceThreshold.setValidRange(100, 500000); + fLowSpaceThreshold.setValidRange(100, 100000000); addField(fLowSpaceThreshold); }