--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.g2d.diagram.handler;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.IElement;\r
+\r
+/**\r
+ * @author Toni Kalajainen\r
+ */\r
+public interface LifeCycle extends DiagramHandler {\r
+\r
+ /**\r
+ * New empty diagram has spawned to the world.\r
+ * \r
+ * @param diagram\r
+ */\r
+ void onDiagramCreated(IDiagram diagram);\r
+\r
+ /**\r
+ * An old diagram has been restored from a other form of state\r
+ * (loaded or cloned).\r
+ * \r
+ * @param diagram\r
+ */\r
+ void onDiagramLoaded(IDiagram diagram, Collection<IElement> initialElements);\r
+\r
+ /**\r
+ * Diagram is about to be disposed\r
+ * @param diagram\r
+ */\r
+ void onDiagramDisposed(IDiagram diagram);\r
+\r
+ /**\r
+ * Diagram is about to be destoyed permanently from the world\r
+ * @param diagram\r
+ */\r
+ void onDiagramDestroyed(IDiagram diagram);\r
+\r
+ /**\r
+ * A stub implementation for {@link LifeCycle} that does not do anything.\r
+ * Extend this to avoid having to implement all methods.\r
+ */\r
+ public class Stub implements LifeCycle {\r
+ @Override\r
+ public void onDiagramCreated(IDiagram diagram) {\r
+ }\r
+\r
+ @Override\r
+ public void onDiagramLoaded(IDiagram diagram, Collection<IElement> initialElements) {\r
+ }\r
+\r
+ @Override\r
+ public void onDiagramDisposed(IDiagram diagram) {\r
+ }\r
+\r
+ @Override\r
+ public void onDiagramDestroyed(IDiagram diagram) {\r
+ }\r
+ }\r
+}\r