com.groovemanager.actions.file
Class FileOpenAction

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

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

This subclass of Action is used to open a file. Before being performed, a Shell has to be assigned to this Action. When performed, an instance of this class will open a FileDialog where the user can select the file(s) to be opened. After closing the dialog, it will notify all registeres FileOpenListeners that the file(s) should be opened.

Author:
Manu Robledo

Field Summary
private  java.util.ArrayList listeners
          List of FileOpenListeners registered to this Action
private  boolean multiple
          Should the user be able to open multiple files at once?
private  java.lang.String path
          The path into which the FileDialog should point when opened
private  org.eclipse.swt.widgets.Shell shell
          The Shell that will be used as parent Shell of the FileDialog
 
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
FileOpenAction(java.lang.String name)
          Constructs a new FileOpenAction with the given name which lets the user select only one file at a time.
FileOpenAction(java.lang.String name, boolean multi)
          Constructs a new FileOpenAction with the given name
 
Method Summary
 void addFileOpenListener(FileOpenListener l)
          Register a FileOpenListener with this Action
 void removeFileOpenListener(FileOpenListener l)
          Remove a registered FileOpenListener from this Action
 void run()
          Perform this Action.
 void setFilterPath(java.lang.String path)
          Set the filter path of the FileDialog
 void setShell(org.eclipse.swt.widgets.Shell s)
          Set the parent Shell of the FileDialog
 
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

listeners

private java.util.ArrayList listeners
List of FileOpenListeners registered to this Action


multiple

private boolean multiple
Should the user be able to open multiple files at once?


path

private java.lang.String path
The path into which the FileDialog should point when opened


shell

private org.eclipse.swt.widgets.Shell shell
The Shell that will be used as parent Shell of the FileDialog

Constructor Detail

FileOpenAction

public FileOpenAction(java.lang.String name)
Constructs a new FileOpenAction with the given name which lets the user select only one file at a time.

Parameters:
name - This Action´s name

FileOpenAction

public FileOpenAction(java.lang.String name,
                      boolean multi)
Constructs a new FileOpenAction with the given name

Parameters:
name - This Action´s name
multi - true if the user should be able to select multiple files at once in the FileDialog, false otherwise
Method Detail

addFileOpenListener

public void addFileOpenListener(FileOpenListener l)
Register a FileOpenListener with this Action

Parameters:
l - The FileOpenListener to register

removeFileOpenListener

public void removeFileOpenListener(FileOpenListener l)
Remove a registered FileOpenListener from this Action

Parameters:
l - The FileOpenListener to remove

run

public void run()
Perform this Action. The FileDialog will be opened. If the user closes it without selecting a file (e.g. Cancel) nothing will happen. Else all registered FileOpenListeners will be notified about all selected files.

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

setFilterPath

public void setFilterPath(java.lang.String path)
Set the filter path of the FileDialog

Parameters:
path - The path to which the FileDialog should point when opened. May be null. In this case, a default path will be used.

setShell

public void setShell(org.eclipse.swt.widgets.Shell s)
Set the parent Shell of the FileDialog

Parameters:
s - The Shell which will be used as parent Shell for the FileDialog