public abstract class SaveActionBase extends DiskAccessAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdaptersc| Constructor and Description |
|---|
SaveActionBase(java.lang.String name,
java.lang.String iconName,
java.lang.String tooltip,
Shortcut shortcut)
Constructs a new
SaveActionBase. |
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e) |
(package private) static void |
addToFileOpenHistory(java.io.File file) |
static java.io.File |
checkFileAndConfirmOverWrite(AbstractFileChooser fc,
java.lang.String extension)
Checks if selected filename has the given extension.
|
static boolean |
confirmOverwrite(java.io.File file)
Asks user to confirm overwiting a file.
|
static java.io.File |
createAndOpenSaveFileChooser(java.lang.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 java.io.File |
createAndOpenSaveFileChooser(java.lang.String title,
java.lang.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,
java.io.File file) |
boolean |
doSave()
Saves the active layer.
|
boolean |
doSave(Layer layer)
Saves the given layer.
|
static boolean |
doSave(Layer layer,
java.io.File file,
boolean checkSaveConditions)
Saves a layer to a given file.
|
protected abstract java.io.File |
getFile(Layer layer) |
(package private) static void |
showAndLogException(java.lang.Exception e) |
protected void |
updateEnabledState()
Refreshes the enabled state
|
createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChoosercheckAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setTooltip, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuturepublic SaveActionBase(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut)
SaveActionBase.name - The action's text as displayed on the menu (if it is added to a menu)iconName - The filename of the icon to usetooltip - A longer description of the action that will be displayed in the tooltipshortcut - A ready-created shortcut object or null if you don't want a shortcutpublic void actionPerformed(java.awt.event.ActionEvent e)
public boolean doSave()
true if the save operation succeedspublic boolean doSave(Layer layer)
layer - layer to savetrue if the save operation succeedspublic static boolean doSave(Layer layer, java.io.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, java.io.File file)
protected void updateEnabledState()
updateEnabledState in class JosmActionJosmAction.updateEnabledState(Collection),
JosmAction.initEnabledState(),
JosmAction.listenToLayerChange()public static java.io.File createAndOpenSaveFileChooser(java.lang.String title, ExtensionFileFilter filter)
ExtensionFileFilter and makes it visible.title - The dialog titlefilter - The dialog file filterFileDiskAccessAction.createAndOpenFileChooser(boolean, boolean, String, FileFilter, int, String)public static java.io.File createAndOpenSaveFileChooser(java.lang.String title, java.lang.String extension)
title - The dialog titleextension - The file extensionFileDiskAccessAction.createAndOpenFileChooser(boolean, boolean, String, String)public static java.io.File checkFileAndConfirmOverWrite(AbstractFileChooser fc, java.lang.String extension)
fc - FileChooser where file was already selectedextension - file extensionFile or null if the user cancelled the dialog.public static boolean confirmOverwrite(java.io.File file)
file - file to overwritetrue if the file can be writtenstatic void addToFileOpenHistory(java.io.File file)
static void showAndLogException(java.lang.Exception e)