Browse Source

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
master
metasim 24 years ago
parent
commit
c87973d59c
3 changed files with 13 additions and 5 deletions
  1. +6
    -2
      src/antidote/org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java
  2. +3
    -0
      src/antidote/org/apache/tools/ant/gui/customizer/StringArrayPropertyEditor.java
  3. +4
    -3
      src/antidote/org/apache/tools/ant/gui/customizer/StringPropertyEditor.java

+ 6
- 2
src/antidote/org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java View File

@@ -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.");
}


+ 3
- 0
src/antidote/org/apache/tools/ant/gui/customizer/StringArrayPropertyEditor.java View File

@@ -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[].");


+ 4
- 3
src/antidote/org/apache/tools/ant/gui/customizer/StringPropertyEditor.java View File

@@ -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;
}



Loading…
Cancel
Save