summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:04:33 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:04:33 +0000
commit127ce4575f2b36c64b3ae0c223f9061c038644e4 (patch)
treee9bdfcc28f004c75b00e03e9ef56aa2c16cde319 /pdf-over-gui/src/main/java/at/asit
parent8a8d34e06e6792e04d05828e74dac1f9aef746c1 (diff)
downloadpdf-over-127ce4575f2b36c64b3ae0c223f9061c038644e4.tar.gz
pdf-over-127ce4575f2b36c64b3ae0c223f9061c038644e4.tar.bz2
pdf-over-127ce4575f2b36c64b3ae0c223f9061c038644e4.zip
Add scrollbar to pdf preview
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@114 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java30
1 files changed, 27 insertions, 3 deletions
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 7d461772..9528dd1e 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
@@ -31,7 +31,12 @@ import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.ScrollBar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,12 +62,14 @@ public class PositioningComposite extends StateComposite {
private Frame frame = null;
- int currentPage;
+ int currentPage = 0;
- int numPages;
+ int numPages = 0;
private SignaturePosition position = null;
+ ScrollBar scrollbar = null;
+
/**
* Set the PDF Document to display
* @param document document to display
@@ -84,6 +91,7 @@ public class PositioningComposite extends StateComposite {
else
this.viewer.setDocument(this.pdf);
this.numPages = this.pdf.getNumPages();
+ this.scrollbar.setValues(1, 1, this.numPages + 1, 1, 1, 1);
showPage(this.numPages);
}
@@ -94,11 +102,14 @@ public class PositioningComposite extends StateComposite {
* @param state
*/
public PositioningComposite(Composite parent, int style, State state) {
- super(parent, style | SWT.EMBEDDED, state);
+ super(parent, style | SWT.EMBEDDED | SWT.V_SCROLL, state);
//this.setLayout(null);
+ this.setBounds(0, 0, 10, 10);
+ this.scrollbar = this.getVerticalBar();
this.frame = SWT_AWT.new_Frame(this);
this.addKeyListener(this.keyListener);
this.frame.addMouseWheelListener(this.mouseListener);
+ this.scrollbar.addSelectionListener(this.selectionListener);
}
private KeyListener keyListener = new KeyAdapter() {
@@ -158,8 +169,21 @@ public class PositioningComposite extends StateComposite {
}
};
+ private SelectionListener selectionListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ PositioningComposite.this.showPage(PositioningComposite.this.scrollbar.getSelection());
+ }
+ };
+
void showPage(int page) {
this.currentPage = page;
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ PositioningComposite.this.scrollbar.setSelection(PositioningComposite.this.currentPage);
+ }
+ });
this.viewer.showPage(page);
}