/** * Sets the selected list item by its index. Any existing selections are cleared. * * @param index The index of the list item to be selected. */ public void setSelectedIndex(int index) { setSelectedItem((Listitem) getChildAt(index)); }
/** * Need to update visual appearance of selection when it is changed. * * @see org.fujion.component.Listbox#setSelectedItem(Listitem) */ @Override public void setSelectedItem(Listitem item) { super.setSelectedItem(item); updateSelection(); }
/** * Locates and selects a matching keyword as the user types in the quick find text box. * * @param event The input event. */ @EventHandler(value = "change", target = "@txtFind") private void onChange$txtFind(ChangeEvent event) { String find = event.getValue(String.class).toLowerCase(); if (StringUtils.isEmpty(find)) { return; } int match = -1; for (int i = 0; i < keywordList.size(); i++) { if (keywordList.get(i).toLowerCase().startsWith(find)) { match = i; break; } } if (match != lstKeywords.getSelectedIndex()) { Listitem item = match == -1 ? null : (Listitem) lstKeywords.getChildAt(match); lstKeywords.setSelectedItem(item); onSelect$lstKeywords(); } }
/** * Refresh the list. * * @param deflt The layout to select initially. */ private void refresh(String deflt) { modelAndView.setModel(new ListModel<>(LayoutUtil.getLayouts(shared))); lstLayouts.setSelectedItem(deflt == null ? null : (Listitem) lstLayouts.findChildByLabel(deflt)); updateControls(); }
/** * Updated the list box selection when the history selection changes. * * @see org.carewebframework.help.viewer.HelpViewBase#onTopicSelected(HelpTopic) */ @Override public void onTopicSelected(HelpTopic topic) { Listitem item = (Listitem) lstHistory.getChildAt(history.getPosition()); lstHistory.setSelectedItem(item); if (item != null) { getContainer().getAncestor(Tab.class).setVisible(true); item.scrollIntoView(); } }
/** * 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); } }
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()); }); }