Package com.google.gwt.view.client

Examples of com.google.gwt.view.client.Range


   @Override
   public void setPageStart(int index) {
      HasRows display = getDisplay();
      if (display != null) {
         Range range = display.getVisibleRange();
         int pageSize = range.getLength();
         index = Math.max(0, index);
         if (index != range.getStart()) {
            display.setVisibleRange(index, pageSize);
         }
      }
   }
View Full Code Here


    if (lastRefreshTooYoung())
      return;

    lastRefresh = System.currentTimeMillis();

    final Range range = display.getVisibleRange();
    final int start = range.getStart();
    final int end = start + range.getLength();
    final String sortCol = "name";
    final SortDirection direction = (columnSortList == null || columnSortList.size() == 0) ? SortDirection.Ascending : (columnSortList.get(0).isAscending() ? SortDirection.Ascending : SortDirection.Descending);

    bus.fireEvent(new RpcBeginEvent());
   
View Full Code Here

  public void search(final String search, final HasData<Dto> display, final ColumnSortList columnSortList) {
    if (search.isEmpty()) {
      refresh(display, columnSortList);
    } else {
      final Range range = display.getVisibleRange();
      final int start = range.getStart();
      final int end = start + range.getLength();
     
      bus.fireEvent(new RpcBeginEvent());
     
      AsyncProvider.getReadService(new Callback<ReadServiceAsync>() {
        @Override
View Full Code Here

    if (lastRefreshTooYoung())
      return;

    lastRefresh = System.currentTimeMillis();

    final Range range = display.getVisibleRange();
    final int start = range.getStart();
    final int end = start + range.getLength();

    readService.getAll(module, start, end, new AsyncCallback<ListQueryResult>() {
      @Override
      public void onSuccess(ListQueryResult result) {
        insertRefreshedData(display, result);
View Full Code Here

    if (lastRefreshTooYoung())
      return;
   
    lastRefresh = System.currentTimeMillis();
   
    final Range range = display.getVisibleRange();
    final int start = range.getStart();
    final int end = start + range.getLength();
   
    readService.getAllAssignedTo(module, User.getUserId(), start, end, new AsyncCallback<ListQueryResult>() {
      @Override
      public void onSuccess(ListQueryResult result) {
        insertRefreshedData(display, result);
View Full Code Here

  /**
   * Return the range of data being displayed.
   */
  public Range getVisibleRange() {
    return new Range(getPageStart(), getPageSize());
  }
View Full Code Here

    }

    // Update the range if it changed.
    if (newPageStart != pageStart || newPageSize != pageSize) {
      pending.keyboardSelectedRow = index;
      setVisibleRange(new Range(newPageStart, newPageSize), false, false);
    }
  }
View Full Code Here

    // Return the ranges.
    List<Range> toRet = new ArrayList<Range>();
    if (rangeStart0 != -1) {
      int rangeLength0 = rangeEnd0 - rangeStart0;
      toRet.add(new Range(rangeStart0, rangeLength0));
    }
    if (rangeStart1 != -1) {
      int rangeLength1 = rangeEnd1 - rangeStart1;
      toRet.add(new Range(rangeStart1, rangeLength1));
    }
    return toRet;
  }
View Full Code Here

    }

    // Calculate the modified ranges.
    List<Range> modifiedRanges = calculateModifiedRanges(modifiedRows,
        pageStart, pageEnd);
    Range range0 = modifiedRanges.size() > 0 ? modifiedRanges.get(0) : null;
    Range range1 = modifiedRanges.size() > 1 ? modifiedRanges.get(1) : null;
    int replaceDiff = 0; // The total number of rows to replace.
    for (Range range : modifiedRanges) {
      replaceDiff += range.getLength();
    }

    /*
     * Check the various conditions that require redraw.
     */
    int oldPageStart = oldState.getPageStart();
    int oldPageSize = oldState.getPageSize();
    int oldRowDataCount = oldState.getRowDataSize();
    boolean redrawRequired = pending.redrawRequired;
    if (pageStart != oldPageStart) {
      // Redraw if pageStart changes.
      redrawRequired = true;
    } else if (rowDataCount < oldRowDataCount) {
      // Redraw if we have trimmed the row data.
      redrawRequired = true;
    } else if (range1 == null && range0 != null
        && range0.getStart() == pageStart
        && (replaceDiff >= oldRowDataCount || replaceDiff > oldPageSize)) {
      // Redraw if the new data completely overlaps the old data.
      redrawRequired = true;
    } else if (replaceDiff >= REDRAW_MINIMUM
        && replaceDiff > REDRAW_THRESHOLD * oldRowDataCount) {
      /*
       * Redraw if the number of modified rows represents a large portion of the
       * view, defined as greater than 30% of the rows (minimum of 5).
       */
      redrawRequired = true;
    } else if (replacedEmptyRange && oldRowDataCount == 0) {
      /*
       * If the user replaced an empty range, pass it to the view. This is a
       * useful edge case that provides consistency in the way data is pushed to
       * the view.
       */
      redrawRequired = true;
    }

    // Update the loading state in the view.
    updateLoadingState();

    /*
     * Push changes to the view.
     */
    if (redrawRequired) {
      // Redraw the entire content.
      SafeHtmlBuilder sb = new SafeHtmlBuilder();
      view.render(sb, pending.rowData, pending.pageStart, selectionModel);
      SafeHtml newContents = sb.toSafeHtml();
      if (!newContents.equals(lastContents)) {
        lastContents = newContents;
        view.replaceAllChildren(pending.rowData, newContents,
            pending.keyboardStealFocus);
      }
      view.resetFocus();
    } else if (range0 != null) {
      // Replace specific rows.
      lastContents = null;

      // Replace range0.
      {
        int absStart = range0.getStart();
        int relStart = absStart - pageStart;
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        List<T> replaceValues = pending.rowData.subList(relStart, relStart
            + range0.getLength());
        view.render(sb, replaceValues, absStart, selectionModel);
        view.replaceChildren(replaceValues, relStart, sb.toSafeHtml(),
            pending.keyboardStealFocus);
      }

      // Replace range1 if it exists.
      if (range1 != null) {
        int absStart = range1.getStart();
        int relStart = absStart - pageStart;
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        List<T> replaceValues = pending.rowData.subList(relStart, relStart
            + range1.getLength());
        view.render(sb, replaceValues, absStart, selectionModel);
        view.replaceChildren(replaceValues, relStart, sb.toSafeHtml(),
            pending.keyboardStealFocus);
      }

View Full Code Here

     *
     * @param start the start index
     * @param end the end index
     */
    public void replaceRange(int start, int end) {
      replacedRanges.add(new Range(start, end - start));
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.view.client.Range

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.