Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbundles/runtime/org.eclipse.fx.core/META-INF/MANIFEST.MF1
-rw-r--r--bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/operation/CancelableOperation.java34
-rw-r--r--bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/operation/Operation.java40
3 files changed, 75 insertions, 0 deletions
diff --git a/bundles/runtime/org.eclipse.fx.core/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.core/META-INF/MANIFEST.MF
index 4fcd380de..707e16113 100755
--- a/bundles/runtime/org.eclipse.fx.core/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.core/META-INF/MANIFEST.MF
@@ -13,6 +13,7 @@ Export-Package: org.eclipse.fx.core,
org.eclipse.fx.core.command,
org.eclipse.fx.core.function,
org.eclipse.fx.core.log,
+ org.eclipse.fx.core.operation,
org.eclipse.fx.core.text,
org.eclipse.fx.core.update
Bundle-Vendor: %Bundle-Vendor
diff --git a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/operation/CancelableOperation.java b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/operation/CancelableOperation.java
new file mode 100644
index 000000000..927e49a3e
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/operation/CancelableOperation.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2015 BestSolution.at and others.
+ * 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.core.operation;
+
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * Abstract operation who can be canceled
+ *
+ * @param <T>
+ * the type produced when completed successfully
+ */
+public interface CancelableOperation<T> extends Operation<T> {
+ /**
+ * Called when the operation is canceled
+ *
+ * @param consumer
+ * the consumer
+ */
+ public void onCancel(@NonNull Runnable consumer);
+
+ /**
+ * Cancel the running operation
+ */
+ public void cancel();
+}
diff --git a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/operation/Operation.java b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/operation/Operation.java
new file mode 100644
index 000000000..4791c9cd7
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/operation/Operation.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2015 BestSolution.at and others.
+ * 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.core.operation;
+
+import java.util.function.Consumer;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * Abstract operation who is running async and informs about its state
+ *
+ * @param <T>
+ * the value produced by the operation
+ */
+public interface Operation<T> {
+ /**
+ * Called when the operation completes successfully
+ *
+ * @param consumer
+ * consumer invoked
+ */
+ public void onComplete(@NonNull Consumer<@Nullable T> consumer);
+
+ /**
+ * Called when the operation completes with an exception
+ *
+ * @param consumer
+ * the consumer invoked
+ */
+ public void onException(@NonNull Consumer<@NonNull Throwable> consumer);
+}

Back to the top