Changeset 5260

Show
Ignore:
Timestamp:
08/25/08 11:04:16 (3 months ago)
Author:
matti.tahvonen@…
Message:

fixes #1973, changed cache row fetching to be more lazy - no re-fetching for rendered rows, but may affect one extra fetch in some situations.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java

    r5254 r5260  
    17081708                } 
    17091709                fixSpacers(); 
    1710                 DeferredCommand.addCommand(new Command() { 
    1711                     public void execute() { 
    1712                         // this may be a new set of rows due content change, 
    1713                         // ensure we have proper cache rows 
    1714                         int reactFirstRow = (int) (firstRowInViewPort - pageLength 
    1715                                 * CACHE_REACT_RATE); 
    1716                         int reactLastRow = (int) (firstRowInViewPort 
    1717                                 + pageLength + pageLength * CACHE_REACT_RATE); 
    1718                         if (reactFirstRow < 0) { 
    1719                             reactFirstRow = 0; 
    1720                         } 
    1721                         if (reactLastRow > totalRows) { 
    1722                             reactLastRow = totalRows - 1; 
    1723                         } 
    1724                         if (reactFirstRow < firstRendered 
    1725                                 || reactLastRow > lastRendered) { 
    1726                             // re-fetch full cache area 
    1727                             reactFirstRow = (int) (firstRowInViewPort - pageLength 
    1728                                     * CACHE_RATE); 
    1729                             reactLastRow = (int) (firstRowInViewPort 
    1730                                     + pageLength + pageLength * CACHE_RATE); 
    1731                             if (reactFirstRow < 0) { 
    1732                                 reactFirstRow = 0; 
    1733                             } 
    1734                             if (reactLastRow > totalRows) { 
    1735                                 reactLastRow = totalRows - 1; 
    1736                             } 
    1737                             // fetch some lines before 
    1738                             rowRequestHandler.setReqFirstRow(reactFirstRow); 
    1739                             rowRequestHandler.setReqRows((int) (2 * pageLength 
    1740                                     * CACHE_RATE + pageLength)); 
    1741                             rowRequestHandler.deferRowFetch(1); 
    1742                         } 
    1743                     } 
    1744                 }); 
     1710            } 
     1711            // this may be a new set of rows due content change, 
     1712            // ensure we have proper cache rows 
     1713            int reactFirstRow = (int) (firstRowInViewPort - pageLength 
     1714                    * CACHE_REACT_RATE); 
     1715            int reactLastRow = (int) (firstRowInViewPort + pageLength + pageLength 
     1716                    * CACHE_REACT_RATE); 
     1717            if (reactFirstRow < 0) { 
     1718                reactFirstRow = 0; 
     1719            } 
     1720            if (reactLastRow > totalRows) { 
     1721                reactLastRow = totalRows - 1; 
     1722            } 
     1723            if (lastRendered < reactLastRow) { 
     1724                // get some cache rows below visible area 
     1725                rowRequestHandler.setReqFirstRow(lastRendered + 1); 
     1726                rowRequestHandler.setReqRows(reactLastRow - lastRendered - 1); 
     1727                rowRequestHandler.deferRowFetch(1); 
     1728            } else if (IScrollTable.this.tBody.getFirstRendered() > reactFirstRow) { 
     1729                /* 
     1730                 * Branch for fetching cache above visible area. 
     1731                 *  
     1732                 * If cache needed for both before and after visible area, this 
     1733                 * will be rendered after-cache is reveived and rendered. So in 
     1734                 * some rare situations table may take two cache visits to 
     1735                 * server. 
     1736                 */ 
     1737                rowRequestHandler.setReqFirstRow(reactFirstRow); 
     1738                rowRequestHandler.setReqRows(firstRendered - reactFirstRow); 
     1739                rowRequestHandler.deferRowFetch(1); 
    17451740            } 
    17461741        }