DesktopCheckBox sets value to false, if value == null and setValue(null) is invoked #PL-4071

This commit is contained in:
Yuriy Artamonov 2014-07-04 14:20:37 +00:00
parent f2965df904
commit 2c5c101704

View File

@ -51,6 +51,7 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
);
}
@SuppressWarnings("unchecked")
@Override
public <T> T getValue() {
return (T) (Boolean) impl.isSelected();
@ -63,6 +64,10 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
return;
}
if (value == null) {
value = false;
}
if (!ObjectUtils.equals(prevValue, value)) {
updateComponent(value);
updateInstance();
@ -84,6 +89,7 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
return metaProperty;
}
@SuppressWarnings("unchecked")
@Override
public void setDatasource(Datasource datasource, String property) {
this.datasource = datasource;
@ -95,12 +101,10 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
final MetaClass metaClass = datasource.getMetaClass();
metaPropertyPath = metaClass.getPropertyPath(property);
try {
metaProperty = metaPropertyPath.getMetaProperty();
}
catch (ArrayIndexOutOfBoundsException e) {
throw new RuntimeException("Metaproperty name is possibly wrong: " + property, e);
if (metaPropertyPath == null) {
throw new RuntimeException("Metaproperty name is possibly wrong: " + property);
}
metaProperty = metaPropertyPath.getMetaProperty();
datasource.addListener(
new DsListenerAdapter() {
@ -109,6 +113,10 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
if (updatingInstance)
return;
Boolean value = InstanceUtils.getValueEx(item, metaPropertyPath.getPath());
if (value == null) {
value = false;
}
updateComponent(value);
fireChangeListeners(value);
}
@ -118,6 +126,10 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
if (updatingInstance)
return;
if (property.equals(metaPropertyPath.toString())) {
if (value == null) {
value = false;
}
updateComponent(value);
fireChangeListeners(value);
}