Package org.openstreetmap.josm.actions
Class AddImageryLayerAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.AddImageryLayerAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,AdaptableAction
,Destroyable
public class AddImageryLayerAction extends JosmAction implements AdaptableAction
Action displayed in imagery menu to add a new imagery layer.- Since:
- 3715
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AddImageryLayerAction.LayerSelection
Represents the user choices when selecting layers to display.(package private) static class
AddImageryLayerAction.SelectWmsLayersDialog
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
-
Field Summary
Fields Modifier and Type Field Description private ImageryInfo
info
-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Constructor Description AddImageryLayerAction(ImageryInfo info)
Constructs a newAddImageryLayerAction
for the givenImageryInfo
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
private static AddImageryLayerAction.LayerSelection
askToSelectLayers(WMSImagery wms)
private static ImageryInfo
convertImagery(ImageryInfo info)
Converts general ImageryInfo to specific one, that does not need any user action to initialize see: https://josm.openstreetmap.de/ticket/13868protected static ImageryInfo
getWMSLayerInfo(ImageryInfo info)
Asks user to choose a WMS layer from a WMS endpoint.static ImageryInfo
getWMSLayerInfo(ImageryInfo info, java.util.function.Function<WMSImagery,AddImageryLayerAction.LayerSelection> choice)
Asks user to choose a WMS layer from a WMS endpoint.private static void
handleException(java.lang.Exception ex, java.lang.String uiMessage, java.lang.String uiTitle, java.lang.String logMessage)
protected boolean
listenToSelectionChange()
Overwrite this ifJosmAction.updateEnabledState()
should be called when the selection changed.java.lang.String
toString()
protected void
updateEnabledState()
Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.-
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, setHelpId, setToolbarId, setTooltip, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
info
private final transient ImageryInfo info
-
-
Constructor Detail
-
AddImageryLayerAction
public AddImageryLayerAction(ImageryInfo info)
Constructs a newAddImageryLayerAction
for the givenImageryInfo
. If an http:// icon is specified, it is fetched asynchronously.- Parameters:
info
- The imagery info
-
-
Method Detail
-
convertImagery
private static ImageryInfo convertImagery(ImageryInfo info)
Converts general ImageryInfo to specific one, that does not need any user action to initialize see: https://josm.openstreetmap.de/ticket/13868- Parameters:
info
- ImageryInfo that will be converted (or returned when no conversion needed)- Returns:
- ImageryInfo object that's ready to be used to create TileSource
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
askToSelectLayers
private static AddImageryLayerAction.LayerSelection askToSelectLayers(WMSImagery wms)
-
getWMSLayerInfo
protected static ImageryInfo getWMSLayerInfo(ImageryInfo info) throws java.io.IOException, WMSImagery.WMSGetCapabilitiesException
Asks user to choose a WMS layer from a WMS endpoint.- Parameters:
info
- the WMS endpoint.- Returns:
- chosen WMS layer, or null
- Throws:
java.io.IOException
- if any I/O error occurs while contacting the WMS endpointWMSImagery.WMSGetCapabilitiesException
- if the WMS getCapabilities request failsjava.nio.file.InvalidPathException
- if a Path object cannot be constructed for the capabilities cached file
-
getWMSLayerInfo
public static ImageryInfo getWMSLayerInfo(ImageryInfo info, java.util.function.Function<WMSImagery,AddImageryLayerAction.LayerSelection> choice) throws java.io.IOException, WMSImagery.WMSGetCapabilitiesException
Asks user to choose a WMS layer from a WMS endpoint.- Parameters:
info
- the WMS endpoint.choice
- how the user may choose the WMS layer- Returns:
- chosen WMS layer, or null
- Throws:
java.io.IOException
- if any I/O error occurs while contacting the WMS endpointWMSImagery.WMSGetCapabilitiesException
- if the WMS getCapabilities request failsjava.nio.file.InvalidPathException
- if a Path object cannot be constructed for the capabilities cached file- Since:
- 14549
-
handleException
private static void handleException(java.lang.Exception ex, java.lang.String uiMessage, java.lang.String uiTitle, java.lang.String logMessage)
-
listenToSelectionChange
protected boolean listenToSelectionChange()
Description copied from class:JosmAction
Overwrite this ifJosmAction.updateEnabledState()
should be called when the selection changed. Default is true.- Overrides:
listenToSelectionChange
in classJosmAction
- Returns:
true
if aDataSelectionListener
should be registered.
-
updateEnabledState
protected void updateEnabledState()
Description copied from class:JosmAction
Override 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:
updateEnabledState
in classJosmAction
- See Also:
JosmAction.updateEnabledState(Collection)
,JosmAction.initEnabledState()
,JosmAction.listenToLayerChange()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-