]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/ElementWriter.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / graph / ElementWriter.java
diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/ElementWriter.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/ElementWriter.java
new file mode 100644 (file)
index 0000000..1af9377
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************\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.diagram.synchronization.graph;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.synchronization.IHintSynchronizer;\r
+import org.simantics.g2d.element.IElement;\r
+\r
+/**\r
+ * This interface is used by DiagramGraphSynchronizer as a first time only\r
+ * mechanism for customizable IElement->Graph synchronization of element that\r
+ * have been newly added to a diagram. These methods are only invoked once for\r
+ * any single element.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ * \r
+ * @see IHintSynchronizer\r
+ * \r
+ * TODO: try to unify this with other elementloader/graphelementfactory etc. mechanisms\r
+ * TODO: transform this into ElementGraphLifecycle ?\r
+ */\r
+public interface ElementWriter {\r
+\r
+    /**\r
+     * @param graph\r
+     * @param element\r
+     * @param elementResource\r
+     * @throws DatabaseException\r
+     */\r
+    void addToGraph(WriteGraph graph, IElement element, Resource elementResource) throws DatabaseException;\r
+\r
+    /**\r
+     * Sometimes {@link #writeGraph(WriteGraph, IElement, Resource)}\r
+     * can write things into the graph that are not removed by the standard\r
+     * deletion procedure. The standard procedure is to remove the element\r
+     * resource from the diagram's ordered set and then remove everything that\r
+     * the element resource <em>is composed of</em>. This method may implement\r
+     * customized code for removing any other kinds of affiliations the element\r
+     * might have in the graph.\r
+     * \r
+     * @param graph\r
+     * @param elementResource\r
+     */\r
+    void removeFromGraph(WriteGraph graph, Resource elementResource) throws DatabaseException;\r
+\r
+}\r