private void updatePageNumber() { int pageIndex = preview.getPageIndex(); int pageCount = preview.getPageCount(); int visiblePageCount = preview.getHorizontalPageCount() * preview.getVerticalPageCount(); String text = (visiblePageCount > 1 ? "Pages " + (pageIndex + 1) + "-" + Math.min(pageCount, pageIndex + visiblePageCount) : "Page " + (pageIndex + 1)) + " of " + pageCount; pageNumber.setText(text); previousPage.setEnabled(pageIndex > 0); nextPage.setEnabled(pageIndex < pageCount - visiblePageCount); shell.layout(new Control[] {pageNumber}); }
private void setPreviewPageIndex(int pageIndex) { preview.setPageIndex(Math.max(Math.min(pageIndex, preview.getPageCount() - 1), 0)); updatePageNumber(); }