]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.diagram.synchronization.graph;\r
13 \r
14 import org.simantics.db.Resource;\r
15 import org.simantics.db.WriteGraph;\r
16 import org.simantics.db.exception.DatabaseException;\r
17 import org.simantics.diagram.synchronization.IHintSynchronizer;\r
18 import org.simantics.g2d.element.IElement;\r
19 \r
20 /**\r
21  * This interface is used by DiagramGraphSynchronizer as a first time only\r
22  * mechanism for customizable IElement->Graph synchronization of element that\r
23  * have been newly added to a diagram. These methods are only invoked once for\r
24  * any single element.\r
25  * \r
26  * @author Tuukka Lehtonen\r
27  * \r
28  * @see IHintSynchronizer\r
29  * \r
30  * TODO: try to unify this with other elementloader/graphelementfactory etc. mechanisms\r
31  * TODO: transform this into ElementGraphLifecycle ?\r
32  */\r
33 public interface ElementWriter {\r
34 \r
35     /**\r
36      * @param graph\r
37      * @param element\r
38      * @param elementResource\r
39      * @throws DatabaseException\r
40      */\r
41     void addToGraph(WriteGraph graph, IElement element, Resource elementResource) throws DatabaseException;\r
42 \r
43     /**\r
44      * Sometimes {@link #writeGraph(WriteGraph, IElement, Resource)}\r
45      * can write things into the graph that are not removed by the standard\r
46      * deletion procedure. The standard procedure is to remove the element\r
47      * resource from the diagram's ordered set and then remove everything that\r
48      * the element resource <em>is composed of</em>. This method may implement\r
49      * customized code for removing any other kinds of affiliations the element\r
50      * might have in the graph.\r
51      * \r
52      * @param graph\r
53      * @param elementResource\r
54      */\r
55     void removeFromGraph(WriteGraph graph, Resource elementResource) throws DatabaseException;\r
56 \r
57 }\r