org.pietschy.command.file

Class AbstractFileOpenCommand

Implemented Interfaces:
ActionCommandExecutor

public abstract class AbstractFileOpenCommand
extends AbstractFileCommand

The command provides generic file open behaviour. One execution, the command will display a JFileChooser and if the selection is successful performOpen(File[]) will be invoked with the selected files. Subclasses must implement performOpen(File[]) to implement the required behaviour.

Subclasses can change the default settings by overriding AbstractFileOpenCommand and configuring appropriately.

Version:
$Revision: 1.5 $
Author:
andrewp

Field Summary

Fields inherited from class org.pietschy.command.ActionCommand

HINT_ACTION_EVENT, HINT_INVOKER, HINT_INVOKER_WINDOW, HINT_MODIFIERS

Fields inherited from class org.pietschy.command.Command

internalLog, listenerList, pcs

Constructor Summary

AbstractFileOpenCommand(String id, FileFilter filter)
Creates a new command with the specified id and FileFilter.
AbstractFileOpenCommand(String id, FileFilter[] filters)
Creates a new command with the specified id and list of FileFilter.
AbstractFileOpenCommand(CommandManager manager, String id, FileFilter filter)
Creates a new command with the specified id and FileFilter
AbstractFileOpenCommand(CommandManager manager, String id, FileFilter[] filters)
Creates a new command with the specified id and list of FileFilter

Method Summary

boolean
isMultiselectionEnabled()
Checks if multiple selection is enabled.
protected void
performFileAction(File[] files, JFileChooser chooser, Window invoker)
protected abstract void
performOpen(File[] files)
This method is called when the user selects one or more files to open.
void
setMultiselectionEnabled(boolean multiselectionEnabled)
Configures if the JFileChooser allows multiple selection.
protected int
showChooserDialog(JFileChooser chooser, Window invoker)

Methods inherited from class org.pietschy.command.file.AbstractFileCommand

afterExecute, beforeExecute, confirmProceed, getDefaultFileFilter, getFileChooser, handleCancel, handleError, handleExecute, isAcceptAllFileFilterUsed, isCenterOnInvoker, isRememberLastFilter, performFileAction, setAcceptAllFileFilterUsed, setCenterOnInvoker, setDefaultFileFilter, setRememberLastFilter, showChooserDialog

Methods inherited from class org.pietschy.command.ActionCommand

addCommandListener, addInterceptor, areEqual, attach, configureButtonStates, detach, execute, execute, getActionAdapter, getActionAdapter, getActionCommand, getActionEvent, getHint, getHint, getHints, getInvoker, getInvokerWindow, getModifiers, handleExecute, installShortCut, installShortCut, postExecute, preExecute, putHint, putHints, removeCommandListener, removeInterceptor, requestDefautIn, setActionCommand, uninstallShortCut, uninstallShortCut

Methods inherited from class org.pietschy.command.Command

addFace, addHoverListener, addNewFace, addNotify, addPropertyChangeListener, addPropertyChangeListener, attach, buttonIterator, configureButtonAppearance, configureButtonAppearances, configureButtonAppearances, configureButtonStates, createButton, createButton, createButton, createButton, createMenuItem, createMenuItem, createMenuItem, createMenuItem, detach, export, faceExists, fireHoverEnded, fireHoverStarted, getAccelerator, getAlternativeFaceNames, getButtonFactory, getButtonIn, getCommandManager, getDefaultFace, getDefaultFace, getDescription, getFace, getFace, getIcon, getId, getLongDescription, getMenuFactory, getMnemonic, getMnemonicIndex, getProperty, getProperty, getPropertyNames, getSelectedIcon, getText, getTextPosition, getToolbarFactory, initCommandManager, installFace, isAnonymous, isAttachedTo, isEnabled, isVisible, putProperty, removeHoverListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, requestFocusIn, setAccelerator, setButtonFactory, setDescription, setEnabled, setIcon, setLongDescription, setMenuFactory, setMnemonic, setMnemonicIndex, setSelectedIcon, setText, setTextPosition, setToolbarFactory, setVisible, toString

Constructor Details

AbstractFileOpenCommand

public AbstractFileOpenCommand(String id,
                               FileFilter filter)
Creates a new command with the specified id and FileFilter. This command is bound to the default command manager.
Parameters:
id - the id of the command.
filter - the FileFilter to use.

AbstractFileOpenCommand

public AbstractFileOpenCommand(String id,
                               FileFilter[] filters)
Creates a new command with the specified id and list of FileFilter. This command is bound to the default command manager.
Parameters:
id - the id of the command.
filters - a list of FileFilter instances to use.

AbstractFileOpenCommand

public AbstractFileOpenCommand(CommandManager manager,
                               String id,
                               FileFilter filter)
Creates a new command with the specified id and FileFilter
Parameters:
id - the id of the command.
filter - the FileFilter to use.

AbstractFileOpenCommand

public AbstractFileOpenCommand(CommandManager manager,
                               String id,
                               FileFilter[] filters)
Creates a new command with the specified id and list of FileFilter
Parameters:
id - the id of the command.
filters - a list of FileFilter instances to use.

Method Details

isMultiselectionEnabled

public boolean isMultiselectionEnabled()
Checks if multiple selection is enabled.
Returns:
true if multiple selection is enabled.

performFileAction

protected void performFileAction(File[] files,
                                 JFileChooser chooser,
                                 Window invoker)
Overrides:
performFileAction in interface AbstractFileCommand

performOpen

protected abstract void performOpen(File[] files)
Parameters:
files - the files that the user has selected.

setMultiselectionEnabled

public void setMultiselectionEnabled(boolean multiselectionEnabled)
Configures if the JFileChooser allows multiple selection.
Parameters:
multiselectionEnabled - true to allow multiple file selection, false otherwise.

showChooserDialog

protected int showChooserDialog(JFileChooser chooser,
                                Window invoker)
Overrides:
showChooserDialog in interface AbstractFileCommand