diff options
author | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2014-12-03 18:10:46 +0100 |
---|---|---|
committer | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2014-12-03 18:10:46 +0100 |
commit | 8e56cd2c9a300f7f9251263d6aceb2b00453324b (patch) | |
tree | 3bef62c79d46a87324634402d0d44b14691129c4 /pdf-over-gui/src/main/java/at/asit/pdfover/gui | |
parent | 942b27169ce8b38f780a9a2de912b2efec94ebea (diff) | |
download | pdf-over-8e56cd2c9a300f7f9251263d6aceb2b00453324b.tar.gz pdf-over-8e56cd2c9a300f7f9251263d6aceb2b00453324b.tar.bz2 pdf-over-8e56cd2c9a300f7f9251263d6aceb2b00453324b.zip |
Add cancel button to Mobile BKU dialogs
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui')
4 files changed, 115 insertions, 24 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java index f08c885e..828a23ac 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java @@ -76,11 +76,15 @@ public class MobileBKUConnector implements BkuSlConnector { do {
// Check if credentials are available, get them from user if not
this.state.checkCredentials();
-
+
+ if (this.state.getStatus().getErrorMessage() != null &&
+ this.state.getStatus().getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ throw new SignatureException(new IllegalStateException());
+
// Post credentials
try {
String responseData = handler.postCredentials();
-
+
// Now we have received some data lets check it:
log.debug("Response from mobile BKU: " + responseData); //$NON-NLS-1$
@@ -103,7 +107,11 @@ public class MobileBKUConnector implements BkuSlConnector { do {
// Get TAN
this.state.checkTAN();
-
+
+ if (this.state.getStatus().getErrorMessage() != null &&
+ this.state.getStatus().getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ throw new SignatureException(new IllegalStateException());
+
// Post TAN
try {
String responseData = handler.postTAN();
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 17e82d07..d6e6a5e5 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 @@ -19,6 +19,7 @@ package at.asit.pdfover.gui.composites; import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; @@ -54,7 +55,7 @@ public class MobileBKUEnterNumberComposite extends StateComposite { /** * */ - private final SelectionListener okListener = new SelectionListener() { + private final SelectionListener okListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if(!MobileBKUEnterNumberComposite.this.btn_ok.isEnabled()) { @@ -79,7 +80,7 @@ public class MobileBKUEnterNumberComposite extends StateComposite { MobileBKUEnterNumberComposite.this.mobilePassword = password; MobileBKUEnterNumberComposite.this.setUserAck(true); - + MobileBKUEnterNumberComposite.this.btn_ok.setEnabled(false); } catch(InvalidNumberException ex) { @@ -100,19 +101,22 @@ public class MobileBKUEnterNumberComposite extends StateComposite { MobileBKUEnterNumberComposite.this.txt_number.setFocus(); return; } - + //MobileBKUEnterNumberComposite.this.state.updateStateMachine(); } + }; - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) - */ + /** + * + */ + private final SelectionListener cancelListener = new SelectionAdapter() { @Override - public void widgetDefaultSelected(SelectionEvent e) { - // Nothing to do here + public void widgetSelected(SelectionEvent e) { + MobileBKUEnterNumberComposite.this.setUserCancel(true); } }; + String mobileNumber; String mobilePassword; @@ -124,6 +128,7 @@ public class MobileBKUEnterNumberComposite extends StateComposite { String errorMessage = null; boolean userAck = false; + boolean userCancel = false; /** * @return the userAck @@ -140,13 +145,28 @@ public class MobileBKUEnterNumberComposite extends StateComposite { this.userAck = userAck; } - private Label lbl_error; + /** + * @return the userCancel + */ + public boolean isUserCancel() { + return this.userCancel; + } - private Label lbl_password; + /** + * @param userCancel + * the userCancel to set + */ + public void setUserCancel(boolean userCancel) { + this.userCancel = userCancel; + } + + private Label lbl_error; + private Label lbl_password; private Label lbl_number; Button btn_ok; + Button btn_cancel; /** * @return the errorMessage @@ -266,16 +286,26 @@ public class MobileBKUEnterNumberComposite extends StateComposite { //fd_btn_ok.top = new FormAttachment(87, 0); fd_btn_ok.bottom = new FormAttachment(100, -20); fd_btn_ok.right = new FormAttachment(100, -20); - fd_btn_ok.left = new FormAttachment(100, -70); + //fd_btn_ok.left = new FormAttachment(100, -70); this.btn_ok.setLayoutData(fd_btn_ok); this.btn_ok.addSelectionListener(this.okListener); - + + this.btn_cancel = new Button(containerComposite, SWT.NATIVE); + this.btn_cancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$ + FormData fd_btn_cancel = new FormData(); + //fd_btn_cancel.top = new FormAttachment(87, 0); + fd_btn_cancel.bottom = new FormAttachment(100, -20); + fd_btn_cancel.right = new FormAttachment(this.btn_ok, -10); + //fd_btn_cancel.left = new FormAttachment(100, -70); + this.btn_cancel.setLayoutData(fd_btn_cancel); + this.btn_cancel.addSelectionListener(this.cancelListener); + this.lbl_error = new Label(containerComposite, SWT.WRAP | SWT.NATIVE); FormData fd_lbl_error = new FormData(); //fd_lbl_error.top = new FormAttachment(70, -15); fd_lbl_error.bottom = new FormAttachment(100, -20); fd_lbl_error.left = new FormAttachment(15, 0); - fd_lbl_error.right = new FormAttachment(this.btn_ok, -10); + fd_lbl_error.right = new FormAttachment(this.btn_cancel, -10); this.lbl_error.setLayoutData(fd_lbl_error); } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java index 28f8b65e..66063a62 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java @@ -93,6 +93,22 @@ public class MobileBKUEnterTANComposite extends StateComposite { } /** + * + */ + private final class CancelSelectionListener extends SelectionAdapter { + /** + * Empty constructor + */ + public CancelSelectionListener() { + } + + @Override + public void widgetSelected(SelectionEvent e) { + MobileBKUEnterTANComposite.this.setUserCancel(true); + } + } + + /** * SLF4J Logger instance **/ static final Logger log = LoggerFactory @@ -101,6 +117,7 @@ public class MobileBKUEnterTANComposite extends StateComposite { Text txt_tan; boolean userAck = false; + boolean userCancel = false; private Label lblRefVal; @@ -126,12 +143,11 @@ public class MobileBKUEnterTANComposite extends StateComposite { String tan; private Label lblTries; - private Label lblRefValLabel; - private Label lblTan; Button btn_ok; + Button btn_cancel; /** * @return the userAck @@ -141,6 +157,13 @@ public class MobileBKUEnterTANComposite extends StateComposite { } /** + * @return the userCancel + */ + public boolean isUserCancel() { + return this.userCancel; + } + + /** * Set how many tries are left * * @param tries @@ -183,6 +206,14 @@ public class MobileBKUEnterTANComposite extends StateComposite { } /** + * @param userCancel + * the userCancel to set + */ + public void setUserCancel(boolean userCancel) { + this.userCancel = userCancel; + } + + /** * @return the reference value */ public String getRefVal() { @@ -375,8 +406,6 @@ public class MobileBKUEnterTANComposite extends StateComposite { } }); - this.btn_ok = new Button(containerComposite, SWT.NATIVE); - Link lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE); FormData fd_lnk_data = new FormData(); @@ -387,11 +416,14 @@ public class MobileBKUEnterTANComposite extends StateComposite { lnk_sig_data.addSelectionListener(new ShowSignatureDataListener()); lnk_sig_data.setText(Messages.getString("mobileBKU.show")); //$NON-NLS-1$ lnk_sig_data.setToolTipText(Messages.getString("mobileBKU.show_tooltip")); //$NON-NLS-1$ - + + this.btn_ok = new Button(containerComposite, SWT.NATIVE); + this.btn_cancel = new Button(containerComposite, SWT.NATIVE); + this.lblTries = new Label(containerComposite, SWT.WRAP | SWT.NATIVE); FormData fd_lbl_tries = new FormData(); // fd_lbl_tries.left = new FormAttachment(15, 5); - fd_lbl_tries.right = new FormAttachment(this.btn_ok, -10); + fd_lbl_tries.right = new FormAttachment(this.btn_cancel, -10); // fd_lbl_tries.top = new FormAttachment(70, -15); fd_lbl_tries.bottom = new FormAttachment(100, -20); this.lblTries.setLayoutData(fd_lbl_tries); @@ -406,6 +438,15 @@ public class MobileBKUEnterTANComposite extends StateComposite { this.btn_ok.setText(Messages.getString("common.Ok")); //$NON-NLS-1$ this.btn_ok.addSelectionListener(new OkSelectionListener()); + FormData fd_btn_cancel = new FormData(); + // fd_btn_cancel.left = new FormAttachment(95, 0); + fd_btn_cancel.right = new FormAttachment(this.btn_ok, -20); + //fd_btn_cancel.left = new FormAttachment(100, -70); + fd_btn_cancel.bottom = new FormAttachment(100, -20); + + this.btn_cancel.setLayoutData(fd_btn_cancel); + this.btn_cancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$ + this.btn_cancel.addSelectionListener(new CancelSelectionListener()); } @Override 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 4a825d17..1df8f755 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 @@ -223,13 +223,19 @@ public class MobileBKUState extends State { getStateMachine().getGUIProvider().display(ui); Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay(); - while (!ui.isUserAck()) { + while (!ui.isUserAck() && !ui.isUserCancel()) { if (!display.readAndDispatch()) { display.sleep(); } } } + if (ui.isUserCancel()) { + ui.setUserCancel(false); + mobileStatus.setErrorMessage("cancel"); //$NON-NLS-1$ + return; + } + // user hit ok ui.setUserAck(false); @@ -272,13 +278,19 @@ public class MobileBKUState extends State { getStateMachine().getGUIProvider().display(tan); Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay(); - while (!tan.isUserAck()) { + while (!tan.isUserAck() && !tan.isUserCancel()) { if (!display.readAndDispatch()) { display.sleep(); } } } + if (tan.isUserCancel()) { + tan.setUserCancel(false); + mobileStatus.setErrorMessage("cancel"); //$NON-NLS-1$ + return; + } + // user hit ok! tan.setUserAck(false); |