--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.g2d.diagram.handler;\r
+\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementClass.Required;\r
+import org.simantics.g2d.element.ElementClass.Single;\r
+\r
+/**\r
+ * @author Toni Kalajainen\r
+ */\r
+@Single\r
+@Required\r
+public interface TransactionContext extends DiagramHandler {\r
+\r
+ public static enum TransactionType {\r
+ READ, WRITE\r
+ }\r
+\r
+ public static interface Transaction {\r
+ TransactionType getType();\r
+\r
+ public static class Impl implements Transaction {\r
+ TransactionType type;\r
+ public Impl(TransactionType type) {\r
+ this.type = type;\r
+ }\r
+ @Override\r
+ public TransactionType getType() {\r
+ return type;\r
+ }\r
+ @Override\r
+ public String toString() {\r
+ return "Transaction.Impl[" + type + "]";\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * A listener for diagram transaction context events.\r
+ */\r
+ public static interface TransactionListener {\r
+ /**\r
+ * Invoked when the transaction has been started and locked properly\r
+ * using\r
+ * {@link TransactionContext#startTransaction(IDiagram, TransactionType)}\r
+ * .\r
+ * \r
+ * @param d the diagram where the transaction has started\r
+ * @param t the transaction handle\r
+ */\r
+ void transactionStarted(IDiagram d, Transaction t);\r
+\r
+ /**\r
+ * Invoked if a transaction is committed using\r
+ * {@link TransactionContext#finishTransaction(IDiagram, Transaction)}\r
+ * while transaction t still holds on to its lock, either read or write.\r
+ * \r
+ * @param d the diagram where the transaction took place\r
+ * @param t the transaction handle\r
+ */\r
+ void transactionFinished(IDiagram d, Transaction t);\r
+ }\r
+\r
+ void addTransactionListener(IDiagram d, TransactionListener l);\r
+ void removeTransactionListener(IDiagram d, TransactionListener l);\r
+\r
+ Transaction startTransaction(IDiagram d, TransactionType type);\r
+ void finishTransaction(IDiagram d, Transaction t);\r
+\r
+// /**\r
+// * @deprecated will be removed\r
+// */\r
+// @Deprecated\r
+// public static class ChangeSet {\r
+// public List<IElement> added, removed;\r
+// public Map<IElement, HintContext> modifications;\r
+// }\r
+\r
+}\r