]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/ResourceSynchronizer.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / graph / ResourceSynchronizer.java
index 17b61381c4ff6cafb7bbcc29f981ace9fadbe352..443d56b7e11acf59a1fbb1e75d412292ade89d06 100644 (file)
@@ -1,83 +1,83 @@
-/*******************************************************************************\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 org.simantics.db.Resource;\r
-import org.simantics.diagram.synchronization.IHintSynchronizer;\r
-import org.simantics.diagram.synchronization.IModificationQueue;\r
-import org.simantics.diagram.synchronization.ISynchronizationContext;\r
-import org.simantics.diagram.synchronization.SynchronizationHints;\r
-import org.simantics.g2d.element.ElementHints;\r
-import org.simantics.utils.datastructures.hints.IHintObservable;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
-\r
-/**\r
- * One should implement\r
- * {@link #hintChanged(ISynchronizationContext, IModificationQueue, Resource, IHintObservable, Key, Object, Object)}\r
- * and\r
- * {@link #getSynchronizedHints()}.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public abstract class ResourceSynchronizer implements IHintSynchronizer {\r
-\r
-    @Override\r
-    public final int synchronize(ISynchronizationContext context, IHintObservable observable) {\r
-        Object o = observable.getHint(ElementHints.KEY_OBJECT);\r
-        if (o instanceof Resource) {\r
-            IModificationQueue queue = context.get(SynchronizationHints.MODIFICATION_QUEUE);\r
-            return synchronize(context, queue, (Resource) o, observable);\r
-        }\r
-        return 0;\r
-    }\r
-\r
-    public abstract Key[] getSynchronizedHints();\r
-\r
-    public int synchronize(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable observable) {\r
-        int count = 0;\r
-        for (Key key : getSynchronizedHints()) {\r
-            count += synchronizeHint(context, queue, object, observable, key);\r
-        }\r
-        return count;\r
-    }\r
-\r
-    protected final int synchronizeHint(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable observable, Key key) {\r
-        return hintChanged(context, queue, object, observable, key, null, observable.getHint(key)) ? 1 : 0;\r
-    }\r
-\r
-    @Override\r
-    public final boolean hintChanged(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
-        Object o = sender.getHint(ElementHints.KEY_OBJECT);\r
-        if (o instanceof Resource) {\r
-            IModificationQueue queue = context.get(SynchronizationHints.MODIFICATION_QUEUE);\r
-            return hintChanged(context, queue, (Resource) o, sender, key, oldValue, newValue);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public final boolean hintRemoved(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue) {\r
-        Object o = sender.getHint(ElementHints.KEY_OBJECT);\r
-        if (o instanceof Resource) {\r
-            IModificationQueue queue = context.get(SynchronizationHints.MODIFICATION_QUEUE);\r
-            return hintRemoved(context, queue, (Resource) o, sender, key, oldValue);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    public abstract boolean hintChanged(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable sender, Key key, Object oldValue, Object newValue);\r
-\r
-    public boolean hintRemoved(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable sender, Key key, Object oldValue) {\r
-        return false;\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 org.simantics.db.Resource;
+import org.simantics.diagram.synchronization.IHintSynchronizer;
+import org.simantics.diagram.synchronization.IModificationQueue;
+import org.simantics.diagram.synchronization.ISynchronizationContext;
+import org.simantics.diagram.synchronization.SynchronizationHints;
+import org.simantics.g2d.element.ElementHints;
+import org.simantics.utils.datastructures.hints.IHintObservable;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
+
+/**
+ * One should implement
+ * {@link #hintChanged(ISynchronizationContext, IModificationQueue, Resource, IHintObservable, Key, Object, Object)}
+ * and
+ * {@link #getSynchronizedHints()}.
+ * 
+ * @author Tuukka Lehtonen
+ */
+public abstract class ResourceSynchronizer implements IHintSynchronizer {
+
+    @Override
+    public final int synchronize(ISynchronizationContext context, IHintObservable observable) {
+        Object o = observable.getHint(ElementHints.KEY_OBJECT);
+        if (o instanceof Resource) {
+            IModificationQueue queue = context.get(SynchronizationHints.MODIFICATION_QUEUE);
+            return synchronize(context, queue, (Resource) o, observable);
+        }
+        return 0;
+    }
+
+    public abstract Key[] getSynchronizedHints();
+
+    public int synchronize(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable observable) {
+        int count = 0;
+        for (Key key : getSynchronizedHints()) {
+            count += synchronizeHint(context, queue, object, observable, key);
+        }
+        return count;
+    }
+
+    protected final int synchronizeHint(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable observable, Key key) {
+        return hintChanged(context, queue, object, observable, key, null, observable.getHint(key)) ? 1 : 0;
+    }
+
+    @Override
+    public final boolean hintChanged(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue, Object newValue) {
+        Object o = sender.getHint(ElementHints.KEY_OBJECT);
+        if (o instanceof Resource) {
+            IModificationQueue queue = context.get(SynchronizationHints.MODIFICATION_QUEUE);
+            return hintChanged(context, queue, (Resource) o, sender, key, oldValue, newValue);
+        }
+        return false;
+    }
+
+    @Override
+    public final boolean hintRemoved(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue) {
+        Object o = sender.getHint(ElementHints.KEY_OBJECT);
+        if (o instanceof Resource) {
+            IModificationQueue queue = context.get(SynchronizationHints.MODIFICATION_QUEUE);
+            return hintRemoved(context, queue, (Resource) o, sender, key, oldValue);
+        }
+        return false;
+    }
+
+    public abstract boolean hintChanged(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable sender, Key key, Object oldValue, Object newValue);
+
+    public boolean hintRemoved(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable sender, Key key, Object oldValue) {
+        return false;
+    }
+
+}