From: jsimomaa Date: Mon, 14 Aug 2017 03:55:32 +0000 (+0300) Subject: SCLProgressMonitor implements IProgressMonitor X-Git-Tag: v1.31.0~250 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=5d2dad68967203d1354410c153d219fc684f30e0;p=simantics%2Fplatform.git SCLProgressMonitor implements IProgressMonitor refs #7426 Change-Id: I17975178e3627db2ba623edc22cf938e4df9c9b8 --- diff --git a/bundles/org.simantics.scl.osgi/scl/UI/Progress.scl b/bundles/org.simantics.scl.osgi/scl/UI/Progress.scl index 6e8c0ed30..05e870406 100644 --- a/bundles/org.simantics.scl.osgi/scl/UI/Progress.scl +++ b/bundles/org.simantics.scl.osgi/scl/UI/Progress.scl @@ -11,3 +11,7 @@ importJava "org.eclipse.core.runtime.IProgressMonitor" where importJava "org.eclipse.core.runtime.NullProgressMonitor" where @JavaName "" createNullProgressMonitor :: () -> ProgressMonitor + +importJava "org.simantics.scl.osgi.SCLProgressMonitor" where + @JavaName "" + sclProgressMonitor :: (String -> Float -> ()) -> (() -> ()) -> (() -> Boolean) -> (Boolean -> ()) -> (String -> ()) -> (String -> ()) -> (Float -> ()) -> ProgressMonitor 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 new file mode 100644 index 000000000..4f115a87d --- /dev/null +++ b/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/SCLProgressMonitor.java @@ -0,0 +1,69 @@ +package org.simantics.scl.osgi; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.simantics.scl.runtime.function.Function1; +import org.simantics.scl.runtime.function.Function2; +import org.simantics.scl.runtime.tuple.Tuple0; + +public class SCLProgressMonitor implements IProgressMonitor { + + private final Function2 beginTask; + private final Function1 done; + private final Function1 isCanceled; + private final Function1 setCanceled; + private final Function1 setTaskName; + private final Function1 subTask; + private final Function1 worked; + + public SCLProgressMonitor(Function2 beginTask, Function1 done, + Function1 isCanceled, Function1 setCanceled, + Function1 setTaskName, Function1 subTask, Function1 worked) { + this.beginTask = beginTask; + this.done = done; + this.isCanceled = isCanceled; + this.setCanceled = setCanceled; + this.setTaskName = setTaskName; + this.subTask = subTask; + this.worked = worked; + } + + @Override + public void beginTask(String name, int totalWork) { + beginTask.apply(name, new Float(totalWork)); + } + + @Override + public void done() { + done.apply(Tuple0.INSTANCE); + } + + @Override + public void internalWorked(double work) { + } + + @Override + public boolean isCanceled() { + return isCanceled.apply(Tuple0.INSTANCE); + } + + @Override + public void setCanceled(boolean value) { + setCanceled.apply(value); + } + + @Override + public void setTaskName(String name) { + setTaskName.apply(name); + } + + @Override + public void subTask(String name) { + subTask.apply(name); + } + + @Override + public void worked(int work) { + worked.apply(new Float(work)); + } + +}