]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.db.service;\r
13 \r
14 import java.util.Collection;\r
15 import java.util.List;\r
16 \r
17 import org.simantics.db.Operation;\r
18 import org.simantics.db.Session;\r
19 import org.simantics.db.UndoContext;\r
20 import org.simantics.db.WriteGraph;\r
21 import org.simantics.db.exception.ConflictException;\r
22 import org.simantics.db.exception.DatabaseException;\r
23 \r
24 public interface UndoRedoSupport {\r
25 \r
26     Operation getCurrent();\r
27 \r
28     /**\r
29      * @param operations\r
30      * @return Operation generated by the undo operation.\r
31      * \r
32      * @throws DatabaseException\r
33      * @throws ConflictException\r
34      */\r
35     Operation undo(Collection<Operation> operations)\r
36     throws DatabaseException, ConflictException;\r
37 \r
38     /**\r
39      * This is just a wrapper for the undo operation above. See documentation above\r
40      * \r
41      * @param op the operation that will be undone.\r
42      * @throws DatabaseException\r
43      * @throws ConflictException\r
44      */\r
45     void undo(Operation op)\r
46     throws DatabaseException, ConflictException;\r
47 \r
48     /**\r
49      * Undo first count operations from the session undo list.\r
50      * \r
51      * @param count number of operations to revert and move to sessions redo list.\r
52      * @return Number of changes sets reverted.\r
53      * @throws DatabaseException\r
54      * @throws ConflictException\r
55      */\r
56     int undo(Session session, int count)\r
57     throws DatabaseException;\r
58     \r
59     List<Operation> undoAndReturnOperations(Session session, int count)\r
60     throws DatabaseException;   \r
61     \r
62     List<Operation> redo(Session session, int count)\r
63     throws DatabaseException;\r
64 \r
65     int undoTo(Session session, long changeSet)\r
66     throws DatabaseException;\r
67 \r
68     int initUndoListFrom(Session session, long changeSet)\r
69     throws DatabaseException;\r
70 \r
71     /**\r
72      * @return undo context used by given session. If session does not support\r
73      *         undo or session is disposed, <code>null</code> will be returned.\r
74      */\r
75     UndoContext getUndoContext(Session session);\r
76 \r
77     interface ChangeListener {\r
78         /**\r
79          * Called when undo/redo lists change. \r
80          */\r
81         void onChanged();\r
82     }\r
83     void subscribe(ChangeListener changeListener);\r
84     void cancel(ChangeListener changeListener);\r
85     \r
86     void addExternalOperation(WriteGraph graph, ExternalOperation op);\r
87     \r
88 }\r