X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Fscl%2FVariableStructuralContext.java;h=492c1de1ba7f57f28ea9096a915c75e186fc5e8c;hb=e6e555f4c17e686c44d0681a01eab17d0ec6f2aa;hp=43f406d3dfaa9c29471033981d0e45661d3f46ec;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/scl/VariableStructuralContext.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/scl/VariableStructuralContext.java index 43f406d3d..492c1de1b 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/scl/VariableStructuralContext.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/scl/VariableStructuralContext.java @@ -1,73 +1,73 @@ -package org.simantics.structural2.scl; - -import java.util.List; - -import org.simantics.databoard.Bindings; -import org.simantics.databoard.adapter.AdaptException; -import org.simantics.databoard.binding.Binding; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.layer0.Layer0; -import org.simantics.structural.stubs.StructuralResource2; -import org.simantics.structural2.scl.StructuralComponent; - -public class VariableStructuralContext extends StructuralComponent { - - final public Variable variable; - - public VariableStructuralContext(ReadGraph graph, Variable selfVariable) throws DatabaseException { - this.variable = selfVariable.getParent(graph).getParent(graph); - } - - public VariableStructuralContext(Variable variable) throws DatabaseException { - this.variable = variable; - } - - @Override - public Resource getType(ReadGraph g) throws DatabaseException { - throw new UnsupportedOperationException(); - } - - @Override - public Object getValue(ReadGraph g, Resource attribute, Binding binding) throws DatabaseException, AdaptException { - - Layer0 L0 = Layer0.getInstance(g); - StructuralResource2 STR = StructuralResource2.getInstance(g); - if(STR.input.equals(attribute)) { - return variable.getPropertyValue(g, "input"); - } - - String name = g.getRelatedValue(attribute, L0.HasName, Bindings.STRING); - return variable.getPropertyValue(g, name); - - } - - @Override - public boolean isParametrized(ReadGraph g) throws DatabaseException { - throw new UnsupportedOperationException(); - } - - @Override - public Variable getConnection(ReadGraph g, Resource connectionPoint) throws DatabaseException { - throw new UnsupportedOperationException(); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public List getConnections(ReadGraph g, Resource connectionPoint) throws DatabaseException { - throw new UnsupportedOperationException(); - } - - @Override - public Resource getResource() { - throw new UnsupportedOperationException(); - } - - @Override - public StructuralComponent getContext() { - throw new UnsupportedOperationException(); - } - -} +package org.simantics.structural2.scl; + +import java.util.List; + +import org.simantics.databoard.Bindings; +import org.simantics.databoard.adapter.AdaptException; +import org.simantics.databoard.binding.Binding; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.layer0.Layer0; +import org.simantics.structural.stubs.StructuralResource2; +import org.simantics.structural2.scl.StructuralComponent; + +public class VariableStructuralContext extends StructuralComponent { + + final public Variable variable; + + public VariableStructuralContext(ReadGraph graph, Variable selfVariable) throws DatabaseException { + this.variable = selfVariable.getParent(graph).getParent(graph); + } + + public VariableStructuralContext(Variable variable) throws DatabaseException { + this.variable = variable; + } + + @Override + public Resource getType(ReadGraph g) throws DatabaseException { + throw new UnsupportedOperationException(); + } + + @Override + public Object getValue(ReadGraph g, Resource attribute, Binding binding) throws DatabaseException, AdaptException { + + Layer0 L0 = Layer0.getInstance(g); + StructuralResource2 STR = StructuralResource2.getInstance(g); + if(STR.input.equals(attribute)) { + return variable.getPropertyValue(g, "input"); + } + + String name = g.getRelatedValue(attribute, L0.HasName, Bindings.STRING); + return variable.getPropertyValue(g, name); + + } + + @Override + public boolean isParametrized(ReadGraph g) throws DatabaseException { + throw new UnsupportedOperationException(); + } + + @Override + public Variable getConnection(ReadGraph g, Resource connectionPoint) throws DatabaseException { + throw new UnsupportedOperationException(); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public List getConnections(ReadGraph g, Resource connectionPoint) throws DatabaseException { + throw new UnsupportedOperationException(); + } + + @Override + public Resource getResource() { + throw new UnsupportedOperationException(); + } + + @Override + public StructuralComponent getContext() { + throw new UnsupportedOperationException(); + } + +}