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