--- /dev/null
+package org.simantics.structural2.scl;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.adapter.AdaptException;\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.structural2.scl.StructuralComponent;\r
+\r
+public class VariableStructuralContext extends StructuralComponent<Variable> {\r
+\r
+ final public Variable variable;\r
+ \r
+ public VariableStructuralContext(ReadGraph graph, Variable selfVariable) throws DatabaseException {\r
+ this.variable = selfVariable.getParent(graph).getParent(graph);\r
+ }\r
+\r
+ public VariableStructuralContext(Variable variable) throws DatabaseException {\r
+ this.variable = variable;\r
+ }\r
+\r
+ @Override\r
+ public Resource getType(ReadGraph g) throws DatabaseException {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public Object getValue(ReadGraph g, Resource attribute, Binding binding) throws DatabaseException, AdaptException {\r
+ \r
+ Layer0 L0 = Layer0.getInstance(g);\r
+ StructuralResource2 STR = StructuralResource2.getInstance(g);\r
+ if(STR.input.equals(attribute)) {\r
+ return variable.getPropertyValue(g, "input");\r
+ }\r
+\r
+ String name = g.getRelatedValue(attribute, L0.HasName, Bindings.STRING);\r
+ return variable.getPropertyValue(g, name);\r
+ \r
+ }\r
+\r
+ @Override\r
+ public boolean isParametrized(ReadGraph g) throws DatabaseException {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public Variable getConnection(ReadGraph g, Resource connectionPoint) throws DatabaseException {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @SuppressWarnings({ "unchecked", "rawtypes" })\r
+ @Override\r
+ public List getConnections(ReadGraph g, Resource connectionPoint) throws DatabaseException {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public Resource getResource() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public StructuralComponent<Variable> getContext() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+}\r