Search in sources :

Example 1 with ColumnSortList

use of com.google.gwt.user.cellview.client.ColumnSortList in project rstudio by rstudio.

the class FilesList method addColumnSortHandler.

private void addColumnSortHandler() {
    filesDataGrid_.addColumnSortHandler(new Handler() {

        @Override
        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 < filesDataGrid_.getColumnCount(); c++) {
                    if (filesDataGrid_.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 final native JsArray<ColumnSortInfo> newSortOrderArray();

        private boolean forceSizeSortDescending = true;

        private boolean forceModifiedSortDescending = true;
    });
}
Also used : ColumnSortInfo(org.rstudio.core.client.cellview.ColumnSortInfo) JsArray(com.google.gwt.core.client.JsArray) Handler(com.google.gwt.user.cellview.client.ColumnSortEvent.Handler) ResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler) ColumnSortEvent(com.google.gwt.user.cellview.client.ColumnSortEvent) ColumnSortList(com.google.gwt.user.cellview.client.ColumnSortList)

Example 2 with ColumnSortList

use of com.google.gwt.user.cellview.client.ColumnSortList in project rstudio by rstudio.

the class FilesList method setColumnSortOrder.

public void setColumnSortOrder(JsArray<ColumnSortInfo> sortOrder) {
    if (sortOrder != null) {
        ColumnSortInfo.setSortList(filesDataGrid_, sortOrder);
    } else {
        ColumnSortList columnSortList = filesDataGrid_.getColumnSortList();
        columnSortList.clear();
        columnSortList.push(nameColumn_);
    }
}
Also used : ColumnSortList(com.google.gwt.user.cellview.client.ColumnSortList)

Example 3 with ColumnSortList

use of com.google.gwt.user.cellview.client.ColumnSortList in project rstudio by rstudio.

the class ColumnSortInfo method setSortList.

public static ColumnSortList setSortList(AbstractCellTable<?> table, JsArray<ColumnSortInfo> sortArray) {
    ColumnSortList list = table.getColumnSortList();
    list.clear();
    for (int i = 0; i < sortArray.length(); i++) list.insert(i, sortArray.get(i).toGwtSortInfo(table));
    return list;
}
Also used : ColumnSortList(com.google.gwt.user.cellview.client.ColumnSortList)

Example 4 with ColumnSortList

use of com.google.gwt.user.cellview.client.ColumnSortList in project rstudio by rstudio.

the class ColumnSortInfo method getSortList.

@SuppressWarnings("rawtypes")
public static JsArray<ColumnSortInfo> getSortList(CellTable table) {
    ColumnSortList sortList = table.getColumnSortList();
    JsArray<ColumnSortInfo> result = JsArray.createArray().cast();
    for (int i = 0; i < sortList.size(); i++) result.push(fromGwtSortInfo(table, sortList.get(i)));
    return result;
}
Also used : ColumnSortList(com.google.gwt.user.cellview.client.ColumnSortList)

Aggregations

ColumnSortList (com.google.gwt.user.cellview.client.ColumnSortList)4 JsArray (com.google.gwt.core.client.JsArray)1 ResizeHandler (com.google.gwt.event.logical.shared.ResizeHandler)1 ColumnSortEvent (com.google.gwt.user.cellview.client.ColumnSortEvent)1 Handler (com.google.gwt.user.cellview.client.ColumnSortEvent.Handler)1 ColumnSortInfo (org.rstudio.core.client.cellview.ColumnSortInfo)1