1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.service;
14 import java.util.Collection;
15 import java.util.List;
17 import org.simantics.db.Operation;
18 import org.simantics.db.Session;
19 import org.simantics.db.UndoContext;
20 import org.simantics.db.WriteGraph;
21 import org.simantics.db.exception.ConflictException;
22 import org.simantics.db.exception.DatabaseException;
24 public interface UndoRedoSupport {
26 Operation getCurrent();
30 * @return Operation generated by the undo operation.
32 * @throws DatabaseException
33 * @throws ConflictException
35 Operation undo(Collection<Operation> operations)
36 throws DatabaseException, ConflictException;
39 * This is just a wrapper for the undo operation above. See documentation above
41 * @param op the operation that will be undone.
42 * @throws DatabaseException
43 * @throws ConflictException
45 void undo(Operation op)
46 throws DatabaseException, ConflictException;
49 * Undo first count operations from the session undo list.
51 * @param count number of operations to revert and move to sessions redo list.
52 * @return Number of changes sets reverted.
53 * @throws DatabaseException
54 * @throws ConflictException
56 int undo(Session session, int count)
57 throws DatabaseException;
59 List<Operation> undoAndReturnOperations(Session session, int count)
60 throws DatabaseException;
62 List<Operation> redo(Session session, int count)
63 throws DatabaseException;
65 int undoTo(Session session, long changeSet)
66 throws DatabaseException;
68 int initUndoListFrom(Session session, long changeSet)
69 throws DatabaseException;
72 * @return undo context used by given session. If session does not support
73 * undo or session is disposed, <code>null</code> will be returned.
75 UndoContext getUndoContext(Session session);
77 interface ChangeListener {
79 * Called when undo/redo lists change.
83 void subscribe(ChangeListener changeListener);
84 void cancel(ChangeListener changeListener);
86 void addExternalOperation(WriteGraph graph, ExternalOperation op);