From: Reino Ruusu Date: Wed, 6 Nov 2019 10:49:33 +0000 (+0200) Subject: Check for null values in property manipulators X-Git-Tag: v1.43.0~143 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=faa2c9d309cd59039b49cb4a2f6b21b21546b951;p=simantics%2F3d.git Check for null values in property manipulators Change-Id: Id075b3cdce3483c14257e0949ed898670c82b42e --- diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/BooleanPropertyManipulator.java b/org.simantics.g3d/src/org/simantics/g3d/property/BooleanPropertyManipulator.java index a4534a47..7d9b65b6 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/BooleanPropertyManipulator.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/BooleanPropertyManipulator.java @@ -42,7 +42,9 @@ public class BooleanPropertyManipulator implements PropertyManipulator { if (editMode) return editValue; try { - return provider.getValue(input).toString(); + Object value = provider.getValue(input); + if (value == null) return null; + return value.toString(); } catch (Exception e) { return null; } diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/DoubleArrayPropertyManipulator.java b/org.simantics.g3d/src/org/simantics/g3d/property/DoubleArrayPropertyManipulator.java index bfaa4a50..a9971605 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/DoubleArrayPropertyManipulator.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/DoubleArrayPropertyManipulator.java @@ -51,6 +51,7 @@ public class DoubleArrayPropertyManipulator implements PropertyManipulator { } try { double[] val = getValue(); + if (val == null) return null; return Arrays.toString(val); } catch (Exception e) { return null; diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/DoubleArrayPropertyManipulator2.java b/org.simantics.g3d/src/org/simantics/g3d/property/DoubleArrayPropertyManipulator2.java index 82e9a062..6b7a2e11 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/DoubleArrayPropertyManipulator2.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/DoubleArrayPropertyManipulator2.java @@ -51,6 +51,8 @@ public class DoubleArrayPropertyManipulator2 implements PropertyManipulator { } try { double[] val = getValue(); + if (val == null) + return null; if (val.length == i) return "New"; if (val.length < i) diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/DoublePropertyManipulator.java b/org.simantics.g3d/src/org/simantics/g3d/property/DoublePropertyManipulator.java index 47f6ca7d..4f7c670f 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/DoublePropertyManipulator.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/DoublePropertyManipulator.java @@ -41,7 +41,9 @@ public class DoublePropertyManipulator implements PropertyManipulator { if (editMode) return editValue; try { - return provider.getValue(input).toString(); + Object value = provider.getValue(input); + if (value == null) return null; + return value.toString(); } catch (Exception e) { return null; } diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/IntegerPropertyManipulator.java b/org.simantics.g3d/src/org/simantics/g3d/property/IntegerPropertyManipulator.java index d0f5e1d6..045aa830 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/IntegerPropertyManipulator.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/IntegerPropertyManipulator.java @@ -42,7 +42,9 @@ public class IntegerPropertyManipulator implements PropertyManipulator { if (editMode) return editValue; try { - return provider.getValue(input).toString(); + Object value = provider.getValue(input); + if (value == null) return null; + return value.toString(); } catch (Exception e) { return null; }