|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pietschy.command.Command
org.pietschy.command.ActionCommand
org.pietschy.command.file.AbstractFileCommand
public abstract class AbstractFileCommand
This is the base implementation of file commands. It provides the basic JFileChooser
functionality. Subclass must override showChooserDialog(javax.swing.JFileChooser, java.awt.Window)
and performFileAction(java.io.File[], javax.swing.JFileChooser, java.awt.Window)
.
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 | |
---|---|
AbstractFileCommand(CommandManager manager,
java.lang.String id,
javax.swing.filechooser.FileFilter[] filters)
Creates a new AbstractFileCommand with the specified file filters. |
Method Summary | |
---|---|
protected void |
afterExecute()
Deprecated. Use ActionCommandInterceptor instead. |
protected void |
beforeExecute()
Deprecated. Use ActionCommandInterceptor instead. |
protected boolean |
confirmProceed()
This is method can be overridden to prevent the action from proceeding. |
javax.swing.filechooser.FileFilter |
getDefaultFileFilter()
Gets the default FileFilter that will be selected in the chooser if
isRememberLastFilter() is false . |
protected javax.swing.JFileChooser |
getFileChooser()
Gets the file choose the command will use. |
protected void |
handleCancel(javax.swing.JFileChooser chooser,
java.awt.Window invokerWindow)
This method is invoked if the user cancels the file chooser dialog. |
protected void |
handleError(javax.swing.JFileChooser chooser,
java.awt.Window invoker)
This method is invoked if the showChooserDialog(javax.swing.JFileChooser, java.awt.Window) returns
JFileChooser.ERROR_OPTION . |
protected void |
handleExecute()
Main entry point for command subclasses that must be implemented to provide command specific behaviour. |
boolean |
isAcceptAllFileFilterUsed()
Used to configure JFileChooser.setAcceptAllFileFilterUsed(boolean) . |
boolean |
isCenterOnInvoker()
Checks if this command will be centering the chooser on the invoker window. |
boolean |
isRememberLastFilter()
Checks if the last FileFilter used by the user will be remembered. |
protected abstract void |
performFileAction(java.io.File[] files,
javax.swing.JFileChooser chooser,
java.awt.Window invoker)
This method is invoked if the showChooserDialog(javax.swing.JFileChooser, java.awt.Window) returns
JFileChooser.APPROVE_OPTION . |
void |
setAcceptAllFileFilterUsed(boolean accept)
Used to configure JFileChooser.setAcceptAllFileFilterUsed(boolean) . |
void |
setCenterOnInvoker(boolean centerOnInvoker)
Configures if command will centre the chooser over the invoker or centre in the desktop. |
void |
setDefaultFileFilter(javax.swing.filechooser.FileFilter defaultFileFilter)
Sets the default FileFilter that will be selected in the chooser if
isRememberLastFilter() is false . |
void |
setRememberLastFilter(boolean rememberLastFilter)
Configures this command to remember the FileFilter last used by the user. |
protected abstract int |
showChooserDialog(javax.swing.JFileChooser chooser,
java.awt.Window centerOn)
Called to display the JFileChooser . |
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, installShortCut, installShortCut, postExecute, preExecute, putHint, putHints, removeCommandListener, removeInterceptor, requestDefautIn, setActionCommand, uninstallShortCut, uninstallShortCut |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.pietschy.command.ActionCommandExecutor |
---|
addPropertyChangeListener, addPropertyChangeListener, isEnabled, removePropertyChangeListener, removePropertyChangeListener |
Constructor Detail |
---|
public AbstractFileCommand(CommandManager manager, java.lang.String id, javax.swing.filechooser.FileFilter[] filters)
FileFilter
.
filters
- the file filters to use.
java.lang.NullPointerException
- if filters is null
java.lang.IllegalArgumentException
- if filters is an empty array.Method Detail |
---|
protected final void handleExecute()
ActionCommand
This method should never be called directly to invoke a comand. All
command invocation must be performed using the ActionCommand.execute()
and
ActionCommand.execute(Map)
methods.
handleExecute
in class ActionCommand
protected void handleCancel(javax.swing.JFileChooser chooser, java.awt.Window invokerWindow)
chooser
- the chooser that was cancelled.invokerWindow
- the window associated with the button or menu that invoked the command.protected boolean confirmProceed()
true
to preceed with showing the chooser, false
to cancel the
action. This method always returns true
.protected void beforeExecute()
ActionCommandInterceptor
instead.
protected void afterExecute()
ActionCommandInterceptor
instead.
protected void handleError(javax.swing.JFileChooser chooser, java.awt.Window invoker)
showChooserDialog(javax.swing.JFileChooser, java.awt.Window)
returns
JFileChooser.ERROR_OPTION
. The default implementation does nothing, subclasses
can override to handle the error.
chooser
- the JFileChooser
that was displayed.invoker
- the owner window.protected abstract int showChooserDialog(javax.swing.JFileChooser chooser, java.awt.Window centerOn)
JFileChooser
. Subclasses override to display an appropriate
version of the chooser (such as an open or save dialog). This method must return the result
of the JFileChooser
show method. Eg.
protected int showChooserDialog(JFileChooser chooser, Window invoker) { return chooser.showOpenDialog(invoker); }
chooser
- the chooser to display
JFileChooser.showDialog(java.awt.Component, java.lang.String)
, JFileChooser.showOpenDialog(java.awt.Component)
or
JFileChooser.showSaveDialog(java.awt.Component)
.protected abstract void performFileAction(java.io.File[] files, javax.swing.JFileChooser chooser, java.awt.Window invoker)
showChooserDialog(javax.swing.JFileChooser, java.awt.Window)
returns
JFileChooser.APPROVE_OPTION
. Subclasses must override to perform the specific file
operation.
files
- the files that were selected in the JFileChooser
chooser
- the JFileChooser
that was displayed.invoker
- the owner window.protected javax.swing.JFileChooser getFileChooser()
JFileChooser
.public javax.swing.filechooser.FileFilter getDefaultFileFilter()
FileFilter
that will be selected in the chooser if
isRememberLastFilter()
is false
.
If not explicitly specified, this value will be the filter specified in the constructor, or the first filter if a list of filteres was specified.
public void setDefaultFileFilter(javax.swing.filechooser.FileFilter defaultFileFilter)
FileFilter
that will be selected in the chooser if
isRememberLastFilter()
is false
.
If not explicitly specified, this value will be the filter specified in the constructor, or the first filter if a list of filteres was specified.
defaultFileFilter
- the default file filter.public boolean isRememberLastFilter()
FileFilter
used by the user will be remembered.
FileFilter
used by the
user, false if default is always used.public void setRememberLastFilter(boolean rememberLastFilter)
FileFilter
last used by the user. This
property defaults to false.
rememberLastFilter
- true to remember the last FileFilter
used,
false to always used the default FileFilter
.public boolean isAcceptAllFileFilterUsed()
JFileChooser.setAcceptAllFileFilterUsed(boolean)
.
public void setAcceptAllFileFilterUsed(boolean accept)
JFileChooser.setAcceptAllFileFilterUsed(boolean)
.
public boolean isCenterOnInvoker()
showChooserDialog(javax.swing.JFileChooser, java.awt.Window)
with a null window to
center on.
This setting will only be honoured if subclasses implement showChooserDialog(javax.swing.JFileChooser, java.awt.Window)
to
correctly utilize the centerOn parameter.
public void setCenterOnInvoker(boolean centerOnInvoker)
showChooserDialog(javax.swing.JFileChooser, java.awt.Window)
with a null window to
center on.
centerOnInvoker
- true to center the chooser on the invoker window, false to
centre on the desktop.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |