/** * Returns a list of listbox items. * * @param selectedOnly If true, only selected items are returned. * @return List of list items. */ protected List<Listitem> getItems(boolean selectedOnly) { return selectedOnly ? ListUtil.getSelectedItems(listBox) : listBox.getItems(); }
public List getItems(Component comp) { if (comp instanceof Listbox) { final Listbox listbox = (Listbox) comp; return listbox.getItems(); } else { throw new UiException("Unsupported type for ListitemCollectionItem: " + comp); } }
/** * Re-renders a model object. * * @param object Model object */ protected void rerender(M object) { int index = ListUtil.findListboxData(listBox, object); if (index >= 0) { rerender(listBox.getItems().get(index)); } }
/** Sorts the items. If with group, each group is sorted independently. */ @SuppressWarnings("unchecked") private static void sort0(Listbox box, Comparator cmpr) { if (box.hasGroup()) for (Listgroup g : box.getGroups()) { int index = g.getIndex() + 1; Components.sort(box.getItems(), index, index + g.getItemCount(), cmpr); } else Components.sort(box.getItems(), cmpr); }
private void restoreGridState() { lbProblems.clearSelection(); for (Object object : lbProblems.getItems()) { Listitem item = (Listitem) object; lbProblems.renderItem(item); if (selectedProblems.contains(item.getValue())) { item.setSelected(true); } } selectedProblems.clear(); updateControls(); }
/** * Adds drag/drop support to the items belonging to the specified list box. * * @param lb The list box. * @param dropId The drop id to be used. * @param eventListener The event listener to handle the drag/drop operations. */ private void addDragDropSupport(Listbox lb, String dropId, EventListener<?> eventListener) { for (Object object : lb.getItems()) { Listitem item = (Listitem) object; item.setDraggable(dropId); item.setDroppable(dropId); item.addEventListener(Events.ON_DROP, eventListener); } }
private void displaySearchMessage(String message) { lstSearch.clearSelection(); lstSearch.setModel((ListModelList<?>) null); lstSearch.getItems().clear(); if (message != null) { lstSearch.appendItem(message, null).setTooltiptext(message); } Clients.scrollIntoView(lstSearch.getFirstChild()); }
/** * Renders all {@link Listitem} if not loaded yet, with * {@link #getItemRenderer}. * * @see #renderItem * @see #renderItems */ public void renderAll() { if (_model == null) return; _renderAll = true; getDataLoader().setLoadAll(_renderAll); final Renderer renderer = new Renderer(); if (!getItems().isEmpty()) try { Listitem item = getItems().get(0); int index = item.getIndex(); for (Listitem nxt; item != null; item = nxt) { nxt = nextListitem(item); //retrieve first since it might be changed renderer.render(item, index++); } } catch (Throwable ex) { renderer.doCatch(ex); } finally { renderer.doFinally(); } }
private void refreshFilterList() { boolean hasFilter = activeList != null && activeList.isFiltered(); lstFilter.setVisible(hasFilter); if (hasFilter) { activeFilter = activeList.getActiveFilter(); Collection<AbstractPatientListFilter> filters = activeList.getFilters(); if (filters == null || filters.isEmpty()) { lstFilter.setModel((ListModelList<?>) null); lstFilter.getItems().clear(); lstFilter.appendItem(txtNoFilters, null); } else { lstFilter.setModel(new ListModelList<AbstractPatientListFilter>(filters)); if (activeFilter == null) { activeFilter = filters.iterator().next(); activeList.setActiveFilter(activeFilter); } } selectFilter(lstFilter, activeFilter); } }
private void loadResults(List<String> v) { lbResults.getItems().clear();
/** * Checks whether to invalidate, when a child has been added or or will be * removed. * * @param bRemove * if child will be removed */ private void checkInvalidateForMoved(Listitem child, boolean bRemove) { // No need to invalidate if // 1) act == last and child in act // 2) act != last and child after act // Except removing last elem which in act and act has only one elem if (inPagingMold() && !isInvalidated()) { final int j = child.getIndex(), pgsz = getPageSize(), n = (getActivePage() + 1) * pgsz; if (j >= n) return; // case 2 final int cnt = getItems().size(), n2 = n - pgsz; if (j >= n2 && cnt <= n && (!bRemove || cnt > n2 + 1)) return; // case 1 invalidate(); } }
/** * updates the status of the changed group. * @param event * @since 8.0.4 */ public void doGroupsDataChange(GroupsDataEvent event) { if (event.getType() == GroupsDataEvent.GROUPS_OPENED) { Listbox listbox = (Listbox) getOwner(); GroupsListModel groupsListModel = ((GroupsListModel) listbox.getModel()); int offset = groupsListModel.getGroupOffset(event.getGroupIndex()); ((Listgroup) listbox.getItems().get(offset)).setOpen(groupsListModel.getDataInfo(offset).isOpen()); } }
/** * Selects the list box item corresponding to the specified filter. * * @param lb List box to search. * @param filter The filter whose associated list item is to be selected. * @return True if the item was successfully selected. */ private boolean selectFilter(Listbox lb, AbstractPatientListFilter filter) { if (filter != null) { for (Object object : lb.getItems()) { Listitem item = (Listitem) object; lb.renderItem(item); AbstractPatientListFilter flt = (AbstractPatientListFilter) item.getValue(); if (flt != null && filter.equals(flt)) { lb.setSelectedItem(item); Clients.scrollIntoView(item); return true; } } } return false; }
/** * Scroll to document with same header. */ public void onSelect$cboHeader() { Document doc = cboHeader.getSelectedItem().getValue(); for (Listitem item : listBox.getItems()) { Document doc2 = (Document) item.getValue(); if (doc2 == null) { listBox.renderItem(item); doc2 = (Document) item.getValue(); } if (doc == doc2) { Clients.scrollIntoView(item); break; } } }
for (Listitem item : lbox.getItems()) { item.insertBefore(item.getChildren().get(from), item.getChildren().get(to));
private void loadNotes() { if (VistAUtil.parseIEN(problem) == 0) { lstNotes.setVisible(false); txtNotes.setVisible(true); capNotes.setLabel("Note (3-60 characters)"); return; } lstNotes.getItems().clear(); List<String> notes = getBroker().callRPCList("BGOPRBN GET", null, problem.getId().getIdPart()); if (PCC.errorCheck(notes)) { return; } /* * Location IEN [1] ^ Note IEN [2] ^ Note # [3] ^ Narrative [4] ^ * Status [5] ^ Date Added [6] ^ Author Name [7] * e.g., * 3987^1^1^STECWFD DEPENDENCY (LOW DOSE)^A^2960901^ */ for (String note : notes) { renderNote(new ProblemNote(note)); } }
private void loadSkinTests(boolean noAsync) { lbTests.getItems().clear(); getAsyncDispatcher().abort(); Patient patient = PatientContext.getActivePatient(); if (patient == null) { return; } EventUtil.status("Loading Skin Test Data"); if (allowAsync && !noAsync) { getAsyncDispatcher().callRPCAsync("BGOVSK GET", patient.getId().getIdPart()); } else { loadSkinTests(getBroker().callRPCList("BGOVSK GET", null, patient.getId().getIdPart())); } EventUtil.status(); }
private void loadProblems(boolean noAsync) { lbProblems.getItems().clear(); getAsyncDispatcher().abort(); Patient patient = PatientContext.getActivePatient(); if (patient == null) { return; } EventUtil.status("Loading Problem List Data"); if (allowAsync && !noAsync) { getAsyncDispatcher().callRPCAsync("BGOPROB GET", patient.getId().getIdPart()); } else { loadProblems(getBroker().callRPCList("BGOPROB GET", null, patient.getId().getIdPart())); } EventUtil.status(); }
private void initGrid(int colcount, int rowcount) { lstVitals.getItems().clear(); hdrVitals.getChildren().clear(); if (colcount > 2 && rowcount > 0) { tbarPaging.setVisible(true); sldVitals.setMaxpos(colcount - 2); sldVitals.setCurpos(maxCols); pgVitals.setActivePage(0); pgVitals.setTotalSize(colcount - 2); pgVitals.setPageSize(maxCols + 1); getCell(colcount - 1, rowcount - 1); for (int i = 1; i <= colcount; i++) { Listheader lh = new Listheader(); lh.setVisible(i <= maxCols || i == colcount); lh.setAlign(i == 1 ? "right" : i == colcount ? "left" : "center"); lh.setHflex("1"); hdrVitals.appendChild(lh); } } else { hdrVitals.appendChild(new Listheader()); tbarPaging.setVisible(false); } }
public void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Listbox self = (Listbox)comp; final String uuid = self.getUuid(); wh.write("<select id=\"").write(uuid).write("\" z.type=\"zul.sel.Lisel\"") .write(self.getOuterAttrs()).write(self.getInnerAttrs()).writeln(">"); for (Iterator it = self.getItems().iterator(); it.hasNext();) { final Listitem item = (Listitem)it.next(); if (item.isVisible()) { wh.write("<option id=\"").write(item.getUuid()).write("\"") .write(item.getOuterAttrs()) .write(item.getInnerAttrs()).write(">"); new Out(item.getLabel()).setMaxlength(self.getMaxlength()) .render(out); wh.writeln("</option>"); } } wh.write("</select>"); }