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