diff options
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java index 9bc4bfec..c8d74161 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java @@ -44,8 +44,11 @@ public class StatusImpl implements Status { private State currentState = null; + private State previousState = null; + private MainWindowBehavior behavior; + /** * Constructor */ @@ -59,14 +62,33 @@ public class StatusImpl implements Status { } /** - * Sets the current state - * @param currentState + * Changes the current state + * @param currentState the current State */ public void setCurrentState(State currentState) { + if (this.previousState == this.currentState) + log.error("Changing to same state? " + this.currentState); + + if (this.previousState != null && this.previousState != currentState) + { + //Reference to previous state will be lost - perform cleanup + log.debug("Cleaning up " + this.previousState); + this.previousState.cleanUp(); + } + + this.previousState = this.currentState; this.currentState = currentState; } /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.Status#getPreviousState() + */ + @Override + public State getPreviousState() { + return this.previousState; + } + + /* (non-Javadoc) * @see at.asit.pdfover.gui.workflow.Status#setDocument(java.io.File) */ @Override @@ -119,6 +141,6 @@ public class StatusImpl implements Status { */ @Override public MainWindowBehavior getBehavior() { - return behavior; + return this.behavior; } } |