summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java/at')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java11
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java27
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java31
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java25
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java80
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java20
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java112
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java68
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java66
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java106
10 files changed, 287 insertions, 259 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java
index 0f9fa724..40fe6474 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.commons.Constants;
import at.asit.pdfover.gui.controls.ClickableCanvas;
import at.asit.pdfover.commons.Messages;
+import at.asit.pdfover.gui.utils.SWTUtils;
import at.asit.pdfover.gui.workflow.states.State;
import at.asit.pdfover.signator.BKUs;
@@ -135,7 +136,7 @@ public class BKUSelectionComposite extends StateComposite {
public void setKeystoreEnabled(boolean enabled) {
if (enabled) {
this.btnKS = new Button(this, SWT.NONE);
- StateComposite.anchor(this.btnKS).top(this.btnCard, 10).left(this.btnMobile, 0, SWT.LEFT).right(this.btnCard, 0, SWT.RIGHT).set();
+ SWTUtils.anchor(this.btnKS).top(this.btnCard, 10).left(this.btnMobile, 0, SWT.LEFT).right(this.btnCard, 0, SWT.RIGHT).set();
this.btnKS.addSelectionListener(new KSSelectionListener());
reloadResources();
@@ -157,10 +158,10 @@ public class BKUSelectionComposite extends StateComposite {
this.setLayout(new FormLayout());
ClickableCanvas cc_mobile = new ClickableCanvas(this, SWT.NATIVE | SWT.RESIZE);
- StateComposite.anchor(cc_mobile).right(50, -5).top(40, -20).set();
+ SWTUtils.anchor(cc_mobile).right(50, -5).top(40, -20).set();
Image mobile = new Image(getDisplay(), new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE)));
cc_mobile.setImage(mobile);
- StateComposite.setFontHeight(cc_mobile, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.setFontHeight(cc_mobile, Constants.TEXT_SIZE_BUTTON);
cc_mobile.addMouseListener(new MouseAdapter() {
@Override
@@ -170,10 +171,10 @@ public class BKUSelectionComposite extends StateComposite {
});
ClickableCanvas cc_karte = new ClickableCanvas(this, SWT.NATIVE | SWT.RESIZE);
- StateComposite.anchor(cc_karte).left(50, 5).top(40, -20).set();
+ SWTUtils.anchor(cc_karte).left(50, 5).top(40, -20).set();
Image karte = new Image(getDisplay(), new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_CARD)));
cc_karte.setImage(karte);
- StateComposite.setFontHeight(cc_karte, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.setFontHeight(cc_karte, Constants.TEXT_SIZE_BUTTON);
cc_karte.addMouseListener(new MouseAdapter() {
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
index f5481595..bb214583 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
@@ -36,6 +36,7 @@ import at.asit.pdfover.gui.composites.configuration.KeystoreConfigurationComposi
import at.asit.pdfover.gui.composites.configuration.SimpleConfigurationComposite;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.exceptions.ResumableException;
+import at.asit.pdfover.gui.utils.SWTUtils;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
@@ -129,8 +130,8 @@ public class ConfigurationComposite extends StateComposite {
this.containerComposite = new Composite(this, SWT.FILL | SWT.RESIZE);
this.tabFolder = new TabFolder(this.containerComposite, SWT.NONE);
- StateComposite.anchor(tabFolder).bottom(100, -5).right(100, -5).top(0, 5).left(0, 5).set();
- StateComposite.setFontHeight(tabFolder, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(tabFolder).bottom(100, -5).right(100, -5).top(0, 5).left(0, 5).set();
+ SWTUtils.setFontHeight(tabFolder, Constants.TEXT_SIZE_NORMAL);
this.simpleTabItem = new TabItem(this.tabFolder, SWT.NONE);
@@ -169,8 +170,8 @@ public class ConfigurationComposite extends StateComposite {
this.tabFolder.setSelection(this.simpleTabItem);
this.btnSpeichern = new Button(this, SWT.NONE);
- StateComposite.anchor(btnSpeichern).right(100, -5).bottom(100).set();
- StateComposite.setFontHeight(btnSpeichern, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnSpeichern).right(100, -5).bottom(100).set();
+ SWTUtils.setFontHeight(btnSpeichern, Constants.TEXT_SIZE_BUTTON);
this.btnSpeichern.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -184,8 +185,8 @@ public class ConfigurationComposite extends StateComposite {
getShell().setDefaultButton(this.btnSpeichern);
this.btnAbbrechen = new Button(this, SWT.NONE);
- StateComposite.anchor(btnAbbrechen).right(btnSpeichern, -10).bottom(btnSpeichern, 0, SWT.BOTTOM).set();
- StateComposite.setFontHeight(btnAbbrechen, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnAbbrechen).right(btnSpeichern, -10).bottom(btnSpeichern, 0, SWT.BOTTOM).set();
+ SWTUtils.setFontHeight(btnAbbrechen, Constants.TEXT_SIZE_BUTTON);
this.btnAbbrechen.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -195,7 +196,7 @@ public class ConfigurationComposite extends StateComposite {
}
});
- StateComposite.anchor(containerComposite).top(0, 5).bottom(btnSpeichern, -10).left(0, 5).right(100, -5).set();
+ SWTUtils.anchor(containerComposite).top(0, 5).bottom(btnSpeichern, -10).left(0, 5).right(100, -5).set();
this.containerComposite.setLayout(this.compositeStack);
this.compositeStack.topControl = this.tabFolder;
@@ -426,13 +427,13 @@ public class ConfigurationComposite extends StateComposite {
*/
@Override
public void reloadResources() {
- StateComposite.setLocalizedText(simpleTabItem, "config.Simple");
- StateComposite.setLocalizedText(advancedTabItem, "config.Advanced");
- StateComposite.setLocalizedText(aboutTabItem, "config.About", Constants.APP_NAME);
+ SWTUtils.setLocalizedText(simpleTabItem, "config.Simple");
+ SWTUtils.setLocalizedText(advancedTabItem, "config.Advanced");
+ SWTUtils.setLocalizedText(aboutTabItem, "config.About", Constants.APP_NAME);
if (this.keystoreTabItem != null)
- StateComposite.setLocalizedText(keystoreTabItem, "config.Keystore");
+ SWTUtils.setLocalizedText(keystoreTabItem, "config.Keystore");
- StateComposite.setLocalizedText(btnSpeichern, "common.Save");
- StateComposite.setLocalizedText(btnAbbrechen, "common.Cancel");
+ SWTUtils.setLocalizedText(btnSpeichern, "common.Save");
+ SWTUtils.setLocalizedText(btnAbbrechen, "common.Cancel");
}
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
index 6568addb..c238cc62 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
@@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.commons.Constants;
import at.asit.pdfover.gui.bku.mobile.MobileBKUHelper;
import at.asit.pdfover.gui.exceptions.InvalidPasswordException;
+import at.asit.pdfover.gui.utils.SWTUtils;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.states.State;
@@ -167,44 +168,44 @@ public class MobileBKUEnterNumberComposite extends StateComposite {
10, 10);
});
containerComposite.setLayout(new FormLayout());
- StateComposite.anchor(containerComposite).top(50, -120).bottom(50, 120).left(50, -200).right(50, 200).set();
+ SWTUtils.anchor(containerComposite).top(50, -120).bottom(50, 120).left(50, -200).right(50, 200).set();
this.txt_number = new Text(containerComposite, SWT.SINGLE | SWT.NATIVE | SWT.BORDER);
- StateComposite.anchor(txt_number).bottom(50, -10).left(50, 10).right(100, -20).set();
+ SWTUtils.anchor(txt_number).bottom(50, -10).left(50, 10).right(100, -20).set();
this.txt_number.setEditable(true);
this.lbl_number = new Label(containerComposite, SWT.NATIVE);
this.lbl_number.setAlignment(SWT.RIGHT);
- StateComposite.anchor(lbl_number).bottom(50, -10).right(50, -10).set();
+ SWTUtils.anchor(lbl_number).bottom(50, -10).right(50, -10).set();
ImageData mobileIconData = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
Image mobileIcon = new Image(getDisplay(), mobileIconData);
Label lbl_image = new Label(containerComposite, SWT.NATIVE);
- StateComposite.anchor(lbl_image).top(20, -1 * (mobileIconData.width / 2)).bottom(20, mobileIconData.width / 2).left(0, 10).width(mobileIconData.width).set();
+ SWTUtils.anchor(lbl_image).top(20, -1 * (mobileIconData.width / 2)).bottom(20, mobileIconData.width / 2).left(0, 10).width(mobileIconData.width).set();
lbl_image.setImage(mobileIcon);
this.txt_password = new Text(containerComposite, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER | SWT.NATIVE);
- StateComposite.anchor(txt_password).top(50, 10).left(50, 10).right(100, -20).set();
+ SWTUtils.anchor(txt_password).top(50, 10).left(50, 10).right(100, -20).set();
this.txt_password.setEditable(true);
this.lbl_password = new Label(containerComposite, SWT.NATIVE);
- StateComposite.anchor(lbl_password).top(50, 10).right(50, -10).set();
+ SWTUtils.anchor(lbl_password).top(50, 10).right(50, -10).set();
this.lbl_password.setAlignment(SWT.RIGHT);
this.btn_ok = new Button(containerComposite, SWT.NATIVE);
- StateComposite.anchor(btn_ok).bottom(100, -20).right(100, -20).set();
+ SWTUtils.anchor(btn_ok).bottom(100, -20).right(100, -20).set();
this.btn_ok.addSelectionListener(this.okListener);
this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
- StateComposite.anchor(btn_cancel).bottom(100, -20).right(btn_ok, -10).set();
+ SWTUtils.anchor(btn_cancel).bottom(100, -20).right(btn_ok, -10).set();
this.btn_cancel.addSelectionListener(this.cancelListener);
this.lbl_error = new Label(containerComposite, SWT.WRAP | SWT.NATIVE );
- StateComposite.anchor(lbl_error).bottom(103, -20).left(5, 0).right(btn_cancel, -10).set();
+ SWTUtils.anchor(lbl_error).bottom(103, -20).left(5, 0).right(btn_cancel, -10).set();
this.btn_remember = new Button(containerComposite, SWT.CHECK);
- StateComposite.anchor(btn_remember).right(100, -10).top(0, 5).set();
+ SWTUtils.anchor(btn_remember).right(100, -10).top(0, 5).set();
}
@Override
@@ -279,11 +280,11 @@ public class MobileBKUEnterNumberComposite extends StateComposite {
*/
@Override
public void reloadResources() {
- StateComposite.setLocalizedText(lbl_number, "mobileBKU.number");
- StateComposite.setLocalizedText(lbl_password, "mobileBKU.password");
- StateComposite.setLocalizedText(btn_remember, "mobileBKU.rememberPassword");
- StateComposite.setLocalizedText(btn_ok, "common.Ok");
- StateComposite.setLocalizedText(btn_cancel, "common.Cancel");
+ SWTUtils.setLocalizedText(lbl_number, "mobileBKU.number");
+ SWTUtils.setLocalizedText(lbl_password, "mobileBKU.password");
+ SWTUtils.setLocalizedText(btn_remember, "mobileBKU.rememberPassword");
+ SWTUtils.setLocalizedText(btn_ok, "common.Ok");
+ SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
this.btn_remember.setToolTipText(Messages.getString("mobileBKU.rememberPasswordNote"));
}
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 1336d7b6..7f21904b 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
@@ -42,7 +42,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
+import at.asit.pdfover.gui.utils.SWTUtils;
import at.asit.pdfover.gui.workflow.states.State;
import at.asit.pdfover.signator.SignaturePosition;
@@ -79,21 +79,21 @@ public class PositioningComposite extends StateComposite {
this.setLayout(new FormLayout());
this.bottomBar = new Composite(this, SWT.NONE);
- StateComposite.anchor(bottomBar).left(0).right(100).bottom(100).set();
+ SWTUtils.anchor(bottomBar).left(0).right(100).bottom(100).set();
this.bottomBar.setLayout(new FormLayout());
this.btnSign = new Button(this.bottomBar, SWT.PUSH);
- StateComposite.anchor(btnSign).right(100).top(0).set();
+ SWTUtils.anchor(btnSign).right(100).top(0).set();
this.getShell().setDefaultButton(this.btnSign);
this.btnNewPage = new Button(this.bottomBar, SWT.TOGGLE);
- StateComposite.anchor(btnNewPage).right(btnSign).top(0).set();
+ SWTUtils.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();
+ SWTUtils.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();
+ SWTUtils.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);
@@ -296,20 +296,19 @@ public class PositioningComposite extends StateComposite {
int numPages = this.numPages;
if ((previousPage > numPages) && (currentPage <= numPages)) {
// Was on new page
- StateComposite.setLocalizedText(btnNewPage, "positioning.newPage");
+ SWTUtils.setLocalizedText(btnNewPage, "positioning.newPage");
this.btnNewPage.setSelection(false);
this.bottomBar.layout();
this.scrollbar.setMaximum(numPages + 1);
} else if ((previousPage <= numPages) && (currentPage > numPages)) {
// Go to new page
- StateComposite.setLocalizedText(btnNewPage, "positioning.removeNewPage");
- this.btnNewPage.setText(Messages.getString("positioning.removeNewPage"));
+ SWTUtils.setLocalizedText(btnNewPage, "positioning.removeNewPage");
this.btnNewPage.setSelection(true);
this.bottomBar.layout();
this.scrollbar.setMaximum(numPages + 2);
}
this.scrollbar.setSelection(currentPage);
- StateComposite.setLocalizedText(lblPage, "positioning.page", currentPage, numPages);
+ SWTUtils.setLocalizedText(lblPage, "positioning.page", currentPage, numPages);
});
EventQueue.invokeLater(() -> {
PositioningComposite.this.viewer.showPage(page);
@@ -392,8 +391,8 @@ public class PositioningComposite extends StateComposite {
*/
@Override
public void reloadResources() {
- StateComposite.setLocalizedText(btnNewPage, (this.currentPage <= this.numPages) ? "positioning.newPage" : "positioning.removeNewPage");
- StateComposite.setLocalizedText(btnSign, "positioning.sign");
- StateComposite.setLocalizedText(lblPage, "positioning.page", this.currentPage, this.numPages);
+ SWTUtils.setLocalizedText(btnNewPage, (this.currentPage <= this.numPages) ? "positioning.newPage" : "positioning.removeNewPage");
+ SWTUtils.setLocalizedText(btnSign, "positioning.sign");
+ SWTUtils.setLocalizedText(lblPage, "positioning.page", this.currentPage, this.numPages);
}
}
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 65ca274a..833669ff 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
@@ -15,19 +15,9 @@
*/
package at.asit.pdfover.gui.composites;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Button;
// Imports
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Label;
-import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.states.State;
/**
@@ -62,74 +52,4 @@ public abstract class StateComposite extends Composite {
* Reloads the localizeable resources
*/
public abstract void reloadResources();
-
- public static void disableEventDefault(Control c, int event)
- {
- c.addListener(event, (Event e) -> { e.doit = false; });
- }
-
- public static void setLocalizedText(Item i, String messageKey) { i.setText(Messages.getString(messageKey)); }
- public static void setLocalizedText(Item i, String formatMessageKey, Object... formatArgs) { i.setText(String.format(Messages.getString(formatMessageKey), formatArgs)); }
- public static void setLocalizedText(Label l, String messageKey) { l.setText(Messages.getString(messageKey)); l.requestLayout(); }
- public static void setLocalizedText(Label l, String formatMessageKey, Object... formatArgs) { l.setText(String.format(Messages.getString(formatMessageKey), formatArgs)); l.requestLayout(); }
- public static void setLocalizedText(Button b, String messageKey) { b.setText(Messages.getString(messageKey)); b.requestLayout(); }
- public static void setLocalizedText(Button b, String formatMessageKey, Object... formatArgs) { b.setText(String.format(Messages.getString(formatMessageKey), formatArgs)); b.requestLayout(); }
-
- public static void setFontHeight(Control c, int height)
- {
- FontData[] fD = c.getFont().getFontData();
- fD[0].setHeight(height);
- Font font = new Font(c.getDisplay(), fD[0]);
- c.setFont(font);
- }
-
- public static void setFontStyle(Control c, int style)
- {
- FontData[] fD = c.getFont().getFontData();
- fD[0].setStyle(style);
- Font font = new Font(c.getDisplay(), fD[0]);
- c.setFont(font);
- }
-
- public static class AnchorSetter
- {
- private final Control c;
- private final FormData fd = new FormData();
- public AnchorSetter(Control c) { this.c = c; }
-
- public void set() { this.c.setLayoutData(this.fd); }
-
- public AnchorSetter height(int h) { fd.height = h; return this; }
- public AnchorSetter width(int w) { fd.width = w; return this; }
-
- public AnchorSetter top(FormAttachment a) { fd.top = a; return this; }
- public AnchorSetter left(FormAttachment a) { fd.left = a; return this; }
- public AnchorSetter right(FormAttachment a) { fd.right = a; return this; }
- public AnchorSetter bottom(FormAttachment a) { fd.bottom = a; return this; }
-
- 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)); }
- }
- public static AnchorSetter anchor(Control c) { return new AnchorSetter(c); }
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
index 1f1cc1ba..2582cf17 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
@@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.commons.Constants;
import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.composites.StateComposite;
+import at.asit.pdfover.gui.utils.SWTUtils;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
public class AboutComposite extends ConfigurationCompositeBase {
@@ -39,21 +39,21 @@ public class AboutComposite extends ConfigurationCompositeBase {
setLayout(new FormLayout());
this.lnkAbout = new Link(this, SWT.WRAP);
- StateComposite.anchor(lnkAbout).top(0,5).right(100,-5).left(0,5).set();
- StateComposite.setFontHeight(lnkAbout, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lnkAbout).top(0,5).right(100,-5).left(0,5).set();
+ SWTUtils.setFontHeight(lnkAbout, Constants.TEXT_SIZE_NORMAL);
this.lblDataProtection = new Label(this, SWT.WRAP);
- StateComposite.anchor(lblDataProtection).top(lnkAbout, 15).left(0,5).right(100,-5).set();
- StateComposite.setFontHeight(lblDataProtection, Constants.TEXT_SIZE_BIG);
- StateComposite.setFontStyle(lblDataProtection, SWT.BOLD);
+ SWTUtils.anchor(lblDataProtection).top(lnkAbout, 15).left(0,5).right(100,-5).set();
+ SWTUtils.setFontHeight(lblDataProtection, Constants.TEXT_SIZE_BIG);
+ SWTUtils.setFontStyle(lblDataProtection, SWT.BOLD);
this.lnkDataProtection = new Link(this, SWT.WRAP);
- StateComposite.anchor(lnkDataProtection).top(lblDataProtection,10).left(0,5).right(100,-5).set();
- StateComposite.setFontHeight(lnkDataProtection, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lnkDataProtection).top(lblDataProtection,10).left(0,5).right(100,-5).set();
+ SWTUtils.setFontHeight(lnkDataProtection, Constants.TEXT_SIZE_NORMAL);
this.btnOpenLogDirectory = new Button(this, SWT.NONE);
- StateComposite.anchor(btnOpenLogDirectory).bottom(100, -5).right(100, -5).set();
- StateComposite.setFontHeight(btnOpenLogDirectory, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnOpenLogDirectory).bottom(100, -5).right(100, -5).set();
+ SWTUtils.setFontHeight(btnOpenLogDirectory, Constants.TEXT_SIZE_BUTTON);
this.lnkAbout.addSelectionListener(new SelectionAdapter() {
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
index e9776846..66ad128a 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
@@ -46,13 +46,13 @@ import at.asit.pdfover.commons.Constants;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.commons.Profile;
import at.asit.pdfover.gui.composites.ConfigurationComposite;
-import at.asit.pdfover.gui.composites.StateComposite;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.controls.ErrorMarker;
import at.asit.pdfover.gui.exceptions.InvalidPortException;
import at.asit.pdfover.gui.exceptions.OutputfolderDoesntExistException;
import at.asit.pdfover.gui.exceptions.OutputfolderNotADirectoryException;
+import at.asit.pdfover.gui.utils.SWTUtils;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
import at.asit.pdfover.gui.workflow.states.State;
@@ -130,12 +130,12 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
layout.marginHeight = 10;
layout.marginWidth = 5;
this.grpSignatur.setLayout(layout);
- StateComposite.anchor(grpSignatur).top(0,5).right(100,-5).left(0,5).set();
- StateComposite.setFontHeight(grpSignatur, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(grpSignatur).top(0,5).right(100,-5).left(0,5).set();
+ SWTUtils.setFontHeight(grpSignatur, Constants.TEXT_SIZE_NORMAL);
this.btnAutomatischePositionierung = new Button(this.grpSignatur, SWT.CHECK);
- StateComposite.anchor(btnAutomatischePositionierung).right(100,-5).top(0).left(0,5).set();
- StateComposite.setFontHeight(btnAutomatischePositionierung, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnAutomatischePositionierung).right(100,-5).top(0).left(0,5).set();
+ SWTUtils.setFontHeight(btnAutomatischePositionierung, Constants.TEXT_SIZE_BUTTON);
this.btnAutomatischePositionierung.addSelectionListener(new SelectionAdapter() {
@Override
@@ -146,8 +146,8 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
});
this.btnPdfACompat = new Button(this.grpSignatur, SWT.CHECK);
- StateComposite.anchor(btnPdfACompat).right(100,-5).top(btnAutomatischePositionierung, 5).left(0,5).set();
- StateComposite.setFontHeight(btnPdfACompat, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnPdfACompat).right(100,-5).top(btnAutomatischePositionierung, 5).left(0,5).set();
+ SWTUtils.setFontHeight(btnPdfACompat, Constants.TEXT_SIZE_BUTTON);
this.btnPdfACompat.addSelectionListener(new SelectionAdapter() {
@Override
@@ -158,24 +158,24 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
});
this.lblTransparenz = new Label(this.grpSignatur, SWT.HORIZONTAL);
- StateComposite.anchor(lblTransparenz).top(btnPdfACompat, 5).left(0,5).set();
- StateComposite.setFontHeight(lblTransparenz, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lblTransparenz).top(btnPdfACompat, 5).left(0,5).set();
+ SWTUtils.setFontHeight(lblTransparenz, Constants.TEXT_SIZE_NORMAL);
this.lblTransparenzLinks = new Label(this.grpSignatur, SWT.HORIZONTAL);
- StateComposite.anchor(lblTransparenzLinks).top(lblTransparenz, 5).left(0,15).set();
- StateComposite.setFontHeight(lblTransparenzLinks, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lblTransparenzLinks).top(lblTransparenz, 5).left(0,15).set();
+ SWTUtils.setFontHeight(lblTransparenzLinks, Constants.TEXT_SIZE_NORMAL);
this.lblTransparenzRechts = new Label(this.grpSignatur, SWT.HORIZONTAL);
- StateComposite.anchor(lblTransparenzRechts).top(lblTransparenz, 5).right(100,-5).set();
- StateComposite.setFontHeight(lblTransparenzRechts, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lblTransparenzRechts).top(lblTransparenz, 5).right(100,-5).set();
+ SWTUtils.setFontHeight(lblTransparenzRechts, Constants.TEXT_SIZE_NORMAL);
this.sclTransparenz = new Scale(this.grpSignatur, SWT.HORIZONTAL);
- StateComposite.anchor(sclTransparenz).right(lblTransparenzRechts, -5).top(lblTransparenz, 5).left(lblTransparenzLinks, 5).set();
+ SWTUtils.anchor(sclTransparenz).right(lblTransparenzRechts, -5).top(lblTransparenz, 5).left(lblTransparenzLinks, 5).set();
this.sclTransparenz.setMinimum(0);
this.sclTransparenz.setMaximum(255);
this.sclTransparenz.setIncrement(1);
this.sclTransparenz.setPageIncrement(10);
- StateComposite.disableEventDefault(sclTransparenz, SWT.MouseVerticalWheel);
+ SWTUtils.disableEventDefault(sclTransparenz, SWT.MouseVerticalWheel);
this.sclTransparenz.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -188,12 +188,12 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
layout_grpPlaceholder.marginHeight = 10;
layout_grpPlaceholder.marginWidth = 5;
this.grpPlaceholder.setLayout(layout_grpPlaceholder);
- StateComposite.anchor(grpPlaceholder).top(grpSignatur, 5).left(0,5).right(100,-5).set();
- StateComposite.setFontHeight(grpPlaceholder, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(grpPlaceholder).top(grpSignatur, 5).left(0,5).right(100,-5).set();
+ SWTUtils.setFontHeight(grpPlaceholder, Constants.TEXT_SIZE_NORMAL);
this.btnEnablePlaceholderUsage = new Button(this.grpPlaceholder, SWT.CHECK);
- StateComposite.anchor(btnEnablePlaceholderUsage).top(0,5).left(0,5).right(100,-5).set();
- StateComposite.setFontHeight(btnEnablePlaceholderUsage, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnEnablePlaceholderUsage).top(0,5).left(0,5).right(100,-5).set();
+ SWTUtils.setFontHeight(btnEnablePlaceholderUsage, Constants.TEXT_SIZE_BUTTON);
this.btnEnablePlaceholderUsage.addSelectionListener(new SelectionAdapter() {
@Override
@@ -205,8 +205,8 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
});
this.btnPlatzhalterVerwenden = new Button(this.grpPlaceholder, SWT.RADIO);
- StateComposite.anchor(btnPlatzhalterVerwenden).right(100,-5).top(btnEnablePlaceholderUsage,5).left(0,5).set();
- StateComposite.setFontHeight(btnPlatzhalterVerwenden, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnPlatzhalterVerwenden).right(100,-5).top(btnEnablePlaceholderUsage,5).left(0,5).set();
+ SWTUtils.setFontHeight(btnPlatzhalterVerwenden, Constants.TEXT_SIZE_BUTTON);
this.btnPlatzhalterVerwenden.addSelectionListener(new SelectionAdapter() {
@Override
@@ -217,8 +217,8 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
});
this.btnSignatureFieldsUsage = new Button(this.grpPlaceholder, SWT.RADIO);
- StateComposite.anchor(btnSignatureFieldsUsage).right(100,-5).top(btnPlatzhalterVerwenden, 5).left(0,5).set();
- StateComposite.setFontHeight(btnSignatureFieldsUsage, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnSignatureFieldsUsage).right(100,-5).top(btnPlatzhalterVerwenden, 5).left(0,5).set();
+ SWTUtils.setFontHeight(btnSignatureFieldsUsage, Constants.TEXT_SIZE_BUTTON);
this.btnSignatureFieldsUsage.addSelectionListener(new SelectionAdapter() {
@Override
@@ -233,13 +233,13 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
layout.marginHeight = 10;
layout.marginWidth = 5;
this.grpBkuAuswahl.setLayout(layout);
- StateComposite.anchor(grpBkuAuswahl).top(grpPlaceholder, 5).left(0,5).right(100,-5).set();
- StateComposite.setFontHeight(grpBkuAuswahl, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(grpBkuAuswahl).top(grpPlaceholder, 5).left(0,5).right(100,-5).set();
+ SWTUtils.setFontHeight(grpBkuAuswahl, Constants.TEXT_SIZE_NORMAL);
this.cmbBKUAuswahl = new Combo(this.grpBkuAuswahl, SWT.READ_ONLY);
- StateComposite.anchor(cmbBKUAuswahl).right(100,-5).top(0).left(0,5).set();
- StateComposite.setFontHeight(cmbBKUAuswahl, Constants.TEXT_SIZE_NORMAL);
- StateComposite.disableEventDefault(cmbBKUAuswahl, SWT.MouseVerticalWheel);
+ SWTUtils.anchor(cmbBKUAuswahl).right(100,-5).top(0).left(0,5).set();
+ SWTUtils.setFontHeight(cmbBKUAuswahl, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.disableEventDefault(cmbBKUAuswahl, SWT.MouseVerticalWheel);
this.bkuStrings = Arrays.stream(BKUs.values()).map(s -> Messages.getString("BKU."+s)).collect(Collectors.toList());
this.cmbBKUAuswahl.setItems(bkuStrings.toArray(new String[0]));
@@ -257,8 +257,8 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
});
this.btnKeystoreEnabled = new Button(this.grpBkuAuswahl, SWT.CHECK);
- StateComposite.anchor(btnKeystoreEnabled).right(100,-5).top(cmbBKUAuswahl,5).left(0,5).set();
- StateComposite.setFontHeight(btnKeystoreEnabled, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnKeystoreEnabled).right(100,-5).top(cmbBKUAuswahl,5).left(0,5).set();
+ SWTUtils.setFontHeight(btnKeystoreEnabled, Constants.TEXT_SIZE_BUTTON);
this.btnKeystoreEnabled.addSelectionListener(new SelectionAdapter() {
@Override
@@ -270,15 +270,15 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
this.grpSpeicherort = new Group(this, SWT.NONE);
grpSpeicherort.setLayout(new GridLayout(3, false));
- StateComposite.anchor(grpSpeicherort).left(0,5).top(grpBkuAuswahl, 5).right(100,-5).set();
- StateComposite.setFontHeight(grpSpeicherort, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(grpSpeicherort).left(0,5).top(grpBkuAuswahl, 5).right(100,-5).set();
+ SWTUtils.setFontHeight(grpSpeicherort, Constants.TEXT_SIZE_NORMAL);
this.lblDefaultOutputFolder = new Label(this.grpSpeicherort, SWT.NONE);
- StateComposite.setFontHeight(lblDefaultOutputFolder, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(lblDefaultOutputFolder, Constants.TEXT_SIZE_NORMAL);
this.txtOutputFolder = new Text(this.grpSpeicherort, SWT.BORDER);
txtOutputFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- StateComposite.setFontHeight(txtOutputFolder, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(txtOutputFolder, Constants.TEXT_SIZE_NORMAL);
this.txtOutputFolder.addFocusListener(new FocusAdapter() {
@Override
@@ -289,7 +289,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
this.btnBrowse = new Button(this.grpSpeicherort, SWT.NONE);
btnBrowse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- StateComposite.setFontHeight(btnBrowse, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.setFontHeight(btnBrowse, Constants.TEXT_SIZE_BUTTON);
this.btnBrowse.addSelectionListener(new SelectionAdapter() {
@Override
@@ -319,11 +319,11 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
this.lblSaveFilePostFix = new Label(this.grpSpeicherort, SWT.NONE);
lblSaveFilePostFix.setText(Messages.getString("AdvancedConfigurationComposite.lblSaveFilePostFix.text"));
- StateComposite.setFontHeight(lblSaveFilePostFix, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(lblSaveFilePostFix, Constants.TEXT_SIZE_NORMAL);
this.txtSaveFilePostFix = new Text(this.grpSpeicherort, SWT.BORDER);
txtSaveFilePostFix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- StateComposite.setFontHeight(txtSaveFilePostFix, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(txtSaveFilePostFix, Constants.TEXT_SIZE_NORMAL);
this.txtSaveFilePostFix.addFocusListener(new FocusAdapter() {
@Override
@@ -337,14 +337,14 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
layout_grpLocaleAuswahl.marginHeight = 10;
layout_grpLocaleAuswahl.marginWidth = 5;
this.grpLocaleAuswahl.setLayout(layout_grpLocaleAuswahl);
- StateComposite.anchor(grpLocaleAuswahl).top(grpSpeicherort, 5).left(0,5).right(100,-5).set();
- StateComposite.setFontHeight(grpLocaleAuswahl, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(grpLocaleAuswahl).top(grpSpeicherort, 5).left(0,5).right(100,-5).set();
+ SWTUtils.setFontHeight(grpLocaleAuswahl, Constants.TEXT_SIZE_NORMAL);
this.cmbLocaleAuswahl = new Combo(this.grpLocaleAuswahl, SWT.READ_ONLY);
- StateComposite.anchor(cmbLocaleAuswahl).right(100,-5).top(0).left(0,5).set();
- StateComposite.setFontHeight(cmbLocaleAuswahl, Constants.TEXT_SIZE_NORMAL);;
+ SWTUtils.anchor(cmbLocaleAuswahl).right(100,-5).top(0).left(0,5).set();
+ SWTUtils.setFontHeight(cmbLocaleAuswahl, Constants.TEXT_SIZE_NORMAL);;
this.cmbLocaleAuswahl.setItems(Arrays.stream(Constants.SUPPORTED_LOCALES).map(l -> l.getDisplayLanguage()).toArray(String[]::new));
- StateComposite.disableEventDefault(cmbLocaleAuswahl, SWT.MouseVerticalWheel);
+ SWTUtils.disableEventDefault(cmbLocaleAuswahl, SWT.MouseVerticalWheel);
this.cmbLocaleAuswahl.addSelectionListener(new SelectionAdapter() {
@Override
@@ -363,12 +363,12 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
layout_grpUpdateCheck.marginHeight = 10;
layout_grpUpdateCheck.marginWidth = 5;
this.grpUpdateCheck.setLayout(layout_grpUpdateCheck);
- StateComposite.anchor(grpUpdateCheck).top(grpLocaleAuswahl, 5).left(0,5).right(100,-5).set();
- StateComposite.setFontHeight(grpUpdateCheck, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(grpUpdateCheck).top(grpLocaleAuswahl, 5).left(0,5).right(100,-5).set();
+ SWTUtils.setFontHeight(grpUpdateCheck, Constants.TEXT_SIZE_NORMAL);
this.btnUpdateCheck = new Button(this.grpUpdateCheck, SWT.CHECK);
- StateComposite.anchor(btnUpdateCheck).right(100,-5).top(0).left(0,5).set();
- StateComposite.setFontHeight(btnUpdateCheck, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnUpdateCheck).right(100,-5).top(0).left(0,5).set();
+ SWTUtils.setFontHeight(btnUpdateCheck, Constants.TEXT_SIZE_BUTTON);
this.btnUpdateCheck.addSelectionListener(new SelectionAdapter() {
@Override
@@ -378,9 +378,9 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
});
this.grpProxy = new Group(this, SWT.NONE);
- StateComposite.anchor(grpProxy).right(100,-5).top(grpUpdateCheck, 5).left(0,5).set();
+ SWTUtils.anchor(grpProxy).right(100,-5).top(grpUpdateCheck, 5).left(0,5).set();
this.grpProxy.setLayout(new GridLayout(2, false));
- StateComposite.setFontHeight(grpProxy, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(grpProxy, Constants.TEXT_SIZE_NORMAL);
this.lblProxyHost = new Label(this.grpProxy, SWT.NONE);
do { /* grid positioning */
@@ -389,18 +389,18 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
this.lblProxyHost.setLayoutData(gd_lblProxyHost);
this.lblProxyHost.setBounds(0, 0, 57, 15);
} while (false);
- StateComposite.setFontHeight(lblProxyHost, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(lblProxyHost, Constants.TEXT_SIZE_NORMAL);
Composite compProxyHostContainer = new Composite(this.grpProxy, SWT.NONE);
compProxyHostContainer.setLayout(new FormLayout());
compProxyHostContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
this.txtProxyHost = new Text(compProxyHostContainer, SWT.BORDER);
- StateComposite.anchor(txtProxyHost).right(100,-42).top(0).left(0,5).set();
- StateComposite.setFontHeight(txtProxyHost, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(txtProxyHost).right(100,-42).top(0).left(0,5).set();
+ SWTUtils.setFontHeight(txtProxyHost, Constants.TEXT_SIZE_NORMAL);
this.proxyHostErrorMarker = new ErrorMarker(compProxyHostContainer, SWT.NONE, "");
- StateComposite.anchor(proxyHostErrorMarker).left(100,-32).right(100).top(0).bottom(0,32).set();
+ SWTUtils.anchor(proxyHostErrorMarker).left(100,-32).right(100).top(0).bottom(0,32).set();
this.proxyHostErrorMarker.setVisible(false);
this.txtProxyHost.addFocusListener(new FocusAdapter() {
@@ -418,15 +418,15 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
this.lblProxyPort = new Label(this.grpProxy, SWT.NONE);
this.lblProxyPort.setBounds(0, 0, 57, 15);
- StateComposite.setFontHeight(lblProxyPort, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(lblProxyPort, Constants.TEXT_SIZE_NORMAL);
Composite compProxyPortContainer = new Composite(this.grpProxy, SWT.NONE);
compProxyPortContainer.setLayout(new FormLayout());
compProxyPortContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
this.txtProxyPort = new Text(compProxyPortContainer, SWT.BORDER);
- StateComposite.anchor(txtProxyPort).top(0,0).left(0,5).right(100,-42).set();
- StateComposite.setFontHeight(txtProxyPort, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(txtProxyPort).top(0,0).left(0,5).right(100,-42).set();
+ SWTUtils.setFontHeight(txtProxyPort, Constants.TEXT_SIZE_NORMAL);
this.txtProxyPort.addTraverseListener(e -> {
if (e.detail == SWT.TRAVERSE_RETURN) {
@@ -435,7 +435,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
});
this.txtProxyPortErrorMarker = new ErrorMarker(compProxyPortContainer, SWT.NONE, "");
- StateComposite.anchor(txtProxyPortErrorMarker).left(100,-32).right(100).top(0).bottom(0,32).set();
+ SWTUtils.anchor(txtProxyPortErrorMarker).left(100,-32).right(100).top(0).bottom(0,32).set();
this.txtProxyPortErrorMarker.setVisible(false);
this.txtProxyPort.addFocusListener(new FocusAdapter() {
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java
index 14100128..1d1efb06 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java
@@ -50,7 +50,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.composites.StateComposite;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.controls.PasswordInputDialog;
@@ -60,6 +59,7 @@ import at.asit.pdfover.gui.exceptions.KeystoreAliasNoKeyException;
import at.asit.pdfover.gui.exceptions.KeystoreDoesntExistException;
import at.asit.pdfover.gui.exceptions.KeystoreKeyPasswordException;
import at.asit.pdfover.gui.keystore.KeystoreUtils;
+import at.asit.pdfover.gui.utils.SWTUtils;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory.KeyStorePassStorageType;
@@ -112,70 +112,70 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
layout.marginWidth = 5;
this.grpKeystore.setLayout(layout);
- StateComposite.anchor(grpKeystore).top(0,5).left(0,5).right(100,-5).set();
- StateComposite.setFontHeight(this.grpKeystore, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(grpKeystore).top(0,5).left(0,5).right(100,-5).set();
+ SWTUtils.setFontHeight(this.grpKeystore, Constants.TEXT_SIZE_NORMAL);
this.lblKeystoreFile = new Label(this.grpKeystore, SWT.NONE);
- StateComposite.anchor(lblKeystoreFile).top(0).left(0,5).set();
+ SWTUtils.anchor(lblKeystoreFile).top(0).left(0,5).set();
FormData fd_lblKeystoreFile = new FormData();
fd_lblKeystoreFile.top = new FormAttachment(0);
fd_lblKeystoreFile.left = new FormAttachment(0, 5);
this.lblKeystoreFile.setLayoutData(fd_lblKeystoreFile);
- StateComposite.setFontHeight(lblKeystoreFile, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(lblKeystoreFile, Constants.TEXT_SIZE_NORMAL);
this.txtKeystoreFile = new Text(grpKeystore, SWT.BORDER);
this.btnBrowse = new Button(grpKeystore, SWT.NONE);
- StateComposite.setFontHeight(txtKeystoreFile, Constants.TEXT_SIZE_NORMAL);
- StateComposite.setFontHeight(btnBrowse, Constants.TEXT_SIZE_BUTTON);
- StateComposite.anchor(txtKeystoreFile).top(lblKeystoreFile, 5).left(0,15).right(btnBrowse,-5).set();
- StateComposite.anchor(btnBrowse).top(lblKeystoreFile, 5).right(100,-5).set();
+ SWTUtils.setFontHeight(txtKeystoreFile, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(btnBrowse, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(txtKeystoreFile).top(lblKeystoreFile, 5).left(0,15).right(btnBrowse,-5).set();
+ SWTUtils.anchor(btnBrowse).top(lblKeystoreFile, 5).right(100,-5).set();
this.lblKeystoreType = new Label(grpKeystore, SWT.NONE);
- StateComposite.anchor(lblKeystoreType).top(txtKeystoreFile, 5).left(0,5).set();
- StateComposite.setFontHeight(lblKeystoreType, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lblKeystoreType).top(txtKeystoreFile, 5).left(0,5).set();
+ SWTUtils.setFontHeight(lblKeystoreType, Constants.TEXT_SIZE_NORMAL);
this.btnLoad = new Button(this.grpKeystore, SWT.NONE);
- StateComposite.anchor(btnLoad).top(lblKeystoreType, 5).right(100,-5).set();
- StateComposite.setFontHeight(btnLoad, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnLoad).top(lblKeystoreType, 5).right(100,-5).set();
+ SWTUtils.setFontHeight(btnLoad, Constants.TEXT_SIZE_BUTTON);
this.cmbKeystoreType = new Combo(grpKeystore, SWT.READ_ONLY);
- StateComposite.anchor(cmbKeystoreType).top(lblKeystoreType, 5).left(0,15).right(btnLoad, -5).set();
- StateComposite.setFontHeight(cmbKeystoreType, Constants.TEXT_SIZE_NORMAL);
- StateComposite.disableEventDefault(cmbKeystoreType, SWT.MouseVerticalWheel);
+ SWTUtils.anchor(cmbKeystoreType).top(lblKeystoreType, 5).left(0,15).right(btnLoad, -5).set();
+ SWTUtils.setFontHeight(cmbKeystoreType, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.disableEventDefault(cmbKeystoreType, SWT.MouseVerticalWheel);
this.lblKeystoreAlias = new Label(grpKeystore, SWT.NONE);
- StateComposite.anchor(lblKeystoreAlias).top(cmbKeystoreType, 5).left(0, 5).set();
- StateComposite.setFontHeight(lblKeystoreAlias, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lblKeystoreAlias).top(cmbKeystoreType, 5).left(0, 5).set();
+ SWTUtils.setFontHeight(lblKeystoreAlias, Constants.TEXT_SIZE_NORMAL);
this.cmbKeystoreAlias = new Combo(grpKeystore, SWT.NONE);
- StateComposite.anchor(cmbKeystoreAlias).top(lblKeystoreAlias, 5).left(0,15).right(100,-5).set();
- StateComposite.setFontHeight(cmbKeystoreAlias, Constants.TEXT_SIZE_NORMAL);
- StateComposite.disableEventDefault(cmbKeystoreAlias, SWT.MouseVerticalWheel);
+ SWTUtils.anchor(cmbKeystoreAlias).top(lblKeystoreAlias, 5).left(0,15).right(100,-5).set();
+ SWTUtils.setFontHeight(cmbKeystoreAlias, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.disableEventDefault(cmbKeystoreAlias, SWT.MouseVerticalWheel);
this.lblKeystorePassStoreType = new Label(this.grpKeystore, SWT.NONE);
- StateComposite.anchor(lblKeystorePassStoreType).top(cmbKeystoreAlias, 5).left(0,5).set();
- StateComposite.setFontHeight(lblKeystorePassStoreType, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lblKeystorePassStoreType).top(cmbKeystoreAlias, 5).left(0,5).set();
+ SWTUtils.setFontHeight(lblKeystorePassStoreType, Constants.TEXT_SIZE_NORMAL);
this.cmbKeystorePassStoreType = new Combo(grpKeystore, SWT.READ_ONLY);
- StateComposite.anchor(cmbKeystorePassStoreType).top(lblKeystorePassStoreType, 5).left(0,15).right(100,-5).set();
- StateComposite.setFontHeight(cmbKeystorePassStoreType, Constants.TEXT_SIZE_NORMAL);
- StateComposite.disableEventDefault(cmbKeystorePassStoreType, SWT.MouseVerticalWheel);
+ SWTUtils.anchor(cmbKeystorePassStoreType).top(lblKeystorePassStoreType, 5).left(0,15).right(100,-5).set();
+ SWTUtils.setFontHeight(cmbKeystorePassStoreType, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.disableEventDefault(cmbKeystorePassStoreType, SWT.MouseVerticalWheel);
this.lblKeystoreStorePass = new Label(grpKeystore, SWT.NONE);
- StateComposite.anchor(lblKeystoreStorePass).top(cmbKeystorePassStoreType, 5).left(0,5).set();
- StateComposite.setFontHeight(lblKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lblKeystoreStorePass).top(cmbKeystorePassStoreType, 5).left(0,5).set();
+ SWTUtils.setFontHeight(lblKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
this.txtKeystoreStorePass = new Text(grpKeystore, SWT.BORDER | SWT.PASSWORD);
- StateComposite.anchor(txtKeystoreStorePass).right(100, -5).top(lblKeystoreStorePass, 5).left(0,15).set();
- StateComposite.setFontHeight(txtKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(txtKeystoreStorePass).right(100, -5).top(lblKeystoreStorePass, 5).left(0,15).set();
+ SWTUtils.setFontHeight(txtKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
this.lblKeystoreKeyPass = new Label(grpKeystore, SWT.NONE);
- StateComposite.anchor(lblKeystoreKeyPass).top(txtKeystoreStorePass, 5).left(0,5).set();
- StateComposite.setFontHeight(lblKeystoreKeyPass, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(lblKeystoreKeyPass).top(txtKeystoreStorePass, 5).left(0,5).set();
+ SWTUtils.setFontHeight(lblKeystoreKeyPass, Constants.TEXT_SIZE_NORMAL);
this.txtKeystoreKeyPass = new Text(grpKeystore, SWT.BORDER | SWT.PASSWORD);
- StateComposite.anchor(txtKeystoreKeyPass).top(lblKeystoreKeyPass, 5).left(0,15).right(100,-5).set();
- StateComposite.setFontHeight(txtKeystoreKeyPass, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(txtKeystoreKeyPass).top(lblKeystoreKeyPass, 5).left(0,15).right(100,-5).set();
+ SWTUtils.setFontHeight(txtKeystoreKeyPass, Constants.TEXT_SIZE_NORMAL);
this.txtKeystoreFile.addFocusListener(new FocusAdapter() {
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
index 767f21d7..9aedf686 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
@@ -55,12 +55,12 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.commons.Constants;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.commons.Profile;
-import at.asit.pdfover.gui.composites.StateComposite;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.controls.ErrorMarker;
import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
import at.asit.pdfover.gui.utils.ImageConverter;
+import at.asit.pdfover.gui.utils.SWTUtils;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
import at.asit.pdfover.gui.workflow.states.State;
@@ -116,25 +116,25 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
setLayout(new FormLayout());
this.grpHandySignatur = new Group(this, SWT.NONE | SWT.RESIZE);
- StateComposite.anchor(grpHandySignatur).right(100,-5).left(0,5).top(0,5).set();
+ SWTUtils.anchor(grpHandySignatur).right(100,-5).left(0,5).top(0,5).set();
grpHandySignatur.setLayout(new GridLayout(2, false));
- StateComposite.setFontHeight(grpHandySignatur, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(grpHandySignatur, Constants.TEXT_SIZE_NORMAL);
this.lblMobileNumber = new Label(grpHandySignatur, SWT.NONE | SWT.RESIZE);
this.lblMobileNumber.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
- StateComposite.setFontHeight(lblMobileNumber, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(lblMobileNumber, Constants.TEXT_SIZE_NORMAL);
Composite compMobileNumerContainer = new Composite(this.grpHandySignatur, SWT.NONE);
compMobileNumerContainer.setLayout(new FormLayout());
compMobileNumerContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
this.txtMobileNumber = new Text(compMobileNumerContainer, SWT.BORDER | SWT.RESIZE);
- StateComposite.anchor(txtMobileNumber).left(0,5).right(100,-42).top(0).set();
- StateComposite.setFontHeight(txtMobileNumber, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(txtMobileNumber).left(0,5).right(100,-42).top(0).set();
+ SWTUtils.setFontHeight(txtMobileNumber, Constants.TEXT_SIZE_NORMAL);
this.txtMobileNumberErrorMarker = new ErrorMarker(compMobileNumerContainer, SWT.NONE, "");
this.txtMobileNumberErrorMarker.setVisible(false);
- StateComposite.anchor(txtMobileNumberErrorMarker).left(100,-32).right(100).top(0).bottom(0,32).set();
+ SWTUtils.anchor(txtMobileNumberErrorMarker).left(100,-32).right(100).top(0).bottom(0,32).set();
this.txtMobileNumber.addTraverseListener(e -> {
if (e.detail == SWT.TRAVERSE_RETURN) {
@@ -150,14 +150,14 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
});
this.grpSignatureProfile = new Group(this, SWT.NONE);
- StateComposite.anchor(grpSignatureProfile).right(100,-5).left(0,5).top(grpHandySignatur, 5).set();
+ SWTUtils.anchor(grpSignatureProfile).right(100,-5).left(0,5).top(grpHandySignatur, 5).set();
this.grpSignatureProfile.setLayout(new FormLayout());
- StateComposite.setFontHeight(grpSignatureProfile, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(grpSignatureProfile, Constants.TEXT_SIZE_NORMAL);
this.cmbSignatureProfiles = new Combo(this.grpSignatureProfile, SWT.READ_ONLY);
- StateComposite.anchor(cmbSignatureProfiles).left(0,10).right(100,-10).top(0,10).bottom(100,-10).set();
- StateComposite.setFontHeight(cmbSignatureProfiles, Constants.TEXT_SIZE_NORMAL);
- StateComposite.disableEventDefault(cmbSignatureProfiles, SWT.MouseVerticalWheel);
+ SWTUtils.anchor(cmbSignatureProfiles).left(0,10).right(100,-10).top(0,10).bottom(100,-10).set();
+ SWTUtils.setFontHeight(cmbSignatureProfiles, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.disableEventDefault(cmbSignatureProfiles, SWT.MouseVerticalWheel);
this.cmbSignatureProfiles.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -171,14 +171,14 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
});
this.grpSignatureLang = new Group(this, SWT.NONE);
- StateComposite.anchor(grpSignatureLang).right(100,-5).top(grpSignatureProfile, 5).left(0,5).set();
+ SWTUtils.anchor(grpSignatureLang).right(100,-5).top(grpSignatureProfile, 5).left(0,5).set();
this.grpSignatureLang.setLayout(new FormLayout());
- StateComposite.setFontHeight(grpSignatureLang, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(grpSignatureLang, Constants.TEXT_SIZE_NORMAL);
this.cmbSignatureLang = new Combo(this.grpSignatureLang, SWT.READ_ONLY);
- StateComposite.anchor(cmbSignatureLang).left(0,10).right(100,-10).top(0,10).bottom(100,-10).set();
- StateComposite.setFontHeight(cmbSignatureLang, Constants.TEXT_SIZE_NORMAL);
- StateComposite.disableEventDefault(cmbSignatureLang, SWT.MouseVerticalWheel);
+ SWTUtils.anchor(cmbSignatureLang).left(0,10).right(100,-10).top(0,10).bottom(100,-10).set();
+ SWTUtils.setFontHeight(cmbSignatureLang, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.disableEventDefault(cmbSignatureLang, SWT.MouseVerticalWheel);
this.cmbSignatureLang.setItems(Arrays.stream(Constants.SUPPORTED_LOCALES).map(l -> l.getDisplayLanguage()).toArray(String[]::new));
this.cmbSignatureLang.addSelectionListener(new SelectionAdapter() {
@@ -193,9 +193,9 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
});
this.grpSignatureNote = new Group(this, SWT.NONE);
- StateComposite.anchor(grpSignatureNote).right(100,-5).top(grpSignatureLang,5).left(0,5).set();
+ SWTUtils.anchor(grpSignatureNote).right(100,-5).top(grpSignatureLang,5).left(0,5).set();
this.grpSignatureNote.setLayout(new GridLayout(2, false));
- StateComposite.setFontHeight(grpSignatureNote, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(grpSignatureNote, Constants.TEXT_SIZE_NORMAL);
this.lblSignatureNote = new Label(this.grpSignatureNote, SWT.NONE);
do { /* grid positioning */
@@ -205,15 +205,15 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
this.lblSignatureNote.setLayoutData(gd_lblSignatureNote);
this.lblSignatureNote.setBounds(0, 0, 57, 15);
} while (false);
- StateComposite.setFontHeight(lblSignatureNote, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(lblSignatureNote, Constants.TEXT_SIZE_NORMAL);
Composite compSignatureNoteContainer = new Composite(this.grpSignatureNote, SWT.NONE);
compSignatureNoteContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
compSignatureNoteContainer.setLayout(new FormLayout());
this.txtSignatureNote = new Text(compSignatureNoteContainer, SWT.BORDER);
- StateComposite.anchor(txtSignatureNote).top(0,0).left(0,5).right(100,-42).set();
- StateComposite.setFontHeight(txtSignatureNote, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(txtSignatureNote).top(0,0).left(0,5).right(100,-42).set();
+ SWTUtils.setFontHeight(txtSignatureNote, Constants.TEXT_SIZE_NORMAL);
this.txtSignatureNote.addFocusListener(new FocusAdapter() {
@Override
@@ -233,8 +233,8 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
compSignatureNoteButtonContainer.setLayout(new FormLayout());
this.btnSignatureNoteDefault = new Button(compSignatureNoteButtonContainer, SWT.NONE);
- StateComposite.anchor(btnSignatureNoteDefault).top(0,0).right(100,-42).set();
- StateComposite.setFontHeight(btnSignatureNoteDefault, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnSignatureNoteDefault).top(0,0).right(100,-42).set();
+ SWTUtils.setFontHeight(btnSignatureNoteDefault, Constants.TEXT_SIZE_BUTTON);
this.btnSignatureNoteDefault.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -243,26 +243,26 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
});
this.grpPreview = new Group(this, SWT.NONE);
- StateComposite.anchor(grpPreview).left(0,5).right(100,-5).top(grpSignatureNote, 5).height(250).set();
+ SWTUtils.anchor(grpPreview).left(0,5).right(100,-5).top(grpSignatureNote, 5).height(250).set();
this.grpPreview.setLayout(new FormLayout());
- StateComposite.setFontHeight(grpPreview, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.setFontHeight(grpPreview, Constants.TEXT_SIZE_NORMAL);
Composite containerComposite = new Composite(this.grpPreview, SWT.NONE);
- StateComposite.anchor(containerComposite).left(0).right(100).top(0).bottom(100).set();
+ SWTUtils.anchor(containerComposite).left(0).right(100).top(0).bottom(100).set();
containerComposite.setLayout(new FormLayout());
this.btnBrowseLogo = new Button(containerComposite, SWT.NONE);
- StateComposite.anchor(btnBrowseLogo).top(0,5).right(50,-5).set();
- StateComposite.setFontHeight(btnBrowseLogo, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnBrowseLogo).top(0,5).right(50,-5).set();
+ SWTUtils.setFontHeight(btnBrowseLogo, Constants.TEXT_SIZE_BUTTON);
this.btnClearImage = new Button(containerComposite, SWT.NATIVE);
- StateComposite.anchor(btnClearImage).top(0,5).left(50, 5).set();
- StateComposite.setFontHeight(btnClearImage, Constants.TEXT_SIZE_BUTTON);
+ SWTUtils.anchor(btnClearImage).top(0,5).left(50, 5).set();
+ SWTUtils.setFontHeight(btnClearImage, Constants.TEXT_SIZE_BUTTON);
this.btnClearImage.setVisible(false);
this.cSigPreview = new Canvas(containerComposite, SWT.RESIZE);
- StateComposite.anchor(cSigPreview).left(0, 5).right(100,-5).top(btnBrowseLogo,5).bottom(100,-5).set();
- StateComposite.setFontHeight(cSigPreview, Constants.TEXT_SIZE_NORMAL);
+ SWTUtils.anchor(cSigPreview).left(0, 5).right(100,-5).top(btnBrowseLogo,5).bottom(100,-5).set();
+ SWTUtils.setFontHeight(cSigPreview, Constants.TEXT_SIZE_NORMAL);
this.cSigPreview.addPaintListener(e -> SimpleConfigurationComposite.this.paintSignaturePreview(e));
DropTarget dnd_target = new DropTarget(containerComposite, DND.DROP_DEFAULT | DND.DROP_COPY);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java
new file mode 100644
index 00000000..9b37117b
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java
@@ -0,0 +1,106 @@
+package at.asit.pdfover.gui.utils;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.commons.Messages;
+import at.asit.pdfover.gui.composites.StateComposite;
+
+public final class SWTUtils {
+
+ private static final Logger log = LoggerFactory.getLogger(SWTUtils.class);
+
+ /* oh how i miss C++, and compile-time safety; this would be so much cleaner as a templated function */
+ private static void genericSetText(Object swtObj, String text) {
+ try {
+ Method m = swtObj.getClass().getMethod("setText", String.class);
+ m.invoke(swtObj, text);
+ } catch (NoSuchMethodException | IllegalAccessException e) {
+ log.error("Attempted to setLocalizedText on object of type {}, which does not have an accessible setText method", swtObj.getClass().getSimpleName(), e);
+ } catch (InvocationTargetException e) {
+ log.error("Failed to setLocalizedText on object of type {}", swtObj.getClass().getSimpleName(), e);
+ }
+
+ try {
+ // request re-layout if possible, changing the text content will change the bounding box
+ Method m = swtObj.getClass().getMethod("requestLayout");
+ m.invoke(swtObj);
+ } catch (NoSuchMethodException | IllegalAccessException e) {
+ // do nothing, this may not exist on every control we use
+ } catch (InvocationTargetException e) {
+ log.error("Failed to re-layout {}", swtObj.getClass().getSimpleName(), e);
+ }
+ }
+
+ public static void setLocalizedText(Object o, String messageKey) { genericSetText(o, Messages.getString(messageKey)); }
+ public static void setLocalizedText(Object o, String formatMessageKey, Object... formatArgs) { genericSetText(o, String.format(Messages.getString(formatMessageKey), formatArgs)); }
+
+ public static void disableEventDefault(Control c, int event) {
+ c.addListener(event, (Event e) -> { e.doit = false; });
+ }
+
+ public static void setFontHeight(Control c, int height) {
+ FontData[] fD = c.getFont().getFontData();
+ fD[0].setHeight(height);
+ Font font = new Font(c.getDisplay(), fD[0]);
+ c.setFont(font);
+ }
+
+ public static void setFontStyle(Control c, int style) {
+ FontData[] fD = c.getFont().getFontData();
+ fD[0].setStyle(style);
+ Font font = new Font(c.getDisplay(), fD[0]);
+ c.setFont(font);
+ }
+
+ public static class AnchorSetter {
+ private final Control c;
+ private final FormData fd = new FormData();
+ private AnchorSetter(Control c) { this.c = c; }
+
+ public void set() { this.c.setLayoutData(this.fd); }
+
+ public AnchorSetter height(int h) { fd.height = h; return this; }
+ public AnchorSetter width(int w) { fd.width = w; return this; }
+
+ public AnchorSetter top(FormAttachment a) { fd.top = a; return this; }
+ public AnchorSetter left(FormAttachment a) { fd.left = a; return this; }
+ public AnchorSetter right(FormAttachment a) { fd.right = a; return this; }
+ public AnchorSetter bottom(FormAttachment a) { fd.bottom = a; return this; }
+
+ 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)); }
+ }
+ public static AnchorSetter anchor(Control c) { return new AnchorSetter(c); }
+
+}