]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
More options for SCL progress monitoring 22/1422/2
authorAntti Villberg <antti.villberg@semantum.fi>
Tue, 6 Feb 2018 06:16:29 +0000 (08:16 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Tue, 6 Feb 2018 07:23:13 +0000 (09:23 +0200)
#7744

Change-Id: I10169845aa780ce6f351ea54fde814d8d2f0eee8

bundles/org.simantics.scl.osgi/scl/UI/Progress.scl
bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/SCLProgressMonitor.java

index f09d49d48c2f7d0ac598750de7e9b6e5b90048bb..3805e163f4111dc7de09685a0f313aab5de61752 100644 (file)
@@ -14,11 +14,20 @@ importJava "org.eclipse.core.runtime.SubMonitor" where
     @JavaName convert
     convertMonitor :: ProgressMonitor -> Integer -> <Proc> SubMonitor
     newChild :: SubMonitor -> Integer -> <Proc> ProgressMonitor
+    split :: SubMonitor -> Integer -> <Proc> ProgressMonitor
+    @JavaName "worked"
+    workedSM :: SubMonitor -> Integer -> <Proc> ()
 
 importJava "org.eclipse.core.runtime.NullProgressMonitor" where
     @JavaName "<init>"
     createNullProgressMonitor :: () -> <Proc> ProgressMonitor
 
 importJava "org.simantics.scl.osgi.SCLProgressMonitor" where
+    data SCLProgressMonitor
     @JavaName "<init>"
     sclProgressMonitor :: (String -> Float -> <Proc> ()) -> (() -> <Proc> ()) -> (() -> <Proc> Boolean) -> (Boolean -> <Proc> ()) -> (String -> <Proc> ()) -> (String -> <Proc> ()) -> (Float -> <Proc> ()) -> <Proc> ProgressMonitor
+    @JavaName "getWork"
+    sclProgressMonitorWork :: SCLProgressMonitor -> <Proc> Float
+    @JavaName "getSubTask"
+    sclProgressMonitorSubTask :: SCLProgressMonitor -> <Proc> String
+    
\ No newline at end of file
index 4f115a87d4cfdc290e46b89a88971644f6c8f242..256a0de57f2ba43236f664c9c071aef19df76720 100644 (file)
@@ -7,6 +7,9 @@ import org.simantics.scl.runtime.tuple.Tuple0;
 
 public class SCLProgressMonitor implements IProgressMonitor {
 
+       int recordedWork = 0;
+       String currentSubtask = "";
+       
     private final Function2<String, Float, Tuple0> beginTask;
     private final Function1<Tuple0, Tuple0> done;
     private final Function1<Tuple0, Boolean> isCanceled;
@@ -59,11 +62,21 @@ public class SCLProgressMonitor implements IProgressMonitor {
     @Override
     public void subTask(String name) {
         subTask.apply(name);
+        currentSubtask = name;
     }
 
     @Override
     public void worked(int work) {
         worked.apply(new Float(work));
+        recordedWork += work;
+    }
+    
+    public float getWork() {
+       return recordedWork;
+    }
+
+    public String getSubTask() {
+       return currentSubtask;
     }
 
 }