]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Minor cleanup for workspace size tracking code. 25/1225/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 15 Nov 2017 07:52:03 +0000 (09:52 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 15 Nov 2017 08:15:36 +0000 (10:15 +0200)
refs #7617
refs #7618

Change-Id: I836bf9bcb9bb50115a308ff3487a98772d5d6f11

bundles/org.simantics.filesystem.services/META-INF/MANIFEST.MF
bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/IWorkspaceSizeTrackerConstants.java
bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/contributions/WorkspaceSizeTrackerTrim.java
bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferenceInitializer.java
bundles/org.simantics.ui.workspace.tracker/src/org/simantics/ui/workspace/tracker/internal/preferences/WorkspaceSizeTrackingPreferencePage.java

index 2347ee2758acfb6f5fc5111f410fadcffbf623d3..dc608d2c41df548610d26745b6b82abd37611d5d 100644 (file)
@@ -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
index d8fe6dc8fb44b32625efda8f14892219a8cc1c3e..2a83778fefa9c18d92787fa2c76d538685a1c6ec 100644 (file)
@@ -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;
+
 }
index 58dca581a771aef0480d71b55887cb34049d99b3..0e133421bbb27507dfbd20f92b13b6adc6b2387d 100644 (file)
@@ -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);
index 27a620e50fcd907db868d96c566a657027772f64..f6eb4084e4a0f283be504068428b7d3221120079 100644 (file)
@@ -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);
        }
 
 }
index 447bd543b698a63761fb8002b275147e64767b94..54cd0fc73965557158c3f29fa1fd3e8b04300f4a 100644 (file)
@@ -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);
        }