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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.service;
\r
14 import java.util.Collection;
\r
15 import java.util.List;
\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
24 public interface UndoRedoSupport {
\r
26 Operation getCurrent();
\r
30 * @return Operation generated by the undo operation.
\r
32 * @throws DatabaseException
\r
33 * @throws ConflictException
\r
35 Operation undo(Collection<Operation> operations)
\r
36 throws DatabaseException, ConflictException;
\r
39 * This is just a wrapper for the undo operation above. See documentation above
\r
41 * @param op the operation that will be undone.
\r
42 * @throws DatabaseException
\r
43 * @throws ConflictException
\r
45 void undo(Operation op)
\r
46 throws DatabaseException, ConflictException;
\r
49 * Undo first count operations from the session undo list.
\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
56 int undo(Session session, int count)
\r
57 throws DatabaseException;
\r
59 List<Operation> undoAndReturnOperations(Session session, int count)
\r
60 throws DatabaseException;
\r
62 List<Operation> redo(Session session, int count)
\r
63 throws DatabaseException;
\r
65 int undoTo(Session session, long changeSet)
\r
66 throws DatabaseException;
\r
68 int initUndoListFrom(Session session, long changeSet)
\r
69 throws DatabaseException;
\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
75 UndoContext getUndoContext(Session session);
\r
77 interface ChangeListener {
\r
79 * Called when undo/redo lists change.
\r
83 void subscribe(ChangeListener changeListener);
\r
84 void cancel(ChangeListener changeListener);
\r
86 void addExternalOperation(WriteGraph graph, ExternalOperation op);
\r