]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ComponentTypeViewerPropertyInfo.java
Merge "Refactoring of simulator toolkit"
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / componentTypeEditor / ComponentTypeViewerPropertyInfo.java
index 7912700a7af703aad9b6f80f976c8f8f4cca559b..c5e77383f4be7330063696ca84807d28d3a6d3f7 100644 (file)
-package org.simantics.modeling.ui.componentTypeEditor;\r
-\r
-import org.simantics.databoard.annotations.Optional;\r
-import org.simantics.databoard.type.NumberType;\r
-import org.simantics.db.Resource;\r
-import org.simantics.utils.strings.AlphanumComparator;\r
-\r
-public class ComponentTypeViewerPropertyInfo implements Comparable<ComponentTypeViewerPropertyInfo> {\r
-    public Resource resource;\r
-    public String name;\r
-    public String type;\r
-    public String defaultValue;\r
-    public String label;\r
-    public String description;\r
-    @Optional\r
-    public String expression;\r
-    @Optional\r
-    public String valid;\r
-    @Optional\r
-    public NumberType numberType;\r
-    @Optional\r
-    public String unit;\r
-    public boolean immutable;\r
-    public Object sectionSpecificData; \r
-\r
-    public ComponentTypeViewerPropertyInfo(Resource resource, String name, String type, String defaultValue, NumberType numberType, String unit, String label, String description, String expression, String valid, boolean immutable) {\r
-        this.resource = resource;\r
-        this.name = name;\r
-        this.type = type;\r
-        this.defaultValue = defaultValue;\r
-        this.numberType = numberType;\r
-        this.unit = unit;\r
-        this.label = label;\r
-        this.description = description;\r
-        this.expression = expression;\r
-        this.valid = valid;\r
-        this.immutable = immutable;\r
-    }\r
-\r
-    @Override\r
-    public int compareTo(ComponentTypeViewerPropertyInfo o) {\r
-        return AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(name, (o.name));\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result\r
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());\r
-        result = prime * result\r
-                + ((description == null) ? 0 : description.hashCode());\r
-        result = prime * result\r
-                + ((expression == null) ? 0 : expression.hashCode());\r
-        result = prime * result + (immutable ? 1231 : 1237);\r
-        result = prime * result + ((label == null) ? 0 : label.hashCode());\r
-        result = prime * result + ((name == null) ? 0 : name.hashCode());\r
-        result = prime * result\r
-                + ((numberType == null) ? 0 : numberType.hashCode());\r
-        result = prime * result\r
-                + ((resource == null) ? 0 : resource.hashCode());\r
-        result = prime * result + ((sectionSpecificData == null) ? 0\r
-                : sectionSpecificData.hashCode());\r
-        result = prime * result + ((type == null) ? 0 : type.hashCode());\r
-        result = prime * result + ((unit == null) ? 0 : unit.hashCode());\r
-        result = prime * result + ((valid == null) ? 0 : valid.hashCode());\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj)\r
-            return true;\r
-        if (obj == null)\r
-            return false;\r
-        if (getClass() != obj.getClass())\r
-            return false;\r
-        ComponentTypeViewerPropertyInfo other = (ComponentTypeViewerPropertyInfo) obj;\r
-        if (defaultValue == null) {\r
-            if (other.defaultValue != null)\r
-                return false;\r
-        } else if (!defaultValue.equals(other.defaultValue))\r
-            return false;\r
-        if (description == null) {\r
-            if (other.description != null)\r
-                return false;\r
-        } else if (!description.equals(other.description))\r
-            return false;\r
-        if (expression == null) {\r
-            if (other.expression != null)\r
-                return false;\r
-        } else if (!expression.equals(other.expression))\r
-            return false;\r
-        if (immutable != other.immutable)\r
-            return false;\r
-        if (label == null) {\r
-            if (other.label != null)\r
-                return false;\r
-        } else if (!label.equals(other.label))\r
-            return false;\r
-        if (name == null) {\r
-            if (other.name != null)\r
-                return false;\r
-        } else if (!name.equals(other.name))\r
-            return false;\r
-        if (numberType == null) {\r
-            if (other.numberType != null)\r
-                return false;\r
-        } else if (!numberType.equals(other.numberType))\r
-            return false;\r
-        if (resource == null) {\r
-            if (other.resource != null)\r
-                return false;\r
-        } else if (!resource.equals(other.resource))\r
-            return false;\r
-        if (sectionSpecificData == null) {\r
-            if (other.sectionSpecificData != null)\r
-                return false;\r
-        } else if (!sectionSpecificData.equals(other.sectionSpecificData))\r
-            return false;\r
-        if (type == null) {\r
-            if (other.type != null)\r
-                return false;\r
-        } else if (!type.equals(other.type))\r
-            return false;\r
-        if (unit == null) {\r
-            if (other.unit != null)\r
-                return false;\r
-        } else if (!unit.equals(other.unit))\r
-            return false;\r
-        if (valid == null) {\r
-            if (other.valid != null)\r
-                return false;\r
-        } else if (!valid.equals(other.valid))\r
-            return false;\r
-        return true;\r
-    }\r
-    \r
-    \r
+package org.simantics.modeling.ui.componentTypeEditor;
+
+import org.simantics.databoard.annotations.Optional;
+import org.simantics.databoard.type.NumberType;
+import org.simantics.db.Resource;
+import org.simantics.utils.strings.AlphanumComparator;
+import org.simantics.utils.strings.StringUtils;
+
+public class ComponentTypeViewerPropertyInfo implements Comparable<ComponentTypeViewerPropertyInfo> {
+    public Resource resource;
+    public String name;
+    public String type;
+    public String defaultValue;
+    public String label;
+    public String description;
+    @Optional
+    public String expression;
+    @Optional
+    public String valid;
+    @Optional
+    public NumberType numberType;
+    @Optional
+    public String unit;
+    public boolean immutable;
+    public Object sectionSpecificData; 
+
+    public ComponentTypeViewerPropertyInfo(Resource resource, String name, String type, String defaultValue, NumberType numberType, String unit, String label, String description, String expression, String valid, boolean immutable) {
+        this.resource = resource;
+        this.name = name;
+        this.type = type;
+        this.defaultValue = defaultValue;
+        this.numberType = numberType;
+        this.unit = unit;
+        this.label = label;
+        this.description = description;
+        this.expression = expression;
+        this.valid = valid;
+        this.immutable = immutable;
+    }
+
+    @Override
+    public int compareTo(ComponentTypeViewerPropertyInfo o) {
+        return AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(name, (o.name));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+        result = prime * result
+                + ((description == null) ? 0 : description.hashCode());
+        result = prime * result
+                + ((expression == null) ? 0 : expression.hashCode());
+        result = prime * result + (immutable ? 1231 : 1237);
+        result = prime * result + ((label == null) ? 0 : label.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result
+                + ((numberType == null) ? 0 : numberType.hashCode());
+        result = prime * result
+                + ((resource == null) ? 0 : resource.hashCode());
+        result = prime * result + ((sectionSpecificData == null) ? 0
+                : sectionSpecificData.hashCode());
+        result = prime * result + ((type == null) ? 0 : type.hashCode());
+        result = prime * result + ((unit == null) ? 0 : unit.hashCode());
+        result = prime * result + ((valid == null) ? 0 : valid.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        ComponentTypeViewerPropertyInfo other = (ComponentTypeViewerPropertyInfo) obj;
+        if (defaultValue == null) {
+            if (other.defaultValue != null)
+                return false;
+        } else if (!defaultValue.equals(other.defaultValue))
+            return false;
+        if (description == null) {
+            if (other.description != null)
+                return false;
+        } else if (!description.equals(other.description))
+            return false;
+        if (expression == null) {
+            if (other.expression != null)
+                return false;
+        } else if (!expression.equals(other.expression))
+            return false;
+        if (immutable != other.immutable)
+            return false;
+        if (label == null) {
+            if (other.label != null)
+                return false;
+        } else if (!label.equals(other.label))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (numberType == null) {
+            if (other.numberType != null)
+                return false;
+        } else if (!numberType.equals(other.numberType))
+            return false;
+        if (resource == null) {
+            if (other.resource != null)
+                return false;
+        } else if (!resource.equals(other.resource))
+            return false;
+        if (sectionSpecificData == null) {
+            if (other.sectionSpecificData != null)
+                return false;
+        } else if (!sectionSpecificData.equals(other.sectionSpecificData))
+            return false;
+        if (type == null) {
+            if (other.type != null)
+                return false;
+        } else if (!type.equals(other.type))
+            return false;
+        if (unit == null) {
+            if (other.unit != null)
+                return false;
+        } else if (!unit.equals(other.unit))
+            return false;
+        if (valid == null) {
+            if (other.valid != null)
+                return false;
+        } else if (!valid.equals(other.valid))
+            return false;
+        return true;
+    }
+
+    public String unitString() {
+        String result = numberType == null ? null : numberType.getUnit();
+        if (result == null)
+            result = unit;
+        return StringUtils.safeString(result);
+    }
+
+    public String rangeString() {
+        return StringUtils.safeString(numberType == null ? null : numberType.getRangeStr());
+    }
+
 }
\ No newline at end of file