Example usage for com.google.gwt.user.cellview.client ColumnSortList insert

List of usage examples for com.google.gwt.user.cellview.client ColumnSortList insert

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client ColumnSortList insert.

Prototype

public void insert(int index, ColumnSortInfo sortInfo) 

Source Link

Document

Inserts the specified ColumnSortInfo at the specified position in this list.

Usage

From source file:org.kaaproject.avro.ui.gwt.client.widget.grid.AbstractGrid.java

License:Apache License

private void processColumnSort(DataGrid<T> table, Column<?, ?> column, Comparator<T> comparator,
        Boolean isSortAscending) {
    if (comparator != null) {
        comparators.put(column, comparator);
        column.setSortable(true);/*from www .  j  a v a  2 s .  c o m*/
        if (isSortAscending != null) {
            ColumnSortList.ColumnSortInfo sortInfo = new ColumnSortList.ColumnSortInfo(column,
                    isSortAscending.booleanValue());
            ColumnSortList sortList = table.getColumnSortList();
            sortList.insert(sortList.size(), sortInfo);
        }
    }
}

From source file:org.rstudio.core.client.cellview.ColumnSortInfo.java

License:Open Source License

public static ColumnSortList setSortList(CellTable<?> table, JsArray<ColumnSortInfo> sortArray) {
    ColumnSortList list = table.getColumnSortList();
    list.clear();/*w w  w. j  a v a 2s .c om*/
    for (int i = 0; i < sortArray.length(); i++)
        list.insert(i, sortArray.get(i).toGwtSortInfo(table));
    return list;
}

From source file:org.rstudio.studio.client.workbench.views.files.ui.FilesList.java

License:Open Source License

private void addColumnSortHandler() {
    filesCellTable_.addColumnSortHandler(new Handler() {
        @Override/*ww  w. ja v  a  2 s  .c o m*/
        public void onColumnSort(ColumnSortEvent event) {
            ColumnSortList sortList = event.getColumnSortList();

            // insert the default initial sort order for size and modified
            if (!applyingProgrammaticSort_) {
                if (event.getColumn().equals(sizeColumn_) && forceSizeSortDescending) {
                    forceSizeSortDescending = false;
                    forceModifiedSortDescending = true;
                    sortList.insert(0, new com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo(
                            event.getColumn(), false));
                } else if (event.getColumn().equals(modifiedColumn_) && forceModifiedSortDescending) {
                    forceModifiedSortDescending = false;
                    forceSizeSortDescending = true;
                    sortList.insert(0, new com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo(
                            event.getColumn(), false));
                } else {
                    forceModifiedSortDescending = true;
                    forceSizeSortDescending = true;
                }
            }

            // record sort order and fire event to observer
            JsArray<ColumnSortInfo> sortOrder = newSortOrderArray();
            for (int i = 0; i < sortList.size(); i++) {
                // match the column index
                com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo sortInfo = sortList.get(i);
                Object column = sortInfo.getColumn();

                for (int c = 0; c < filesCellTable_.getColumnCount(); c++) {
                    if (filesCellTable_.getColumn(c).equals(column)) {
                        boolean ascending = sortInfo.isAscending();
                        sortOrder.push(ColumnSortInfo.create(c, ascending));
                        break;
                    }
                }
            }
            observer_.onColumnSortOrderChanaged(sortOrder);

            // record active sort column ascending state
            activeSortColumnAscending_ = event.isSortAscending();

            // delegate the sort
            sortHandler_.onColumnSort(event);
        }

        private native final JsArray<ColumnSortInfo> newSortOrderArray()
        /*-{
           return [];
        }-*/;

        private boolean forceSizeSortDescending = true;
        private boolean forceModifiedSortDescending = true;
    });
}