Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-11-05 03:59:10 -0500
committerEike Stepper2008-11-05 03:59:10 -0500
commit1a19e4c9621bc7e1f93d03889b949d65b8f9beab (patch)
tree560a443d21bd51cce21d1f43773390abda531cbc
parent0bb0bcba9bb7d9b84953f6f82f20b44af661b236 (diff)
downloadcdo-1a19e4c9621bc7e1f93d03889b949d65b8f9beab.tar.gz
cdo-1a19e4c9621bc7e1f93d03889b949d65b8f9beab.tar.xz
cdo-1a19e4c9621bc7e1f93d03889b949d65b8f9beab.zip
make cancelation public
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java18
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java21
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/DelegatingMonitor.java120
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java15
4 files changed, 165 insertions, 9 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java
index 7aae179ea4..b59bbd6a0b 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java
@@ -60,6 +60,15 @@ public abstract class Monitor implements OMMonitor, OMSubMonitor
}
}
+ public void setCanceled(boolean canceled)
+ {
+ this.canceled = canceled;
+ if (child != null)
+ {
+ child.setCanceled(canceled);
+ }
+ }
+
public String getTask()
{
return task;
@@ -191,15 +200,6 @@ public abstract class Monitor implements OMMonitor, OMSubMonitor
this.child = child;
}
- protected void setCanceled(boolean canceled)
- {
- this.canceled = canceled;
- if (child != null)
- {
- child.setCanceled(canceled);
- }
- }
-
protected Monitor getParent()
{
return parent;
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java
index fe19bf1f9c..1390d8f36d 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.internal.util.om.monitor;
+import org.eclipse.net4j.util.om.monitor.MonitorCanceledException;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.monitor.OMSubMonitor;
@@ -20,10 +21,30 @@ public class NullMonitor implements OMMonitor, OMSubMonitor
{
public static final NullMonitor INSTANCE = new NullMonitor();
+ private boolean canceled;
+
private NullMonitor()
{
}
+ public void checkCanceled() throws MonitorCanceledException
+ {
+ if (canceled)
+ {
+ throw new MonitorCanceledException();
+ }
+ }
+
+ public boolean isCanceled()
+ {
+ return canceled;
+ }
+
+ public void setCanceled(boolean canceled)
+ {
+ this.canceled = canceled;
+ }
+
public void join()
{
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/DelegatingMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/DelegatingMonitor.java
new file mode 100644
index 0000000000..18d7e0c996
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/DelegatingMonitor.java
@@ -0,0 +1,120 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util.om.monitor;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public abstract class DelegatingMonitor implements OMMonitor
+{
+ public DelegatingMonitor()
+ {
+ }
+
+ public void checkCanceled() throws MonitorCanceledException
+ {
+ getDelegate().checkCanceled();
+ }
+
+ public boolean isCanceled()
+ {
+ return getDelegate().isCanceled();
+ }
+
+ public void setCanceled(boolean canceled)
+ {
+ getDelegate().setCanceled(canceled);
+ }
+
+ public OMSubMonitor fork()
+ {
+ return getDelegate().fork();
+ }
+
+ public void fork(int workFromParent, Runnable runnable, String msg)
+ {
+ getDelegate().fork(workFromParent, runnable, msg);
+ }
+
+ public void fork(int workFromParent, Runnable runnable)
+ {
+ getDelegate().fork(workFromParent, runnable);
+ }
+
+ public OMSubMonitor fork(int workFromParent)
+ {
+ return getDelegate().fork(workFromParent);
+ }
+
+ public void fork(Runnable runnable, String msg)
+ {
+ getDelegate().fork(runnable, msg);
+ }
+
+ public void fork(Runnable runnable)
+ {
+ getDelegate().fork(runnable);
+ }
+
+ public String getTask()
+ {
+ return getDelegate().getTask();
+ }
+
+ public int getTotalWork()
+ {
+ return getDelegate().getTotalWork();
+ }
+
+ public boolean hasBegun()
+ {
+ return getDelegate().hasBegun();
+ }
+
+ public void message(String msg)
+ {
+ getDelegate().message(msg);
+ }
+
+ public void setTask(String task)
+ {
+ getDelegate().setTask(task);
+ }
+
+ public void worked()
+ {
+ getDelegate().worked();
+ }
+
+ public void worked(int work, String msg)
+ {
+ getDelegate().worked(work, msg);
+ }
+
+ public void worked(int work)
+ {
+ getDelegate().worked(work);
+ }
+
+ public void worked(String msg)
+ {
+ getDelegate().worked(msg);
+ }
+
+ @Override
+ public String toString()
+ {
+ return getDelegate().toString();
+ }
+
+ protected abstract OMMonitor getDelegate();
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java
index 6da225e1b5..3ba918ecec 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java
@@ -25,6 +25,21 @@ public interface OMMonitor
public boolean hasBegun();
+ /**
+ * @since 2.0
+ */
+ public boolean isCanceled();
+
+ /**
+ * @since 2.0
+ */
+ public void setCanceled(boolean canceled);
+
+ /**
+ * @since 2.0
+ */
+ public void checkCanceled() throws MonitorCanceledException;
+
public void message(String msg);
public void worked(int work, String msg);

Back to the top