1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.synchronization.graph;
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;
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
26 * @author Tuukka Lehtonen
28 * @see IHintSynchronizer
30 * TODO: try to unify this with other elementloader/graphelementfactory etc. mechanisms
31 * TODO: transform this into ElementGraphLifecycle ?
33 public interface ElementWriter {
38 * @param elementResource
39 * @throws DatabaseException
41 void addToGraph(WriteGraph graph, IElement element, Resource elementResource) throws DatabaseException;
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.
53 * @param elementResource
55 void removeFromGraph(WriteGraph graph, Resource elementResource) throws DatabaseException;