public abstract class SwingSaver extends AbstractSaver implements ChangeMonitorable, Savable
Constructor and Description |
---|
SwingSaver() |
SwingSaver(java.lang.String defaultName) |
Modifier and Type | Method and Description |
---|---|
boolean |
askToSave()
Promts the user wheather to save changed data and calls save() if necessary.
|
boolean |
askToSave(java.awt.Component parentComponent) |
javax.swing.JFileChooser |
getFileChooser()
Returns the file dialog used by this instance in
saveAs() and saveAs(Component) . |
boolean |
saveAs()
Opens a save dialog and asks the user where to save the file.
|
boolean |
saveAs(java.awt.Component parentComponent)
Opens a save dialog and asks the user where to save the file.
|
addFileExtension, endsWithDefaultExt, endsWithValidExt, getDefaultExtension, getDefaultName, getDefaultNameOrPath, getFile, getFileExtensions, hasFile, removeFileExtention, save, saveDataToFile, setDefaultExtension, setDefaultName, setFile
hasChanged, registerChange, reset
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addFileExtension, endsWithDefaultExt, endsWithValidExt, getDefaultExtension, getDefaultName, getDefaultNameOrPath, getFile, getFileExtensions, hasFile, removeFileExtention, save, setDefaultExtension, setDefaultName, setFile
hasChanged, registerChange, reset
public SwingSaver()
public SwingSaver(java.lang.String defaultName)
public boolean askToSave()
Savable
true
.askToSave
in interface Savable
askToSave
in class AbstractSaver
true
if the file can be closed or false
if the user
wants to cancelpublic boolean askToSave(java.awt.Component parentComponent)
public boolean saveAs()
saveAs(null).
Note that this method must only be called inside the Swing thread because the used Swing methods are not thread save.
saveAs
in interface Savable
saveAs
in class AbstractSaver
true
if the file was successfully saved, false
if the user canceled the operationpublic boolean saveAs(java.awt.Component parentComponent)
Note that this method must only be called inside the Swing thread because the used Swing methods are not thread save.
parentComponent
- the parent component used to position the file dialogtrue
if the file was successfully saved, false
if the user canceled the operationpublic javax.swing.JFileChooser getFileChooser()
saveAs()
and saveAs(Component)
.
Note that this component will be created when this method is called for the first time. The creation of that component is not thread save and therefore this method should only be called from the Swing thread.