List of usage examples for com.google.gwt.user.cellview.client ColumnSortEvent getColumn
public Column<?, ?> getColumn()
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 w w . j a v a 2 s . co m 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: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//from ww w.j a v a 2 s. c om 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.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);// w w w.j a v a 2s.co 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); }/*from w w w . ja v a 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);/* w w w. j av a 2 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 = 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/*from w w w . j a v a2 s.c o m*/ 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 2s. com 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//www . j a va2s. co 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/*from w ww. ja v a 2s . 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; }); }
From source file:org.ssgwt.client.ui.datagrid.SSDataGrid.java
License:Apache License
/** * Class Constructor/*from w w w . java2 s. c o m*/ * * @author Michael Barnard * @since 02 July 2012 * * @param dataGridResource - The resource that needs to be used for the data grid * @param pagerResource - The resource that needs to be used for the pager * @param multiSelect - Whether the data grid supports multiple selects */ public SSDataGrid(DataGrid.Resources dataGridResource, SSPager.Resources pagerResource, boolean multiSelect) { dataGrid = new DataGrid<T>(10, dataGridResource); dataGrid.addColumnSortHandler(new ColumnSortEvent.Handler() { /** * Will be called on a column sort event * * @param event - The event that initialise the handler */ @Override public void onColumnSort(ColumnSortEvent event) { ColumnSortInfo columnSortInfo; if ((columnSortInfo = columnSortDetail.get(event.getColumn())) != null) { columnSortDetail.remove(event.getColumn()); columnSortDetail.put(event.getColumn(), new ColumnSortInfo(event.getColumn(), !columnSortInfo.isAscending())); } else { columnSortDetail.put(event.getColumn(), new ColumnSortInfo(event.getColumn(), true)); } SSDataGrid.this.dataGrid.getColumnSortList().push(columnSortDetail.get(event.getColumn())); fireEvent(new DataGridSortEvent(event.getColumn(), columnSortDetail.get(event.getColumn()).isAscending())); } }); pager = new SSPager(TextLocation.CENTER, pagerResource, false, 0, true); pager.setDisplay(dataGrid); setMultiSelect(multiSelect); setClickAction(false); this.initWidget(uiBinder.createAndBindUi(this)); Resources.INSTANCE.dataGridStyle().ensureInjected(); actionBar.setStyleName(Resources.INSTANCE.dataGridStyle().actionBarStyle()); noContentLabel.setStyleName(Resources.INSTANCE.dataGridStyle().noContentLabelStyle()); dataGrid.addRangeChangeHandler(this); }