Package org.zkoss.zul.ext

Examples of org.zkoss.zul.ext.Paginal


   
    final ListModel model = _grid.getModel();
    Rows rows = _grid.getRows();
    final int newsz = model.getSize();
    final int oldsz = rows != null ? rows.getChildren().size(): 0;
    final Paginal pgi = _grid.getPaginal();
    final boolean inPaging = inPagingMold();

    int newcnt = newsz - oldsz;
    int atg = pgi != null ? _grid.getActivePage(): 0;
    RowRenderer 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 (newcnt > INVALIDATE_THRESHOLD && !inPaging)
          _grid.invalidate(); //performance is better

        Component comp = (Component)rows.getChildren().get(max);
        next = comp.getNextSibling();
        while (--cnt >= 0) {
          Component p = comp.getPreviousSibling();
          comp.detach();
          comp = p;
        }
      } else { //ListModel
        int addcnt = 0;
        Component row = (Component)rows.getChildren().get(min);
        while (--cnt >= 0) {
          next = row.getNextSibling();

          if (cnt < -newcnt) { //if shrink, -newcnt > 0
            row.detach(); //remove extra
          } else if (((LoadStatus)((AbstractComponent)row).getExtraCtrl()).isLoaded()) {
            if (renderer == null)
              renderer = (RowRenderer)getRealRenderer();
            row.detach(); //always detach
            rows.insertBefore((Row) newUnloadedItem(renderer, min), next);
            ++addcnt;
          }
          ++min;
          row = next;
        }

        if ((addcnt > INVALIDATE_THRESHOLD || addcnt + newcnt > INVALIDATE_THRESHOLD) && !inPaging)
          _grid.invalidate(); //performance is better
      }
    } else {
      min = 0;

      //auto create but it means <grid model="xx"><rows/>... will fail
      if (rows == null) {
        rows = new Rows();
        rows.setParent(_grid);
      }
    }

    for (; --newcnt >= 0; ++min) {
      if (renderer == null)
        renderer = (RowRenderer) getRealRenderer();
      rows.insertBefore((Row)newUnloadedItem(renderer, min), next);
    }
   
    if (pgi != null) {
      if (atg >= pgi.getPageCount())
        atg = pgi.getPageCount() - 1;
      pgi.setActivePage(atg);
    }
  }
View Full Code Here


 
  public Set getAvailableAtClient() {
    if (!isCropper())
      return null;
   
    final Paginal pgi = _grid.getPaginal();
    int pgsz = pgi.getPageSize();
    int ofs = pgi.getActivePage() * pgsz;
    return getAvailableAtClient(ofs, pgsz);
  }
View Full Code Here

  private static boolean shallVisitTree(Tree tree, Component child) {
    final Treeitem item = (Treeitem) child;
    int count = item.isOpen() && item.getTreechildren() != null ?
        item.getTreechildren().getVisibleItemCount(): 0;
    Integer visited = (Integer)tree.getAttribute(Attributes.VISITED_ITEM_COUNT);
    final Paginal pgi = tree.getPaginal();
    final int ofs = pgi.getActivePage() * pgi.getPageSize();
    int visit = visited != null ? visited.intValue() + 1 : 1;
    boolean shoulbBeVisited = ofs < visit + count;
    if (visited == null) visited = new Integer(shoulbBeVisited ? 1 : count + 1);
    else visited = new Integer(visited.intValue()+ (shoulbBeVisited ? 1 : count + 1));

View Full Code Here

  }

  // Returns whether the specified should be rendered.
  static boolean shallRenderTree(Tree tree) {
    Integer visited = (Integer)tree.getAttribute(Attributes.VISITED_ITEM_COUNT);
    final Paginal pgi = tree.getPaginal();
    final int ofs = pgi.getActivePage() * pgi.getPageSize();
    if(ofs < visited.intValue()) {
      // count the rendered item
      Integer renderedCount = (Integer) tree.getAttribute(Attributes.RENDERED_ITEM_COUNT);
      if (renderedCount == null) renderedCount = new Integer(1);
      else renderedCount = new Integer(renderedCount.intValue() + 1);
View Full Code Here

    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();

    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 (newcnt > INVALIDATE_THRESHOLD && !inPaging)
          _listbox.invalidate(); //performance is better

        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 ((addcnt > INVALIDATE_THRESHOLD || addcnt + newcnt > INVALIDATE_THRESHOLD) && !inPagingMold())
          _listbox.invalidate(); //performance is better
      }
    } 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);
    }
  }
View Full Code Here

 
  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);
  }
View Full Code Here

   * a paging controller is created automatically as a child component
   * (see {@link #getPagingChild}).
   */
  public void setPaginal(Paginal pgi) {
    if (!Objects.equals(pgi, _pgi)) {
      final Paginal old = _pgi;
      _pgi = pgi; //assign before detach paging, since removeChild assumes it

      if (inPagingMold()) {
        if (old != null) removePagingListener(old);
        if (_pgi == null) {
View Full Code Here

      _pgImpListener = new EventListener() {
  public void onEvent(Event event) {
    if (_rows != null && _model != null && inPagingMold()) {
    //theorectically, _rows shall not be null if _model is not null when
    //this method is called. But, just in case -- if sent manually
      final Paginal pgi = getPaginal();
      int pgsz = pgi.getPageSize();
      final int ofs = pgi.getActivePage() * pgsz;
      if (_rod) {
        getDataLoader().syncModel(ofs, pgsz);
      }
      postOnInitRender();
    }
    if (getModel() != null || getPagingPosition().equals("both")) invalidate(); // just in case.
    else if (_rows != null) _rows.invalidate();
  }
      };
    pgi.addEventListener("onPagingImpl", _pgImpListener);
  }
View Full Code Here

      if (!defer || !rod) { //if attached and rod, defer the model sync
        getDataLoader().syncModel(-1, -1); //create rows if necessary
      } else if (inPagingMold()) {
        //B30-2129667, B36-2782751, (ROD) exception when zul applyProperties
        //must update paginal totalSize or exception in setActivePage
        final Paginal pgi = getPaginal();
        pgi.setTotalSize(getDataLoader().getTotalSize());
      }
      postOnInitRender();
      //Since user might setModel and setRender separately or repeatedly,
      //we don't handle it right now until the event processing phase
      //such that we won't render the same set of data twice
View Full Code Here

        Executions.getCurrent().removeAttribute("zkoss.Grid.deferInitModel_"+getUuid());
      }
      final DataLoader loader = getDataLoader();
     
      //initialize paginal if any
      Paginal pgi = getPaginal();
      if (pgi != null) pgi.setTotalSize(loader.getTotalSize());
    }
View Full Code Here

TOP

Related Classes of org.zkoss.zul.ext.Paginal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.