From 428f75149d4ee4e61f9c3db4571b7be13f39c259 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 7 Nov 2012 08:16:35 +0100 Subject: + fixed Fixmes on error exit when users cancel document error dialog reset state machine to open status when users cancel an error in signing state reset state machine to BKU selection --- .../src/main/java/at/asit/pdfover/gui/MainWindow.java | 3 ++- .../pdfover/gui/workflow/states/BKUSelectionState.java | 6 ++++-- .../pdfover/gui/workflow/states/LocalBKUState.java | 3 ++- .../pdfover/gui/workflow/states/PositioningState.java | 18 +++++++++++++++--- .../gui/workflow/states/PrepareSigningState.java | 3 ++- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java index 98d0d6c2..a4798c28 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java @@ -126,7 +126,8 @@ public class MainWindow { * @param ctrl */ public void setTopControl(Control ctrl) { - log.debug("Top control: " + ctrl.toString()); //$NON-NLS-1$ + if(ctrl != null) + log.debug("Top control: " + ctrl.toString()); //$NON-NLS-1$ this.stack.topControl = ctrl; this.doLayout(); } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java index b4507e08..797ce925 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java @@ -60,8 +60,10 @@ public class BKUSelectionState extends State { @Override public void run() { Status status = this.stateMachine.getStatus(); - if (!(status.getPreviousState() instanceof BKUSelectionState)) - { + if (!(status.getPreviousState() instanceof BKUSelectionState) && + !(status.getPreviousState() instanceof PositioningState)) { + status.setBKU(BKUs.NONE); + } else if((status.getPreviousState() instanceof PositioningState)) { ConfigProvider config = this.stateMachine.getConfigProvider(); status.setBKU(config.getDefaultBKU()); } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java index 46daf8f7..163b17b3 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java @@ -175,7 +175,8 @@ public class LocalBKUState extends State { Messages.getString("error.LocalBKU"), //$NON-NLS-1$ ERROR_BUTTONS.RETRY_CANCEL); if (dialog.open() != SWT.RETRY) { - this.stateMachine.exit(); + //this.stateMachine.exit(); + this.setNextState(new BKUSelectionState(this.stateMachine)); return; } this.threadException = null; diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java index 449bb93d..17b1619c 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -19,12 +19,15 @@ package at.asit.pdfover.gui.workflow.states; import java.io.IOException; import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.asit.pdfover.gui.MainWindow.Buttons; import at.asit.pdfover.gui.MainWindowBehavior; import at.asit.pdfover.gui.composites.PositioningComposite; +import at.asit.pdfover.gui.controls.ErrorDialog; +import at.asit.pdfover.gui.controls.ErrorDialog.ERROR_BUTTONS; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; import at.asit.pdfover.signator.Emblem; @@ -94,9 +97,18 @@ public class PositioningState extends State { try { position = this.getPositioningComposite(); } catch (IOException e) { - // TODO Auto-generated catch block - // FIXME - e.printStackTrace(); + // FIXME + this.positionComposite = null; + log.error("Failed to display PDF document", e); //$NON-NLS-1$ + ErrorDialog dialog = new ErrorDialog( + this.stateMachine.getGUIProvider().getMainShell(), + e.getMessage(), ERROR_BUTTONS.RETRY_CANCEL); + if(dialog.open() == SWT.RETRY) { + this.stateMachine.update(); + } else { + this.setNextState(new OpenState(this.stateMachine)); + } + return; } this.stateMachine.getGUIProvider().display(position); diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java index d5f67f1e..4a097e8f 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java @@ -166,7 +166,8 @@ public class PrepareSigningState extends State { this.stateMachine.update(); } else { // FIXME: exit? - this.stateMachine.exit(); + //this.stateMachine.exit(); + this.setNextState(new BKUSelectionState(this.stateMachine)); } return; } -- cgit v1.2.3