]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ParentImpl.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / ParentImpl.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ParentImpl.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/ParentImpl.java
new file mode 100644 (file)
index 0000000..8400434
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************\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.impl;\r
+\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.Parent;\r
+\r
+/**\r
+ * The most simple implementation of the {@link Parent} handler.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class ParentImpl implements Parent {\r
+\r
+    public static final ParentImpl INSTANCE = new ParentImpl();\r
+\r
+    private static final long serialVersionUID = 1L;\r
+\r
+    private ParentImpl() {}\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.simantics.g2d.element.handler.Parent#getParent(org.simantics.g2d.element.IElement)\r
+     */\r
+    @Override\r
+    public IElement getParent(IElement element) {\r
+        IElement e = element.getHint(ElementHints.KEY_PARENT_ELEMENT);\r
+        return e;\r
+\r
+//        if (e == null)\r
+//            return null;\r
+//\r
+//        Object obj = e.getHint(ElementHints.KEY_OBJECT);\r
+//        if (obj == null)\r
+//            return e;\r
+//\r
+//        IDiagram diagram = ElementUtils.peekDiagram(element);\r
+//        DataElementMap dem = diagram.getDiagramClass().getAtMostOneItemOfClass(DataElementMap.class);\r
+//        if (dem == null)\r
+//            return e;\r
+//\r
+//        IElement mapped = dem.getElement(diagram, obj);\r
+//        return mapped != null ? mapped : e;\r
+    }\r
+\r
+}\r