예제 #1
0
  /**
   * Retrieves the children available at client with more control.
   *
   * <p>Derived class shall override this method rather than {@link #getAvailableAtClient()}.
   *
   * @param itemOnly whether to return only {@link Listitem} and derives.
   * @since 5.0.10
   */
  protected Set<? extends Component> getAvailableAtClient(boolean itemOnly) {
    if (!isCropper()) return null;

    final Paginal pgi = _listbox.getPaginal();
    int pgsz = pgi.getPageSize();
    int ofs = pgi.getActivePage() * pgsz;
    return getAvailableAtClient(ofs, pgsz, itemOnly);
  }
  public Set getAvailableAtClient() {
    if (!isCropper()) return null;

    final Paginal pgi = _listbox.getPaginal();
    int pgsz = pgi.getPageSize();
    int ofs = pgi.getActivePage() * pgsz;
    return getAvailableAtClient(ofs, pgsz);
  }
예제 #3
0
  private void syncModel0(int offset, int limit) {
    int min = offset;
    int max = offset + limit - 1;

    final ListModel _model = _listbox.getModel();
    final int newsz = _model.getSize();
    final int oldsz = _listbox.getItemCount();
    final Paginal _pgi = _listbox.getPaginal();
    final boolean inPaging = inPagingMold();
    final boolean shallInvalidated = // Bug 3147518: avoid memory leak
        (min < 0 || min == 0) && (max < 0 || max >= newsz || max >= oldsz);

    int newcnt = newsz - oldsz;
    int atg = _pgi != null ? _listbox.getActivePage() : 0;
    ListitemRenderer renderer = null;
    Component next = null;
    if (oldsz > 0) {
      if (min < 0) min = 0;
      else if (min > oldsz - 1) min = oldsz - 1;
      if (max < 0) max = oldsz - 1;
      else if (max > oldsz - 1) max = oldsz - 1;
      if (min > max) {
        int t = min;
        min = max;
        max = t;
      }

      int cnt = max - min + 1; // # of affected
      if (_model instanceof GroupsListModel) {
        // detach all from end to front since groupfoot
        // must be detached before group
        newcnt += cnt; // add affected later
        if ((shallInvalidated || newcnt > INVALIDATE_THRESHOLD) && !inPaging) _listbox.invalidate();
        // Bug 3147518: avoid memory leak
        // Also better performance (outer better than remove a lot)

        Component comp = _listbox.getItemAtIndex(max);
        next = comp.getNextSibling();
        while (--cnt >= 0) {
          Component p = comp.getPreviousSibling();
          comp.detach();
          comp = p;
        }
      } else { // ListModel
        int addcnt = 0;
        Component item = _listbox.getItemAtIndex(min);
        while (--cnt >= 0) {
          next = item.getNextSibling();

          if (cnt < -newcnt) { // if shrink, -newcnt > 0
            item.detach(); // remove extra
          } else if (((Listitem) item).isLoaded()) {
            if (renderer == null) renderer = (ListitemRenderer) getRealRenderer();
            item.detach(); // always detach
            _listbox.insertBefore(newUnloadedItem(renderer, min), next);
            ++addcnt;
          }
          ++min;
          item = next; // B2100338.,next item could be Paging, don't use Listitem directly
        }

        if ((shallInvalidated
                || addcnt > INVALIDATE_THRESHOLD
                || addcnt + newcnt > INVALIDATE_THRESHOLD)
            && !inPagingMold()) _listbox.invalidate();
        // Bug 3147518: avoid memory leak
        // Also better performance (outer better than remove a lot)
      }
    } else {
      min = 0;
    }

    for (; --newcnt >= 0; ++min) {
      if (renderer == null) renderer = (ListitemRenderer) getRealRenderer();
      _listbox.insertBefore(newUnloadedItem(renderer, min), next);
    }
    if (_pgi != null) {
      if (atg >= _pgi.getPageCount()) atg = _pgi.getPageCount() - 1;
      _pgi.setActivePage(atg);
    }
  }