List of usage examples for com.google.gwt.user.cellview.client ColumnSortEvent getColumnSortList
public ColumnSortList getColumnSortList()
From source file:com.bearsoft.gwt.ui.widgets.grid.processing.ListMultiSortHandler.java
@Override public void onColumnSort(final ColumnSortEvent event) { if (unsorted.size() != getList().size()) { setList(getList());/*from w w w .java 2s .co m*/ } if (event.getColumnSortList() == null || event.getColumnSortList().size() == 0) { unsort(); } else { // Sort using the multi comparator. List<T> sorted = getList(); Collections.sort(sorted, new Comparator<T>() { @Override public int compare(T o1, T o2) { for (int i = 0; i < event.getColumnSortList().size(); i++) { ColumnSortInfo sortInfo = event.getColumnSortList().get(i); Comparator<T> c = getComparator((Column<T, ?>) sortInfo.getColumn()); int res = 0; if (c != null) { res = c.compare(o1, o2); } if (res != 0) { return sortInfo.isAscending() ? res : -res; } } return 0; } }); } if (onComplete != null) onComplete.run(); }
From source file:com.bearsoft.gwt.ui.widgets.grid.processing.TreeMultiSortHandler.java
@Override public void onColumnSort(final ColumnSortEvent event) { if (unsorted.size() != getList().size()) { setList(getList());/*from ww w . j a va2 s . co m*/ } if (event.getColumnSortList() == null || event.getColumnSortList().size() == 0) { unsort(); } else { // Sort using the multi comparator. List<T> sorted = getList(); Collections.sort(sorted, new Comparator<T>() { @Override public int compare(T o1, T o2) { if (dataProvider.getTree().getParentOf(o1) != dataProvider.getTree().getParentOf(o2)) { List<T> path1 = dataProvider.buildPathTo(o1); List<T> path2 = dataProvider.buildPathTo(o2); if (path2.contains(o1)) { // o1 is parent of o2 return -1; } if (path1.contains(o2)) { // o2 is parent of o1 return 1; } for (int i = 0; i < Math.min(path1.size(), path2.size()); i++) { if (path1.get(i) != path2.get(i)) { o1 = path1.get(i); o2 = path2.get(i); break; } } } // ordinary sort for (int i = 0; i < event.getColumnSortList().size(); i++) { ColumnSortInfo sortInfo = event.getColumnSortList().get(i); Comparator<T> c = getComparator((Column<T, ?>) sortInfo.getColumn()); int res = 0; if (c != null) { res = c.compare(o1, o2); } if (res != 0) { return sortInfo.isAscending() ? res : -res; } } return 0; } }); } if (onComplete != null) onComplete.run(); }
From source file:com.gafactory.core.client.ui.grids.BaseListGrid.java
License:Open Source License
@Override public void onColumnSort(ColumnSortEvent event) { loader.clearSortInfo();/*from ww w. j a v a 2s. com*/ ColumnSortList sorting = event.getColumnSortList(); for (int i = 0; i < sorting.size(); i++) { ColumnSortList.ColumnSortInfo columnSortInfo = sorting.get(i); String field = columnSortInfo.getColumn().getDataStoreName(); Preconditions.checkNotNull(field); SortInfoBean sortInfoBean = new SortInfoBean(field, columnSortInfo.isAscending() ? SortDir.ASC : SortDir.DESC); loader.addSortInfo(sortInfoBean); } if (secondSortingField != null) { loader.addSortInfo(new SortInfoBean(secondSortingField, SortDir.ASC)); } loader.load(); }
From source file:com.gafactory.core.shared.loader.FilterPagingLoader.java
License:Open Source License
@Override public void onColumnSort(ColumnSortEvent event) { ColumnSortList columnSortList = event.getColumnSortList(); List<SortInfoBean> sortInfoBeans = toSortingBeanList(columnSortList); clearSortInfo();/* w w w . j a v a 2s. c o m*/ for (SortInfoBean sortInfoBean : sortInfoBeans) { addSortInfo(sortInfoBean); } load(); }
From source file:de.uni_koeln.spinfo.maalr.webapp.ui.admin.client.user.list.UserListDataProvider.java
License:Apache License
public UserListDataProvider(final PagingDataGrid<LightUserInfo> table) { this.service = GWT.create(UserService.class); this.table = table; // Callback responsible for updating the list callback = new AsyncCallback<List<LightUserInfo>>() { @Override/*w w w. j a v a 2 s.c o m*/ public void onFailure(Throwable caught) { Dialog.showError("Failed to update user list", caught); } @Override public void onSuccess(List<LightUserInfo> result) { update(result); current += result.size(); // Check if results are found but the scrollbar // is not yet visible. In this case, continue // fetching data if (result.size() > 0) { ScrollPanel panel = table.getScrollPanel(); if (panel.getMaximumVerticalScrollPosition() == 0) { doUpdate(); } } } }; addDataDisplay(table); // Enable sorting columns table.addColumnSortHandler(new Handler() { @Override public void onColumnSort(ColumnSortEvent event) { Column<?, ?> column = event.getColumn(); // Update sort properties and start a new query sortAscending = event.getColumnSortList().get(0).isAscending(); sortColumn = column.getDataStoreName(); reset(); } }); }
From source file:org.overlord.sramp.ui.client.widgets.DataTableWithPager.java
License:Apache License
/** * Called to configure the table./*from ww w . j a va2 s. c om*/ * @param table */ protected void configureTable(DataTable<T> table) { table.getElement().setClassName("dataTable"); table.setWidth("100%"); table.addColumnSortHandler(new Handler() { @Override public void onColumnSort(ColumnSortEvent event) { ColumnSortList columnSortList = event.getColumnSortList(); ColumnSortInfo sortInfo = columnSortList.get(0); onSort(sortInfo.getColumn().getDataStoreName(), sortInfo.isAscending()); } }); }
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//from w w w .j ava2s. 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; }); }