com.google.gwt.view.client.Range.getLength()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中com.google.gwt.view.client.Range.getLength方法的一些代码示例,展示了Range.getLength的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.getLength方法的具体详情如下:
包路径:com.google.gwt.view.client.Range
类名称:Range
方法名:getLength

Range.getLength介绍

[英]Get the length of the range.
[中]获取范围的长度。

代码示例

代码示例来源:origin: kaaproject/kaa

@Override
protected String createText() {
 Range range = getDisplay().getVisibleRange();
 int currentPage = range.getStart() / (range.getLength() != 0 ? range.getLength() : 1) + 1;
 return Utils.messages.pagerText(currentPage + "");
}

代码示例来源:origin: kaaproject/kaa

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

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Return true if this ranges's start end length are equal to those of
 * the given object.
 */
@Override
public boolean equals(Object o) {
 if (!(o instanceof Range)) {
  return false;
 }
 Range r = (Range) o;
 return start == r.getStart() && length == r.getLength();
}

代码示例来源:origin: stackoverflow.com

@Override
public void onRangeChange(RangeChangeEvent event)
{
  Range range = cellTable.getVisibleRange();
  int start = range.getStart();
  int length = range.getLength();
  List<ForumMessage> toSet = new ArrayList<ForumMessage>(length);
  for (int i = start; i < start + length && i < AllMessages.size(); i++)
    toSet.add((ForumMessage) AllMessages.get(i));
  cellTable.setRowData(start, toSet);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Get the page size.
 *
 * @return the page size, or -1 if the display is not set
 * @see #setPageSize(int)
 */
public int getPageSize() {
 return display == null ? -1 : display.getVisibleRange().getLength();
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Return the range size.
 * 
 * @return the size of the range as an int
 * 
 * @see #getVisibleRange()
 * @see #setPageSize(int)
 */
public final int getPageSize() {
 return getVisibleRange().getLength();
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
 public AbstractPager create(HasRows display) {
  return new PageSizePager(display.getVisibleRange().getLength());
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Returns true if there is enough data to display a given number of previous
 * pages.
 *
 * @param pages the number of previous pages to query
 * @return true if there are {@code pages} previous pages
 */
protected boolean hasPreviousPages(int pages) {
 if (display == null) {
  return false;
 }
 Range range = display.getVisibleRange();
 return (pages - 1) * range.getLength() < range.getStart();
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Move the starting row back by 'pageSize' rows.
 */
protected void previousPage() {
 if (display != null) {
  Range range = display.getVisibleRange();
  setPageStart(range.getStart() - range.getLength());
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

void showFewer() {
 Range range = listView.getVisibleRange();
 int defaultPageSize = listView.getDefaultPageSize();
 int maxSize = Math.max(defaultPageSize, range.getLength() - defaultPageSize);
 listView.setVisibleRange(range.getStart(), maxSize);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Advance the starting row by 'pageSize' rows.
 */
protected void nextPage() {
 if (display != null) {
  Range range = display.getVisibleRange();
  setPageStart(range.getStart() + range.getLength());
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
 public void onRowCountChange(RowCountChangeEvent event) {
  int rowCount = event.getNewRowCount();
  boolean isExact = event.isNewRowCountExact();
  int pageSize = getVisibleRange().getLength();
  showOrHide(nodeView.showMoreElem, isExact && rowCount > pageSize);
 }
});

代码示例来源:origin: com.google.gwt/gwt-servlet

public void onClick(ClickEvent event) {
  // Display should be non-null, but we check defensively.
  HasRows display = getDisplay();
  if (display != null) {
   Range range = display.getVisibleRange();
   int pageSize = Math.max(range.getLength() - increment, increment);
   display.setVisibleRange(range.getStart(), pageSize);
  }
 }
});

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Returns true if there is enough data to display a given number of
 * additional pages.
 *
 * @param pages the number of pages to query
 * @return true if there are {@code pages} next pages
 */
protected boolean hasNextPages(int pages) {
 if (display == null) {
  return false;
 }
 Range range = display.getVisibleRange();
 return range.getStart() + pages * range.getLength() < display.getRowCount();
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Set the page start index.
 *
 * @param index the index
 * @see #getPageStart()
 */
protected void setPageStart(int index) {
 if (display != null) {
  Range range = display.getVisibleRange();
  int pageSize = range.getLength();
  if (isRangeLimited && display.isRowCountExact()) {
   index = Math.min(index, display.getRowCount() - pageSize);
  }
  index = Math.max(0, index);
  if (index != range.getStart()) {
   display.setVisibleRange(index, pageSize);
  }
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

void showMore() {
 Range range = listView.getVisibleRange();
 int pageSize = range.getLength() + listView.getDefaultPageSize();
 listView.setVisibleRange(range.getStart(), pageSize);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

public void onClick(ClickEvent event) {
  // Display should be non-null, but we check defensively.
  HasRows display = getDisplay();
  if (display != null) {
   Range range = display.getVisibleRange();
   int pageSize = Math.min(range.getLength() + increment,
     display.getRowCount()
       + (display.isRowCountExact() ? 0 : increment));
   display.setVisibleRange(range.getStart(), pageSize);
  }
 }
});

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Returns true if there is enough data such that a call to
 * {@link #nextPage()} will succeed in moving the starting point of the table
 * forward.
 *
 * @return true if there is a next page
 */
protected boolean hasNextPage() {
 if (display == null || display.getRowCount() == 0) {
  return false;
 } else if (!display.isRowCountExact()) {
  return true;
 }
 Range range = display.getVisibleRange();
 return range.getStart() + range.getLength() < display.getRowCount();
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Get the text to display in the pager that reflects the state of the pager.
 *
 * @return the text
 */
protected String createText() {
 // Default text is 1 based.
 NumberFormat formatter = NumberFormat.getFormat("#,###");
 HasRows display = getDisplay();
 Range range = display.getVisibleRange();
 int pageStart = range.getStart() + 1;
 int pageSize = range.getLength();
 int dataSize = display.getRowCount();
 int endIndex = Math.min(dataSize, pageStart + pageSize - 1);
 endIndex = Math.max(pageStart, endIndex);
 boolean exact = display.isRowCountExact();
 return formatter.format(pageStart) + "-" + formatter.format(endIndex)
   + (exact ? " of " : " of over ") + formatter.format(dataSize);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
protected void onRangeOrRowCountChanged() {
 // Assumes a page start index of 0.
 HasRows display = getDisplay();
 int pageSize = display.getVisibleRange().getLength();
 boolean hasLess = pageSize > increment;
 boolean hasMore = !display.isRowCountExact()
   || pageSize < display.getRowCount();
 showLessButton.setVisible(hasLess);
 showMoreButton.setVisible(hasMore);
 layout.setText(0, 1, (hasLess && hasMore) ? " | " : "");
}

相关文章