import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import org.eclipse.swt.widgets.FontDialog;
import org.simantics.Simantics;
import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.common.modifiers.EnumerationValue;
import org.simantics.browsing.ui.content.Labeler.DialogModifier;
+import org.simantics.browsing.ui.graph.impl.GetEnumerationValue;
import org.simantics.common.format.Formatter;
import org.simantics.databoard.Bindings;
import org.simantics.databoard.Datatypes;
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;
import org.simantics.ui.selection.WorkbenchSelectionElement;
import org.simantics.ui.selection.WorkbenchSelectionUtils;
import org.simantics.utils.datastructures.collections.CollectionUtils;
+import org.simantics.utils.strings.AlphanumComparator;
import org.simantics.utils.ui.AdaptionUtils;
import org.simantics.utils.ui.ErrorLogger;
import org.simantics.utils.ui.ISelectionUtils;
Resource parameterResource = parameter.getRepresents(graph);
if(graph.sync(new IsEnumeratedValue(parameterResource))) {
Map<String, Resource> map = graph.sync(new InstanceEnumerationMap(parameterResource));
- return new ArrayList<String>(map.keySet());
+ ArrayList<String> values = new ArrayList<>(map.keySet());
+ Collections.sort(values, AlphanumComparator.COMPARATOR);
+ return values;
} else if(graph.isInstanceOf(parameterResource, L0.Boolean)) {
return CollectionUtils.toList("true", "false");
}
public static Object getPropertyChildName(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
if(context instanceof Variable) {
Variable variable = (Variable)context;
+ String label = variable.getParent(graph).getPossiblePropertyValue(graph, "HasLabel", Bindings.STRING);
+ if(label != null)
+ return label;
return variable.getParent(graph).getName(graph);
}
throw new DatabaseException("Unknown context " + context);
}
- if(!asserted) {
- Resource assertedObject = Layer0Utils.getPossibleAssertedObject(graph, container, property);
- if(assertedObject != null) {
- if(graph.isInstanceOf(assertedObject, newType)) {
- Object assertedValue = graph.getValue(assertedObject, (Binding)_binding);
- if(assertedValue.equals(value)) {
- graph.deny(container, property);
- return null;
- }
- }
- }
- }
-
Datatype datatype = variable.getDatatype(graph);
Binding binding = (Binding)_binding;
Layer0Utils.claimAdaptedValue(graph, objectResource, value, binding, datatype);
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));
+ }
+ }
+
+ Resource possibleValue = context.getParent(graph).getPossibleRepresents(graph);
+ if(possibleValue != null) {
+ if(graph.syncRequest(new IsEnumeratedValue(possibleValue))) {
+ return GetEnumerationValue.getEnumerationValueName(graph, possibleValue);
+ }
+ }
+
+ if(value == null) {
Variant variant = property.getVariantValue(graph);
value = variant.getValue();
-
Binding binding = variant.getBinding();
if(binding != null) {
Datatype dt = binding.type();
String parsedLabel = (String)_value;
Object value = parsedLabel;
+ boolean isEnumeration = false;
+ Resource possibleValue = context.getParent(graph).getPossibleRepresents(graph);
+ if(possibleValue != null) {
+ isEnumeration = graph.syncRequest(new IsEnumeratedValue(possibleValue));
+ }
+
Datatype type = context.getParent(graph).getPossibleDatatype(graph);
- if (type != null) {
+ if (type != null && !isEnumeration) {
Binding binding = Bindings.getBinding(type);