import org.simantics.db.layer0.variable.Variables;
import org.simantics.layer0.Layer0;
import org.simantics.modeling.ModelingResources;
+import org.simantics.scl.runtime.function.Function1;
public class DisplayValueVariableAdapter extends SimpleContextualAdapter<Variable, ModelledVariablePropertyDescriptor> {
Object value = property.getValue(graph);
- Resource formatter = property.getPossiblePropertyValue(graph, Variables.FORMATTER);
- if(formatter != null) {
- Formatter fmt = graph.adaptContextual(formatter, property, Variable.class, Formatter.class);
- value = fmt.format(value);
- } else {
+ Resource formatter = property.getPossiblePropertyValue(graph, Variables.FORMATTER);
+ if(formatter != null) {
+ Formatter fmt = graph.adaptContextual(formatter, property, Variable.class, Formatter.class);
+ value = fmt.format(property.getValue(graph));
+ }
+ if(value == null) {
+ SelectionViewResources SEL = SelectionViewResources.getInstance(graph);
+ Function1<Object,String> formatterFunction = property.getPossiblePropertyValue(graph, SEL.formatter);
+ if(formatterFunction != null) {
+ value = formatterFunction.apply(property.getValue(graph));
+ }
+ }
+ if(value == null) {
Datatype dt = property.getPossibleDatatype(graph);
if(dt != null) {