List of usage examples for com.google.gwt.user.cellview.client ColumnSortEvent isSortAscending
public boolean isSortAscending()
From source file:client.ui.views.series.TableSeriesView.java
License:Open Source License
@Override public void onColumnSort(ColumnSortEvent event) { SeriesManager.Ordering.Direction direction; if (event.isSortAscending()) { direction = SeriesManager.Ordering.Direction.ASC; } else {/* w ww .ja v a 2 s. com*/ direction = SeriesManager.Ordering.Direction.DESC; } Column<?, ?> column = event.getColumn(); if (column instanceof CountryNameColumn) { manager.setOrdering(new SeriesManager.Ordering(SeriesManager.Ordering.BY_COUNTRY_NAME, direction)); } if (column instanceof YearColumn) { manager.setOrdering(new SeriesManager.Ordering(((YearColumn) column).getYear(), direction)); } }
From source file:org.dashbuilder.renderer.client.table.TableDisplayer.java
License:Apache License
protected PagedTable<Integer> createTable() { final PagedTable<Integer> pagedTable = new PagedTable<Integer>(displayerSettings.getTablePageSize()); List<DataColumn> dataColumns = dataSet.getColumns(); for (int i = 0; i < dataColumns.size(); i++) { DataColumn dataColumn = dataColumns.get(i); ColumnSettings columnSettings = displayerSettings.getColumnSettings(dataColumn); String columnName = columnSettings.getColumnName(); Column<Integer, ?> column = createColumn(dataColumn, i); if (column != null) { column.setSortable(true);//www .j a v a2 s . c o m pagedTable.addColumn(column, columnName); } } pagedTable.setRowCount(numberOfRows, true); int height = 40 * displayerSettings.getTablePageSize() + 20; pagedTable.setHeight((height > (Window.getClientHeight() - this.getAbsoluteTop()) ? (Window.getClientHeight() - this.getAbsoluteTop()) : height) + "px"); int tableWidth = displayerSettings.getTableWidth(); pagedTable.setWidth(tableWidth == 0 ? dataColumns.size() * 100 + "px" : tableWidth + "px"); pagedTable.setEmptyTableCaption(TableConstants.INSTANCE.tableDisplayer_noDataAvailable()); if (displayerSettings.isTableSortEnabled()) { pagedTable.addColumnSortHandler(new ColumnSortEvent.AsyncHandler(pagedTable) { public void onColumnSort(ColumnSortEvent event) { lastOrderedColumn = ((DataColumnCell) event.getColumn().getCell()).columnId; lastSortOrder = event.isSortAscending() ? SortOrder.ASCENDING : SortOrder.DESCENDING; redraw(); } }); } return pagedTable; }
From source file:org.dashbuilder.renderer.client.table.TableDisplayerView.java
License:Apache License
@Override public void setSortEnabled(boolean enabled) { table.addColumnSortHandler(new ColumnSortEvent.AsyncHandler(table) { public void onColumnSort(ColumnSortEvent event) { String column = ((DataColumnCell) event.getColumn().getCell()).columnId; SortOrder order = event.isSortAscending() ? SortOrder.ASCENDING : SortOrder.DESCENDING; getPresenter().sortBy(column, order); }//ww w . java 2 s. c o m }); }
From source file:org.dashbuilder.renderer.table.client.TableDisplayer.java
License:Apache License
protected PagedTable<Integer> createTable() { final PagedTable<Integer> pagedTable = new PagedTable<Integer>(displayerSettings.getTablePageSize()); List<DataColumn> dataColumns = dataSet.getColumns(); for (int i = 0; i < dataColumns.size(); i++) { DataColumn dataColumn = dataColumns.get(i); String columnId = dataColumn.getId(); String columnName = dataColumn.getName(); Column<Integer, ?> column = createColumn(dataColumn.getColumnType(), columnId, i); if (column != null) { column.setSortable(true);/*from w w w . jav a 2s. c o m*/ pagedTable.addColumn(column, columnName); } } pagedTable.setRowCount(numberOfRows, true); int height = 40 * displayerSettings.getTablePageSize() + 20; pagedTable.setHeight((height > (Window.getClientHeight() - this.getAbsoluteTop()) ? (Window.getClientHeight() - this.getAbsoluteTop()) : height) + "px"); int tableWidth = displayerSettings.getTableWidth(); pagedTable.setWidth(tableWidth == 0 ? dataColumns.size() * 100 + "px" : tableWidth + "px"); pagedTable.setEmptyTableCaption(TableConstants.INSTANCE.tableDisplayer_noDataAvailable()); if (displayerSettings.isTableSortEnabled()) { pagedTable.addColumnSortHandler(new ColumnSortEvent.AsyncHandler(pagedTable) { public void onColumnSort(ColumnSortEvent event) { lastOrderedColumn = event.getColumn().getDataStoreName(); lastSortOrder = event.isSortAscending() ? SortOrder.ASCENDING : SortOrder.DESCENDING; redraw(); } }); } return pagedTable; }
From source file:org.kie.workbench.common.screens.datamodeller.client.widgets.editor.DataObjectBrowserViewImpl.java
License:Apache License
private void addSortHandler() { propertiesTable.addColumnSortHandler(new ColumnSortEvent.Handler() { @Override// w w w . j a v a 2 s . com public void onColumnSort(ColumnSortEvent event) { Column<?, ?> column = event.getColumn(); ColumnId columnId; if ((columnId = columnIds.get(column)) != null) { switch (columnId) { case NAME_COLUMN: presenter.onSortByName(event.isSortAscending()); break; case LABEL_COLUMN: presenter.onSortByLabel(event.isSortAscending()); break; case TYPE_COLUMN: presenter.onSortByType(event.isSortAscending()); } } } }); }
From source file:org.rstudio.core.client.widget.ModifyKeyboardShortcutsWidget.java
License:Open Source License
private void addHandlers() { table_.addCellPreviewHandler(new CellPreviewEvent.Handler<KeyboardShortcutEntry>() { @Override/*from w ww . j a v a 2 s . c o m*/ public void onCellPreview(CellPreviewEvent<KeyboardShortcutEntry> preview) { Handle shortcutsHandler = shortcuts_.disable(); int column = preview.getColumn(); if (column == 0) onNameCellPreview(preview); else if (column == 1) onShortcutCellPreview(preview); else if (column == 2) onNameCellPreview(preview); shortcutsHandler.close(); } }); table_.addColumnSortHandler(new ColumnSortEvent.Handler() { @Override public void onColumnSort(ColumnSortEvent event) { List<KeyboardShortcutEntry> data = dataProvider_.getList(); if (event.getColumn().equals(nameColumn_)) sort(data, 0, event.isSortAscending()); else if (event.getColumn().equals(shortcutColumn_)) sort(data, 1, event.isSortAscending()); else if (event.getColumn().equals(typeColumn_)) sort(data, 2, event.isSortAscending()); updateData(data); } }); // Fix a bug where clicking on a table header would also // select the cell at position [0, 0]. It seems that GWT's // DataGrid over-aggressively selects the first cell on the // _first_ mouse down event seen; after the first click, // cell selection occurs only after full mouse clicks. table_.addDomHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent event) { Element target = event.getNativeEvent().getEventTarget().cast(); if (target.hasAttribute("__gwt_header")) { event.stopPropagation(); event.preventDefault(); } } }, MouseDownEvent.getType()); }
From source file:org.rstudio.studio.client.workbench.BrowseAddinsDialog.java
License:Open Source License
private void addColumns() { // Package ---- pkgColumn_ = new TextColumn<RAddin>() { @Override/*from ww w. ja v a 2s.c o m*/ public String getValue(RAddin addin) { return addin.getPackage(); } }; pkgColumn_.setSortable(true); table_.addColumn(pkgColumn_, new TextHeader("Package")); table_.setColumnWidth(pkgColumn_, "120px"); // Name ---- nameColumn_ = new TextColumn<RAddin>() { @Override public String getValue(RAddin addin) { return StringUtil.truncate(addin.getName(), 120, "..."); } }; nameColumn_.setSortable(true); table_.addColumn(nameColumn_, new TextHeader("Name")); table_.setColumnWidth(nameColumn_, "120px"); // Description ---- descColumn_ = new TextColumn<RAddin>() { @Override public String getValue(RAddin addin) { return addin.getDescription(); } }; descColumn_.setSortable(true); table_.addColumn(descColumn_, new TextHeader("Description")); table_.addColumnSortHandler(new ColumnSortEvent.Handler() { @Override public void onColumnSort(ColumnSortEvent event) { int index = -1; if (event.getColumn().equals(pkgColumn_)) index = 0; else if (event.getColumn().equals(nameColumn_)) index = 1; else if (event.getColumn().equals(descColumn_)) index = 2; if (index == -1) return; sort(index, event.isSortAscending()); } }); }
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.j a v a2s . co 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; }); }
From source file:stroom.entity.client.presenter.EntityServiceFindActionDataProvider.java
License:Apache License
@Override public void onColumnSort(final ColumnSortEvent event) { if (event.getColumn() instanceof OrderByColumn<?, ?>) { final OrderBy orderBy = ((OrderByColumn<?, ?>) event.getColumn()).getOrderBy(); if (findAction != null) { if (event.isSortAscending()) { findAction.getCriteria().setOrderBy(orderBy, OrderByDirection.ASCENDING); } else { findAction.getCriteria().setOrderBy(orderBy, OrderByDirection.DESCENDING); }/*from w w w .ja v a2s .c om*/ refresh(); } } }