From 18fab2e12d5205159f99695f0439adfbb9d336c9 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:11:57 +0000 Subject: Update Scrollbar on new page git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@189 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../gui/composites/PositioningComposite.java | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'pdf-over-gui/src/main/java/at') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java index 9d3fa864..ef0177c5 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java @@ -301,25 +301,29 @@ public class PositioningComposite extends StateComposite { }; void showPage(int page) { + final int previousPage = this.currentPage; this.currentPage = page; this.getDisplay().syncExec(new Runnable() { @Override public void run() { - PositioningComposite.this.scrollbar.setSelection( - PositioningComposite.this.currentPage); - PositioningComposite.this.lblPage.setText(String.format( - "Page %d of %d", //$NON-NLS-1$ - PositioningComposite.this.currentPage, - PositioningComposite.this.numPages)); - if (PositioningComposite.this.currentPage > PositioningComposite.this.numPages) { - PositioningComposite.this.btnNewPage.setText( - Messages.getString("positioning.removeNewPage")); //$NON-NLS-1$ - PositioningComposite.this.btnNewPage.setSelection(true); - } else { + int currentPage = PositioningComposite.this.currentPage; + int numPages = PositioningComposite.this.numPages; + if ((previousPage > numPages) && (currentPage <= numPages)) { + // Was on new page PositioningComposite.this.btnNewPage.setText( Messages.getString("positioning.newPage")); //$NON-NLS-1$ PositioningComposite.this.btnNewPage.setSelection(false); + PositioningComposite.this.scrollbar.setMaximum(numPages); + } else if ((previousPage <= numPages) && (currentPage > numPages)) { + // Go to new page + PositioningComposite.this.btnNewPage.setText( + Messages.getString("positioning.removeNewPage")); //$NON-NLS-1$ + PositioningComposite.this.btnNewPage.setSelection(true); + PositioningComposite.this.scrollbar.setMaximum(numPages + 1); } + PositioningComposite.this.scrollbar.setSelection(currentPage); + PositioningComposite.this.lblPage.setText(String.format( + "Page %d of %d", currentPage, numPages)); //$NON-NLS-1$ } }); this.viewer.showPage(page); -- cgit v1.2.3