Package org.openstreetmap.josm.actions
Class DiskAccessAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.DiskAccessAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,Destroyable
- Direct Known Subclasses:
GpxExportAction
,OpenFileAction
,SaveActionBase
,SessionLoadAction
,SessionSaveAction
public abstract class DiskAccessAction extends JosmAction
Helper class for all actions that access the disk.- Since:
- 78
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
-
Field Summary
-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DiskAccessAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut)
Constructs a newDiskAccessAction
.protected
DiskAccessAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, boolean register, java.lang.String toolbarId, boolean installAdapters)
Constructs a newDiskAccessAction
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AbstractFileChooser
createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title)
Creates a newAbstractFileChooser
and makes it visible.static AbstractFileChooser
createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title, java.lang.String extension)
Creates a newAbstractFileChooser
and makes it visible.static AbstractFileChooser
createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title, java.lang.String extension, int selectionMode, boolean allTypes, java.lang.String lastDirProperty)
Creates a newAbstractFileChooser
and makes it visible.static AbstractFileChooser
createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title, java.util.Collection<? extends javax.swing.filechooser.FileFilter> filters, javax.swing.filechooser.FileFilter defaultFilter, int selectionMode, java.lang.String lastDirProperty)
Creates a newAbstractFileChooser
for severalFileFilter
s and makes it visible.static AbstractFileChooser
createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title, javax.swing.filechooser.FileFilter filter, int selectionMode, java.lang.String lastDirProperty)
Creates a newAbstractFileChooser
for a singleFileFilter
and makes it visible.protected static Notification
showSavedNotification(Notification savingNotification, java.lang.String filename)
Show "Successfully saved file" notification and returns it.protected static Notification
showSavingNotification(java.lang.String filename)
Show "saving file ..." notification and returns it, for future replacement.-
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setToolbarId, setTooltip, updateEnabledState, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Constructor Detail
-
DiskAccessAction
protected DiskAccessAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut)
Constructs a newDiskAccessAction
.- Parameters:
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 ornull
if you don't want a shortcut- Since:
- 1084
-
DiskAccessAction
protected DiskAccessAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, boolean register, java.lang.String toolbarId, boolean installAdapters)
Constructs a newDiskAccessAction
.- Parameters:
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 shortcutregister
- Register this action for the toolbar preferences?toolbarId
- Identifier for the toolbar preferences. The iconName is used, if this parameter is nullinstallAdapters
- False, if you don't want to install layer changed and selection changed adapters- Since:
- 5438
-
-
Method Detail
-
createAndOpenFileChooser
public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title)
Creates a newAbstractFileChooser
and makes it visible.- Parameters:
open
- If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialogmultiple
- If true, makes the dialog allow multiple file selectionstitle
- The string that goes in the dialog window's title bar- Returns:
- The
AbstractFileChooser
. - Since:
- 1646
-
createAndOpenFileChooser
public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title, java.lang.String extension)
Creates a newAbstractFileChooser
and makes it visible.- Parameters:
open
- If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialogmultiple
- If true, makes the dialog allow multiple file selectionstitle
- The string that goes in the dialog window's title barextension
- The file extension that will be selected as the default file filter- Returns:
- The
AbstractFileChooser
. - Since:
- 2020
-
createAndOpenFileChooser
public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title, java.lang.String extension, int selectionMode, boolean allTypes, java.lang.String lastDirProperty)
Creates a newAbstractFileChooser
and makes it visible.- Parameters:
open
- If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialogmultiple
- If true, makes the dialog allow multiple file selectionstitle
- The string that goes in the dialog window's title barextension
- The file extension that will be selected as the default file filterselectionMode
- The selection mode that allows the user to:- just select files (
JFileChooser.FILES_ONLY
) - just select directories (
JFileChooser.DIRECTORIES_ONLY
) - select both files and directories (
JFileChooser.FILES_AND_DIRECTORIES
)
- just select files (
allTypes
- If true, all the files types known by JOSM will be proposed in the "file type" combobox. If false, only the file filters that includeextension
will be proposedlastDirProperty
- The name of the property used to setup the AbstractFileChooser initial directory. This property will then be updated to the new "last directory" chosen by the user. If null, the default property "lastDirectory" will be used.- Returns:
- The
AbstractFileChooser
. - Since:
- 5438
-
createAndOpenFileChooser
public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title, javax.swing.filechooser.FileFilter filter, int selectionMode, java.lang.String lastDirProperty)
Creates a newAbstractFileChooser
for a singleFileFilter
and makes it visible.- Parameters:
open
- If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialogmultiple
- If true, makes the dialog allow multiple file selectionstitle
- The string that goes in the dialog window's title barfilter
- The only file filter that will be proposed by the dialogselectionMode
- The selection mode that allows the user to:- just select files (
JFileChooser.FILES_ONLY
) - just select directories (
JFileChooser.DIRECTORIES_ONLY
) - select both files and directories (
JFileChooser.FILES_AND_DIRECTORIES
)
- just select files (
lastDirProperty
- The name of the property used to setup the AbstractFileChooser initial directory. This property will then be updated to the new "last directory" chosen by the user- Returns:
- The
AbstractFileChooser
. - Since:
- 5438
-
createAndOpenFileChooser
public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, java.lang.String title, java.util.Collection<? extends javax.swing.filechooser.FileFilter> filters, javax.swing.filechooser.FileFilter defaultFilter, int selectionMode, java.lang.String lastDirProperty)
Creates a newAbstractFileChooser
for severalFileFilter
s and makes it visible.- Parameters:
open
- If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialogmultiple
- If true, makes the dialog allow multiple file selectionstitle
- The string that goes in the dialog window's title barfilters
- The file filters that will be proposed by the dialogdefaultFilter
- The file filter that will be selected by defaultselectionMode
- The selection mode that allows the user to:- just select files (
JFileChooser.FILES_ONLY
) - just select directories (
JFileChooser.DIRECTORIES_ONLY
) - select both files and directories (
JFileChooser.FILES_AND_DIRECTORIES
)
- just select files (
lastDirProperty
- The name of the property used to setup the JFileChooser initial directory. This property will then be updated to the new "last directory" chosen by the user- Returns:
- The
AbstractFileChooser
. - Since:
- 5438
-
showSavingNotification
protected static Notification showSavingNotification(java.lang.String filename)
Show "saving file ..." notification and returns it, for future replacement.- Parameters:
filename
- filename of file to save- Returns:
Notification
to provide toshowSavedNotification(org.openstreetmap.josm.gui.Notification, java.lang.String)
once saving is successful- Since:
- 18135
-
showSavedNotification
protected static Notification showSavedNotification(Notification savingNotification, java.lang.String filename)
Show "Successfully saved file" notification and returns it.- Parameters:
savingNotification
-Notification
returned byshowSavingNotification(java.lang.String)
filename
- filename of file saved- Returns:
Notification
displayed- Since:
- 18135
-
-