From 11eb20e8c57df9fc846ff200112fafb4b8683a05 Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Tue, 6 Feb 2018 08:16:29 +0200 Subject: [PATCH] More options for SCL progress monitoring #7744 Change-Id: I10169845aa780ce6f351ea54fde814d8d2f0eee8 --- bundles/org.simantics.scl.osgi/scl/UI/Progress.scl | 9 +++++++++ .../org/simantics/scl/osgi/SCLProgressMonitor.java | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/bundles/org.simantics.scl.osgi/scl/UI/Progress.scl b/bundles/org.simantics.scl.osgi/scl/UI/Progress.scl index f09d49d48..3805e163f 100644 --- a/bundles/org.simantics.scl.osgi/scl/UI/Progress.scl +++ b/bundles/org.simantics.scl.osgi/scl/UI/Progress.scl @@ -14,11 +14,20 @@ importJava "org.eclipse.core.runtime.SubMonitor" where @JavaName convert convertMonitor :: ProgressMonitor -> Integer -> SubMonitor newChild :: SubMonitor -> Integer -> ProgressMonitor + split :: SubMonitor -> Integer -> ProgressMonitor + @JavaName "worked" + workedSM :: SubMonitor -> Integer -> () importJava "org.eclipse.core.runtime.NullProgressMonitor" where @JavaName "" createNullProgressMonitor :: () -> ProgressMonitor importJava "org.simantics.scl.osgi.SCLProgressMonitor" where + data SCLProgressMonitor @JavaName "" sclProgressMonitor :: (String -> Float -> ()) -> (() -> ()) -> (() -> Boolean) -> (Boolean -> ()) -> (String -> ()) -> (String -> ()) -> (Float -> ()) -> ProgressMonitor + @JavaName "getWork" + sclProgressMonitorWork :: SCLProgressMonitor -> Float + @JavaName "getSubTask" + sclProgressMonitorSubTask :: SCLProgressMonitor -> String + \ No newline at end of file diff --git a/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/SCLProgressMonitor.java b/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/SCLProgressMonitor.java index 4f115a87d..256a0de57 100644 --- a/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/SCLProgressMonitor.java +++ b/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/SCLProgressMonitor.java @@ -7,6 +7,9 @@ import org.simantics.scl.runtime.tuple.Tuple0; public class SCLProgressMonitor implements IProgressMonitor { + int recordedWork = 0; + String currentSubtask = ""; + private final Function2 beginTask; private final Function1 done; private final Function1 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; } } -- 2.47.1