]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/LazyParametrizedViewpoint.java
Multiple reader thread support for db client
[simantics/platform.git] / bundles / org.simantics.browsing.ui.graph.impl / src / org / simantics / browsing / ui / graph / impl / LazyParametrizedViewpoint.java
index 91aeb9c5d4539b5e2e4e189fc703b5f2bdd6cb03..c5d96a90a81fac91b86f556acc421e61130eb153 100644 (file)
@@ -11,8 +11,6 @@
  *******************************************************************************/
 package org.simantics.browsing.ui.graph.impl;
 
-import java.util.function.Consumer;
-
 import org.simantics.browsing.ui.BuiltinKeys;
 import org.simantics.browsing.ui.DataSource;
 import org.simantics.browsing.ui.NodeContext;
@@ -20,6 +18,7 @@ import org.simantics.browsing.ui.PrimitiveQueryUpdater;
 import org.simantics.browsing.ui.common.viewpoints.ViewpointStub;
 import org.simantics.browsing.ui.content.Viewpoint;
 import org.simantics.browsing.ui.graph.impl.request.ParametrizedResourceQuery;
+import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.Listener;
@@ -135,7 +134,7 @@ public abstract class LazyParametrizedViewpoint extends ViewpointStub {
        @Override
        public NodeContext[] getChildren() {
                if (children == Viewpoint.PENDING_CHILDREN) {
-                       DataSource<ReadGraph> source = updater.getDataSource(ReadGraph.class);
+                       DataSource<AsyncReadGraph> source = updater.getDataSource(AsyncReadGraph.class);
                        if (source != null) {
                                source.schedule(graph -> graph.asyncRequest(childQuery, childQueryProcedure));
                        }
@@ -147,17 +146,11 @@ public abstract class LazyParametrizedViewpoint extends ViewpointStub {
        @Override
        public Boolean getHasChildren() {
                if (hasChildren == Viewpoint.PENDING_HAS_CHILDREN) {
-                       DataSource<ReadGraph> source = updater.getDataSource(ReadGraph.class);
+                       DataSource<AsyncReadGraph> source = updater.getDataSource(AsyncReadGraph.class);
                        if (source != null) {
-                               source.schedule(new Consumer<ReadGraph>() {
-                                       @Override
-                                       public void accept(ReadGraph source) {
-                                               source.asyncRequest(hasChildQuery, hasChildQueryProcedure);
-                                       }
-                               });
+                               source.schedule(graph -> graph.asyncRequest(hasChildQuery, hasChildQueryProcedure));
                        }
                }
-
                return hasChildren;
        }