From 74338c719f6e983ea0d01362b7aaeabff4b45725 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 31 Oct 2012 16:37:05 +0000 Subject: Update Scrollbar on new page git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12775 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../gui/composites/PositioningComposite.java | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'trunk/pdf-over-gui/src') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java index 9d3fa864..ef0177c5 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java +++ b/trunk/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