Package org.openstreetmap.josm.actions
Class ToggleAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.ToggleAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,Destroyable
- Direct Known Subclasses:
ChangesetManagerToggleAction
,DialogsToggleAction
,ExpertToggleAction
,FullscreenToggleAction
,OnlineResourceMenu.ToggleOnlineResourceAction
,PreferenceToggleAction
,TiledRenderToggleAction
,ViewportFollowToggleAction
,WireframeToggleAction
public abstract class ToggleAction extends JosmAction
Abstract class for Toggle Actions.- Since:
- 6220
- 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 Modifier and Type Field Description private java.util.Set<javax.swing.ButtonModel>
buttonModels
-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ToggleAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, boolean registerInToolbar)
Constructs aToggleAction
.protected
ToggleAction(java.lang.String name, ImageProvider icon, java.lang.String tooltip, Shortcut shortcut, boolean registerInToolbar, java.lang.String toolbarId, boolean installAdapters)
Constructs aToggleAction
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addButtonModel(javax.swing.ButtonModel model)
Adds a button modelboolean
isSelected()
Determines if this action is currently being selected.protected void
notifySelectedState()
void
removeButtonModel(javax.swing.ButtonModel model)
Removes a button modelprotected void
setSelected(boolean selected)
protected void
toggleSelectedState(java.awt.event.ActionEvent e)
Toggles the selected action state, if needed according to the ActionEvent that triggered the action.-
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
-
-
-
-
Field Detail
-
buttonModels
private final transient java.util.Set<javax.swing.ButtonModel> buttonModels
-
-
Constructor Detail
-
ToggleAction
protected ToggleAction(java.lang.String name, ImageProvider icon, java.lang.String tooltip, Shortcut shortcut, boolean registerInToolbar, java.lang.String toolbarId, boolean installAdapters)
Constructs aToggleAction
.- Parameters:
name
- the action's text as displayed on the menu (if it is added to a menu)icon
- the icon to usetooltip
- a longer description of the action that will be displayed in the tooltip. Please note that html is not supported for menu actions on some platforms.shortcut
- a ready-created shortcut object or null if you don't want a shortcut. But you always do want a shortcut, remember you can always register it with group=none, so you won't be assigned a shortcut unless the user configures one. If you pass null here, the user CANNOT configure a shortcut for your action.registerInToolbar
- 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
-
ToggleAction
protected ToggleAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, boolean registerInToolbar)
Constructs aToggleAction
.- Parameters:
name
- the action's text as displayed on the menu (if it is added to a menu)iconName
- the name of icon to usetooltip
- a longer description of the action that will be displayed in the tooltip. Please note that html is not supported for menu actions on some platforms.shortcut
- a ready-created shortcut object or null if you don't want a shortcut. But you always do want a shortcut, remember you can always register it with group=none, so you won't be assigned a shortcut unless the user configures one. If you pass null here, the user CANNOT configure a shortcut for your action.registerInToolbar
- register this action for the toolbar preferences?
-
-
Method Detail
-
setSelected
protected final void setSelected(boolean selected)
-
isSelected
public final boolean isSelected()
Determines if this action is currently being selected.- Returns:
true
if this action is currently being selected,false
otherwise
-
addButtonModel
public final void addButtonModel(javax.swing.ButtonModel model)
Adds a button model- Parameters:
model
- The button model to add
-
removeButtonModel
public final void removeButtonModel(javax.swing.ButtonModel model)
Removes a button model- Parameters:
model
- The button model to remove
-
notifySelectedState
protected void notifySelectedState()
-
toggleSelectedState
protected final void toggleSelectedState(java.awt.event.ActionEvent e)
Toggles the selected action state, if needed according to the ActionEvent that triggered the action. This method will do nothing if the action event comes from a Swing component supporting the SELECTED_KEY property because the component already set the selected state. This method needs to be called especially if the action is associated with a keyboard shortcut to ensure correct selected state.- Parameters:
e
- ActionEvent that triggered the action- See Also:
- Interface Action
-
-