public abstract class SaveActionBase extends DiskAccessAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
Modifier and Type | Field and Description |
---|---|
private boolean |
quiet |
sc
Constructor and Description |
---|
SaveActionBase(java.lang.String name,
java.lang.String iconName,
java.lang.String tooltip,
Shortcut shortcut)
Constructs a new
SaveActionBase . |
SaveActionBase(java.lang.String name,
java.lang.String iconName,
java.lang.String tooltip,
Shortcut shortcut,
boolean quiet)
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 quiet) |
boolean |
doSave()
Saves the active layer.
|
boolean |
doSave(boolean quiet)
Saves the active layer.
|
boolean |
doSave(Layer layer)
Saves the given layer.
|
boolean |
doSave(Layer layer,
boolean quiet)
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()
Override in subclasses to update the enabled state of the action when
something in the JOSM state changes, i.e.
|
createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setTooltip, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
private boolean quiet
public 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 SaveActionBase(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, boolean quiet)
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 shortcutquiet
- whether the quiet exporter is calledpublic void actionPerformed(java.awt.event.ActionEvent e)
public boolean doSave()
true
if the save operation succeedspublic boolean doSave(boolean quiet)
quiet
- If the file is saved without prompting the usertrue
if the save operation succeedspublic boolean doSave(Layer layer)
layer
- layer to savetrue
if the save operation succeedspublic boolean doSave(Layer layer, boolean quiet)
layer
- layer to savequiet
- If the file is saved without prompting the usertrue
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
and prevent dialogs from being shown.true
if the layer has been successfully saved, false
otherwiseprivate static boolean doInternalSave(Layer layer, java.io.File file, boolean quiet)
protected void updateEnabledState()
JosmAction
JosmAction.updateEnabledState(Collection)
to respond to changes in the collection
of selected primitives.
Default behavior is empty.updateEnabledState
in class JosmAction
JosmAction.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 filterFile
DiskAccessAction.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 extensionFile
DiskAccessAction.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)