org.vaadin.viritin.SortableLazyList

Here are the examples of the java api org.vaadin.viritin.SortableLazyList taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

18 Source : MGrid.java
with Apache License 2.0
from ijazfx

public MGrid<T> setRows(List<T> rows) {
    if (getContainerDataSource() instanceof ListContainer) {
        Collection<?> itemIds = getListContainer().gereplacedemIds();
        if (itemIds instanceof SortableLazyList) {
            SortableLazyList<T> old = (SortableLazyList<T>) itemIds;
            if (old.getSortProperty() != null && rows instanceof SortableLazyList) {
                SortableLazyList<T> newList = (SortableLazyList<T>) rows;
                newList.setSortProperty(old.getSortProperty());
                newList.setSortAscending(old.getSortAscending());
            }
        }
        getListContainer().setCollection(rows);
    } else {
        setContainerDataSource(new ListContainer(rows));
    }
    return this;
}

18 Source : MTable.java
with Apache License 2.0
from ijazfx

@Override
public void sort(Object[] propertyId, boolean[] ascending) throws UnsupportedOperationException {
    if (isSorting) {
        // hack to avoid recursion
        return;
    }
    boolean refreshingPreviouslyEnabled = disableContentRefreshing();
    boolean defaultTableSortingMethod = false;
    try {
        isSorting = true;
        // create sort event and fire it, allow user to prevent default
        // operation
        sortAscending = ascending != null && ascending.length > 0 ? ascending[0] : true;
        sortProperty = propertyId != null && propertyId.length > 0 ? propertyId[0].toString() : null;
        final SortEvent sortEvent = new SortEvent(this, sortAscending, sortProperty);
        fireEvent(sortEvent);
        if (!sortEvent.isPreventContainerSort()) {
            // if not prevented, do sorting
            if (bic != null && bic.gereplacedemIds() instanceof SortableLazyList) {
                // Explicit support for SortableLazyList, set sort parameters
                // it uses to backend services and clear internal buffers
                SortableLazyList<T> sll = (SortableLazyList) bic.gereplacedemIds();
                if (ascending == null || ascending.length == 0) {
                    sll.sort(true, null);
                } else {
                    sll.sort(ascending[0], propertyId[0].toString());
                }
                resetPageBuffer();
            } else {
                super.sort(propertyId, ascending);
                defaultTableSortingMethod = true;
            }
        }
        if (!defaultTableSortingMethod) {
            // Ensure the values used in UI are set as this method is public
            // and can be called by both UI event and app logic
            setSortAscending(sortAscending);
            setSortContainerPropertyId(sortProperty);
        }
    } catch (UnsupportedOperationException e) {
        throw new RuntimeException(e);
    } finally {
        isSorting = false;
        if (refreshingPreviouslyEnabled) {
            enableContentRefreshing(true);
        }
    }
}

18 Source : MTable.java
with Apache License 2.0
from ijazfx

public MTable<T> setBeans(Collection<T> beans) {
    if (sortProperty != null && beans instanceof SortableLazyList) {
        final SortableLazyList sll = (SortableLazyList) beans;
        sll.setSortProperty(new String[] { sortProperty });
        sll.setSortAscending(new boolean[] { sortAscending });
    }
    if (!isContainerInitialized() && !beans.isEmpty()) {
        ensureBeanItemContainer(beans);
    } else if (isContainerInitialized()) {
        bic.setCollection(beans);
    }
    return this;
}