|
|||||||||
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
org.pietschy.command.file.AbstractSaveAsCommand
public abstract class AbstractSaveAsCommand
This command provides generic behaviour for the standard "save as" operation. On execution, the
command will display a JFileChooser
and if successful performSave(java.io.File)
will be
invoked. If the file selected by the user already exists the command will prompt the user to
confirm before performSave(java.io.File)
is invoked. The message displayed to the user can be
configured by overriding getFileExistsMessage(java.io.File)
and getFileExistsTitle()
.
ExtensionFileFilter
, the command will also
ensure the extension of the file is correct.
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 | |
---|---|
AbstractSaveAsCommand(CommandManager manager,
java.lang.String id,
javax.swing.filechooser.FileFilter filter)
Creates new instance with the specified id and FileFilter . |
|
AbstractSaveAsCommand(CommandManager manager,
java.lang.String id,
javax.swing.filechooser.FileFilter[] filters)
Creates new instance with the specified id and FileFilters . |
|
AbstractSaveAsCommand(java.lang.String id,
javax.swing.filechooser.FileFilter filter)
Creates new instance with the specified id and FileFilter . |
|
AbstractSaveAsCommand(java.lang.String id,
javax.swing.filechooser.FileFilter[] filters)
Creates new instance with the specified id and FileFilter list. |
Method Summary | |
---|---|
protected boolean |
confirmOverwrite(java.awt.Window invoker,
java.io.File file)
This method is called to confirm the save if the selected file already exists. |
protected java.lang.String |
getFileExistsMessage(java.io.File file)
Gets the text to display in the dialog that confirms file overwrite. |
protected void |
performFileAction(java.io.File[] selectedFiles,
javax.swing.JFileChooser chooser,
java.awt.Window invoker)
This method is invoked if the AbstractFileCommand.showChooserDialog(javax.swing.JFileChooser, java.awt.Window) returns
JFileChooser.APPROVE_OPTION . |
protected abstract void |
performSave(java.io.File file)
Called to perform the save operation. |
protected int |
showChooserDialog(javax.swing.JFileChooser chooser,
java.awt.Window invoker)
Called to display the JFileChooser . |
protected java.io.File |
verifyFileExtension(java.io.File file,
javax.swing.filechooser.FileFilter selectedFilter)
Invoked to verify the extension of the file selected by the user. |
Methods inherited from class org.pietschy.command.file.AbstractFileCommand |
---|
afterExecute, beforeExecute, confirmProceed, getDefaultFileFilter, getFileChooser, handleCancel, handleError, handleExecute, isAcceptAllFileFilterUsed, isCenterOnInvoker, isRememberLastFilter, setAcceptAllFileFilterUsed, setCenterOnInvoker, setDefaultFileFilter, setRememberLastFilter |
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 AbstractSaveAsCommand(java.lang.String id, javax.swing.filechooser.FileFilter filter)
FileFilter
. This command is
bound to the default command manager.
id
- the command id.filter
- the FileFilter
for the JFileChooser
to use. If it is an
instance of ExtensionFileFilter
the command will ensure the selected file has
the correct extension.public AbstractSaveAsCommand(java.lang.String id, javax.swing.filechooser.FileFilter[] filters)
FileFilter
list. This command is
bound to the default command manager.
id
- the command id.filters
- the FileFilter
list for the JFileChooser
to use. If they are
instances of ExtensionFileFilter
the command will ensure the selected file has
the correct extension.public AbstractSaveAsCommand(CommandManager manager, java.lang.String id, javax.swing.filechooser.FileFilter filter)
FileFilter
.
id
- the commands id.filter
- the FileFilter
for the JFileChooser
to use. If it is an
instance of ExtensionFileFilter
the command will ensure the selected file has
the correct extension.public AbstractSaveAsCommand(CommandManager manager, java.lang.String id, javax.swing.filechooser.FileFilter[] filters)
FileFilters
.
id
- the commands id.filters
- the FileFilter
list for the JFileChooser
to use. If they are
instances of ExtensionFileFilter
the command will ensure the selected file has
the correct extension.Method Detail |
---|
protected int showChooserDialog(javax.swing.JFileChooser chooser, java.awt.Window invoker)
AbstractFileCommand
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); }
showChooserDialog
in class AbstractFileCommand
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 void performFileAction(java.io.File[] selectedFiles, javax.swing.JFileChooser chooser, java.awt.Window invoker)
AbstractFileCommand
AbstractFileCommand.showChooserDialog(javax.swing.JFileChooser, java.awt.Window)
returns
JFileChooser.APPROVE_OPTION
. Subclasses must override to perform the specific file
operation.
performFileAction
in class AbstractFileCommand
selectedFiles
- the files that were selected in the JFileChooser
chooser
- the JFileChooser
that was displayed.invoker
- the owner window.protected java.io.File verifyFileExtension(java.io.File file, javax.swing.filechooser.FileFilter selectedFilter)
FileFilter
is an instance of
ExtensionFileFilter
. If it is, it invokes
ExtensionFileFilter.checkAndAddExtension(java.io.File)
on the file, otherwise the file is returned
as is.
file
- the file the users has selected, that may or may not have an extension.selectedFilter
- the FileFilter
selected in the chooser.
ExtensionFileFilter
protected boolean confirmOverwrite(java.awt.Window invoker, java.io.File file)
JOptionPane.showConfirmDialog(java.awt.Component, Object)
with getFileExistsTitle()
and getFileExistsMessage(java.io.File)
.
Subclasses can override for complete control over the confirmation process.
invoker
- the invoker window.file
- the file that is to be overwritten.
true
to overwrite the file, false
to cancel the operation.protected java.lang.String getFileExistsMessage(java.io.File file)
protected abstract void performSave(java.io.File file)
file
- the file to save.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |