be.ugent.caagt.swirl.actions
Class FileSaveAction
java.lang.Object
javax.swing.AbstractAction
be.ugent.caagt.swirl.actions.FileAction
be.ugent.caagt.swirl.actions.FileSaveAction
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
public abstract class FileSaveAction
- extends FileAction
Abstract super class for actions that allow files to be saved.
Clients should at least override saveFile(java.io.File)
.
- See Also:
- Serialized Form
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary |
FileSaveAction(java.awt.Window parent,
javax.swing.filechooser.FileFilter... filters)
Create an action of this type |
Method Summary |
protected void |
dialogApproved()
Invoke saveFile(java.io.File) on the file chosen. |
protected abstract void |
saveFile(java.io.File file)
Called for the file selected by the user. |
protected int |
showDialog()
Shows the file chooser save dialog. |
protected abstract boolean |
showFileExistsDialog(java.io.File file)
Alert the user that a file with the chosen name already exists. |
Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileSaveAction
public FileSaveAction(java.awt.Window parent,
javax.swing.filechooser.FileFilter... filters)
- Create an action of this type
- Parameters:
parent
- Parent window for the file chooser dialogfilters
- File filters for the file chooser dialog
saveFile
protected abstract void saveFile(java.io.File file)
- Called for the file selected by the user. Must be overridden
by clients.
showFileExistsDialog
protected abstract boolean showFileExistsDialog(java.io.File file)
- Alert the user that a file with the chosen name already exists.
- Returns:
- true if the user allows the file to be overwritten.
showDialog
protected int showDialog()
- Shows the file chooser save dialog.
- Specified by:
showDialog
in class FileAction
dialogApproved
protected void dialogApproved()
- Invoke
saveFile(java.io.File)
on the file chosen.
When the file already exists, the user is asked to
confirm the save using showFileExistsDialog(java.io.File)
. If the user types
in a file name without extension and the selected file filter is of type
ExtensionFileFilter
, then an extension is appended
to the file name automatically.
- Specified by:
dialogApproved
in class FileAction