]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ComponentTypeViewer.java
Merge changes I78c3a258,I7bf72f04
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / componentTypeEditor / ComponentTypeViewer.java
index 7d256ba00e2dca5941e632a990105b02daee3d1d..38f24b4f7ddb53d8d7b6b3dafc84403c35042533 100644 (file)
@@ -34,6 +34,7 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.simantics.Simantics;
+import org.simantics.browsing.ui.graph.impl.GetEnumerationValue;
 import org.simantics.databoard.Bindings;
 import org.simantics.databoard.binding.Binding;
 import org.simantics.databoard.binding.error.BindingException;
@@ -42,6 +43,7 @@ import org.simantics.databoard.type.NumberType;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.NamedResource;
+import org.simantics.db.common.request.IsEnumeratedValue;
 import org.simantics.db.common.request.UniqueRead;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
@@ -185,22 +187,24 @@ public class ComponentTypeViewer {
                         String type =  graph.getPossibleRelatedValue(relation, L0.RequiresValueType);
                         String label = graph.getPossibleRelatedValue(relation, L0.HasLabel);
                         if (label == null)
-                            label = "";
+                            label = ""; //$NON-NLS-1$
                         String description = graph.getPossibleRelatedValue(relation, L0.HasDescription);
                         if (description == null)
-                            description = "";
+                            description = ""; //$NON-NLS-1$
                         NumberType numberType = null;
                         if(type == null)
-                            type = "Double";
+                            type = "Double"; //$NON-NLS-1$
                         String unit = graph.getPossibleRelatedValue(relation, L0X.HasUnit, Bindings.STRING);
-                        String defaultValue = "0";
+                        String defaultValue = "0"; //$NON-NLS-1$
                         String expression = null;
                         
                         for(Resource assertion : graph.getAssertedObjects(data.componentType, relation)) {
                             try {
                                 expression = graph.getPossibleRelatedValue(assertion, L0.SCLValue_expression, Bindings.STRING);
                                 if(expression != null) {
-                                       defaultValue = "=" + expression;
+                                       defaultValue = "=" + expression; //$NON-NLS-1$
+                                } else if (graph.sync(new IsEnumeratedValue(assertion))) {
+                                    defaultValue = GetEnumerationValue.getEnumerationValueName(graph, assertion);
                                 } else {
                                        Datatype dt = getPossibleDatatype(graph, assertion);
                                        if (dt == null)
@@ -306,9 +310,9 @@ public class ComponentTypeViewer {
             section.setReadOnly(readOnly);
         IMessageManager mm = data.form.getMessageManager();
         if (readOnly)
-            mm.addMessage("readonly", "(Opened in read-only mode)", null, IMessageProvider.INFORMATION);
+            mm.addMessage("readonly", Messages.ComponentTypeViewer_OpenedInReadOnly, null, IMessageProvider.INFORMATION); //$NON-NLS-1$
         else
-            mm.removeMessage("readonly");
+            mm.removeMessage("readonly"); //$NON-NLS-1$
     }
 
 }