1 package org.simantics.district.network.techtype.variable;
3 import org.simantics.databoard.binding.Binding;
4 import org.simantics.databoard.type.Datatype;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.WriteGraph;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.layer0.variable.ValueAccessor;
10 import org.simantics.db.layer0.variable.Variable;
11 import org.simantics.district.network.techtype.TechTypeUtils;
12 import org.simantics.scl.reflection.annotations.SCLValue;
13 import org.simantics.structural.stubs.StructuralResource2;
15 public class Functions {
16 @SCLValue(type = "ValueAccessor")
17 public static final ValueAccessor techTypeCodeValueAccessor = new ValueAccessor() {
20 public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {
21 return org.simantics.db.layer0.function.All.standardValueAccessor.getValue(graph, context);
25 public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {
26 return org.simantics.db.layer0.function.All.standardValueAccessor.getValue(graph, context, binding);
30 public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {
31 org.simantics.db.layer0.function.All.standardValueAccessor.setValue(graph, context, value);
33 updateComponentProperties(graph, context, value);
37 public void setValue(WriteGraph graph, Variable context, Object value, Binding binding)
38 throws DatabaseException {
39 org.simantics.db.layer0.function.All.standardValueAccessor.setValue(graph, context, value, binding);
41 updateComponentProperties(graph, context, value);
45 public Datatype getDatatype(ReadGraph graph, Variable context) throws DatabaseException {
46 return org.simantics.db.layer0.function.All.standardValueAccessor.getDatatype(graph, context);
51 protected static void updateComponentProperties(WriteGraph graph, Variable context, Object value) throws DatabaseException {
52 Variable component = context.getParent(graph);
53 Resource type = component.getPossibleType(graph, StructuralResource2.getInstance(graph).Component);
57 TechTypeUtils.updateComponent(graph, component.getRepresents(graph));