AbstractMultiGridView extends Composite implements MultiGridView<T, V>,
                                                                                                                                         RequiresResize { protected void addColumnSortHandler(ExtendedPagedTable listTable) { listTable.getColumnSortList().setLimit(1); listTable.addColumnSortHandler(event -> { GridPreferencesStore gridPreferencesStore = listTable.getGridPreferencesStore(); if (gridPreferencesStore != null && event.getColumnSortList().size() > 0) { ColumnSortList.ColumnSortInfo columnSortInfo = event.getColumnSortList().get(0); if (columnSortInfo != null) { GridSortedColumnPreference gridSortedColumnPreference = new GridSortedColumnPreference(columnSortInfo.getColumn().getDataStoreName(), columnSortInfo.isAscending()); gridPreferencesStore.setGridSortedColumnPreference(gridSortedColumnPreference); } } }); }  void displayNotification(String text); @Override void displayBlockingError(String summary,
                                     String content); @Override void clearBlockingError(); void init(final V presenter); @Override void loadListTable(final String key,
                              final Consumer<ListTable<T>> readyCallback); void showBusyIndicator(final String message); void hideBusyIndicator(); ListTable<T> getListGrid(); abstract void initColumns(ListTable<T> extendedPagedTable); void initSelectionModel(final ListTable<T> extendedPagedTable); abstract String getEmptyTableCaption(); abstract List<String> getInitColumns(); abstract List<String> getBannedColumns(); @Inject void setUserPreferencesService(final Caller<UserPreferencesService> userPreferencesService); Column<T, String> createTextColumn(final String columnId,
                                              final Function<T, String> valueFunction); Column<T, Number> createNumberColumn(final String columnId,
                                                final Function<T, Number> valueFunction); ColumnMeta<T> initChecksColumn(final ListTable<T> extendedPagedTable); ColumnMeta<T> initActionsColumn(); List<ColumnMeta<T>> renameVariables(ListTable<T> extendedPagedTable, List<ColumnMeta<T>> columnMetas); void addDomainSpecifColumns(Set<String> columns); void removeDomainSpecifColumns(); @Override void setSaveFilterCallback(final BiConsumer<String, Consumer<String>> filterNameCallback); @Override void addActiveFilter(final ActiveFilterItem<T> filter); @Override void removeActiveFilter(final ActiveFilterItem<T> filter); @Override void removeAllActiveFilters(); @Override void onResize(); @Override String getSortColumn(); @Override Boolean isSortAscending(); static final String COL_ID_SELECT; static final String COL_ID_ACTIONS; static final int ACTIONS_COLUMN_WIDTH; static final int CHECK_COLUMN_WIDTH; static final int ERROR_COLUMN_WIDTH; }
@Test public void testAddColumnSortHandler() { ListTable<T> listTable = mock(ListTable.class); when(listTable.getGridPreferencesStore()).thenReturn(gridPreferencesStore); when(listTable.getColumnSortList()).thenReturn(new ColumnSortList()); doAnswer(invocation -> { final ColumnSortEvent event = mock(ColumnSortEvent.class); final ColumnSortList columnSortList = new ColumnSortList(); columnSortList.push(getColumn("test")); when(event.getColumnSortList()).thenReturn(columnSortList); ((ColumnSortEvent.Handler) invocation.getArguments()[0]).onColumnSort(event); return null; }).when(listTable).addColumnSortHandler(any()); getView().addColumnSortHandler(listTable); ArgumentCaptor<GridSortedColumnPreference> captor = ArgumentCaptor.forClass(GridSortedColumnPreference.class); verify(gridPreferencesStore).setGridSortedColumnPreference(captor.capture()); verify(listTable, never()).saveGridPreferences(); assertNotNull(captor.getValue()); assertEquals("test", captor.getValue().getDataStoreName()); assertEquals(true, captor.getValue().isAscending()); }