public abstract class SaveActionBase extends DiskAccessAction
Modifier and Type | Field and Description |
---|---|
private File |
file |
sc
changeSupport, enabled
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 and Description |
---|
SaveActionBase(String name,
String iconName,
String tooltip,
Shortcut shortcut) |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e) |
protected void |
addToFileOpenHistory() |
private static File |
checkFileAndConfirmOverWrite(AbstractFileChooser fc,
String extension) |
static boolean |
confirmOverwrite(File file) |
static File |
createAndOpenSaveFileChooser(String title,
ExtensionFileFilter filter)
Creates a new "Save" dialog for a single
ExtensionFileFilter and makes it visible.When the user has chosen a file, checks the file extension, and confirms overwrite if needed. |
static File |
createAndOpenSaveFileChooser(String title,
String extension)
Creates a new "Save" dialog for a given file extension and makes it visible.
When the user has chosen a file, checks the file extension, and confirms overwrite if needed. |
private static boolean |
doInternalSave(Layer layer,
File file) |
boolean |
doSave() |
boolean |
doSave(Layer layer) |
static boolean |
doSave(Layer layer,
File file,
boolean checkSaveConditions)
Saves a layer to a given file.
|
protected abstract File |
getFile(Layer layer) |
protected void |
updateEnabledState()
Refreshes the enabled state
|
createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip, updateEnabledState
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
public SaveActionBase(String name, String iconName, String tooltip, Shortcut shortcut)
public void actionPerformed(ActionEvent e)
public boolean doSave()
public static boolean doSave(Layer layer, File file, boolean checkSaveConditions)
layer
- The layer to savefile
- The destination filecheckSaveConditions
- if true
, checks preconditions before saving. Set it to false
to skip it
if preconditions have already been checked (as this check can prompt UI dialog in EDT it may be best in some cases
to do it earlier).true
if the layer has been successfully saved, false
otherwiseprivate static boolean doInternalSave(Layer layer, File file)
protected void updateEnabledState()
updateEnabledState
in class JosmAction
JosmAction.updateEnabledState(Collection)
,
JosmAction.initEnabledState()
public static File createAndOpenSaveFileChooser(String title, ExtensionFileFilter filter)
ExtensionFileFilter
and makes it visible.title
- The dialog titlefilter
- The dialog file filterFile
DiskAccessAction.createAndOpenFileChooser(boolean, boolean, String, FileFilter, int, String)
public static File createAndOpenSaveFileChooser(String title, String extension)
title
- The dialog titleextension
- The file extensionFile
DiskAccessAction.createAndOpenFileChooser(boolean, boolean, String, String)
private static File checkFileAndConfirmOverWrite(AbstractFileChooser fc, String extension)
public static boolean confirmOverwrite(File file)
protected void addToFileOpenHistory()