]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.selectionview/src/org/simantics/selectionview/DisplayValueVariableAdapter.java
String formatter property using SCL function instead of adapter
[simantics/platform.git] / bundles / org.simantics.selectionview / src / org / simantics / selectionview / DisplayValueVariableAdapter.java
index 2eaba75d60db700d72c2d1a337363df7c265ef43..74f1b62bc37e3dcb4ce799964bdfb130e4b4590e 100644 (file)
@@ -31,6 +31,7 @@ import org.simantics.db.layer0.variable.Variable;
 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> {
        
@@ -119,11 +120,19 @@ public class DisplayValueVariableAdapter extends SimpleContextualAdapter<Variabl
        
        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) {