/** * 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); }
ColumnSortInfo sortedInfo = (sortList.size() == 0) ? null : sortList.get(0); Column<?, ?> sortedColumn = (sortedInfo == null) ? null : sortedInfo.getColumn(); boolean isSortAscending = (sortedInfo == null) ? false : sortedInfo.isAscending();
@Before @SuppressWarnings("unchecked") public void setUp() { when(m2service.listArtifacts(any(JarListPageRequest.class))).thenReturn(response); when(m2service.getPomText(Mockito.anyString())).thenReturn(POM_TEXT); when(response.getTotalRowSize()).thenReturn(RESPONSE_ROWS_COUNT); when(response.isTotalRowSizeExact()).thenReturn(RESPONSE_EXACT_ROWS); when(view.getDisplay()).thenReturn(table); when(table.getVisibleRange()).thenReturn(range); when(range.getStart()).thenReturn(REQUEST_RANGE_START); when(range.getLength()).thenReturn(REQUEST_RANGE_LENGTH); when(view.getColumnSortList()).thenReturn(sortList); when(sortList.size()).thenReturn(1); when(sortList.get(0)).thenReturn(sortInfo); when(sortInfo.isAscending()).thenReturn(REQUEST_SORT_ORDER); when(sortInfo.getColumn()).thenReturn(column); // unchecked when(column.getDataStoreName()).thenReturn(REQUEST_SORT_COLUMN); }
.getColumn().getDataStoreName() : "", ( columnSortList.size() > 0 ) ? columnSortList.get( 0 ) .isAscending() : true ); .getColumn().getDataStoreName() : "" ); currentFilter.setIsAscending((columnSortList.size() > 0) ? columnSortList.get(0) .isAscending() : true);
if ( columnSortList != null && columnSortList.size() > 0 ) { dataSetQueryHelper.setLastOrderedColumn( ( columnSortList.size() > 0 ) ? columnSortList.get( 0 ).getColumn().getDataStoreName() : "" ); dataSetQueryHelper.setLastSortOrder( ( columnSortList.size() > 0 ) && columnSortList.get( 0 ).isAscending() ? SortOrder.ASCENDING : SortOrder.DESCENDING ); } else { dataSetQueryHelper.setLastOrderedColumn( COLUMN_START );
@Override public void getData(final Range visibleRange) { try { final FilterSettings currentTableSettings = getDataSetQueryHelper().getCurrentTableSettings(); currentTableSettings.setServerTemplateId(getSelectedServerTemplate()); currentTableSettings.setTablePageSize(view.getListGrid().getPageSize()); ColumnSortList columnSortList = view.getListGrid().getColumnSortList(); if (columnSortList != null && columnSortList.size() > 0) { getDataSetQueryHelper().setLastOrderedColumn(columnSortList.size() > 0 ? columnSortList.get(0).getColumn().getDataStoreName() : ""); getDataSetQueryHelper().setLastSortOrder(columnSortList.size() > 0 && columnSortList.get(0).isAscending() ? SortOrder.ASCENDING : SortOrder.DESCENDING); } getDataSetQueryHelper().setCurrentTableSettings(currentTableSettings); getDataSetQueryHelper().setDataSetHandler(currentTableSettings); getDataSetQueryHelper().lookupDataSet(visibleRange.getStart(), getDataSetReadyCallback(visibleRange.getStart(), currentTableSettings)); } catch (Exception e) { errorCallback.error(e); setEmptyResults(); } }
@Test public void testColumnSortList() { ArtifactListPresenterImpl presenter = new ArtifactListPresenterImpl(view, new CallerMock<M2RepoService>(m2service), event); presenter.init(); // Change sort parameters and refresh when(sortInfo.isAscending()).thenReturn(!REQUEST_SORT_ORDER); when(column.getDataStoreName()).thenReturn("X"); presenter.search(""); // Verify request verify(m2service).listArtifacts(request.capture()); verifyRequest(request.getValue(), "X", "", REQUEST_RANGE_LENGTH, REQUEST_RANGE_START, !REQUEST_SORT_ORDER); // Row data updated verify(table).setRowCount(RESPONSE_ROWS_COUNT, RESPONSE_EXACT_ROWS); }
@Test public void testColumnSortList() { ArtifactListPresenterImpl presenter = new ArtifactListPresenterImpl(view, new CallerMock<M2RepoService>(m2service), event); presenter.init(); // Change sort parameters and refresh when(sortInfo.isAscending()).thenReturn(!REQUEST_SORT_ORDER); when(column.getDataStoreName()).thenReturn("X"); presenter.search(""); // Verify request verify(m2service).listArtifacts(request.capture()); verifyRequest(request.getValue(), "X", "", REQUEST_RANGE_LENGTH, REQUEST_RANGE_START, !REQUEST_SORT_ORDER); // Row data updated verify(table).setRowCount(RESPONSE_ROWS_COUNT, RESPONSE_EXACT_ROWS); }
/** * Push a {@link Column} onto the list at index zero, setting ascending to * true. If the column already exists, it will be removed from its current * position and placed at the start of the list. If the Column is already at * the start of the list, its ascending bit will be flipped (ascending to * descending and vice versa). * * @param column the {@link Column} to push * @return the {@link ColumnSortInfo} that was pushed */ public ColumnSortInfo push(Column<?, ?> column) { // If the column matches the primary column, toggle the order. boolean ascending = (column == null) ? true : column.isDefaultSortAscending(); if (size() > 0 && get(0).getColumn() == column) { ascending = !get(0).isAscending(); } // Push the new column. ColumnSortInfo toRet = new ColumnSortInfo(column, ascending); push(toRet); return toRet; }
/** * Push a {@link Column} onto the list at index zero, setting ascending to * true. If the column already exists, it will be removed from its current * position and placed at the start of the list. If the Column is already at * the start of the list, its ascending bit will be flipped (ascending to * descending and vice versa). * * @param column the {@link Column} to push * @return the {@link ColumnSortInfo} that was pushed */ public ColumnSortInfo push(Column<?, ?> column) { // If the column matches the primary column, toggle the order. boolean ascending = (column == null) ? true : column.isDefaultSortAscending(); if (size() > 0 && get(0).getColumn() == column) { ascending = !get(0).isAscending(); } // Push the new column. ColumnSortInfo toRet = new ColumnSortInfo(column, ascending); push(toRet); return toRet; }
@Override protected void onRangeChanged(final HasData<M> display) { final Range range = display.getVisibleRange(); final int start = range.getStart(); final Optional<C> loadConfig = createConfig(start, range.getLength(), itemToReload); if (loadConfig.isPresent()) { final C conf = loadConfig.get(); // Get the ColumnSortInfo from the table. final ColumnSortList sortList = getColumnSortList(); if (sortList != null && sortList.size() != 0) { final ColumnSortInfo info = sortList.get(0); conf.setAscending(info.isAscending()); conf.setFieldPath(info.getColumn().getDataStoreName()); } service(this).getAll(conf); } } }.addDataDisplay(this);
/** * Check if this object is equal to another. The objects are equal if the * column and ascending values are the equal. * * @param obj the object to check for equality * @return true if objects are the same */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (!(obj instanceof ColumnSortInfo)) { return false; } ColumnSortInfo other = (ColumnSortInfo) obj; return equalsOrBothNull(getColumn(), other.getColumn()) && isAscending() == other.isAscending(); }
@Before @SuppressWarnings("unchecked") public void setUp() { when(m2service.listArtifacts(any(JarListPageRequest.class))).thenReturn(response); when(m2service.getPomText(Mockito.anyString())).thenReturn(POM_TEXT); when(response.getTotalRowSize()).thenReturn(RESPONSE_ROWS_COUNT); when(response.isTotalRowSizeExact()).thenReturn(RESPONSE_EXACT_ROWS); when(view.getDisplay()).thenReturn(table); when(table.getVisibleRange()).thenReturn(range); when(range.getStart()).thenReturn(REQUEST_RANGE_START); when(range.getLength()).thenReturn(REQUEST_RANGE_LENGTH); when(view.getColumnSortList()).thenReturn(sortList); when(sortList.size()).thenReturn(1); when(sortList.get(0)).thenReturn(sortInfo); when(sortInfo.isAscending()).thenReturn(REQUEST_SORT_ORDER); when(sortInfo.getColumn()).thenReturn(column); // unchecked when(column.getDataStoreName()).thenReturn(REQUEST_SORT_COLUMN); }
/** * Check if this object is equal to another. The objects are equal if the * column and ascending values are the equal. * * @param obj the object to check for equality * @return true if objects are the same */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (!(obj instanceof ColumnSortInfo)) { return false; } ColumnSortInfo other = (ColumnSortInfo) obj; return equalsOrBothNull(getColumn(), other.getColumn()) && isAscending() == other.isAscending(); }
private boolean isSortColumnAscending() { final ColumnSortList columnSortList = view.getColumnSortList(); return (columnSortList == null || columnSortList.size() == 0) ? DEFAULT_ORDER_ASCENDING : columnSortList.get(0).isAscending(); } }
/** * Check if the {@link Column} is sorted in ascending order. * * @return true if ascending, false if descending or not sorted */ public boolean isSortAscending() { return (sortList == null || sortList.size() == 0) ? false : sortList.get(0).isAscending(); }
/** * Check if the {@link Column} is sorted in ascending order. * * @return true if ascending, false if descending or not sorted */ public boolean isSortAscending() { return (sortList == null || sortList.size() == 0) ? false : sortList.get(0).isAscending(); }
/** * Push a {@link Column} onto the list at index zero, setting ascending to * true. If the column already exists, it will be removed from its current * position and placed at the start of the list. If the Column is already at * the start of the list, its ascending bit will be flipped (ascending to * descending and vice versa). * * @param column the {@link Column} to push * @return the {@link ColumnSortInfo} that was pushed */ public ColumnSortInfo push(Column<?, ?> column) { // If the column matches the primary column, toggle the order. boolean ascending = (column == null) ? true : column.isDefaultSortAscending(); if (size() > 0 && get(0).getColumn() == column) { ascending = !get(0).isAscending(); } // Push the new column. ColumnSortInfo toRet = new ColumnSortInfo(column, ascending); push(toRet); return toRet; }
/** * Check if this object is equal to another. The objects are equal if the * column and ascending values are the equal. * * @param obj the object to check for equality * @return true if objects are the same */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (!(obj instanceof ColumnSortInfo)) { return false; } ColumnSortInfo other = (ColumnSortInfo) obj; return equalsOrBothNull(getColumn(), other.getColumn()) && isAscending() == other.isAscending(); }
/** * Check if the {@link Column} is sorted in ascending order. * * @return true if ascending, false if descending or not sorted */ public boolean isSortAscending() { return (sortList == null || sortList.size() == 0) ? false : sortList.get(0).isAscending(); }