/** * Compares two list items by comparing the label and value properties, respectively. * * @param o Item to compare. * @return Result of the comparison. */ @Override public int compareTo(Listitem o) { int cmp = ObjectUtils.compare(getLabel(), o.getLabel()); return cmp != 0 ? cmp : ObjectUtils.compare(value, o.value); }
private boolean containsEvent(String eventName) { for (Object object : lboxEventList.getChildren()) { if (((Listitem) object).getLabel().equals(eventName)) { return true; } } return false; }
/** * Searches for a Listitem that has a label that matches the specified value. The search is case * insensitive. * * @param label Label text to find. * @return A Listitem with a matching label., or null if not found. */ public Listitem findMatchingItem(String label) { for (Listitem item : getChildren(Listitem.class)) { if (label.equalsIgnoreCase(item.getLabel())) { return item; } } return null; }
@Override public void onUnload() { super.onUnload(); for (Listitem item : lboxSubscriptions.getChildren(Listitem.class)) { if (item.isSelected()) { subscribe(item.getLabel(), false); } } }
@EventHandler(value = "change", target = "lboxSubscriptions") private void onChange$lboxSubscriptions(ChangeEvent event) { Listitem item = (Listitem) event.getTarget(); subscribe(item.getLabel(), item.isSelected()); }
@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); } }
@EventHandler(value = "change", target = "lboxEventList") private void onChange$lboxEventList(ChangeEvent event) { Listitem item = (Listitem) event.getValue(); String eventName = item.getLabel(); if (item.isSelected()) { eventManager.subscribe(eventName, this); info("Subscribed to", eventName); } else { eventManager.unsubscribe(eventName, this); info("Unsubscribed from", eventName); } }
/** * 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); } }