X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Futil%2FTGSourceRepresentation.java;h=898bb23dd4c65fb65dd43ebdd7214aee1ba4131a;hp=0a9d51027415e8585631bf2d3c71c05d2f35952d;hb=HEAD;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGSourceRepresentation.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGSourceRepresentation.java index 0a9d51027..898bb23dd 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGSourceRepresentation.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGSourceRepresentation.java @@ -1,74 +1,74 @@ -package org.simantics.db.layer0.util; - -import java.util.Arrays; -import java.util.Map; - -import org.simantics.db.ReadGraph; -import org.simantics.db.RequestProcessor; -import org.simantics.db.Resource; -import org.simantics.db.common.request.UniqueRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.util.SimanticsClipboard.Representation; -import org.simantics.graph.db.TransferableGraphSource; -import org.simantics.utils.datastructures.hints.IHintContext.Key; - -public class TGSourceRepresentation implements Representation { - - protected Resource[] resources; - protected boolean ignoreVirtualResources = false; - private TransferableGraphSource value = null; - private TransferableGraphConfiguration2 configuration; - - public TGSourceRepresentation(Resource ... resources) { - this.resources = resources; - } - - public TGSourceRepresentation(boolean ignoreVirtualResources, Resource ... resources) { - this.ignoreVirtualResources = ignoreVirtualResources; - this.resources = resources; - } - - public TGSourceRepresentation(TransferableGraphConfiguration2 configuration) { - this.configuration = configuration; - } - - public TGSourceRepresentation(TransferableGraphSource value) { - this.value = value; - } - - @Override - public Key getKey() { - return SimanticsKeys.KEY_TRANSFERABLE_GRAPH_SOURCE; - } - - public TransferableGraphSource compute(ReadGraph graph, Map hints) throws DatabaseException { - - if(configuration == null) { - configuration = new TransferableGraphConfiguration2(graph, Arrays.asList(resources), ignoreVirtualResources, false); - configuration.exclusionFunction = TGRepresentationUtils.computeExclusionFunction(graph, resources, hints); - } - - return graph.syncRequest(new ModelTransferableGraphSourceRequest(configuration)); - - } - - @SuppressWarnings("unchecked") - @Override - public T getValue(RequestProcessor processor, Map hints) throws DatabaseException { - - if(value == null) { - value = processor.syncRequest(new UniqueRead() { - - @Override - public TransferableGraphSource perform(ReadGraph graph) throws DatabaseException { - return compute(graph, hints); - } - - }); - } - - return (T)value; - - } - +package org.simantics.db.layer0.util; + +import java.util.Arrays; +import java.util.Map; + +import org.simantics.db.ReadGraph; +import org.simantics.db.RequestProcessor; +import org.simantics.db.Resource; +import org.simantics.db.common.request.UniqueRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.SimanticsClipboard.Representation; +import org.simantics.graph.db.TransferableGraphSource; +import org.simantics.utils.datastructures.hints.IHintContext.Key; + +public class TGSourceRepresentation implements Representation { + + protected Resource[] resources; + protected boolean ignoreVirtualResources = false; + private TransferableGraphSource value = null; + private TransferableGraphConfiguration2 configuration; + + public TGSourceRepresentation(Resource ... resources) { + this.resources = resources; + } + + public TGSourceRepresentation(boolean ignoreVirtualResources, Resource ... resources) { + this.ignoreVirtualResources = ignoreVirtualResources; + this.resources = resources; + } + + public TGSourceRepresentation(TransferableGraphConfiguration2 configuration) { + this.configuration = configuration; + } + + public TGSourceRepresentation(TransferableGraphSource value) { + this.value = value; + } + + @Override + public Key getKey() { + return SimanticsKeys.KEY_TRANSFERABLE_GRAPH_SOURCE; + } + + public TransferableGraphSource compute(ReadGraph graph, Map hints) throws DatabaseException { + + if(configuration == null) { + configuration = new TransferableGraphConfiguration2(graph, Arrays.asList(resources), ignoreVirtualResources, false); + configuration.exclusionFunction = TGRepresentationUtils.computeExclusionFunction(graph, resources, hints); + } + + return graph.syncRequest(new ModelTransferableGraphSourceRequest(configuration)); + + } + + @SuppressWarnings("unchecked") + @Override + public T getValue(RequestProcessor processor, Map hints) throws DatabaseException { + + if(value == null) { + value = processor.syncRequest(new UniqueRead() { + + @Override + public TransferableGraphSource perform(ReadGraph graph) throws DatabaseException { + return compute(graph, hints); + } + + }); + } + + return (T)value; + + } + } \ No newline at end of file