X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fquery%2FQueryProxyChildVariable.java;fp=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fquery%2FQueryProxyChildVariable.java;h=6c62c4eb513eee5f88a065e79b8dfb8fedb43abc;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/query/QueryProxyChildVariable.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/query/QueryProxyChildVariable.java new file mode 100644 index 000000000..6c62c4eb5 --- /dev/null +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/query/QueryProxyChildVariable.java @@ -0,0 +1,46 @@ +package org.simantics.modeling.query; + +import java.util.Collection; + +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.ProxyChildVariable; +import org.simantics.db.layer0.variable.Variable; + +public class QueryProxyChildVariable extends ProxyChildVariable { + + public QueryProxyChildVariable(Variable base, Variable parent, Variable other, String name) { + super(base, parent, other, name); + } + + @Override + public Variable create(Variable base, Variable parent, Variable other, String name) { + return new QueryProxyChildVariable(base, parent, other, name); + } + + public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException { + + if(CONTEXT_END.equals(name)) { + if(other instanceof ProxyChildVariable) { + // The context is also a proxy - let it do the job + return super.getPossibleChild(graph, name); + } else { + return new QueryRootVariable(this, base.getRepresents(graph)); + } + } + + return super.getPossibleChild(graph, name); + + } + + public Collection getChildren(ReadGraph graph) throws DatabaseException { + + Collection result = super.getChildren(graph); + if(!(base instanceof ProxyChildVariable)) { + result.add(new QueryRootVariable(this, base.getRepresents(graph))); + } + return result; + + } + +} \ No newline at end of file