]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/LifeCycle.java
Sync git svn branch with SVN repository r33324.
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / LifeCycle.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.g2d.element.handler;\r
13 \r
14 import org.simantics.g2d.diagram.IDiagram;\r
15 import org.simantics.g2d.element.IElement;\r
16 \r
17 /**\r
18  * All ElementContributions that implement LifeCycle get\r
19  * element create and destroy events.\r
20  * \r
21  * @author Toni Kalajainen\r
22  * \r
23  * @see Stub\r
24  */\r
25 public interface LifeCycle extends ElementHandler {\r
26 \r
27     /**\r
28      * a new element has been spawned to the world\r
29      * @param e\r
30      */\r
31     void onElementCreated(IElement e);\r
32 \r
33     /**\r
34      * Element has been destroyed from the world\r
35      * @param e\r
36      */\r
37     void onElementDestroyed(IElement e);\r
38 \r
39     /**\r
40      * Element has been activated (after creation, cloning or loading)\r
41      * and added to a diagram.\r
42      * \r
43      * @param d\r
44      * @param e\r
45      */\r
46     void onElementActivated(IDiagram d, IElement e);\r
47 \r
48     /**\r
49      * Element has been deactivated (disposed)\r
50      * @param d\r
51      * @param e\r
52      */\r
53     void onElementDeactivated(IDiagram d, IElement e);\r
54 \r
55     /**\r
56      * A stub implementation for {@link LifeCycle} that does not do anything.\r
57      * Extend this to avoid having to implement all methods.\r
58      */\r
59     public static class Stub implements LifeCycle {\r
60         private static final long serialVersionUID = -569889719338663795L;\r
61 \r
62         @Override\r
63         public void onElementActivated(IDiagram d, IElement e) {\r
64         }\r
65 \r
66         @Override\r
67         public void onElementCreated(IElement e) {\r
68         }\r
69 \r
70         @Override\r
71         public void onElementDeactivated(IDiagram d, IElement e) {\r
72         }\r
73 \r
74         @Override\r
75         public void onElementDestroyed(IElement e) {\r
76         }\r
77     }\r
78 \r
79 }\r