/** * Returns the number of items potentially visible to the client. * * @return items. */ private int getVisibleItemsCount() { int cnt = 0; for (ResultItemPanel item : items) if (item.isVisibility() && !item.isFiltered()) cnt++; return cnt; }
/** * Sets filtering time. If the time is set to <code>-1</code> then filtering is off. Otherwise it * shows the time after which all items are allowed. * * @param aLimitTime the time used for limiting. */ public void setLimitTime(long aLimitTime) { limitTime = aLimitTime; int shown = 0; int hidden = 0; for (ResultItemPanel item : items) { item.setFiltered(isFiltered(item)); item.setVisibility(!item.isFiltered() && shown < itemLimit); if (item.isVisible()) shown++; else if (!item.isFiltered()) hidden++; } setVisible(shown > 0); moreItem.setCount(hidden); }
/** Recalculates the view. */ private void recalcView() { int more = 0; int visible = 0; for (ResultItemPanel itm : items) { if (itm.isFiltered()) { itm.setVisibility(false); } else if (visible >= itemLimit) { itm.setVisibility(false); more++; } else { itm.setVisibility(true); visible++; } } moreItem.setCount(more); lbCount.setText(Integer.toString(visible + more)); }