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