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> {
String expression = possibleExpression(graph, property);
if(expression != null) return expression;
- Object value = property.getValue(graph);
+ Object value = null;
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 {
+ 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) {
if(!isPrimitive(dt)) {
Binding binding = Bindings.getBinding(dt);
try {
- value = DataValuePrinter.writeValueSingleLine(binding, value);
+ value = DataValuePrinter.writeValueSingleLine(binding, property.getValue(graph));
} catch (IOException e) {
e.printStackTrace();
} catch (BindingException e) {
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.reflection.annotations.SCLValue;
+import org.simantics.scl.runtime.function.Function1;
import org.simantics.selectionview.SelectionInput;
+import org.simantics.selectionview.SelectionViewResources;
import org.simantics.selectionview.StandardSelectionInput;
import org.simantics.ui.colors.Colors;
import org.simantics.ui.fonts.Fonts;
Object value = null;
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));
-
- } else {
+ }
+ 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) {
Variant variant = property.getVariantValue(graph);
value = variant.getValue();
-
Binding binding = variant.getBinding();
if(binding != null) {
Datatype dt = binding.type();