]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/LifeCycle.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / LifeCycle.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/LifeCycle.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/LifeCycle.java
new file mode 100644 (file)
index 0000000..ec69cf2
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************\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.element.handler;\r
+\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.IElement;\r
+\r
+/**\r
+ * All ElementContributions that implement LifeCycle get\r
+ * element create and destroy events.\r
+ * \r
+ * @author Toni Kalajainen\r
+ * \r
+ * @see Stub\r
+ */\r
+public interface LifeCycle extends ElementHandler {\r
+\r
+    /**\r
+     * a new element has been spawned to the world\r
+     * @param e\r
+     */\r
+    void onElementCreated(IElement e);\r
+\r
+    /**\r
+     * Element has been destroyed from the world\r
+     * @param e\r
+     */\r
+    void onElementDestroyed(IElement e);\r
+\r
+    /**\r
+     * Element has been activated (after creation, cloning or loading)\r
+     * and added to a diagram.\r
+     * \r
+     * @param d\r
+     * @param e\r
+     */\r
+    void onElementActivated(IDiagram d, IElement e);\r
+\r
+    /**\r
+     * Element has been deactivated (disposed)\r
+     * @param d\r
+     * @param e\r
+     */\r
+    void onElementDeactivated(IDiagram d, IElement e);\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 static class Stub implements LifeCycle {\r
+        private static final long serialVersionUID = -569889719338663795L;\r
+\r
+        @Override\r
+        public void onElementActivated(IDiagram d, IElement e) {\r
+        }\r
+\r
+        @Override\r
+        public void onElementCreated(IElement e) {\r
+        }\r
+\r
+        @Override\r
+        public void onElementDeactivated(IDiagram d, IElement e) {\r
+        }\r
+\r
+        @Override\r
+        public void onElementDestroyed(IElement e) {\r
+        }\r
+    }\r
+\r
+}\r