Package org.openstreetmap.josm.actions
Class SessionSaveAction
java.lang.Object
javax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
org.openstreetmap.josm.actions.DiskAccessAction
org.openstreetmap.josm.actions.SessionSaveAction
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action,LayerManager.LayerChangeListener,MapFrameListener,Destroyable
- Direct Known Subclasses:
SessionSaveAsAction
public class SessionSaveAction
extends DiskAccessAction
implements MapFrameListener, LayerManager.LayerChangeListener
Saves a JOSM session
- Since:
- 18466
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassThe "Save Session" dialogNested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<Layer,SessionLayerExporter> private static final SessionSaveAction(package private) static booleanprotected FileFilterprotected FileFilter(package private) static List<WeakReference<Layer>>private static booleanprivate Fileprivate static final BooleanPropertyprivate static final BooleanPropertyprivate static final String(package private) static Fileprivate static Stringprivate static final StringFields inherited from class org.openstreetmap.josm.actions.JosmAction
scFields inherited from class javax.swing.AbstractAction
changeSupport, enabledFields inherited from interface javax.swing.Action
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 Summary
ConstructorsModifierConstructorDescriptionConstructs a newSessionSaveAction.protectedSessionSaveAction(boolean toolbar, boolean installAdapters) Constructs a newSessionSaveAction.protectedSessionSaveAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean register, String toolbarId, boolean installAdapters) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidprotected voidcleanup()voiddestroy()Called when the object has been destroyed.protected booleandoGetFile(boolean saveAs, boolean zipRequired) Sets the current session file.protected voiddoGetFileChooser(boolean zipRequired) static SessionSaveActionReturns the instancestatic StringReturns the tooltip for the componentvoidNotifies this listener that a layer has been added.voidNotifies this listener that the order of layers was changed.voidNotifies this listener that a layer was just removed.voidmapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) Called after Main.mapFrame is initialized.private static booleanCheck to see if any plugins want to save their stateprotected voidbooleansaveSession(boolean saveAs, boolean forceSaveAll) Attempts to save the session.private booleansaveSessionImpl(boolean saveAs, boolean forceSaveAll) static voidsetCurrentLayers(List<Layer> layers) Sets the layers that are currently represented in the session filestatic voidsetCurrentSession(File file, boolean zip) Sets the current session filestatic voidsetCurrentSession(File file, List<Layer> layers, Set<SessionWriter.SessionWriterFlags> flags) Sets the current session file and the layers included in that filestatic voidsetCurrentSession(File file, List<Layer> layers, SessionWriter.SessionWriterFlags... flags) Sets the current session file and the layers included in that fileprotected voidOverride in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.private static voidupdateSessionFile(String fileName) Update the session fileMethods inherited from class org.openstreetmap.josm.actions.DiskAccessAction
createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser, createAndOpenFileChooser, showSavedNotification, showSavingNotificationMethods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setToolbarId, setTooltip, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFutureMethods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Field Details
-
layers
-
exporters
-
dependencies
-
SAVE_LOCAL_FILES_PROPERTY
-
SAVE_PLUGIN_INFORMATION_PROPERTY
-
TOOLTIP_DEFAULT
-
SAVE_SESSION
-
joz
-
jos
-
removeFileOnSuccess
-
tooltip
-
sessionFile
-
isZipSessionFile
-
pluginData
-
layersInSessionFile
-
instance
-
-
Constructor Details
-
SessionSaveAction
public SessionSaveAction()Constructs a newSessionSaveAction. -
SessionSaveAction
Constructs a newSessionSaveAction.- Parameters:
toolbar- Register this action for the toolbar preferences?installAdapters- False, if you don't want to install layer changed and selection changed adapters
-
SessionSaveAction
-
-
Method Details
-
getInstance
Returns the instance- Returns:
- the instance
-
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-
destroy
Description copied from interface:DestroyableCalled when the object has been destroyed.- Specified by:
destroyin interfaceDestroyable- Overrides:
destroyin classJosmAction
-
saveSession
Attempts to save the session.- Parameters:
saveAs- true shows the dialogforceSaveAll- saves all layers- Returns:
- if the session and all layers were successfully saved
- Throws:
UserCancelException- when the user has cancelled the save process
-
saveSessionImpl
- Throws:
UserCancelException
-
doGetFile
Sets the current session file. Asks the user if necessary- Parameters:
saveAs- always ask the userzipRequired- zip- Returns:
- if the user was asked
- Throws:
UserCancelException- when the user has cancelled the save process
-
doGetFileChooser
- Throws:
UserCancelException
-
addListeners
-
removeListeners
-
updateEnabledState
Description copied from class:JosmActionOverride in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e. when a layer is removed or added. SeeJosmAction.updateEnabledState(Collection)to respond to changes in the collection of selected primitives. Default behavior is empty.- Overrides:
updateEnabledStatein classJosmAction- See Also:
-
mapFrameInitialized
Description copied from interface:MapFrameListenerCalled after Main.mapFrame is initialized. (After the first data is loaded). You can use this callback to tweak the newFrame to your needs, as example install an alternative Painter.- Specified by:
mapFrameInitializedin interfaceMapFrameListener- Parameters:
oldFrame- The old MapFramenewFrame- The new MapFrame
-
layerAdded
Description copied from interface:LayerManager.LayerChangeListenerNotifies this listener that a layer has been added.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerAddedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The new added layer event
-
layerRemoving
Description copied from interface:LayerManager.LayerChangeListenerNotifies this listener that a layer was just removed.Listeners are called in the EDT thread after the layer was removed. Use
LayerManager.LayerRemoveEvent.scheduleRemoval(Collection)to remove more layers. You should not do blocking or long-running tasks in this method.- Specified by:
layerRemovingin interfaceLayerManager.LayerChangeListener- Parameters:
e- The layer to be removed (as event)
-
layerOrderChanged
Description copied from interface:LayerManager.LayerChangeListenerNotifies this listener that the order of layers was changed.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerOrderChangedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The order change event.
-
updateSessionFile
Update the session file- Parameters:
fileName- The filename to use. If there are no periods in the file, we update the extension.- Throws:
UserCancelException- If the user does not want to overwrite a previously existing file.
-
setCurrentSession
public static void setCurrentSession(File file, List<Layer> layers, SessionWriter.SessionWriterFlags... flags) Sets the current session file and the layers included in that file- Parameters:
file- filelayers- layers that are currently represented in the session fileflags- The flags for the current session- Since:
- 18833
-
setCurrentSession
public static void setCurrentSession(File file, List<Layer> layers, Set<SessionWriter.SessionWriterFlags> flags) Sets the current session file and the layers included in that file- Parameters:
file- filelayers- layers that are currently represented in the session fileflags- The flags for the current session- Since:
- 18833
-
setCurrentSession
Sets the current session file- Parameters:
file- filezip- if it is a zip session file
-
setCurrentLayers
Sets the layers that are currently represented in the session file- Parameters:
layers- layers
-
getTooltip
Returns the tooltip for the component- Returns:
- the tooltip for the component
-
pluginsWantToSave
Check to see if any plugins want to save their state- Returns:
trueif the plugin wants to save their state
-
cleanup
-