]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/PropertyModification.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / graph / PropertyModification.java
index 6bcf9fc3a1ee204ad458603d62301a063542be77..6f0171f1b8d8d9206f4bbe65ba4094eec3fe7e92 100644 (file)
@@ -1,92 +1,92 @@
-/*******************************************************************************\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.diagram.synchronization.graph;\r
-\r
-import java.util.Arrays;\r
-\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.CommentMetadata;\r
-import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.synchronization.ModificationAdapter;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class PropertyModification extends ModificationAdapter {\r
-    private final Resource owner;\r
-    private final Resource relation;\r
-    private final Resource type;\r
-    private final Object value;\r
-    private final Binding binding;\r
-\r
-    public PropertyModification(Resource propertyOwner, Resource propertyRelation, Resource propertyType, Object value, Binding binding) {\r
-        super(LOW_PRIORITY);\r
-        this.owner = propertyOwner;\r
-        this.relation = propertyRelation;\r
-        this.type = propertyType;\r
-        this.value = value;\r
-        this.binding = binding;\r
-    }\r
-    \r
-       private final boolean arrayEquals(Object av1, Object av2) {\r
-               if (av2 == null)\r
-                       return false;\r
-               Class<?> c1 = av1.getClass().getComponentType();\r
-               Class<?> c2 = av2.getClass().getComponentType();\r
-               if (c2 == null || !c1.equals(c2))\r
-                       return false;\r
-               boolean p1 = c1.isPrimitive();\r
-               boolean p2 = c2.isPrimitive();\r
-               if (p1 != p2)\r
-                       return false;\r
-               if (!p1)\r
-                       return Arrays.equals((Object[]) av1, (Object[]) av2);\r
-               if (boolean.class.equals(c1))\r
-                       return Arrays.equals((boolean[]) av1, (boolean[]) av2);\r
-               else if (byte.class.equals(c1))\r
-                       return Arrays.equals((byte[]) av1, (byte[]) av2);\r
-               else if (int.class.equals(c1))\r
-                       return Arrays.equals((int[]) av1, (int[]) av2);\r
-               else if (long.class.equals(c1))\r
-                       return Arrays.equals((long[]) av1, (long[]) av2);\r
-               else if (float.class.equals(c1))\r
-                       return Arrays.equals((float[]) av1, (float[]) av2);\r
-               else if (double.class.equals(c1))\r
-                       return Arrays.equals((double[]) av1, (double[]) av2);\r
-               throw new RuntimeException("??? Contact application querySupport.");\r
-       }\r
-\r
-    private boolean sameValue(Object oldValue, Object newValue) {\r
-               if (newValue.getClass().isArray()) {\r
-                       return arrayEquals(newValue, oldValue);\r
-               } else {\r
-                       return newValue.equals(oldValue);\r
-               }\r
-    }\r
-\r
-    @Override\r
-    public void perform(WriteGraph g) throws DatabaseException {\r
-       \r
-       Object existing = g.getPossibleRelatedValue(owner, relation, binding);\r
-       if(!sameValue(existing, value)) {\r
-               g.markUndoPoint();\r
-            DiagramGraphUtil.setRelatedValue(g, owner, relation, type, value, binding);\r
-               // Add comment to change set.\r
-               CommentMetadata cm = g.getMetadata(CommentMetadata.class);\r
-               g.addMetadata(cm.add("Changed property " + NameUtils.getSafeName(g, relation)));\r
-       }\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.diagram.synchronization.graph;
+
+import java.util.Arrays;
+
+import org.simantics.databoard.binding.Binding;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.CommentMetadata;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.synchronization.ModificationAdapter;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class PropertyModification extends ModificationAdapter {
+    private final Resource owner;
+    private final Resource relation;
+    private final Resource type;
+    private final Object value;
+    private final Binding binding;
+
+    public PropertyModification(Resource propertyOwner, Resource propertyRelation, Resource propertyType, Object value, Binding binding) {
+        super(LOW_PRIORITY);
+        this.owner = propertyOwner;
+        this.relation = propertyRelation;
+        this.type = propertyType;
+        this.value = value;
+        this.binding = binding;
+    }
+    
+       private final boolean arrayEquals(Object av1, Object av2) {
+               if (av2 == null)
+                       return false;
+               Class<?> c1 = av1.getClass().getComponentType();
+               Class<?> c2 = av2.getClass().getComponentType();
+               if (c2 == null || !c1.equals(c2))
+                       return false;
+               boolean p1 = c1.isPrimitive();
+               boolean p2 = c2.isPrimitive();
+               if (p1 != p2)
+                       return false;
+               if (!p1)
+                       return Arrays.equals((Object[]) av1, (Object[]) av2);
+               if (boolean.class.equals(c1))
+                       return Arrays.equals((boolean[]) av1, (boolean[]) av2);
+               else if (byte.class.equals(c1))
+                       return Arrays.equals((byte[]) av1, (byte[]) av2);
+               else if (int.class.equals(c1))
+                       return Arrays.equals((int[]) av1, (int[]) av2);
+               else if (long.class.equals(c1))
+                       return Arrays.equals((long[]) av1, (long[]) av2);
+               else if (float.class.equals(c1))
+                       return Arrays.equals((float[]) av1, (float[]) av2);
+               else if (double.class.equals(c1))
+                       return Arrays.equals((double[]) av1, (double[]) av2);
+               throw new RuntimeException("??? Contact application querySupport.");
+       }
+
+    private boolean sameValue(Object oldValue, Object newValue) {
+               if (newValue.getClass().isArray()) {
+                       return arrayEquals(newValue, oldValue);
+               } else {
+                       return newValue.equals(oldValue);
+               }
+    }
+
+    @Override
+    public void perform(WriteGraph g) throws DatabaseException {
+       
+       Object existing = g.getPossibleRelatedValue(owner, relation, binding);
+       if(!sameValue(existing, value)) {
+               g.markUndoPoint();
+            DiagramGraphUtil.setRelatedValue(g, owner, relation, type, value, binding);
+               // Add comment to change set.
+               CommentMetadata cm = g.getMetadata(CommentMetadata.class);
+               g.addMetadata(cm.add("Changed property " + NameUtils.getSafeName(g, relation)));
+       }
+
+    }
 }
\ No newline at end of file