void (ListSelectionEvent e) { updateAdText(getDataContext()); Object selectedValue = myResultsList.getSelectedValue(); if (selectedValue == null) return; String lastInput = mySearchField.getText(); myIsItemSelected = true; if (isMoreItem(myResultsList.getSelectedIndex())) { if (myLastInputText != null) { mySearchField.setText(myLastInputText); } return; } mySearchField.setText(selectedValue instanceof RunAnythingItem ? ((RunAnythingItem)selectedValue).getCommand() : myLastInputText); if (myLastInputText == null) myLastInputText = lastInput; }