be.ugent.caagt.swirl.actions

Class FileSaveAction


public abstract class FileSaveAction
extends FileAction

Abstract super class for actions that allow files to be saved. Clients should at least override saveFile(File).

Field Summary

Fields inherited from class be.ugent.caagt.swirl.actions.FileAction

fileChooser, parent

Constructor Summary

FileSaveAction(Window parent, FileFilter... filters)
Create an action of this type

Method Summary

protected void
dialogApproved()
Invoke saveFile(File) on the file chosen.
protected abstract void
saveFile(File file)
Called for the file selected by the user.
protected int
showDialog()
Shows the file chooser save dialog.
protected abstract boolean
showFileExistsDialog(File file)
Alert the user that a file with the chosen name already exists.

Methods inherited from class be.ugent.caagt.swirl.actions.FileAction

actionPerformed, createFileChooser, dialogApproved, dialogCanceled, dialogClosed, showDialog

Constructor Details

FileSaveAction

public FileSaveAction(Window parent,
                      FileFilter... filters)
Create an action of this type
Parameters:
parent - Parent window for the file chooser dialog
filters - File filters for the file chooser dialog

Method Details

dialogApproved

protected void dialogApproved()
Invoke saveFile(File) on the file chosen. When the file already exists, the user is asked to confirm the save using showFileExistsDialog(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.
Overrides:
dialogApproved in interface FileAction

saveFile

protected abstract void saveFile(File file)
Called for the file selected by the user. Must be overridden by clients.

showDialog

protected int showDialog()
Shows the file chooser save dialog.
Overrides:
showDialog in interface FileAction

showFileExistsDialog

protected abstract boolean showFileExistsDialog(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.