[DataBinding] Error in impl of (C)ComboObservableValue? [message #447930] |
Tue, 18 April 2006 03:47  |
Eclipse User |
|
|
|
The current implementation of (C)ComboObservableValue.setValue is as
follows:
....
} else if (attribute.equals(SWTProperties.SELECTION)) {
String items[] = combo.getItems();
int index = -1;
if (items != null && value != null) {
for (int i = 0; i < items.length; i++) {
if (value.equals(items[i])) {
index = i;
break;
}
}
if (index == -1) {
combo.setText((String) value);
} else {
combo.select(index); // -1 will not "unselect"
}
}
}
....
My assumption is, that the case value == null is not handled properly
and should have the effect, that the selection text is cleared, e.g.:
....
} else if (attribute.equals(SWTProperties.SELECTION)) {
String items[] = combo.getItems();
if (items != null && value != null) {
int index = -1;
for (int i = 0; i < items.length; i++) {
if (value.equals(items[i])) {
index = i;
break;
}
}
if (index == -1) {
combo.setText((String) value);
} else {
combo.select(index); // -1 will not "unselect"
}
} else if (value == null) {
combo.setText("");
}
}
....
Is this assumption correct? A further question is, whether in case of
null-items, any new value should be set or not (I assume, it should be
set). This would let to:
....
} else if (attribute.equals(SWTProperties.SELECTION)) {
String items[] = combo.getItems();
if (value != null) {
int index = -1;
if (items != null && value != null) {
for (int i = 0; i < items.length; i++) {
if (value.equals(items[i])) {
index = i;
break;
}
}
}
if (index == -1) {
combo.setText(value != null ? (String) value :
"");
} else {
combo.select(index); // -1 will not "unselect"
}
}
....
Greetings from Bremen,
Daniel Krügler
|
|
|
|
Powered by
FUDForum. Page generated in 0.03854 seconds