From c87973d59c91244a8656cdc2ac5c1d84f9d47f34 Mon Sep 17 00:00:00 2001 From: metasim Date: Tue, 16 Jan 2001 19:21:42 +0000 Subject: [PATCH] Changed semantics of initializing with a null value. Now a default value is created. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268472 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/gui/customizer/PropertiesPropertyEditor.java | 8 ++++++-- .../ant/gui/customizer/StringArrayPropertyEditor.java | 3 +++ .../tools/ant/gui/customizer/StringPropertyEditor.java | 7 ++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/antidote/org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java b/src/antidote/org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java index 4af80661b..94743595d 100644 --- a/src/antidote/org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java +++ b/src/antidote/org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java @@ -114,7 +114,7 @@ public class PropertiesPropertyEditor extends AbstractPropertyEditor { * current value. */ public String getJavaInitializationString() { - return getAsText(); + return "new Properties()"; } /** @@ -128,7 +128,11 @@ public class PropertiesPropertyEditor extends AbstractPropertyEditor { * modified value. */ public void setValue(Object value) { - if(value != null && !(value instanceof Properties)) { + if(value == null) { + value = new Properties(); + } + + if(!(value instanceof Properties)) { throw new IllegalArgumentException( value.getClass().getName() + " is not of type Properties."); } diff --git a/src/antidote/org/apache/tools/ant/gui/customizer/StringArrayPropertyEditor.java b/src/antidote/org/apache/tools/ant/gui/customizer/StringArrayPropertyEditor.java index 62be02893..fa17dfe23 100644 --- a/src/antidote/org/apache/tools/ant/gui/customizer/StringArrayPropertyEditor.java +++ b/src/antidote/org/apache/tools/ant/gui/customizer/StringArrayPropertyEditor.java @@ -114,6 +114,9 @@ public class StringArrayPropertyEditor extends AbstractPropertyEditor { * modified value. */ public void setValue(Object value) { + if(value == null) { + value = new String[0]; + } if(!(value instanceof String[])) { throw new IllegalArgumentException( "Value must be of type String[]."); diff --git a/src/antidote/org/apache/tools/ant/gui/customizer/StringPropertyEditor.java b/src/antidote/org/apache/tools/ant/gui/customizer/StringPropertyEditor.java index 7a7304fa0..00b756298 100644 --- a/src/antidote/org/apache/tools/ant/gui/customizer/StringPropertyEditor.java +++ b/src/antidote/org/apache/tools/ant/gui/customizer/StringPropertyEditor.java @@ -119,6 +119,10 @@ public class StringPropertyEditor extends AbstractPropertyEditor { * modified value. */ public void setValue(Object value) { + if(value == null) { + value = ""; + } + Object old = _widget.getText(); _widget.setText(String.valueOf(value)); } @@ -129,9 +133,6 @@ public class StringPropertyEditor extends AbstractPropertyEditor { * object type such as "java.lang.Integer". */ public Object getValue() { String retval = _widget.getText(); - if(retval != null && retval.length() == 0) { - retval = null; - } return retval; }