]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/LifeCycle.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / diagram / 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.diagram.handler;\r
13 \r
14 import java.util.Collection;\r
15 \r
16 import org.simantics.g2d.diagram.IDiagram;\r
17 import org.simantics.g2d.element.IElement;\r
18 \r
19 /**\r
20  * @author Toni Kalajainen\r
21  */\r
22 public interface LifeCycle extends DiagramHandler {\r
23 \r
24     /**\r
25      * New empty diagram has spawned to the world.\r
26      * \r
27      * @param diagram\r
28      */\r
29     void onDiagramCreated(IDiagram diagram);\r
30 \r
31     /**\r
32      * An old diagram has been restored from a other form of state\r
33      * (loaded or cloned).\r
34      * \r
35      * @param diagram\r
36      */\r
37     void onDiagramLoaded(IDiagram diagram, Collection<IElement> initialElements);\r
38 \r
39     /**\r
40      * Diagram is about to be disposed\r
41      * @param diagram\r
42      */\r
43     void onDiagramDisposed(IDiagram diagram);\r
44 \r
45     /**\r
46      * Diagram is about to be destoyed permanently from the world\r
47      * @param diagram\r
48      */\r
49     void onDiagramDestroyed(IDiagram diagram);\r
50 \r
51     /**\r
52      * A stub implementation for {@link LifeCycle} that does not do anything.\r
53      * Extend this to avoid having to implement all methods.\r
54      */\r
55     public class Stub implements LifeCycle {\r
56         @Override\r
57         public void onDiagramCreated(IDiagram diagram) {\r
58         }\r
59 \r
60         @Override\r
61         public void onDiagramLoaded(IDiagram diagram, Collection<IElement> initialElements) {\r
62         }\r
63 \r
64         @Override\r
65         public void onDiagramDisposed(IDiagram diagram) {\r
66         }\r
67 \r
68         @Override\r
69         public void onDiagramDestroyed(IDiagram diagram) {\r
70         }\r
71     }\r
72 }\r