]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/RelationshipHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / diagram / handler / RelationshipHandler.java
index 256bd7bb6d9d4f8e40d531079f929320dd34b8e8..a1002a8af90bc74d62d4f9ba5b86770d608a09cb 100644 (file)
-/*******************************************************************************\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.utils.ObjectUtils;\r
-\r
-/**\r
- * A diagram handler for managing and querying arbitrary relationships between\r
- * diagram objects. The management is done by claiming and denying relationships\r
- * about the objects. A single relationship can only exist once or not at all\r
- * between two objects, i.e. no duplicate relationships can be added.\r
- * \r
- * <p>\r
- * There is no pre-defined meaning for a relationship - it is completely\r
- * customizable by implementing your own {@link Relationship} interface.\r
- * </p>\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public interface RelationshipHandler extends DiagramHandler {\r
-\r
-    /**\r
-     * A simple holder class for a single relationship. Holds all the\r
-     * ingredients: two elements and the role of the relationship. The\r
-     * relationship is either uni- or bi-directional.\r
-     */\r
-    public final class Relation {\r
-        private final Object       subject;\r
-        private final Relationship relationship;\r
-        private final Object       object;\r
-\r
-        public Relation(Object subject, Relationship relationship, Object object) {\r
-            assert subject != null;\r
-            assert relationship != null;\r
-            assert object != null;\r
-            this.subject = subject;\r
-            this.relationship = relationship;\r
-            this.object = object;\r
-        }\r
-\r
-        public Object getSubject() {\r
-            return subject;\r
-        }\r
-\r
-        public Relationship getRelationship() {\r
-            return relationship;\r
-        }\r
-\r
-        public Object getObject() {\r
-            return object;\r
-        }\r
-\r
-        @Override\r
-        public int hashCode() {\r
-            return ((ObjectUtils.hashCode(subject) * 31)\r
-                    + ObjectUtils.hashCode(object) * 31)\r
-                    + ObjectUtils.hashCode(relationship);\r
-        }\r
-\r
-        @Override\r
-        public boolean equals(Object obj) {\r
-            if (obj == this)\r
-                return true;\r
-            if (!(obj instanceof Relation))\r
-                return false;\r
-            Relation other = (Relation) obj;\r
-            return subject.equals(other.subject) && object.equals(other.object) && relationship.equals(other.relationship);\r
-        }\r
-\r
-        @Override\r
-        public String toString() {\r
-            return "(" + subject + ", " + relationship + ", " + object + ")";\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Claim a single relationship between the specified subject and object. An\r
-     * inverse relation will also be claimed if one exists.\r
-     * \r
-     * Subject and object should be alive (not destroyed). However it should not\r
-     * be enforced to be activated within the specified diagram, at the moment\r
-     * of invocation. This is because the relationship may be denied while the\r
-     * elements are still in the process of being added to or removed from a\r
-     * diagram.\r
-     * \r
-     * @param diagram the diagram to operate on\r
-     * @param subject the subject of the relationship\r
-     * @param predicate the relationship itself\r
-     * @param object the object of the relationship\r
-     */\r
-    void claim(IDiagram diagram, Object subject, Relationship predicate, Object object);\r
-\r
-    /**\r
-     * Deny a relationship. This will also deny the inverse relationship if one\r
-     * exists.\r
-     * \r
-     * Subject and object should be alive (not destroyed). However it should not\r
-     * be enforced to be activated within the specified diagram, at the moment\r
-     * of invocation. This is because the relationship may be denied while the\r
-     * elements are still in the process of being added to or removed from a\r
-     * diagram.\r
-     */\r
-    void deny(IDiagram diagram, Object subject, Relationship predicate, Object object);\r
-    void deny(IDiagram diagram, Relation relation);\r
-    void denyAll(IDiagram diagram, Object element);\r
-\r
-    /**\r
-     * Get all the relationships that are recorded for the specified element.\r
-     * \r
-     * @param diagram the diagram to operate on\r
-     * @param element the element to get all relations for\r
-     * @param result a collection for gathering the result of the query or null\r
-     *        to create a new collection for the result.\r
-     * @return\r
-     */\r
-    Collection<Relation> getRelations(IDiagram diagram, Object element, Collection<Relation> result);\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g2d.diagram.handler;
+
+import java.util.Collection;
+
+import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.utils.ObjectUtils;
+
+/**
+ * A diagram handler for managing and querying arbitrary relationships between
+ * diagram objects. The management is done by claiming and denying relationships
+ * about the objects. A single relationship can only exist once or not at all
+ * between two objects, i.e. no duplicate relationships can be added.
+ * 
+ * <p>
+ * There is no pre-defined meaning for a relationship - it is completely
+ * customizable by implementing your own {@link Relationship} interface.
+ * </p>
+ * 
+ * @author Tuukka Lehtonen
+ */
+public interface RelationshipHandler extends DiagramHandler {
+
+    /**
+     * A simple holder class for a single relationship. Holds all the
+     * ingredients: two elements and the role of the relationship. The
+     * relationship is either uni- or bi-directional.
+     */
+    public final class Relation {
+        private final Object       subject;
+        private final Relationship relationship;
+        private final Object       object;
+
+        public Relation(Object subject, Relationship relationship, Object object) {
+            assert subject != null;
+            assert relationship != null;
+            assert object != null;
+            this.subject = subject;
+            this.relationship = relationship;
+            this.object = object;
+        }
+
+        public Object getSubject() {
+            return subject;
+        }
+
+        public Relationship getRelationship() {
+            return relationship;
+        }
+
+        public Object getObject() {
+            return object;
+        }
+
+        @Override
+        public int hashCode() {
+            return ((ObjectUtils.hashCode(subject) * 31)
+                    + ObjectUtils.hashCode(object) * 31)
+                    + ObjectUtils.hashCode(relationship);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj == this)
+                return true;
+            if (!(obj instanceof Relation))
+                return false;
+            Relation other = (Relation) obj;
+            return subject.equals(other.subject) && object.equals(other.object) && relationship.equals(other.relationship);
+        }
+
+        @Override
+        public String toString() {
+            return "(" + subject + ", " + relationship + ", " + object + ")";
+        }
+    }
+
+    /**
+     * Claim a single relationship between the specified subject and object. An
+     * inverse relation will also be claimed if one exists.
+     * 
+     * Subject and object should be alive (not destroyed). However it should not
+     * be enforced to be activated within the specified diagram, at the moment
+     * of invocation. This is because the relationship may be denied while the
+     * elements are still in the process of being added to or removed from a
+     * diagram.
+     * 
+     * @param diagram the diagram to operate on
+     * @param subject the subject of the relationship
+     * @param predicate the relationship itself
+     * @param object the object of the relationship
+     */
+    void claim(IDiagram diagram, Object subject, Relationship predicate, Object object);
+
+    /**
+     * Deny a relationship. This will also deny the inverse relationship if one
+     * exists.
+     * 
+     * Subject and object should be alive (not destroyed). However it should not
+     * be enforced to be activated within the specified diagram, at the moment
+     * of invocation. This is because the relationship may be denied while the
+     * elements are still in the process of being added to or removed from a
+     * diagram.
+     */
+    void deny(IDiagram diagram, Object subject, Relationship predicate, Object object);
+    void deny(IDiagram diagram, Relation relation);
+    void denyAll(IDiagram diagram, Object element);
+
+    /**
+     * Get all the relationships that are recorded for the specified element.
+     * 
+     * @param diagram the diagram to operate on
+     * @param element the element to get all relations for
+     * @param result a collection for gathering the result of the query or null
+     *        to create a new collection for the result.
+     * @return
+     */
+    Collection<Relation> getRelations(IDiagram diagram, Object element, Collection<Relation> result);
+
+}