From d4260503697d423c0f2e18eec0b37646188e6833 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Mon, 1 Aug 2022 16:46:52 +0200 Subject: some cleanups trying to track down #106 --- .../gui/composites/PositioningComposite.java | 34 +++++++++------------- .../pdfover/gui/composites/SignaturePanel.java | 6 ++-- 2 files changed, 16 insertions(+), 24 deletions(-) (limited to 'pdf-over-gui/src/main') 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 e04ad5b5..118f0b35 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 @@ -98,6 +98,17 @@ public class PositioningComposite extends StateComposite { StateComposite.anchor(mainArea).left(0).right(100).top(0).bottom(bottomBar, -5).set(); this.scrollbar = this.mainArea.getVerticalBar(); + this.frame = SWT_AWT.new_Frame(this.mainArea); + this.frame.addKeyListener(this.keyListener); + this.frame.addMouseWheelListener(this.mouseListener); + + this.viewer = new SignaturePanel(); + this.viewer.setSignaturePlaceholderBorderColor(new Color( + Constants.MAINBAR_ACTIVE_BACK_DARK.getRed(), + Constants.MAINBAR_ACTIVE_BACK_DARK.getGreen(), + Constants.MAINBAR_ACTIVE_BACK_DARK.getBlue())); + this.frame.add(this.viewer, BorderLayout.CENTER); + this.btnNewPage.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -109,12 +120,6 @@ public class PositioningComposite extends StateComposite { } }); - EventQueue.invokeLater(() -> { - getDisplay().syncExec(() -> { - this.frame = SWT_AWT.new_Frame(this.mainArea); - this.frame.addKeyListener(this.keyListener); - this.frame.addMouseWheelListener(this.mouseListener); - }); this.btnSign.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -135,20 +140,9 @@ public class PositioningComposite extends StateComposite { * document to display */ public void displayDocument(final PDDocument document) { - if (this.viewer == null) { - EventQueue.invokeLater(() -> { - this.viewer = new SignaturePanel(document); - this.viewer.setSignaturePlaceholderBorderColor(new Color( - Constants.MAINBAR_ACTIVE_BACK_DARK.getRed(), - Constants.MAINBAR_ACTIVE_BACK_DARK.getGreen(), - Constants.MAINBAR_ACTIVE_BACK_DARK.getBlue())); - this.frame.add(this.viewer, BorderLayout.CENTER); - }); - } else { - EventQueue.invokeLater(() -> { - this.viewer.setDocument(document); - }); - } + EventQueue.invokeLater(() -> { + this.viewer.setDocument(document); + }); if (document != null) { diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java index 37ef9eb5..008a2d2c 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java @@ -113,12 +113,10 @@ public class SignaturePanel extends JPanel { /** * Create a new PagePanel. - * @param pdf the PDFFile to display */ - public SignaturePanel(PDDocument pdf) { + public SignaturePanel() { super(new BorderLayout()); - setDocument(pdf); - setPreferredSize(new Dimension(Constants.DEFAULT_MAINWINDOW_WIDTH, Constants.DEFAULT_MAINWINDOW_HEIGHT - Constants.MAINBAR_HEIGHT)); + setDocument(null); setFocusable(true); addMouseListener(this.mouseListener); addMouseMotionListener(this.mouseListener); -- cgit v1.2.3