本文整理汇总了Java中com.google.gwt.user.cellview.client.ColumnSortList类的典型用法代码示例。如果您正苦于以下问题:Java ColumnSortList类的具体用法?Java ColumnSortList怎么用?Java ColumnSortList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnSortList类属于com.google.gwt.user.cellview.client包,在下文中一共展示了ColumnSortList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateColumnSortList
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
/**
* Update list of sorted columns.
*
* @param columnSortList Table {@code ColumnSortList}.
* @param ordering Ordering criteria.
*/
private void updateColumnSortList(
ColumnSortList columnSortList,
SeriesManager.Ordering ordering) {
Column<?, ?> column;
int by = ordering.getBy();
if (by == SeriesManager.Ordering.BY_COUNTRY_NAME) {
column = CountryNameColumn.get();
} else {
column = YearColumn.get(by);
}
ColumnSortList.ColumnSortInfo columnSortInfo =
new ColumnSortList.ColumnSortInfo(column, ordering.isAscending());
columnSortList.clear();
columnSortList.push(columnSortInfo);
}
示例2: addSort
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
public void addSort(ModelColumn aColumn, boolean isAscending) {
if (aColumn.isSortable()) {
boolean contains = false;
int containsAt = -1;
for (int i = 0; i < sortList.size(); i++) {
if (sortList.get(i).getColumn() == aColumn) {
contains = true;
containsAt = i;
break;
}
}
if (contains) {
boolean wasAscending = sortList.get(containsAt).isAscending();
if (wasAscending == isAscending) {
return;
}
}
sortList.insert(sortList.size(), new ColumnSortList.ColumnSortInfo(aColumn, isAscending));
ColumnSortEvent.fire(Grid.this, sortList);
redrawHeaders();
}
}
示例3: buildHeaderOrFooterImpl
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
@Override
protected boolean buildHeaderOrFooterImpl() {
TableRowBuilder tr = startRow();
ColumnSortList sortList = dataGrid.getColumnSortList();
ColumnSortInfo sortedInfo = (sortList.size() == 0) ? null : sortList.get(0);
Column<?, ?> sortedColumn = (sortedInfo == null) ? null : sortedInfo.getColumn();
boolean isSortAscending = (sortedInfo == null) ? false : sortedInfo.isAscending();
// Add column headers.
tr = startRow();
buildHeader(tr, titleHeader, titleColumn, sortedColumn, isSortAscending, false, false);
tr.endTR();
return true;
}
示例4: updateData
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
/**
* Update data.
*/
public void updateData() {
List<T> filteredData = dataGrid.filter(data);
if (dataFilter != null) {
List<T> newFilteredData = new ArrayList<>();
for (T value : filteredData) {
if (dataFilter.accept(value)) {
newFilteredData.add(value);
}
}
filteredData = newFilteredData;
}
updateRowCount(filteredData.size(), true);
ColumnSortList sortList = dataGrid.getDataGrid().getColumnSortList();
Column<?, ?> column = (sortList == null || sortList.size() == 0) ? null
: sortList.get(0).getColumn();
boolean isSortAscending = !(sortList == null || sortList.size() == 0)
&& sortList.get(0).isAscending();
if (column != null) {
dataGrid.sort(filteredData, column, isSortAscending);
}
updateRowData(0, filteredData);
}
示例5: onRangeChanged
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
@Override
protected void onRangeChanged(final HasData<Row> display) {
final ColumnSortList columnSortList = dataGrid.getColumnSortList();
Collections.sort(data,
new Comparator<Row>() {
@Override
public int compare(final Row o1,
final Row o2) {
if (columnSortList == null || columnSortList.size() == 0 || columnSortList.get(0).isAscending() == false) {
return o1.getName().compareTo(o2.getName());
} else {
return o2.getName().compareTo(o1.getName());
}
}
});
Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
@Override
public boolean execute() {
updateRowCount(data.size(),
true);
updateRowData(0,
data);
return false;
}
},
1000);
}
示例6: processColumnSort
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
private void processColumnSort(DataGrid<T> table, Column<?,?> column,
Comparator<T> comparator, Boolean isSortAscending) {
if (comparator != null) {
comparators.put(column, comparator);
column.setSortable(true);
if (isSortAscending != null) {
ColumnSortList.ColumnSortInfo sortInfo = new ColumnSortList.ColumnSortInfo(column, isSortAscending.booleanValue());
ColumnSortList sortList = table.getColumnSortList();
sortList.insert(sortList.size(), sortInfo);
}
}
}
示例7: getColumnSortList
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
public ColumnSortList getColumnSortList() {
return dataGrid.getColumnSortList();
}
示例8: getSortColumnDataStoreName
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
private String getSortColumnDataStoreName() {
final ColumnSortList columnSortList = view.getColumnSortList();
return (columnSortList == null || columnSortList.size() == 0) ? null : columnSortList.get(0).getColumn().getDataStoreName();
}
示例9: isSortColumnAscending
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
private boolean isSortColumnAscending() {
final ColumnSortList columnSortList = view.getColumnSortList();
return (columnSortList == null || columnSortList.size() == 0) ? DEFAULT_ORDER_ASCENDING : columnSortList.get(0).isAscending();
}
示例10: getColumnSortList
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
@Override
public ColumnSortList getColumnSortList() {
return dataGrid.getColumnSortList();
}
示例11: getSortList
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
@Override
public ColumnSortList getSortList() {
return sortList;
}
示例12: buildHeaderOrFooterImpl
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
@Override
protected boolean buildHeaderOrFooterImpl() {
AbstractCellTable<T> table = getTable();
boolean isFooter = isBuildingFooter();
int columnCount = table.getColumnCount();
if (columnCount > 0) {
// Early exit if there aren't any headers or footers in the columns
// to render.
boolean hasHeadersOrFooters = false;
for (int i = 0; i < columnCount; i++) {
if (getHeader(i) != null) {
hasHeadersOrFooters = true;
break;
}
}
if (hasHeadersOrFooters) {
List<HeaderNode<T>> headersForest;
if (headerNodes == null) {
headersForest = new ArrayList<>();
for (int curColumn = 0; curColumn < columnCount; curColumn++) {
Header<?> headerOrFooter = getHeader(curColumn);
HeaderNode<T> hn = new HeaderNode<T>();
hn.setHeader((Header<String>) headerOrFooter);
headersForest.add(hn);
}
} else {
headersForest = headerNodes;
}
// Get information about the sorted columns.
ColumnSortList sortList;
if (sortListHolder != null) {
sortList = sortListHolder.getSortList();
} else {
sortList = table.getColumnSortList();
}
Map<Column<T, ?>, ColumnSortList.ColumnSortInfo> sortedColumns = new HashMap<>();
if (sortList != null) {
for (int i = 0; i < sortList.size(); i++) {
ColumnSortList.ColumnSortInfo sInfo = sortList.get(i);
sortedColumns.put((Column<T, ?>) sInfo.getColumn(), sInfo);
}
}
buildNodes(headersForest, sortedColumns);
return true;
} else {
// No headers to render;
return false;
}
} else {
// Nothing to render;
return false;
}
}
示例13: buildNodes
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
protected void buildNodes(List<HeaderNode<T>> aHeaders, Map<Column<T, ?>, ColumnSortList.ColumnSortInfo> sortedColumns) {
// AbstractCellTable<T> table = getTable();
List<HeaderNode<T>> children = new ArrayList<>();
boolean isFooter = isBuildingFooter();
// Get the common style names.
String className = isBuildingFooter() ? ThemedGridResources.instance.cellTableStyle().cellTableFooter() : ThemedGridResources.instance.cellTableStyle().cellTableHeader();
String sortableStyle = ThemedGridResources.instance.cellTableStyle().cellTableSortableHeader();
String sortedAscStyle = ThemedGridResources.instance.cellTableStyle().cellTableSortedHeaderAscending();
String sortedDescStyle = ThemedGridResources.instance.cellTableStyle().cellTableSortedHeaderDescending();
TableRowBuilder tr = startRow();
// Loop through all column header nodes.
for (int i = 0; i < aHeaders.size(); i++) {
HeaderNode<T> headerNode = aHeaders.get(i);
children.addAll(headerNode.getChildren());
Header<?> headerOrFooter = headerNode.getHeader();
Column<T, ?> column = null;
if (headerOrFooter instanceof HasColumn<?>)
column = ((HasColumn<T>) headerOrFooter).getColumn();
boolean isSortable = !isFooter && column != null && column.isSortable();
ColumnSortList.ColumnSortInfo sortedInfo = sortedColumns.get(column);
boolean isSorted = sortedInfo != null;
StringBuilder classesBuilder = new StringBuilder(className);
boolean isSortAscending = isSortable && sortedInfo != null ? sortedInfo.isAscending() : false;
if (isSortable) {
if (classesBuilder.length() > 0) {
classesBuilder.append(" ");
}
classesBuilder.append(sortableStyle);
if (isSorted) {
if (classesBuilder.length() > 0) {
classesBuilder.append(" ");
}
classesBuilder.append(isSortAscending ? sortedAscStyle : sortedDescStyle);
}
}
// Render the header or footer.
TableCellBuilder th = tr.startTH();
if (headerNode.getDepthRemainder() > 0)
th.rowSpan(headerNode.getDepthRemainder() + 1);
if (headerNode.getLeavesCount() > 1)
th.colSpan(headerNode.getLeavesCount());
th.className(classesBuilder.toString());
StylesBuilder thStyles = th.style();
if (headerNode.getBackground() != null) {
thStyles.trustedBackgroundColor(headerNode.getBackground().toStyled());
}
if (headerNode.getForeground() != null) {
thStyles.trustedColor(headerNode.getForeground().toStyled());
}
if (headerNode.getFont() != null) {
thStyles.trustedProperty("font-family", headerNode.getFont().getFamily());
thStyles.fontSize(headerNode.getFont().getSize(), Style.Unit.PX);
thStyles.fontStyle(headerNode.getFont().isItalic() ? FontStyle.ITALIC : FontStyle.NORMAL);
thStyles.fontWeight(headerNode.getFont().isBold() ? FontWeight.BOLD : FontWeight.NORMAL);
}
if (headerOrFooter != null) {
appendExtraStyles(headerOrFooter, classesBuilder);
if (column != null) {
enableColumnHandlers(th, column);
}
// Build the header.
Cell.Context context = new Cell.Context(0, i, headerOrFooter.getKey());
// Add div element with aria button role
if (isSortable) {
// TODO: Figure out aria-label and translation
// of label text
th.attribute("role", "button");
th.tabIndex(-1);
}
renderSortableHeader(th, context, headerOrFooter, isSorted, isSortAscending);
}
th.endTH();
}
// End the row.
tr.endTR();
if (!children.isEmpty()) {
buildNodes(children, sortedColumns);
}
}
示例14: buildHeaderOrFooterImpl
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
@Override
protected boolean buildHeaderOrFooterImpl() {
Style style = dataGrid.getResources().style();
String groupHeaderCell = resources.styles().groupHeaderCell();
// Add a 2x2 header above the checkbox and show friends columns.
TableRowBuilder tr = startRow();
tr.startTH().colSpan(2).rowSpan(2)
.className(style.header() + " " + style.firstColumnHeader());
tr.endTH();
/*
* Name group header. Associated with the last name column, so clicking on
* the group header sorts by last name.
*/
TableCellBuilder th = tr.startTH().colSpan(2).className(groupHeaderCell);
enableColumnHandlers(th, lastNameColumn);
th.style().trustedProperty("border-right", "10px solid white").cursor(Cursor.POINTER)
.endStyle();
th.text("Name").endTH();
// Information group header.
th = tr.startTH().colSpan(3).className(groupHeaderCell);
th.text("Information").endTH();
// Get information about the sorted column.
ColumnSortList sortList = dataGrid.getColumnSortList();
ColumnSortInfo sortedInfo = (sortList.size() == 0) ? null : sortList.get(0);
Column<?, ?> sortedColumn = (sortedInfo == null) ? null : sortedInfo.getColumn();
boolean isSortAscending = (sortedInfo == null) ? false : sortedInfo.isAscending();
// Add column headers.
tr = startRow();
buildHeader(tr, firstNameHeader, firstNameColumn, sortedColumn, isSortAscending, false, false);
buildHeader(tr, lastNameHeader, lastNameColumn, sortedColumn, isSortAscending, false, false);
buildHeader(tr, ageHeader, ageColumn, sortedColumn, isSortAscending, false, false);
buildHeader(tr, categoryHeader, categoryColumn, sortedColumn, isSortAscending, false, false);
buildHeader(tr, addressHeader, addressColumn, sortedColumn, isSortAscending, false, true);
tr.endTR();
return true;
}
示例15: getSortOrder
import com.google.gwt.user.cellview.client.ColumnSortList; //导入依赖的package包/类
/**
* Return the column to be sorted.
*
* @return column to be sorted
*/
protected ColumnSortList.ColumnSortInfo getSortOrder() {
ColumnSortList sortList = getColumnSortList();
return sortList == null ? null : sortList.get(0);
}