final int selectedItemIndex = getSelectedIndex(data);
if (screen.isActivePopup(popupInstance)) {
dropDown.getElement().getControl(DropDownControl.class).close(new EndNotify() {
@Override
public void perform() {
nifty.publishEvent(dropDown.getId(), new DropDownSelectionChangedEvent(dropDown, selectedItem, selectedItemIndex));
}
});
} else {
nifty.publishEvent(dropDown.getId(), new DropDownSelectionChangedEvent(dropDown, selectedItem, selectedItemIndex));
}
}