From ccc3d5358ccc4c698c73d780d28415e131224fc0 Mon Sep 17 00:00:00 2001 From: tkellner Date: Fri, 24 Aug 2012 17:04:51 +0000 Subject: StateMachine cleanup JumpToState stuff git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12389 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../at/asit/pdfover/gui/workflow/StatusImpl.java | 28 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java index 9bc4bfec..c8d74161 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java +++ b/trunk/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,13 +62,32 @@ 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) */ @@ -119,6 +141,6 @@ public class StatusImpl implements Status { */ @Override public MainWindowBehavior getBehavior() { - return behavior; + return this.behavior; } } -- cgit v1.2.3