]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.db/src/org/simantics/graph/db/TGStatusMonitor.java
Sync git svn branch with SVN repository r33349.
[simantics/platform.git] / bundles / org.simantics.graph.db / src / org / simantics / graph / db / TGStatusMonitor.java
index 06e0adbedb659f31fe4e1092c28ef8d9643128b9..8f93639eac225667401e242bd1e1e0b8993cc6ff 100644 (file)
@@ -20,23 +20,28 @@ public interface TGStatusMonitor {
     public static class Updater {\r
         private final TGStatusMonitor monitor;\r
         private final int total;\r
-        private int percentage;\r
+        private int low;\r
+        private int high;\r
+        private int current;\r
         private int worked;\r
 \r
-        public Updater(TGStatusMonitor monitor, int total) {\r
+        public Updater(TGStatusMonitor monitor, int lowPercentage, int highPercentage, int totalWork) {\r
             this.monitor = monitor;\r
-            this.total = total;\r
+            this.low = lowPercentage;\r
+            this.high = highPercentage;\r
+            this.total = totalWork;\r
         }\r
 \r
         public int worked(int work) {\r
             worked += work;\r
-            return percentage = updatePercentage(monitor, percentage, worked, total);\r
+            return current = updatePercentage(monitor, low, high, current, worked, total);\r
         }\r
     }\r
 \r
-    public static int updatePercentage(TGStatusMonitor monitor, int oldPercentage, int done, int total) {\r
-        int current = (100 * done) / total;\r
-        if (current > oldPercentage) {\r
+    public static int updatePercentage(TGStatusMonitor monitor, int low, int high, int oldPercentage, int done, int total) {\r
+        int range = high - low;\r
+        int current = low + (range * done) / total;\r
+        if (current != oldPercentage) {\r
             oldPercentage = current;\r
             if (monitor != null) \r
                 monitor.status(oldPercentage);\r