org.embl.ebi.escience.scuflui.actions
Class SaveWorkflowAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.embl.ebi.escience.scuflui.actions.SaveWorkflowAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

public class SaveWorkflowAction
extends javax.swing.AbstractAction

Action and static methods for saving a workflow or workflow components.

Author:
Kevin Glover, David Withers, Stian Soiland
See Also:
Serialized Form

Field Summary
static java.lang.String EXTENSION
           
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
SaveWorkflowAction(java.awt.Component parentComponent)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
static java.io.File saveDialogue(java.awt.Component parentComponent, ScuflModel model, java.lang.String extension, java.lang.String windowTitle)
          Pop up a save dialogue relating to the given workflow.
 boolean saveToFile()
          Prompt for a file name, and then save the current workflow to the file.
static boolean saveToFile(java.awt.Component parentComponent, ScuflModel model)
          Prompt for a file name, and then save the given workflow to that file.
static void saveToFile(ScuflModel model, java.io.File file)
          Save the given workflow to the given file.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTENSION

public static final java.lang.String EXTENSION
See Also:
Constant Field Values
Constructor Detail

SaveWorkflowAction

public SaveWorkflowAction(java.awt.Component parentComponent)
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)

saveToFile

public boolean saveToFile()
                   throws java.io.FileNotFoundException,
                          java.lang.SecurityException
Prompt for a file name, and then save the current workflow to the file.

Returns:
true if file was saved, or false if the action was cancelled
Throws:
java.io.FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
java.lang.SecurityException - if a security manager exists and its checkWrite method denies write access to the file.

saveToFile

public static boolean saveToFile(java.awt.Component parentComponent,
                                 ScuflModel model)
Prompt for a file name, and then save the given workflow to that file. This static version of saveToFile()is intended for non-action invocation of file saving, such as through a "Do you want to save?" dialogue when closing Taverna.

Parameters:
parentComponent - Parent component for dialogue window
model - Workflow to save
Returns:
true if file was saved, or false if the action was cancelled
Throws:
java.io.FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
java.lang.SecurityException - if a security manager exists and its checkWrite method denies write access to the file.
See Also:
saveToFile()

saveToFile

public static void saveToFile(ScuflModel model,
                              java.io.File file)
                       throws java.io.FileNotFoundException,
                              java.lang.SecurityException
Save the given workflow to the given file. The filename will be marked as saved to the given file, and that file will be suggested in future save dialogues.

Parameters:
model - Workflow to save
file - Abstract file of where to save the workflow
Throws:
java.io.FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
java.lang.SecurityException - if a security manager exists and its checkWrite method denies write access to the file.

saveDialogue

public static java.io.File saveDialogue(java.awt.Component parentComponent,
                                        ScuflModel model,
                                        java.lang.String extension,
                                        java.lang.String windowTitle)
Pop up a save dialogue relating to the given workflow. This general static method can be used for example for saving the workflow diagram as .png, and will use the existing workflow title as a base for suggesting a filename.

Parameters:
parentComponent - Parent component for dialogue window
model - Workflow to save
extension - Extension for filename, such as "jpg"
windowTitle - Title for dialogue box, such as "Save workflow diagram"
Returns:
File instance for the selected abstract filename, or null if the dialogue was cancelled.