Exploding Alias
kleopatra edited this page Oct 17, 2014
·
2 revisions
All code inside the skin: listening to items property and to changes of its content:
@Override protected void handleControlPropertyChanged(String p) {
if ("ITEMS".equals(p)) {
updateComboBoxItems();
updateListViewItems();
}
...
}
private void updateComboBoxItems() {
comboBoxItems = comboBox.getItems();
comboBoxItems = comboBoxItems == null ? FXCollections.<T>emptyObservableList() : comboBoxItems;
}
public void updateListViewItems() {
if (listViewItems != null) {
listViewItems.removeListener(weakListViewItemsListener);
}
this.listViewItems = comboBoxItems;
listView.setItems(listViewItems);
if (listViewItems != null) {
listViewItems.addListener(weakListViewItemsListener);
}
...
}
Now the quick fix for RT-15793 in the ComboBox itself:
private ObjectProperty<ObservableList<T>> items = new SimpleObjectProperty<ObservableList<T>>(this, "items") {
@Override protected void invalidated() {
// FIXME temporary fix for RT-15793. This will need to be
// properly fixed when time permits
....
if (getSkin() instanceof ComboBoxListViewSkin) {
ComboBoxListViewSkin<?> skin = (ComboBoxListViewSkin<?>) getSkin();
skin.updateListViewItems();
}
}
};
Spot the blot?
Took me a while - started with being plain confused of RT-38731 being virulent for a ComboBox as well as for a ChoiceBox: the hack above should have worked for the CombBox (ChoiceBox probably was simply forgotten).