]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/CompositeHintSynchronizer.java
Some enhancements to GraphLayer-related utilities for Diagram layers
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / CompositeHintSynchronizer.java
index 4d63a16ff868d6d2b79d643803b9049c4ac539de..361cdc32278396a4cf7c8f8a3ca22f8c8c3913a3 100644 (file)
@@ -1,79 +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.diagram.synchronization;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.List;\r
-\r
-import org.simantics.utils.datastructures.hints.IHintObservable;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
-\r
-/**\r
- * Synchronizer that is composed of several other synchronizers. It will consult\r
- * the composed synchronizers in the order in which they were specified. Should\r
- * a composed synchronizer report that it has handled the synchronization, i.e.\r
- * returns <code>true</code>, the consultation will end there.\r
- * \r
- * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
- * @author Tuukka Lehtonen\r
- */\r
-public class CompositeHintSynchronizer implements IHintSynchronizer {\r
-\r
-    private final List<IHintSynchronizer> synchronizers = new ArrayList<IHintSynchronizer>();\r
-\r
-    public CompositeHintSynchronizer() {\r
-    }\r
-\r
-    public CompositeHintSynchronizer(IHintSynchronizer... synchronizers) {\r
-        for (IHintSynchronizer s : synchronizers)\r
-            this.synchronizers.add(s);\r
-    }\r
-\r
-    public CompositeHintSynchronizer(Collection<IHintSynchronizer> synchronizers) {\r
-        this.synchronizers.addAll(synchronizers);\r
-    }\r
-\r
-    public CompositeHintSynchronizer add(IHintSynchronizer s) {\r
-        synchronizers.add(s);\r
-        return this;\r
-    }\r
-\r
-    @Override\r
-    public int synchronize(ISynchronizationContext context, IHintObservable observable) {\r
-        int count = 0;\r
-        for (IHintSynchronizer synchronizer : synchronizers) {\r
-            count += synchronizer.synchronize(context, observable);\r
-        }\r
-        return count;\r
-    }\r
-\r
-    @Override\r
-    public boolean hintChanged(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue,\r
-            Object newValue) {\r
-        for (IHintSynchronizer s : synchronizers) {\r
-            if (s.hintChanged(context, sender, key, oldValue, newValue))\r
-                return true;\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public boolean hintRemoved(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue) {\r
-        for (IHintSynchronizer s : synchronizers) {\r
-            if (s.hintRemoved(context, sender, key, oldValue))\r
-                return true;\r
-        }\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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.simantics.utils.datastructures.hints.IHintObservable;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
+
+/**
+ * Synchronizer that is composed of several other synchronizers. It will consult
+ * the composed synchronizers in the order in which they were specified. Should
+ * a composed synchronizer report that it has handled the synchronization, i.e.
+ * returns <code>true</code>, the consultation will end there.
+ * 
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
+ * @author Tuukka Lehtonen
+ */
+public class CompositeHintSynchronizer implements IHintSynchronizer {
+
+    private final List<IHintSynchronizer> synchronizers = new ArrayList<IHintSynchronizer>();
+
+    public CompositeHintSynchronizer() {
+    }
+
+    public CompositeHintSynchronizer(IHintSynchronizer... synchronizers) {
+        for (IHintSynchronizer s : synchronizers)
+            this.synchronizers.add(s);
+    }
+
+    public CompositeHintSynchronizer(Collection<IHintSynchronizer> synchronizers) {
+        this.synchronizers.addAll(synchronizers);
+    }
+
+    public CompositeHintSynchronizer add(IHintSynchronizer s) {
+        synchronizers.add(s);
+        return this;
+    }
+
+    @Override
+    public int synchronize(ISynchronizationContext context, IHintObservable observable) {
+        int count = 0;
+        for (IHintSynchronizer synchronizer : synchronizers) {
+            count += synchronizer.synchronize(context, observable);
+        }
+        return count;
+    }
+
+    @Override
+    public boolean hintChanged(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue,
+            Object newValue) {
+        for (IHintSynchronizer s : synchronizers) {
+            if (s.hintChanged(context, sender, key, oldValue, newValue))
+                return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean hintRemoved(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue) {
+        for (IHintSynchronizer s : synchronizers) {
+            if (s.hintRemoved(context, sender, key, oldValue))
+                return true;
+        }
+        return false;
+    }
+
+}