com.groovemanager.actions.file
Class FileSaveAction

java.lang.Object
  extended by org.eclipse.jface.action.Action
      extended by com.groovemanager.actions.file.FileSaveAction
All Implemented Interfaces:
org.eclipse.jface.action.IAction
Direct Known Subclasses:
FileSaveAsAction

public class FileSaveAction
extends org.eclipse.jface.action.Action

This subclass of Action is used to save a file without user interaction. Before being performed, a File has to be assigned to this Action. When performed, an instance of this class will notify all registeres FileSaveListeners that the file should be saved.

Author:
Manu Robledo

Field Summary
private  java.io.File file
          The file currently assigned to this Action
protected  java.util.ArrayList listeners
          List of FileSaveListeners registeres to this Action
 
Fields inherited from interface org.eclipse.jface.action.IAction
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, IMAGE, TEXT, TOOL_TIP_TEXT
 
Constructor Summary
FileSaveAction(java.lang.String name)
          Constructs a new FIleSaveAction with the given name
 
Method Summary
 void addFileSaveListener(FileSaveListener l)
          Register a FileSaveListener with this Action
 java.io.File getFile()
          Get the file currently assigned to this Action
 void removeFileSaveListener(FileSaveListener l)
          Remove a registered FileSaveListener to this Action
 void run()
          Perform this Action.
 void setFile(java.io.File f)
          Set the file that should be saved.
 
Methods inherited from class org.eclipse.jface.action.Action
addPropertyChangeListener, convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, firePropertyChange, firePropertyChange, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, removeAcceleratorText, removePropertyChangeListener, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

private java.io.File file
The file currently assigned to this Action


listeners

protected java.util.ArrayList listeners
List of FileSaveListeners registeres to this Action

Constructor Detail

FileSaveAction

public FileSaveAction(java.lang.String name)
Constructs a new FIleSaveAction with the given name

Parameters:
name - This Action´s name
Method Detail

addFileSaveListener

public void addFileSaveListener(FileSaveListener l)
Register a FileSaveListener with this Action

Parameters:
l - The FileSaveListener to register

getFile

public java.io.File getFile()
Get the file currently assigned to this Action

Returns:
The file to be saved

removeFileSaveListener

public void removeFileSaveListener(FileSaveListener l)
Remove a registered FileSaveListener to this Action

Parameters:
l - The FileSaveListener to be removed

run

public void run()
Perform this Action. If no file has been assigned to this Action, nothing will happen. Else all registered listeners will be notified that this file should be saved.

Specified by:
run in interface org.eclipse.jface.action.IAction
Overrides:
run in class org.eclipse.jface.action.Action
See Also:
IAction.run()

setFile

public void setFile(java.io.File f)
Set the file that should be saved. If the argument is null, the action will be disabled. Otherwise it will be enabled.

Parameters:
f - The file to be saved or null