@Test public void setupCountersWhenInFirstPageListTest() throws NoSuchFieldException { new FieldSetter(presenter, AbstractArchetypeTablePresenter.class.getDeclaredField("currentPage")) .set(1); presenter.setupCounters(100); assertEquals(1, presenter.currentPage); assertEquals(10, presenter.totalPages); verify(view).enablePreviousButton(false); verify(view).enableNextButton(true); verify(view).enableFirstButton(false); verify(view).enableLastButton(true); }
void setupCounters(final int totalArchetypes) { this.currentPage = Math.max(1, this.currentPage); if (totalArchetypes < (currentPage - 1) * PAGE_SIZE + 1) { currentPage = totalArchetypes / PAGE_SIZE; } final int offset = (currentPage - 1) * PAGE_SIZE; final int fromCount = totalArchetypes > 0 ? offset + 1 : offset; final int toCount = resolveCounter(totalArchetypes, offset + PAGE_SIZE); final int totalCount = resolveCounter(totalArchetypes, 0); final String indicatorText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_ItemCountIndicatorText, fromCount, toCount, totalCount); view.setPageIndicator(indicatorText); totalPages = (int) Math.ceil(totalArchetypes / (float) PAGE_SIZE); final String totalText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_OfN, Math.max(totalPages, 1)); view.setTotalPages(totalText); view.setCurrentPage(currentPage); checkPaginationButtons(); }
AbstractArchetypeTablePresenter implements ArchetypeTablePresenter,
                                                                 HasBusyIndicator { void setupCounters(final int totalArchetypes) { this.currentPage = Math.max(1, this.currentPage); if (totalArchetypes < (currentPage - 1) * PAGE_SIZE + 1) { currentPage = totalArchetypes / PAGE_SIZE; } final int offset = (currentPage - 1) * PAGE_SIZE; final int fromCount = totalArchetypes > 0 ? offset + 1 : offset; final int toCount = resolveCounter(totalArchetypes, offset + PAGE_SIZE); final int totalCount = resolveCounter(totalArchetypes, 0); final String indicatorText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_ItemCountIndicatorText, fromCount, toCount, totalCount); view.setPageIndicator(indicatorText); totalPages = (int) Math.ceil(totalArchetypes / (float) PAGE_SIZE); final String totalText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_OfN, Math.max(totalPages, 1)); view.setTotalPages(totalText); view.setCurrentPage(currentPage); checkPaginationButtons(); } }
AbstractArchetypeTablePresenter implements ArchetypeTablePresenter,
                                                                 HasBusyIndicator { void setupCounters(final int totalArchetypes) { this.currentPage = Math.max(1, this.currentPage); if (totalArchetypes < (currentPage - 1) * PAGE_SIZE + 1) { currentPage = totalArchetypes / PAGE_SIZE; } final int offset = (currentPage - 1) * PAGE_SIZE; final int fromCount = totalArchetypes > 0 ? offset + 1 : offset; final int toCount = resolveCounter(totalArchetypes, offset + PAGE_SIZE); final int totalCount = resolveCounter(totalArchetypes, 0); final String indicatorText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_ItemCountIndicatorText, fromCount, toCount, totalCount); view.setPageIndicator(indicatorText); totalPages = (int) Math.ceil(totalArchetypes / (float) PAGE_SIZE); final String totalText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_OfN, Math.max(totalPages, 1)); view.setTotalPages(totalText); view.setCurrentPage(currentPage); checkPaginationButtons(); } AbstractArchetypeTablePresenter(final View view,
                                           final ArchetypeListPresenter archetypeListPresenter,
                                           final BusyIndicatorView busyIndicatorView,
                                           final TranslationService ts,
                                           final AddArchetypeModalPresenter addArchetypeModalPresenter,
                                           final ArchetypePreferences archetypePreferences,
                                           final Caller<ArchetypeService> archetypeService,
                                           final PreferenceScopeFactory preferenceScopeFactory,
                                           final Promises promises); }
AbstractArchetypeTablePresenter implements ArchetypeTablePresenter,
                                                                 HasBusyIndicator { void setupCounters(final int totalArchetypes) { this.currentPage = Math.max(1, this.currentPage); if (totalArchetypes < (currentPage - 1) * PAGE_SIZE + 1) { currentPage = totalArchetypes / PAGE_SIZE; } final int offset = (currentPage - 1) * PAGE_SIZE; final int fromCount = totalArchetypes > 0 ? offset + 1 : offset; final int toCount = resolveCounter(totalArchetypes, offset + PAGE_SIZE); final int totalCount = resolveCounter(totalArchetypes, 0); final String indicatorText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_ItemCountIndicatorText, fromCount, toCount, totalCount); view.setPageIndicator(indicatorText); totalPages = (int) Math.ceil(totalArchetypes / (float) PAGE_SIZE); final String totalText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_OfN, Math.max(totalPages, 1)); view.setTotalPages(totalText); view.setCurrentPage(currentPage); checkPaginationButtons(); } AbstractArchetypeTablePresenter(final View view,
                                           final ArchetypeListPresenter archetypeListPresenter,
                                           final BusyIndicatorView busyIndicatorView,
                                           final TranslationService ts,
                                           final AddArchetypeModalPresenter addArchetypeModalPresenter,
                                           final ArchetypePreferences archetypePreferences,
                                           final Caller<ArchetypeService> archetypeService,
                                           final PreferenceScopeFactory preferenceScopeFactory,
                                           final Promises promises); void onArchetypeListUpdatedEvent(@Observes final ArchetypeListUpdatedEvent event); abstract Promise<Void> makeDefaultValue(String alias,
                                                   boolean updateList); abstract Promise<Void> loadPreferences(PaginatedArchetypeList paginatedList); abstract boolean canMakeChanges(); @Override void showBusyIndicator(final String message); @Override void hideBusyIndicator(); @Override boolean isSetup(); @Override ArchetypePreferences getPreferences(); @Override boolean isEmpty(); @Override void reset(); @Override Promise<Void> setup(final boolean isRefresh,
                               final Runnable onChangedCallback); View getView(); void setCurrentPage(final int currentPage); void goToPreviousPage(); void goToNextPage(); void goToFirstPage(); void goToLastPage(); void search(final String searchText); void addArchetype(); List<String> getIncluded(); boolean isShowIncludeColumn(); boolean isShowStatusColumn(); boolean isShowDeleteAction(); boolean isShowValidateAction(); void setSelected(final ArchetypeItem archetypeItem,
                            final boolean isSelected); void updateSelectionCounter(); Promise<Void> savePreferences(final PreferenceScope scope,
                                         final boolean updateList); Promise<Void> savePreferences(final PreferenceScopeResolutionStrategyInfo strategyInfo,
                                         final boolean updateList); }
AbstractArchetypeTablePresenter implements ArchetypeTablePresenter,
                                                                 HasBusyIndicator { void setupCounters(final int totalArchetypes) { this.currentPage = Math.max(1, this.currentPage); if (totalArchetypes < (currentPage - 1) * PAGE_SIZE + 1) { currentPage = totalArchetypes / PAGE_SIZE; } final int offset = (currentPage - 1) * PAGE_SIZE; final int fromCount = totalArchetypes > 0 ? offset + 1 : offset; final int toCount = resolveCounter(totalArchetypes, offset + PAGE_SIZE); final int totalCount = resolveCounter(totalArchetypes, 0); final String indicatorText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_ItemCountIndicatorText, fromCount, toCount, totalCount); view.setPageIndicator(indicatorText); totalPages = (int) Math.ceil(totalArchetypes / (float) PAGE_SIZE); final String totalText = ts.format(ArchetypeManagementConstants.ArchetypeManagement_OfN, Math.max(totalPages, 1)); view.setTotalPages(totalText); view.setCurrentPage(currentPage); checkPaginationButtons(); } AbstractArchetypeTablePresenter(final View view,
                                           final ArchetypeListPresenter archetypeListPresenter,
                                           final BusyIndicatorView busyIndicatorView,
                                           final TranslationService ts,
                                           final AddArchetypeModalPresenter addArchetypeModalPresenter,
                                           final ArchetypePreferences archetypePreferences,
                                           final Caller<ArchetypeService> archetypeService,
                                           final PreferenceScopeFactory preferenceScopeFactory,
                                           final Promises promises); void onArchetypeListUpdatedEvent(@Observes final ArchetypeListUpdatedEvent event); abstract Promise<Void> makeDefaultValue(String alias,
                                                   boolean updateList); abstract Promise<Void> loadPreferences(PaginatedArchetypeList paginatedList); abstract boolean canMakeChanges(); @Override void showBusyIndicator(final String message); @Override void hideBusyIndicator(); @Override boolean isSetup(); @Override ArchetypePreferences getPreferences(); @Override boolean isEmpty(); @Override void reset(); @Override Promise<Void> setup(final boolean isRefresh,
                               final Runnable onChangedCallback); View getView(); void setCurrentPage(final int currentPage); void goToPreviousPage(); void goToNextPage(); void goToFirstPage(); void goToLastPage(); void search(final String searchText); void addArchetype(); List<String> getIncluded(); boolean isShowIncludeColumn(); boolean isShowStatusColumn(); boolean isShowDeleteAction(); boolean isShowValidateAction(); void setSelected(final ArchetypeItem archetypeItem,
                            final boolean isSelected); void updateSelectionCounter(); Promise<Void> savePreferences(final PreferenceScope scope,
                                         final boolean updateList); Promise<Void> savePreferences(final PreferenceScopeResolutionStrategyInfo strategyInfo,
                                         final boolean updateList);  }