summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java7
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java180
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java74
3 files changed, 117 insertions, 144 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
index a48c0e5e..8b05a528 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
@@ -140,11 +140,8 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
@Override
public void invokeUpdate() {
if (this.display != null) {
- this.display.asyncExec(new Runnable() {
- @Override
- public void run() {
- StateMachineImpl.this.update();
- }
+ this.display.asyncExec(() -> {
+ StateMachineImpl.this.update();
});
}
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
index 86266b13..153d4b1d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
@@ -180,13 +180,9 @@ public class MobileBKUState extends State {
*/
public void displayError(final String message) {
log.error(message);
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- ErrorDialog error = new ErrorDialog(getStateMachine().getGUIProvider()
- .getMainShell(), message, BUTTONS.OK);
- error.open();
- }
+ Display.getDefault().syncExec(() -> {
+ ErrorDialog error = new ErrorDialog(getStateMachine().getGUIProvider().getMainShell(), message, BUTTONS.OK);
+ error.open();
});
}
@@ -200,62 +196,57 @@ public class MobileBKUState extends State {
mobileStatus.mobilePassword != null && !mobileStatus.mobilePassword.isEmpty())
return;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MobileBKUEnterNumberComposite ui = MobileBKUState.this
- .getMobileBKUEnterNumberComposite();
-
- if (!ui.userAck) {
- // We need number and password => show UI!
- if (mobileStatus.errorMessage != null
- && !mobileStatus.errorMessage.isEmpty()) {
- // set possible error message
- ui.setErrorMessage(mobileStatus.errorMessage);
- mobileStatus.errorMessage = null;
- } else if (mobileStatus instanceof ATrustStatus) {
- ui.setErrorMessage(Messages.getString("mobileBKU.aTrustDisclaimer")); //
- }
+ Display.getDefault().syncExec(() -> {
+ MobileBKUEnterNumberComposite ui = this.getMobileBKUEnterNumberComposite();
+
+ if (!ui.userAck) {
+ // We need number and password => show UI!
+ if (mobileStatus.errorMessage != null
+ && !mobileStatus.errorMessage.isEmpty()) {
+ // set possible error message
+ ui.setErrorMessage(mobileStatus.errorMessage);
+ mobileStatus.errorMessage = null;
+ } else if (mobileStatus instanceof ATrustStatus) {
+ ui.setErrorMessage(Messages.getString("mobileBKU.aTrustDisclaimer")); //
+ }
- if (ui.getMobileNumber() == null
- || ui.getMobileNumber().isEmpty()) {
- // set possible phone number
- ui.setMobileNumber(mobileStatus.phoneNumber);
- }
+ if (ui.getMobileNumber() == null
+ || ui.getMobileNumber().isEmpty()) {
+ // set possible phone number
+ ui.setMobileNumber(mobileStatus.phoneNumber);
+ }
- if (ui.getMobilePassword() == null
- || ui.getMobilePassword().isEmpty()) {
- // set possible password
- ui.setMobilePassword(mobileStatus.mobilePassword);
- }
- ui.enableButton();
- getStateMachine().getGUIProvider().display(ui);
-
- Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
- while (!ui.userAck && !ui.userCancel) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
+ if (ui.getMobilePassword() == null
+ || ui.getMobilePassword().isEmpty()) {
+ // set possible password
+ ui.setMobilePassword(mobileStatus.mobilePassword);
}
+ ui.enableButton();
+ getStateMachine().getGUIProvider().display(ui);
- if (ui.userCancel) {
- ui.userCancel = false;
- mobileStatus.errorMessage = "cancel"; //
- return;
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ while (!ui.userAck && !ui.userCancel) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
}
+ }
- // user hit ok
- ui.userAck = false;
+ if (ui.userCancel) {
+ ui.userCancel = false;
+ mobileStatus.errorMessage = "cancel"; //
+ return;
+ }
- // get number and password from UI
- mobileStatus.phoneNumber = ui.getMobileNumber();
- mobileStatus.mobilePassword = ui.getMobilePassword();
+ // user hit ok
+ ui.userAck = false;
- // show waiting composite
- getStateMachine().getGUIProvider().display(
- MobileBKUState.this.getWaitingComposite());
- }
+ // get number and password from UI
+ mobileStatus.phoneNumber = ui.getMobileNumber();
+ mobileStatus.mobilePassword = ui.getMobilePassword();
+
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(MobileBKUState.this.getWaitingComposite());
});
}
@@ -265,50 +256,45 @@ public class MobileBKUState extends State {
public void checkTAN() {
final MobileBKUStatus mobileStatus = this.status;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MobileBKUEnterTANComposite tan = MobileBKUState.this
- .getMobileBKUEnterTANComposite();
-
- if (!tan.isUserAck()) {
- // we need the TAN
- tan.setRefVal(mobileStatus.refVal);
- tan.setSignatureData(mobileStatus.signatureDataURL);
- tan.setErrorMessage(mobileStatus.errorMessage);
- if (mobileStatus.tanTries < mobileStatus.getMaxTanTries()
- && mobileStatus.tanTries > 0) {
- // show warning message x tries left!
- // overrides error message
-
- tan.setTries(mobileStatus.tanTries);
- }
- tan.enableButton();
- getStateMachine().getGUIProvider().display(tan);
-
- Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
- while (!tan.isUserAck() && !tan.isUserCancel()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
+ Display.getDefault().syncExec(() -> {
+ MobileBKUEnterTANComposite tan = getMobileBKUEnterTANComposite();
+
+ if (!tan.isUserAck()) {
+ // we need the TAN
+ tan.setRefVal(mobileStatus.refVal);
+ tan.setSignatureData(mobileStatus.signatureDataURL);
+ tan.setErrorMessage(mobileStatus.errorMessage);
+ if (mobileStatus.tanTries < mobileStatus.getMaxTanTries()
+ && mobileStatus.tanTries > 0) {
+ // show warning message x tries left!
+ // overrides error message
+
+ tan.setTries(mobileStatus.tanTries);
}
+ tan.enableButton();
+ getStateMachine().getGUIProvider().display(tan);
- if (tan.isUserCancel()) {
- tan.setUserCancel(false);
- mobileStatus.errorMessage = "cancel";
- return;
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ while (!tan.isUserAck() && !tan.isUserCancel()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
}
+ }
+
+ if (tan.isUserCancel()) {
+ tan.setUserCancel(false);
+ mobileStatus.errorMessage = "cancel";
+ return;
+ }
- // user hit ok!
- tan.setUserAck(false);
+ // user hit ok!
+ tan.setUserAck(false);
- mobileStatus.tan = tan.getTan();
+ mobileStatus.tan = tan.getTan();
- // show waiting composite
- getStateMachine().getGUIProvider().display(
- MobileBKUState.this.getWaitingComposite());
- }
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(getWaitingComposite());
});
}
@@ -321,7 +307,6 @@ public class MobileBKUState extends State {
final Timer checkDone = new Timer();
checkDone.scheduleAtFixedRate(new TimerTask() {
-
@Override
public void run() {
// ping signature page to see if code has been scanned
@@ -390,11 +375,8 @@ public class MobileBKUState extends State {
* This composite notifies the user to open the signature-app
*/
public void showOpenAppMessage() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- getStateMachine().getGUIProvider().display(MobileBKUState.this.getWaitingForAppComposite());
- }
+ Display.getDefault().syncExec(() -> {
+ getStateMachine().getGUIProvider().display(this.getWaitingForAppComposite());
});
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
index d653a07f..062231b4 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
@@ -461,47 +461,41 @@ public class PrepareConfigurationState extends State {
// Check for updates
if (config.getUpdateCheck() && Constants.APP_VERSION != null) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- HttpClient client = (HttpClient) BKUHelper.getHttpClient();
- GetMethod method = new GetMethod(Constants.CURRENT_RELEASE_URL);
- try {
- client.executeMethod(method);
- final String version = method.getResponseBodyAsString().trim();
- if (!VersionComparator.before(Constants.APP_VERSION, version))
- return;
-
- // wait 500ms before invoke the GUI message, because GUI had to be started from
- // main thread
- try {Thread.sleep(500); } catch (InterruptedException e1) { }
- // invoke GUI message in main thread
- gui.getMainShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- Dialog info = new Dialog(gui.getMainShell(),
- Messages.getString("version_check.UpdateTitle"), //
- String.format(Messages.getString("version_check.UpdateText"), //
- version),
- BUTTONS.OK_CANCEL, ICON.INFORMATION);
- if (info.open() == SWT.OK)
- {
- if (Desktop.isDesktopSupported()) {
- try {
- Desktop.getDesktop().browse(new URI(Constants.UPDATE_URL));
- } catch (Exception e) {
- log.error("Error opening update location ", e); //
- }
- } else {
- log.info("SWT Desktop is not supported on this platform"); //
- Program.launch(Constants.UPDATE_URL);
- }
- }
+ new Thread(() -> {
+ HttpClient client = (HttpClient) BKUHelper.getHttpClient();
+ GetMethod method = new GetMethod(Constants.CURRENT_RELEASE_URL);
+ try {
+ client.executeMethod(method);
+ final String version = method.getResponseBodyAsString().trim();
+ if (!VersionComparator.before(Constants.APP_VERSION, version))
+ return;
+
+ // wait 500ms before invoke the GUI message, because GUI had to be started from
+ // main thread
+ try {Thread.sleep(500); } catch (InterruptedException e1) { }
+ // invoke GUI message in main thread
+ gui.getMainShell().getDisplay().asyncExec(() -> {
+ Dialog info = new Dialog(gui.getMainShell(),
+ Messages.getString("version_check.UpdateTitle"), //
+ String.format(Messages.getString("version_check.UpdateText"), version),
+ BUTTONS.OK_CANCEL, ICON.INFORMATION);
+
+ if (info.open() == SWT.OK)
+ {
+ if (Desktop.isDesktopSupported()) {
+ try {
+ Desktop.getDesktop().browse(new URI(Constants.UPDATE_URL));
+ } catch (Exception e) {
+ log.error("Error opening update location ", e); //
+ }
+ } else {
+ log.info("SWT Desktop is not supported on this platform"); //
+ Program.launch(Constants.UPDATE_URL);
}
- });
- } catch (Exception e) {
- log.error("Error downloading update information: ", e); //
- }
+ }
+ });
+ } catch (Exception e) {
+ log.error("Error downloading update information: ", e); //
}
}).start();
}