public void removeItem(ListItem<T> item) { int idx = item.getIndex(); for (int i = idx + 1; i < item.getParent().size(); i++) { ListItem<?> itemReIndex = (ListItem<?>) item.getParent().get(i); itemReIndex.setIndex(itemReIndex.getIndex() - 1); } items.remove(item.getIndex()); remove(item); }
public void draw() { clearBox(); int length = (itemsLista.size() < super.inHeight ? itemsLista.size() : super.inHeight); for (int i = 0; i < length; i++) { ListItem item = (ListItem) itemsLista.elementAt(i); si.print(inPosition.x, inPosition.y + i, item.getIndex(), item.getIndexColor()); if (item.getRow().length() > inWidth) si.print( inPosition.x + 2, inPosition.y + i, item.getRow().substring(0, inWidth), foreColor); else si.print(inPosition.x + 2, inPosition.y + i, item.getRow(), foreColor); } }
/** @see org.apache.wicket.markup.repeater.AbstractRepeater#onPopulate() */ @SuppressWarnings("unchecked") @Override protected final void onPopulate() { // Get number of items to be displayed final int size = getViewSize(); if (size > 0) { if (getReuseItems()) { // Remove all ListItems no longer required final int maxIndex = firstIndex + size; for (final Iterator<Component> iterator = iterator(); iterator.hasNext(); ) { // Get next child component final ListItem<?> child = (ListItem<?>) iterator.next(); if (child != null) { final int index = child.getIndex(); if (index < firstIndex || index >= maxIndex) { iterator.remove(); } } } } else { // Automatically rebuild all ListItems before rendering the // list view removeAll(); } boolean hasChildren = size() != 0; // Loop through the markup in this container for each item for (int i = 0; i < size; i++) { // Get index final int index = firstIndex + i; ListItem<T> item = null; if (hasChildren) { // If this component does not already exist, populate it item = (ListItem<T>) get(Integer.toString(index)); } if (item == null) { // Create item for index item = newItem(index, getListItemModel(getModel(), index)); // Add list item add(item); // Populate the list item onBeginPopulateItem(item); populateItem(item); } } } else { removeAll(); } }