本文整理汇总了Java中com.google.gwt.user.cellview.client.ColumnSortEvent.getColumnSortList方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnSortEvent.getColumnSortList方法的具体用法?Java ColumnSortEvent.getColumnSortList怎么用?Java ColumnSortEvent.getColumnSortList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.cellview.client.ColumnSortEvent
的用法示例。
在下文中一共展示了ColumnSortEvent.getColumnSortList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onColumnSort
import com.google.gwt.user.cellview.client.ColumnSortEvent; //导入方法依赖的package包/类
@Override
public void onColumnSort(final ColumnSortEvent event) {
if (unsorted.size() != getList().size()) {
setList(getList());
}
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();
}
示例2: onColumnSort
import com.google.gwt.user.cellview.client.ColumnSortEvent; //导入方法依赖的package包/类
@Override
public void onColumnSort(final ColumnSortEvent event) {
if (unsorted.size() != getList().size()) {
setList(getList());
}
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();
}