From 12fe32df6f5b17abb5d1f9bac9f5fb87b961f0c2 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 18:56:29 +0000 Subject: Configuration Changes git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@49 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../pdfover/gui/workflow/StateMachineImpl.java | 86 +++++++++++++++------- 1 file changed, 60 insertions(+), 26 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java') 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 cf764a73..90b2fba9 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 @@ -80,32 +80,45 @@ public class StateMachineImpl implements StateMachine, GUIProvider { State next = null; while (this.status.getCurrentState() != null) { State current = this.status.getCurrentState(); - try - { + try { current.run(); - } - catch(Exception e) { + } catch (Exception e) { log.error("StateMachine update: ", e); //$NON-NLS-1$ // TODO: GOTO generic error state! } - if (this.mainWindow != null - && !this.mainWindow.getShell().isDisposed()) { - log.debug("Allowing MainWindow to update its state for " //$NON-NLS-1$ - + current); - current.updateMainWindowBehavior(); - this.mainWindow.applyBehavior(); - this.mainWindow.doLayout(); - } - next = current.nextState(); - if (next == current) { - break; + + if (this.exit) { + // exit request ignore + next = null; + this.status.setCurrentState(next); + } else { + + if (this.mainWindow != null + && !this.mainWindow.getShell().isDisposed()) { + log.debug("Allowing MainWindow to update its state for " //$NON-NLS-1$ + + current); + current.updateMainWindowBehavior(); + this.mainWindow.applyBehavior(); + this.mainWindow.doLayout(); + } + next = current.nextState(); + if (next == current) { + break; + } + + if (next == null) { + log.info("Next state is null -> exit"); //$NON-NLS-1$ + this.status.setCurrentState(next); + break; + } + + log.debug("Changing state from: " //$NON-NLS-1$ + + current + " to " //$NON-NLS-1$ + + next.toString()); + this.status.setCurrentState(next); } - log.debug("Changing state from: " //$NON-NLS-1$ - + current + " to " //$NON-NLS-1$ - + next.toString()); - this.status.setCurrentState(next); } - + // TODO: Remove following line when releasing ... if (this.status.getCurrentState() != null) { this.setCurrentStateMessage(this.status.getCurrentState() @@ -205,9 +218,8 @@ public class StateMachineImpl implements StateMachine, GUIProvider { Composite.class, int.class, State.class); composite = constructor.newInstance(getComposite(), style, state); } catch (Exception e) { - log.error( - "Could not create Composite for Class " //$NON-NLS-1$ - + compositeClass.getName(), e); + log.error("Could not create Composite for Class " //$NON-NLS-1$ + + compositeClass.getName(), e); } return composite; } @@ -221,12 +233,17 @@ public class StateMachineImpl implements StateMachine, GUIProvider { return this.shell; } + private boolean exit = false; + /** * Exists the Workflow */ @Override public void exit() { - this.shell.dispose(); + this.exit = true; + if (this.shell != null) { + this.shell.dispose(); + } } /** @@ -249,6 +266,12 @@ public class StateMachineImpl implements StateMachine, GUIProvider { Shell shell = this.nonCreatingGetShell(); Display display = this.nonCreatingGetDisplay(); + if (this.status.getCurrentState() == null) { + if (shell != null) { + this.shell.dispose(); + } + } + if (shell != null && display != null) { while (!shell.isDisposed()) { if (!display.readAndDispatch()) { @@ -288,8 +311,10 @@ public class StateMachineImpl implements StateMachine, GUIProvider { public PDFSigner getPDFSigner() { return this.pdfSigner; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see at.asit.pdfover.gui.workflow.StateMachine#getGUIProvider() */ @Override @@ -318,7 +343,16 @@ public class StateMachineImpl implements StateMachine, GUIProvider { * * @return the command line arguments */ + @Override public String[] getCmdArgs() { return this.cmdLineArgs; } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.StateMachine#getConfigManipulator() + */ + @Override + public ConfigManipulator getConfigManipulator() { + return this.configProvider; + } } -- cgit v1.2.3