com.google.gwt.view.client.HasData Java Examples

The following examples show how to use com.google.gwt.view.client.HasData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableDisplayerView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
/**
 * This is invoked internally by the PagedTable on navigation actions.
 */
protected void onRangeChanged(final HasData<Integer> display) {
    int start = ((PagedTable) display).getPageStart();
    final List<Integer> rows = getCurrentPageRows(display);

    if (lastOffset == start) {
        updateRowData(lastOffset, rows);
    }
    else {
        lastOffset = start;
        getPresenter().lookupCurrentPage(rowsFetched -> {
            updateRowData(lastOffset, rows);
            table.setHeight(calculateHeight(rowsFetched) + "px");
        });
    }
}
 
Example #2
Source File: DefaultCellBrowser.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected <C> Widget createPager(final HasData<C> display)
{
    // by returning null we can prevent the "flickering" of the "show more" link
    // see http://stackoverflow.com/a/6827755/1538056
    //return null;


    PageSizePager pager = new PageSizePager(Integer.MAX_VALUE);

    // removes the text "Show More" during loading
    display.setRowCount(0);

    // increase the visible range so that no one ever needs to page
    display.setVisibleRange(0, Integer.MAX_VALUE);
    pager.setDisplay(display);

    return pager;
}
 
Example #3
Source File: TableDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
protected List<Integer> getCurrentPageRows(HasData<Integer> display) {
    final int start = ((PagedTable) display).getPageStart();
    int pageSize = ((PagedTable) display).getPageSize();
    int end = start + pageSize;
    if (end > table.getRowCount()) {
        end = table.getRowCount();
    }

    final List<Integer> rows = new ArrayList<Integer>(end-start);
    for (int i = 0; i < end-start; i++) {
        rows.add(i);
    }
    return rows;
}
 
Example #4
Source File: TableDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked from createWidget just after the data set has been fetched.
 */
public void addDataDisplay(HasData<Integer> display) {
    // Avoid fetching the data set again
    lastOffset = 0;

    // This calls internally to onRangeChanged()
    super.addDataDisplay(display);
}
 
Example #5
Source File: CellTreeNodeView.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Fire an event to the {@link com.google.gwt.cell.client.AbstractCell}.
 *
 * @param event the native event
 */
@SuppressWarnings("unchecked")
protected void fireEventToCell(NativeEvent event) {
  if (parentNodeInfo == null) {
    return;
  }

  Cell<T> parentCell = parentNodeInfo.getCell();
  String eventType = event.getType();
  Element cellParent = getCellParent();
  Object key = getValueKey();
  Context context = new Context(getIndex(), 0, key);
  boolean cellWasEditing = parentCell.isEditing(context, cellParent, value);

  // Update selection.
  boolean isSelectionHandled = parentCell.handlesSelection() || KeyboardSelectionPolicy.BOUND_TO_SELECTION == tree.getKeyboardSelectionPolicy();
  HasData<T> display = (HasData<T>)parentNode.listView;
  CellPreviewEvent<T> previewEvent = CellPreviewEvent.fire(display, event, display, context, value, cellWasEditing, isSelectionHandled);

  // Forward the event to the cell.
  if (previewEvent.isCanceled() || !cellParent.isOrHasChild(Element.as(event.getEventTarget()))) {
    return;
  }
  Set<String> consumedEvents = parentCell.getConsumedEvents();
  if (consumedEvents != null && consumedEvents.contains(eventType)) {
    parentCell.onBrowserEvent(context, cellParent, value, event, parentNodeInfo.getValueUpdater());
    tree.cellIsEditing = parentCell.isEditing(context, cellParent, value);
    if (cellWasEditing && !tree.cellIsEditing) {
      CellBasedWidgetImpl.get().resetFocus(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
          tree.setFocus(true);
        }
      });
    }
  }
}
 
Example #6
Source File: CellBrowser.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Create a pager to control the list view.
 *
 * @param <C> the item type in the list view
 * @param display the list view to add paging too
 * @return the pager
 */
protected <C> Widget createPager(HasData<C> display) {
  if (pagerFactory == null) {
    return null;
  }
  AbstractPager pager = pagerFactory.create(display);
  pager.setDisplay(display);
  return pager;
}
 
Example #7
Source File: AuditLogItemDataProvider.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void onRangeChanged(final HasData<AuditLogItem> display) {
    Range range = display.getVisibleRange();
    int start = min(range.getStart(), store.size() - 1);
    int end = min(start + range.getLength(), store.size());
    List<AuditLogItem> items = store.subList(start, end);
    display.setRowData(start, items);
}
 
Example #8
Source File: DataProviderFilter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void clearSelection() {
    for (HasData<T> table : delegate.getDataDisplays()) {
        SelectionModel<? super T> selectionModel = table.getSelectionModel();
        if (selectionModel instanceof SingleSelectionModel) {
            SingleSelectionModel<T> sm = (SingleSelectionModel<T>) selectionModel;
            T selectedObject = sm.getSelectedObject();
            if (selectedObject != null) {
                ((SingleSelectionModel<T>) selectionModel).setSelected(selectedObject, false);
            }
        }
    }
}