1 package org.simantics.scl.osgi;
3 import org.eclipse.core.runtime.IProgressMonitor;
4 import org.simantics.scl.runtime.function.Function1;
5 import org.simantics.scl.runtime.function.Function2;
6 import org.simantics.scl.runtime.tuple.Tuple0;
8 public class SCLProgressMonitor implements IProgressMonitor {
10 private final Function2<String, Float, Tuple0> beginTask;
11 private final Function1<Tuple0, Tuple0> done;
12 private final Function1<Tuple0, Boolean> isCanceled;
13 private final Function1<Boolean, Tuple0> setCanceled;
14 private final Function1<String, Tuple0> setTaskName;
15 private final Function1<String, Tuple0> subTask;
16 private final Function1<Float, Tuple0> worked;
18 public SCLProgressMonitor(Function2<String, Float, Tuple0> beginTask, Function1<Tuple0, Tuple0> done,
19 Function1<Tuple0, Boolean> isCanceled, Function1<Boolean, Tuple0> setCanceled,
20 Function1<String, Tuple0> setTaskName, Function1<String, Tuple0> subTask, Function1<Float, Tuple0> worked) {
21 this.beginTask = beginTask;
23 this.isCanceled = isCanceled;
24 this.setCanceled = setCanceled;
25 this.setTaskName = setTaskName;
26 this.subTask = subTask;
31 public void beginTask(String name, int totalWork) {
32 beginTask.apply(name, new Float(totalWork));
37 done.apply(Tuple0.INSTANCE);
41 public void internalWorked(double work) {
45 public boolean isCanceled() {
46 return isCanceled.apply(Tuple0.INSTANCE);
50 public void setCanceled(boolean value) {
51 setCanceled.apply(value);
55 public void setTaskName(String name) {
56 setTaskName.apply(name);
60 public void subTask(String name) {
65 public void worked(int work) {
66 worked.apply(new Float(work));