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.g2d.diagram.handler;
14 import org.simantics.g2d.diagram.IDiagram;
15 import org.simantics.g2d.element.ElementClass.Required;
16 import org.simantics.g2d.element.ElementClass.Single;
19 * @author Toni Kalajainen
23 public interface TransactionContext extends DiagramHandler {
25 public static enum TransactionType {
29 public static interface Transaction {
30 TransactionType getType();
32 public static class Impl implements Transaction {
34 public Impl(TransactionType type) {
38 public TransactionType getType() {
42 public String toString() {
43 return "Transaction.Impl[" + type + "]";
49 * A listener for diagram transaction context events.
51 public static interface TransactionListener {
53 * Invoked when the transaction has been started and locked properly
55 * {@link TransactionContext#startTransaction(IDiagram, TransactionType)}
58 * @param d the diagram where the transaction has started
59 * @param t the transaction handle
61 void transactionStarted(IDiagram d, Transaction t);
64 * Invoked if a transaction is committed using
65 * {@link TransactionContext#finishTransaction(IDiagram, Transaction)}
66 * while transaction t still holds on to its lock, either read or write.
68 * @param d the diagram where the transaction took place
69 * @param t the transaction handle
71 void transactionFinished(IDiagram d, Transaction t);
74 void addTransactionListener(IDiagram d, TransactionListener l);
75 void removeTransactionListener(IDiagram d, TransactionListener l);
77 Transaction startTransaction(IDiagram d, TransactionType type);
78 void finishTransaction(IDiagram d, Transaction t);
81 // * @deprecated will be removed
84 // public static class ChangeSet {
85 // public List<IElement> added, removed;
86 // public Map<IElement, HintContext> modifications;