]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/procedure/single/SingleSetAsyncListener.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / procedure / single / SingleSetAsyncListener.java
index 7a30cc591760108f18fcf43cb4bfb4f5e9e073a2..3f156c5fe3c94a20744eb5a6a909072005971959 100644 (file)
@@ -1,68 +1,68 @@
-/*******************************************************************************\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.db.common.procedure.single;\r
-\r
-import java.util.Collection;\r
-import java.util.HashSet;\r
-\r
-import org.simantics.db.AsyncReadGraph;\r
-import org.simantics.db.procedure.AsyncListener;\r
-\r
-abstract public class SingleSetAsyncListener<T> implements AsyncListener<Collection<T>>{\r
-    \r
-       final private boolean changesOnly;\r
-       private Collection<T> previous = null;\r
-    \r
-    public void add(AsyncReadGraph graph, T item) {}\r
-    public void remove(AsyncReadGraph graph, T item) {}\r
-    \r
-    public SingleSetAsyncListener() {\r
-       this(false);\r
-    }\r
-    \r
-    public SingleSetAsyncListener(boolean changesOnly) {\r
-       this.changesOnly = changesOnly;\r
-    }\r
-\r
-    @Override\r
-    public void execute(AsyncReadGraph graph, final Collection<T> result) {\r
-       \r
-        if(previous == null) {\r
-\r
-               if(!changesOnly) {\r
-//                     for(T t : result)\r
-//                             add(graph, t);\r
-//             } else {\r
-                       first(graph, result);\r
-               }\r
-\r
-        } else {\r
-\r
-            HashSet<T> added = new HashSet<T>(result);\r
-            added.removeAll(previous);\r
-            HashSet<T> removed = new HashSet<T>(previous);\r
-            removed.removeAll(result);\r
-\r
-            for(T t : added) add(graph, t);\r
-            for(T t : removed) remove(graph, t);\r
-\r
-        }\r
-\r
-        previous = result;\r
-        \r
-    }\r
-    \r
-    public void first(AsyncReadGraph graph, final Collection<T> result) {\r
-       for(T t : result) add(graph, t);\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.db.common.procedure.single;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.procedure.AsyncListener;
+
+abstract public class SingleSetAsyncListener<T> implements AsyncListener<Collection<T>>{
+    
+       final private boolean changesOnly;
+       private Collection<T> previous = null;
+    
+    public void add(AsyncReadGraph graph, T item) {}
+    public void remove(AsyncReadGraph graph, T item) {}
+    
+    public SingleSetAsyncListener() {
+       this(false);
+    }
+    
+    public SingleSetAsyncListener(boolean changesOnly) {
+       this.changesOnly = changesOnly;
+    }
+
+    @Override
+    public void execute(AsyncReadGraph graph, final Collection<T> result) {
+       
+        if(previous == null) {
+
+               if(!changesOnly) {
+//                     for(T t : result)
+//                             add(graph, t);
+//             } else {
+                       first(graph, result);
+               }
+
+        } else {
+
+            HashSet<T> added = new HashSet<T>(result);
+            added.removeAll(previous);
+            HashSet<T> removed = new HashSet<T>(previous);
+            removed.removeAll(result);
+
+            for(T t : added) add(graph, t);
+            for(T t : removed) remove(graph, t);
+
+        }
+
+        previous = result;
+        
+    }
+    
+    public void first(AsyncReadGraph graph, final Collection<T> result) {
+       for(T t : result) add(graph, t);
+    }
+       
+}