/** * Returns the index of the selected list item. If there are multiple selections, the index of * the first selected item will be returned. * * @return The index of the selected list item. If there is no current selection, returns -1. */ public int getSelectedIndex() { Listitem item = getSelectedItem(); return item == null ? -1 : item.getIndex(); }
/** * Returns the identifier of the currently selected layout, or null if none selected. * * @return The currently selected layout. */ private LayoutIdentifier getSelectedLayout() { Listitem item = lstLayouts.getSelectedItem(); return item == null ? null : (LayoutIdentifier) item.getData(); }
/** * Double-clicking a list item adds it to the info panel. */ public void onDoubleClick$listbox() { pushDrop(listbox.getSelectedItem()); }
@EventHandler(value = "click", target = "btnRemoveSubscription") private void onClick$btnRemoveSubscription() { Listitem item = lboxSubscriptions.getSelectedItem(); if (item != null) { if (item.isSelected()) { subscribe(item.getLabel(), false); } lboxSubscriptions.removeChild(item); } }
/** * Set the topic view when a topic selection is made. */ @EventHandler(value = "change", target = "@lstTopics") private void onSelect$lstTopics() { Listitem item = lstTopics.getSelectedItem(); Listitem keywordItem = lstKeywords.getSelectedItem(); if (item == null) { int i = keywordItem.hasAttribute("last") ? (Integer) keywordItem.getAttribute("last") : 0; item = (Listitem) lstTopics.getChildAt(i); lstTopics.setSelectedItem(item); } if (item != null) { keywordItem.setAttribute("last", lstTopics.getSelectedIndex()); setTopic((HelpTopic) item.getData()); } else { setTopic(null); } }
/** * Initialize the topic list when a keyword is selected. The last topic selected for the keyword * is automatically selected. */ @EventHandler(value = "change", target = "@lstKeywords") private void onSelect$lstKeywords() { Listitem item = lstKeywords.getSelectedItem(); if (item == null) { lstTopics.destroyChildren(); setTopic(null); return; } List<HelpTopic> topics = getTopics(item.getLabel()); if (!item.hasAttribute("sorted")) { item.setAttribute("sorted", true); Collections.sort(topics); } modelAndView.setModel(new ListModel<>(topics)); onSelect$lstTopics(); }
public void onClick$btnSendEvent() { Listitem item = actions.getSelectedItem(); if (item != null) { Action action = Action.valueOf(item.getLabel()); EventManager.getInstance().fireLocalEvent(getEvent(action), action); } }
private void processListResponses() { List<?> responses = control.getResponses(); listbox.setVisible(true); for (Object rsp : responses) { DialogResponse<?> response = (DialogResponse<?>) rsp; Listitem item = new Listitem(StrUtil.formatMessage(response.getLabel())); item.addEventListener(DblclickEvent.TYPE, clickListener); item.setData(response); listbox.addChild(item); if (response.isDefault()) { item.setSelected(true); } } if (listbox.getSelectedCount() == 0) { listbox.setSelectedItem(listbox.getChild(Listitem.class)); } addButton(LABEL_ID_CANCEL, "danger", (event) -> { close(null); }); addButton(LABEL_ID_OK, "success", (event) -> { close(listbox.getSelectedItem()); }); }