com.groovemanager.actions.file
Class FileCloseAction

java.lang.Object
  extended by org.eclipse.jface.action.Action
      extended by com.groovemanager.actions.file.FileCloseAction
All Implemented Interfaces:
org.eclipse.jface.action.IAction

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

This subclass of Action is used to close an open file. A File needs to be assigned to an instance of this class before it can be performed. When performed, an instance of this class will do nothing else than notify all registeres FileCLoseListeners that the file should be closed.

Author:
Manu Robledo

Field Summary
private  java.io.File file
          The file currently associated to this Action
private  java.util.ArrayList listeners
          List of FileCloseListeners registered with 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
FileCloseAction(java.lang.String text)
          Constructs a new FileCloseAction
FileCloseAction(java.lang.String text, org.eclipse.jface.resource.ImageDescriptor image)
          Constructs a new FileCloseAction
FileCloseAction(java.lang.String text, int style)
          Constructs a new FileCloseAction
 
Method Summary
 void addFileCloseListener(FileCloseListener listener)
          Register a listener with this Action that will be notified when the Action is performed.
 java.io.File getFile()
          Get the file currently assigned to this Action, that is the file that should be closed
 void removeFileCloseListener(FileCloseListener listener)
          Remove a registered listener from this Action
 void run()
          Perform this Action.
 void setFile(java.io.File f)
          Assign a file to this Action.
 
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 associated to this Action


listeners

private java.util.ArrayList listeners
List of FileCloseListeners registered with this Action

Constructor Detail

FileCloseAction

public FileCloseAction(java.lang.String text)
Constructs a new FileCloseAction

Parameters:
text - The name of the Action

FileCloseAction

public FileCloseAction(java.lang.String text,
                       org.eclipse.jface.resource.ImageDescriptor image)
Constructs a new FileCloseAction

Parameters:
text - The name of the Action
image - The image assigned to this Action

FileCloseAction

public FileCloseAction(java.lang.String text,
                       int style)
Constructs a new FileCloseAction

Parameters:
text - The name of the Action
style - The style constant used by this Action
Method Detail

addFileCloseListener

public void addFileCloseListener(FileCloseListener listener)
Register a listener with this Action that will be notified when the Action is performed.

Parameters:
listener - The FileCloseListener to add

getFile

public java.io.File getFile()
Get the file currently assigned to this Action, that is the file that should be closed

Returns:
The file to be closed

removeFileCloseListener

public void removeFileCloseListener(FileCloseListener listener)
Remove a registered listener from this Action

Parameters:
listener - The FileCloseListener to remove

run

public void run()
Perform this Action. When no file is assigned to this Action, nothing will happen. Else all registeres listeners will be notified that this file should be closed.

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)
Assign a file to this Action. If the argument is null, the action will be disabled, otherwise it will be enabled

Parameters:
f - The file to be closed or null