]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db/src/org/simantics/db/service/UndoRedoSupport.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / service / UndoRedoSupport.java
diff --git a/bundles/org.simantics.db/src/org/simantics/db/service/UndoRedoSupport.java b/bundles/org.simantics.db/src/org/simantics/db/service/UndoRedoSupport.java
new file mode 100644 (file)
index 0000000..36b5a96
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.service;\r
+\r
+import java.util.Collection;\r
+import java.util.List;\r
+\r
+import org.simantics.db.Operation;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.UndoContext;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.ConflictException;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public interface UndoRedoSupport {\r
+\r
+    Operation getCurrent();\r
+\r
+    /**\r
+     * @param operations\r
+     * @return Operation generated by the undo operation.\r
+     * \r
+     * @throws DatabaseException\r
+     * @throws ConflictException\r
+     */\r
+    Operation undo(Collection<Operation> operations)\r
+    throws DatabaseException, ConflictException;\r
+\r
+    /**\r
+     * This is just a wrapper for the undo operation above. See documentation above\r
+     * \r
+     * @param op the operation that will be undone.\r
+     * @throws DatabaseException\r
+     * @throws ConflictException\r
+     */\r
+    void undo(Operation op)\r
+    throws DatabaseException, ConflictException;\r
+\r
+    /**\r
+     * Undo first count operations from the session undo list.\r
+     * \r
+     * @param count number of operations to revert and move to sessions redo list.\r
+     * @return Number of changes sets reverted.\r
+     * @throws DatabaseException\r
+     * @throws ConflictException\r
+     */\r
+    int undo(Session session, int count)\r
+    throws DatabaseException;\r
+    \r
+    List<Operation> undoAndReturnOperations(Session session, int count)\r
+    throws DatabaseException;   \r
+    \r
+    List<Operation> redo(Session session, int count)\r
+    throws DatabaseException;\r
+\r
+    int undoTo(Session session, long changeSet)\r
+    throws DatabaseException;\r
+\r
+    int initUndoListFrom(Session session, long changeSet)\r
+    throws DatabaseException;\r
+\r
+    /**\r
+     * @return undo context used by given session. If session does not support\r
+     *         undo or session is disposed, <code>null</code> will be returned.\r
+     */\r
+    UndoContext getUndoContext(Session session);\r
+\r
+    interface ChangeListener {\r
+        /**\r
+         * Called when undo/redo lists change. \r
+         */\r
+        void onChanged();\r
+    }\r
+    void subscribe(ChangeListener changeListener);\r
+    void cancel(ChangeListener changeListener);\r
+    \r
+    void addExternalOperation(WriteGraph graph, ExternalOperation op);\r
+    \r
+}\r