X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fbrowsing%2FINodeEvaluators.java;h=73293455b2c93b3d5d4159cdad0bd185b83d768f;hb=3dddcb9694df9a9da950b625345ba218344b9a37;hp=e5a7abe733de17c4cc2746251ad77c3a0af1dd88;hpb=f5f3478ec45f4130ffa077a13b25ac342088614e;p=simantics%2Finterop.git diff --git a/org.simantics.interop/src/org/simantics/interop/browsing/INodeEvaluators.java b/org.simantics.interop/src/org/simantics/interop/browsing/INodeEvaluators.java index e5a7abe..7329345 100644 --- a/org.simantics.interop/src/org/simantics/interop/browsing/INodeEvaluators.java +++ b/org.simantics.interop/src/org/simantics/interop/browsing/INodeEvaluators.java @@ -3,6 +3,8 @@ package org.simantics.interop.browsing; import java.util.Collection; import java.util.Collections; import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Supplier; import org.eclipse.jface.resource.ImageDescriptor; import org.simantics.browsing.ui.BuiltinKeys; @@ -31,8 +33,8 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.modeling.ui.modelBrowser.model.IChildrenCallback; import org.simantics.modeling.ui.modelBrowser.model.IDisposable; import org.simantics.modeling.ui.modelBrowser.model.IUpdateable; -import org.simantics.utils.datastructures.Callable; -import org.simantics.utils.datastructures.Callback; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class INodeEvaluators { @@ -49,9 +51,12 @@ public class INodeEvaluators { } abstract class BaseViewpointFactory implements ViewpointFactory { - protected abstract class VPB extends LazyViewpoint implements Callable, IChildrenCallback { - public VPB(PrimitiveQueryUpdater updater, NodeContext context, ViewpointKey key) { + protected abstract class VPB extends LazyViewpoint implements Supplier, IChildrenCallback { + PrimitiveQueryUpdater updater; + + public VPB(PrimitiveQueryUpdater updater, NodeContext context, ViewpointKey key) { super(updater, context, key); + this.updater = updater; } @Override @@ -68,9 +73,9 @@ abstract class BaseViewpointFactory implements ViewpointFactory { // BaseViewpointFactory unique. return BaseViewpointFactory.this.getClass(); } - + @Override - public Boolean call() { + public Boolean get() { return Boolean.valueOf(updater.isDisposed()); } @@ -78,7 +83,7 @@ abstract class BaseViewpointFactory implements ViewpointFactory { public void refreshChildren(Collection newChildren) { NodeContext[] ncs = toContextsWithInput(newChildren); setHasChildren(ncs.length > 0); - setChildren(ncs); + setChildren(updater,ncs); updater.scheduleReplace(context, key, this); } @@ -142,6 +147,11 @@ class NodeLabelerFactory implements LabelerFactory { public int category(ReadGraph graph) throws DatabaseException { return ((INode) context.getConstant(BuiltinKeys.INPUT)).getCategory(graph); } + + @Override + public Logger getLogger() { + return LoggerFactory.getLogger(NodeLabelerFactory.class); + } }; } } @@ -155,10 +165,11 @@ class NodeImagerFactory implements ImagerFactory { DataSource source = updater.getDataSource(ReadGraph.class); - source.schedule(new Callback() { - @Override - public void run(ReadGraph g) { - try { + source.schedule(new Consumer() { + + @Override + public void accept(ReadGraph g) { + try { INode node = (INode)context.getConstant(BuiltinKeys.INPUT); ImageDescriptor descriptor = node.getImage(g); result.setImage(descriptor);