summaryrefslogtreecommitdiff
path: root/pdf-over-gui
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-01 15:55:46 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-01 15:55:46 +0200
commitc65a56c81433f8b675b2f5527bfa298ab1894333 (patch)
treeea37c439d23858e8afbf735074b7671e3a915842 /pdf-over-gui
parent9913cb733ce30660fab92e4ef17bf509492ee4a8 (diff)
downloadpdf-over-c65a56c81433f8b675b2f5527bfa298ab1894333.tar.gz
pdf-over-c65a56c81433f8b675b2f5527bfa298ab1894333.tar.bz2
pdf-over-c65a56c81433f8b675b2f5527bfa298ab1894333.zip
anchoring refactor for PositioningComposite
Diffstat (limited to 'pdf-over-gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java55
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java4
3 files changed, 23 insertions, 39 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 dc512d19..e04ad5b5 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
@@ -81,33 +81,23 @@ public class PositioningComposite extends StateComposite {
this.setLayout(new FormLayout());
this.bottomBar = new Composite(this, SWT.NONE);
- FormData fd_bottomBar = new FormData();
- fd_bottomBar.left = new FormAttachment(0);
- fd_bottomBar.right = new FormAttachment(100);
- fd_bottomBar.bottom = new FormAttachment(100);
- this.bottomBar.setLayoutData(fd_bottomBar);
+ StateComposite.anchor(bottomBar).left(0).right(100).bottom(100).set();
this.bottomBar.setLayout(new FormLayout());
this.btnSign = new Button(this.bottomBar, SWT.PUSH);
- this.btnSign.setText(Messages.getString("positioning.sign"));
- FormData fd_btnSign = new FormData();
- fd_btnSign.right = new FormAttachment(100);
- fd_btnSign.top = new FormAttachment(0);
- this.btnSign.setLayoutData(fd_btnSign);
+ StateComposite.anchor(btnSign).right(100).top(0).set();
this.getShell().setDefaultButton(this.btnSign);
- this.btnSign.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setFinalPosition();
- }
- });
this.btnNewPage = new Button(this.bottomBar, SWT.TOGGLE);
- this.btnNewPage.setText(Messages.getString("positioning.newPage"));
- FormData fd_btnNewPage = new FormData();
- fd_btnNewPage.right = new FormAttachment(this.btnSign);
- fd_btnNewPage.top = new FormAttachment(0);
- this.btnNewPage.setLayoutData(fd_btnNewPage);
+ StateComposite.anchor(btnNewPage).right(btnSign).top(0).set();
+
+ this.lblPage = new Label(this.bottomBar, SWT.CENTER);
+ StateComposite.anchor(lblPage).left(0).right(btnNewPage, 5).bottom(100).set();
+
+ this.mainArea = new Composite(this, SWT.EMBEDDED | SWT.V_SCROLL);
+ StateComposite.anchor(mainArea).left(0).right(100).top(0).bottom(bottomBar, -5).set();
+ this.scrollbar = this.mainArea.getVerticalBar();
+
this.btnNewPage.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -119,31 +109,22 @@ public class PositioningComposite extends StateComposite {
}
});
- this.lblPage = new Label(this.bottomBar, SWT.CENTER);
- FormData fd_lblPage = new FormData();
- fd_lblPage.left = new FormAttachment(0);
- fd_lblPage.right = new FormAttachment(this.btnNewPage, 5);
- fd_lblPage.bottom = new FormAttachment(100);
- this.lblPage.setLayoutData(fd_lblPage);
-
- this.mainArea = new Composite(this, SWT.EMBEDDED | SWT.V_SCROLL);
- FormData fd_mainArea = new FormData();
- fd_mainArea.left = new FormAttachment(0);
- fd_mainArea.right = new FormAttachment(100);
- fd_mainArea.top = new FormAttachment(0);
- fd_mainArea.bottom = new FormAttachment(this.bottomBar, -5);
- this.mainArea.setLayoutData(fd_mainArea);
- this.scrollbar = this.mainArea.getVerticalBar();
-
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) {
+ setFinalPosition();
+ }
});
this.scrollbar.addSelectionListener(this.selectionListener);
+
+ reloadResources();
requestFocus();
}
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 82dc6539..37ef9eb5 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
@@ -50,8 +50,7 @@ public class SignaturePanel extends JPanel {
/**
* SLF4J Logger instance
**/
- private static final Logger log = LoggerFactory
- .getLogger(SignaturePanel.class);
+ private static final Logger log = LoggerFactory.getLogger(SignaturePanel.class);
/** Default serial version ID */
private static final long serialVersionUID = 1L;
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
index 7030a2fa..a5ea4e4d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
@@ -104,21 +104,25 @@ public abstract class StateComposite extends Composite {
public AnchorSetter top(Control control, int offset, int alignment) { return top(new FormAttachment(control, offset, alignment)); }
public AnchorSetter top(Control control, int offset) { return top(new FormAttachment(control, offset)); }
+ public AnchorSetter top(Control control) { return top(new FormAttachment(control)); }
public AnchorSetter top(int num, int offset) { return top(new FormAttachment(num, offset)); }
public AnchorSetter top(int num) { return top(new FormAttachment(num)); }
public AnchorSetter left(Control control, int offset, int alignment) { return left(new FormAttachment(control, offset, alignment)); }
public AnchorSetter left(Control control, int offset) { return left(new FormAttachment(control, offset)); }
+ public AnchorSetter left(Control control) { return left(new FormAttachment(control)); }
public AnchorSetter left(int num, int offset) { return left(new FormAttachment(num, offset)); }
public AnchorSetter left(int num) { return left(new FormAttachment(num)); }
public AnchorSetter right(Control control, int offset, int alignment) { return right(new FormAttachment(control, offset, alignment)); }
public AnchorSetter right(Control control, int offset) { return right(new FormAttachment(control, offset)); }
+ public AnchorSetter right(Control control) { return right(new FormAttachment(control)); }
public AnchorSetter right(int num, int offset) { return right(new FormAttachment(num, offset)); }
public AnchorSetter right(int num) { return right(new FormAttachment(num)); }
public AnchorSetter bottom(Control control, int offset, int alignment) { return bottom(new FormAttachment(control, offset, alignment)); }
public AnchorSetter bottom(Control control, int offset) { return bottom(new FormAttachment(control, offset)); }
+ public AnchorSetter bottom(Control control) { return bottom(new FormAttachment(control)); }
public AnchorSetter bottom(int num, int offset) { return bottom(new FormAttachment(num, offset)); }
public AnchorSetter bottom(int num) { return bottom(new FormAttachment(num)); }
}