Class JosmAction

java.lang.Object
javax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action, Destroyable
Direct Known Subclasses:
AboutAction, AbstractAudioAction, AbstractInfoAction, AbstractMergeAction, AbstractPasteAction, AbstractUploadAction, AddImageryLayerAction, AddNodeAction, AlignGridRotationAction, AlignInCircleAction, AlignInLineAction, AutoScaleAction, ChangesetDialog.CloseOpenChangesetsAction, ChangesetDialog.LaunchChangesetManagerAction, ChangesetDialog.ReadChangesetsAction, ChangesetDialog.SelectObjectsAction, ChangesetDialog.ShowChangesetInfoAction, CloseChangesetAction, CombineWayAction, CommandStackDialog.SelectAction, CommandStackDialog.UndoRedoAction, CopyAction, CopyCoordinatesAction, CopyUrlAction, CreateCircleAction, CreateMultipolygonAction, CycleLayerDownAction, CycleLayerUpAction, DeleteAction, DeleteLayerAction, DiskAccessAction, DistributeAction, DownloadAction, DownloadAlongAction, DownloadNotesInViewAction, DownloadOsmInViewAction, DownloadPrimitiveAction, DownloadReferrersAction, DrawAction.SnapChangeAction, EditImagesSequenceAction, ExitAction, ExtrudeAction.DualAlignChangeAction, FilterDialog.FilterAction, FollowLineAction, HelpAction, HelpAwareOptionPane.HelpAction, HistoryInfoAction, ImageryMenu.AdjustImageryOffsetAction, ImageViewerDialog.CloseOtherTabsAction, ImageViewerDialog.ImageAction, ImageViewerDialog.ImageCenterViewAction, ImageViewerDialog.ImageCollapseAction, ImageViewerDialog.ImageCopyPathAction, ImageViewerDialog.ImageExtendedInfoAction, ImageViewerDialog.ImageOpenExternalAction, ImageViewerDialog.ImageRemoveAction, ImageViewerDialog.ImageRemoveFromDiskAction, ImageViewerDialog.ImageZoomAction, InfoAction, InvertSelectionAction, JoinAreasAction, JoinNodeWayAction, JumpToAction, MapMode, MapPaintDialog.MoveUpDownAction, MapPaintDialog.OnOffAction, MapPaintMenu.MapPaintAction, MapRectifierWMSmenuAction, MenuItemSearchDialog.Action, MergeNodesAction, MirrorAction, MoveAction, MoveNodeAction, NewAction, NewLocalAction, NotesDialog.AddCommentAction, NotesDialog.CloseAction, NotesDialog.NewAction, NotesDialog.OpenInBrowserAction, NotesDialog.ReopenAction, NotesDialog.SortAction, OpenLocationAction, OrthogonalizeAction, OrthogonalizeAction.Undo, PasteTagsAction, PreferencesAction, PropertiesDialog.AddAction, PropertiesDialog.DeleteAction, PropertiesDialog.EditAction, PurgeAction, RecentRelationsAction, RedoAction, RelationListDialog.NewAction, ReorderImageryLayersAction, ReportBugAction, RestartAction, ReverseWayAction, SaveLayersDialog.SaveSessionButtonAction, SearchAction, SearchNotesDownloadAction, SelectAllAction, SelectNonBranchingWaySequencesAction, SelectSharedChildObjectsAction, SetGridOriginAction, ShowStatusReportAction, SimplifyWayAction, SplitWayAction, TaggingPresetSearchAction, TaggingPresetSearchPrimitiveDialog.Action, ToggleAction, ToggleDialog.ToggleDialogAction, UndoAction, UnGlueAction, UnJoinNodeWayAction, UnselectAllAction, UpdateDataAction, UpdateSelectionAction, UploadNotesAction, UserListDialog.SelectUsersPrimitivesAction, ValidateAction, WikimediaCommonsLoader.WikimediaCommonsLoadImagesAction, ZoomInAction, ZoomOutAction

public abstract class JosmAction extends AbstractAction implements Destroyable
Base class helper for all Actions in JOSM. Just to make the life easier. This action allows you to set up an icon, a tooltip text, a globally registered shortcut, register it in the main toolbar and set up layer/selection listeners that call updateEnabledState() whenever the global context is changed. A JosmAction can register a LayerManager.LayerChangeListener and a DataSelectionListener. Upon a layer change event or a selection change event it invokes updateEnabledState(). Subclasses can override updateEnabledState() in order to update the AbstractAction.isEnabled()-state of a JosmAction depending on the getLayerManager() state. destroy() from interface Destroyable is called e.g. for MapModes, when the last layer has been removed and so the mapframe will be destroyed. For other JosmActions, destroy() may never be called (currently).
See Also:
  • Field Details

  • Constructor Details

    • JosmAction

      protected JosmAction(String name, ImageProvider icon, String tooltip, Shortcut shortcut, boolean registerInToolbar, String toolbarId, boolean installAdapters)
      Constructs a JosmAction.
      Parameters:
      name - the action's text as displayed on the menu (if it is added to a menu)
      icon - the icon to use
      tooltip - 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
      installAdapters - false, if you don't want to install layer changed and selection changed adapters
    • JosmAction

      protected JosmAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar, String toolbarId, boolean installAdapters)
      The new super for all actions. Use this super constructor to setup your action.
      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 use
      tooltip - 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 null
      installAdapters - false, if you don't want to install layer changed and selection changed adapters
    • JosmAction

      protected JosmAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar, boolean installAdapters)
      Constructs a new JosmAction. Use this super constructor to setup your action.
      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 use
      tooltip - 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?
      installAdapters - false, if you don't want to install layer changed and selection changed adapters
    • JosmAction

      protected JosmAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar)
      Constructs a new JosmAction and installs layer changed and selection changed adapters. Use this super constructor to setup your action.
      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 use
      tooltip - 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?
    • JosmAction

      protected JosmAction()
      Constructs a new JosmAction.
    • JosmAction

      protected JosmAction(boolean installAdapters)
      Constructs a new JosmAction.
      Parameters:
      installAdapters - false, if you don't want to install layer changed and selection changed adapters
    • JosmAction

      protected JosmAction(String name, String iconName, String tooltip, List<Shortcut> shortcuts)
      Constructs a new JosmAction. Use this super constructor to setup your action.
      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 use
      tooltip - 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.
      shortcuts - ready-created shortcut objects
      Since:
      14012
  • Method Details