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