org.embl.ebi.escience.scuflui.shared
Class WorkflowChanges

java.lang.Object
  extended by org.embl.ebi.escience.scuflui.shared.WorkflowChanges

public class WorkflowChanges
extends java.lang.Object

Detect changes to open workflows since last save to disk.

Use hasChanged() to check if the workflow has been changed since the last save. Use syncedWithFile() to notify that the workflow has been saved.

Author:
Stian Soiland

Method Summary
 void destroy()
          Unregister as listener with ScuflModelSet and known ScuflModels
static WorkflowChanges getInstance()
          Get the singleton WorkflowChanges instance.
 boolean hasChanged(ScuflModel workflow)
          Return true if workflow has been changed since creation or last save, otherwise false.
 java.io.File lastFilename(ScuflModel workflow)
          Find the latest filename to which the workflow was saved, as notified with syncedWithFile().
 void synced(ScuflModel workflow)
          Mark the workflow as synchronized with source.
 void syncedWithFile(ScuflModel workflow, java.io.File file)
          Mark the workflow as synchronized by saving to given file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static WorkflowChanges getInstance()
Get the singleton WorkflowChanges instance.

Returns:
The WorkflowChanges instance.

destroy

public void destroy()
Unregister as listener with ScuflModelSet and known ScuflModels


hasChanged

public boolean hasChanged(ScuflModel workflow)
Return true if workflow has been changed since creation or last save, otherwise false.

Parameters:
workflow - that
Returns:
true if workflow has been changed

synced

public void synced(ScuflModel workflow)
Mark the workflow as synchronized with source. Concurrent calls to hasChanged() will return false until the workflow model is changed.

Parameters:
workflow - ScuflModel that has been synchronized

syncedWithFile

public void syncedWithFile(ScuflModel workflow,
                           java.io.File file)
Mark the workflow as synchronized by saving to given file. Concurrent calls to hasChanged() will return false until the workflow model is changed. Calls to lastFilename() will return the given file unless the workflow is later syncedWithFile() with some other file.

Parameters:
workflow - ScuflModel that has been synchronized
file - File where the workflow has been stored

lastFilename

public java.io.File lastFilename(ScuflModel workflow)
Find the latest filename to which the workflow was saved, as notified with syncedWithFile().

Note: This method does not guarantee that the actual file has not been overwritten by some other process or workflow save since the last save.

Parameters:
workflow - ScuflModel that has been previously saved
Returns:
File of the last saved