Package org.zkoss.zul

Examples of org.zkoss.zul.Rows$ExtraCtrl


public class Grid extends org.zkoss.zul.Grid {

  public Grid() {
    super()
    setHflex("1");
    appendChild(new Rows());
  }
View Full Code Here


    for(String col : columns) {
      org.zkoss.zul.Column column = new org.zkoss.zul.Column(col);
      header.appendChild(column);
    }
    appendChild(header);
    appendChild(new Rows());
  }
View Full Code Here

  public int getLimit() {
    return 20;
  }

  public int getTotalSize() {
    final Rows rows = _grid.getRows();
    final ListModel model = _grid.getModel();
    return model != null ? model.getSize() : rows != null ? rows.getVisibleItemCount() : 0;
  }
View Full Code Here

  }

  private static int INVALIDATE_THRESHOLD = 10
  public void doListDataChange(ListDataEvent event) {
    //when this is called _model is never null
    final Rows rows = _grid.getRows();
    final int newsz = event.getModel().getSize(), oldsz = rows.getChildren().size();
    int min = event.getIndex0(), max = event.getIndex1(), cnt;

    switch (event.getType()) {
    case ListDataEvent.INTERVAL_ADDED:
      cnt = newsz - oldsz;
      if (cnt <= 0) {
        syncModel(-1, -1); //out of sync, force sync
        return;
        //throw new UiException("Adding causes a smaller list?");
      }
      if (cnt > INVALIDATE_THRESHOLD && !inPagingMold())
        _grid.invalidate(); //performance is better
      if (min < 0)
        if (max < 0) min = 0;
        else min = max - cnt + 1;
      if (min > oldsz) min = oldsz;

      RowRenderer renderer = null;
      final Component next =
        min < oldsz ? (Component)rows.getChildren().get(min): null;
      while (--cnt >= 0) {
        if (renderer == null)
          renderer = (RowRenderer) getRealRenderer();
        rows.insertBefore((Row)newUnloadedItem(renderer, min++), next);
      }
      break;

    case ListDataEvent.INTERVAL_REMOVED:
      cnt = oldsz - newsz;
      if (cnt <= 0) {
        syncModel(-1, -1); //out of sync, force sync
        return;
        //throw new UiException("Removal causes a larger list?");
      }
      if (min >= 0) max = min + cnt - 1;
      else if (max < 0) max = cnt - 1; //0 ~ cnt - 1     
      if (max > oldsz - 1) max = oldsz - 1;

      //detach from end (due to groopfoot issue)
      Component comp = (Component)rows.getChildren().get(max);
      while (--cnt >= 0) {
        Component p = comp.getPreviousSibling();
        comp.detach();
        comp = p;
      }
View Full Code Here

  public void syncModel(int offset, int limit) {
    int min = offset;
    int max = offset + limit - 1;
   
    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;
View Full Code Here

    return getAvailableAtClient(ofs, pgsz);
  }
 
  protected Set getAvailableAtClient(int offset, int limit) {
    final Set avail = new LinkedHashSet(32);
    final Rows rows = _grid.getRows();
    Row row = (Row) rows.getFirstChild();
    while(row != null) {
      if (limit == 0) break;
      if (row.isVisible()) {
        if (--offset < 0) {
          --limit;
View Full Code Here

    final Column column2 = new Column();
    column2.setWidth("35%");
    column2.setLabel("records");
    column2.setParent(columns);

    final Rows rows = new Rows();
    rows.setParent(grid);

    /**
     * For performance boosting, we get now all the table recordCounts out
     * from ONE Service Call and get back the results in a map.
     */
 
View Full Code Here

    final Column column2 = new Column();
    column2.setWidth("35%");
    column2.setLabel("value");
    column2.setParent(columns);

    final Rows rows = new Rows();
    rows.setParent(grid);

    // short date
    String date = ZksampleDateFormat.getDateTimeFormater().format(stat.getStartTime());

    addNewRow(rows, "Application Start-Time", date);
View Full Code Here

    final Column column1 = new Column();
    column1.setWidth("100%");
    column1.setLabel("values are randomly created");
    column1.setParent(columns);

    final Rows rows = new Rows();
    rows.setParent(grid);

    final Row row = new Row();
    row.setParent(rows);

    this.Vbox_Buttons = new Vbox();
View Full Code Here

    columnRecordCount.setWidth("35%");
    columnRecordCount.setLabel(Labels.getLabel("common.Count"));
    columnRecordCount.setStyle("color: red");
    columnRecordCount.setParent(columns);

    rows = new Rows();
    rows.setParent(grid);

    doReadData();

  }
View Full Code Here

TOP

Related Classes of org.zkoss.zul.Rows$ExtraCtrl

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.