Changeset 18715 in josm for trunk/src/org


Ignore:
Timestamp:
2023-04-25T17:06:43+02:00 (14 months ago)
Author:
taylor.smock
Message:

Fix #22798: Convert dialog actions which extend AbstractAction to ones which extend JosmAction

This will allow users to bind shortcuts to actions they make frequently, such as
creating new relations.

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java

    r17333 r18715  
    1010import java.awt.event.ItemEvent;
    1111import java.awt.event.ItemListener;
     12import java.awt.event.KeyEvent;
    1213import java.awt.event.MouseAdapter;
    1314import java.awt.event.MouseEvent;
    14 import java.awt.event.KeyEvent;
    1515import java.util.Arrays;
    1616import java.util.Collection;
     
    2222import java.util.stream.Collectors;
    2323
    24 import javax.swing.AbstractAction;
    2524import javax.swing.Action;
    2625import javax.swing.DefaultListSelectionModel;
     
    3534import javax.swing.event.ListSelectionListener;
    3635
     36import org.openstreetmap.josm.actions.JosmAction;
    3737import org.openstreetmap.josm.actions.OpenBrowserAction;
    3838import org.openstreetmap.josm.actions.downloadtasks.ChangesetHeaderDownloadTask;
     
    6060import org.openstreetmap.josm.io.OnlineResource;
    6161import org.openstreetmap.josm.spi.preferences.Config;
    62 import org.openstreetmap.josm.tools.ImageProvider;
    6362import org.openstreetmap.josm.tools.Logging;
    6463import org.openstreetmap.josm.tools.OpenBrowser;
     64import org.openstreetmap.josm.tools.Shortcut;
    6565import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;
    66 import org.openstreetmap.josm.tools.Shortcut;
    6766
    6867/**
     
    297296     * Selects objects for the currently selected changesets.
    298297     */
    299     class SelectObjectsAction extends AbstractAction implements ListSelectionListener, ItemListener {
     298    class SelectObjectsAction extends JosmAction implements ListSelectionListener, ItemListener {
    300299
    301300        SelectObjectsAction() {
    302             putValue(NAME, tr("Select"));
    303             putValue(SHORT_DESCRIPTION, tr("Select all objects assigned to the currently selected changesets"));
    304             new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true);
    305             updateEnabledState();
    306         }
    307 
     301            super(tr("Select"), "dialogs/select", tr("Select all objects assigned to the currently selected changesets"),
     302                    Shortcut.registerShortcut("changeset:select:objects",
     303                            tr("Changesets: Select all objects assigned to the currently selected changesets"),
     304                            KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     305                    false, false);
     306            updateEnabledState();
     307        }
     308
     309        /**
     310         * Select objects based off of the changeset id
     311         * @param ds The dataset to select objects from
     312         * @param ids The ids to select
     313         */
    308314        public void selectObjectsByChangesetIds(DataSet ds, Set<Integer> ids) {
    309315            if (ds == null || ids == null)
     
    328334        }
    329335
     336        @Override
    330337        protected void updateEnabledState() {
    331338            setEnabled(getCurrentChangesetList().getSelectedIndices().length > 0);
     
    348355     *
    349356     */
    350     class ReadChangesetsAction extends AbstractAction implements ListSelectionListener, ItemListener {
     357    class ReadChangesetsAction extends JosmAction implements ListSelectionListener, ItemListener {
    351358        ReadChangesetsAction() {
    352             putValue(NAME, tr("Download"));
    353             putValue(SHORT_DESCRIPTION, tr("Download information about the selected changesets from the OSM server"));
    354             new ImageProvider("download").getResource().attachImageIcon(this, true);
     359            super(tr("Download"), "download", tr("Download information about the selected changesets from the OSM server"),
     360                    Shortcut.registerShortcut("changeset:download:information",
     361                            tr("Changesets: Download information about the selected changeset from the OSM server"),
     362                            KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     363                    false, false);
    355364            updateEnabledState();
    356365        }
     
    366375        }
    367376
     377        @Override
    368378        protected void updateEnabledState() {
    369379            setEnabled(getCurrentChangesetList().getSelectedIndices().length > 0 && !NetworkManager.isOffline(OnlineResource.OSM_API));
     
    385395     *
    386396     */
    387     class CloseOpenChangesetsAction extends AbstractAction implements ListSelectionListener, ItemListener {
     397    class CloseOpenChangesetsAction extends JosmAction implements ListSelectionListener, ItemListener {
    388398        CloseOpenChangesetsAction() {
    389             putValue(NAME, tr("Close open changesets"));
    390             putValue(SHORT_DESCRIPTION, tr("Close the selected open changesets"));
    391             new ImageProvider("closechangeset").getResource().attachImageIcon(this, true);
     399            super(tr("Close open changesets"), "closechangeset", tr("Close the selected open changesets"),
     400                    Shortcut.registerShortcut("changeset:close",
     401                            tr("Changesets: Close the selected open changesets"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     402                    false, false);
    392403            updateEnabledState();
    393404        }
     
    401412        }
    402413
     414        @Override
    403415        protected void updateEnabledState() {
    404416            setEnabled(getCurrentChangesetListModel().hasSelectedOpenChangesets());
     
    420432     *
    421433     */
    422     class ShowChangesetInfoAction extends AbstractAction implements ListSelectionListener, ItemListener {
     434    class ShowChangesetInfoAction extends JosmAction implements ListSelectionListener, ItemListener {
    423435        ShowChangesetInfoAction() {
    424             putValue(NAME, tr("Show info"));
    425             putValue(SHORT_DESCRIPTION, tr("Open a web page for each selected changeset"));
    426             new ImageProvider("help/internet").getResource().attachImageIcon(this, true);
     436            super(tr("Show info"), "help/internet", tr("Open a web page for each selected changeset"),
     437                    Shortcut.registerShortcut("changeset:info",
     438                            tr("Changesets: Open a web page for each selected changeset"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     439                    false, false);
    427440            updateEnabledState();
    428441        }
     
    441454        }
    442455
     456        @Override
    443457        protected void updateEnabledState() {
    444458            setEnabled(getCurrentChangesetList().getSelectedIndices().length > 0);
     
    460474     *
    461475     */
    462     class LaunchChangesetManagerAction extends AbstractAction {
     476    class LaunchChangesetManagerAction extends JosmAction {
    463477        LaunchChangesetManagerAction() {
    464             putValue(NAME, tr("Details"));
    465             putValue(SHORT_DESCRIPTION, tr("Opens the Changeset Manager window for the selected changesets"));
    466             new ImageProvider("dialogs/changeset", "changesetmanager").getResource().attachImageIcon(this, true);
     478            super(tr("Details"), "dialogs/changeset/changesetmanager", tr("Opens the Changeset Manager window for the selected changesets"),
     479                    Shortcut.registerShortcut("changeset:launch:manager",
     480                            tr("Changesets: Opens the Changeset Manager window for the selected changesets"),
     481                            KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     482                    false, false);
    467483        }
    468484
  • trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

    r17772 r18715  
    1717import java.util.Set;
    1818
    19 import javax.swing.AbstractAction;
    2019import javax.swing.Box;
    2120import javax.swing.JComponent;
     
    3938import org.openstreetmap.josm.actions.AutoScaleAction;
    4039import org.openstreetmap.josm.actions.AutoScaleAction.AutoScaleMode;
     40import org.openstreetmap.josm.actions.JosmAction;
    4141import org.openstreetmap.josm.command.Command;
    4242import org.openstreetmap.josm.command.PseudoCommand;
     
    5454import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    5555import org.openstreetmap.josm.tools.GBC;
    56 import org.openstreetmap.josm.tools.ImageProvider;
    5756import org.openstreetmap.josm.tools.InputMapUtils;
    5857import org.openstreetmap.josm.tools.Shortcut;
     
    411410     * Action that selects the objects that take part in a command.
    412411     */
    413     public class SelectAction extends AbstractAction implements IEnabledStateUpdating {
     412    public class SelectAction extends JosmAction implements IEnabledStateUpdating {
    414413
    415414        /**
     
    417416         */
    418417        public SelectAction() {
    419             putValue(NAME, tr("Select"));
    420             putValue(SHORT_DESCRIPTION, tr("Selects the objects that take part in this command (unless currently deleted)"));
    421             new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true);
     418            this(tr("Select"), "dialogs/select", tr("Selects the objects that take part in this command (unless currently deleted)"),
     419                    Shortcut.registerShortcut("command:stack:select", tr("Command Stack: Select"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     420                    false, null, false);
     421        }
     422
     423        /**
     424         * Constructs a new {@code SelectAction} that calls
     425         * {@link JosmAction#JosmAction(String, String, String, Shortcut, boolean, String, boolean)}
     426         *
     427         * The new super for all CommandStack actions.
     428         *
     429         * Use this super constructor to setup your action.
     430         *
     431         * @param name the action's text as displayed on the menu (if it is added to a menu)
     432         * @param iconName the filename of the icon to use
     433         * @param tooltip  a longer description of the action that will be displayed in the tooltip. Please note
     434         *           that html is not supported for menu actions on some platforms.
     435         * @param shortcut a ready-created shortcut object or null if you don't want a shortcut. But you always
     436         *            do want a shortcut, remember you can always register it with group=none, so you
     437         *            won't be assigned a shortcut unless the user configures one. If you pass null here,
     438         *            the user CANNOT configure a shortcut for your action.
     439         * @param registerInToolbar register this action for the toolbar preferences?
     440         * @param toolbarId identifier for the toolbar preferences. The iconName is used, if this parameter is null
     441         * @param installAdapters false, if you don't want to install layer changed and selection changed adapters
     442         */
     443        protected SelectAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar,
     444                               String toolbarId, boolean installAdapters) {
     445            super(name, iconName, tooltip, shortcut, registerInToolbar, toolbarId, installAdapters);
    422446        }
    423447
     
    465489         */
    466490        public SelectAndZoomAction() {
    467             putValue(NAME, tr("Select and zoom"));
    468             putValue(SHORT_DESCRIPTION,
    469                     tr("Selects the objects that take part in this command (unless currently deleted), then and zooms to it"));
    470             new ImageProvider("dialogs/autoscale", "selection").getResource().attachImageIcon(this, true);
     491            super(tr("Select and zoom"), "dialogs/autoscale/selection",
     492                    tr("Selects the objects that take part in this command (unless currently deleted), then and zooms to it"),
     493                    Shortcut.registerShortcut("command:stack:select_and_zoom", tr("Command Stack: Select and zoom"),
     494                            KeyEvent.VK_UNDEFINED, Shortcut.NONE), false, null, false);
    471495        }
    472496
     
    489513     * Action to undo or redo all commands up to (and including) the seleced item.
    490514     */
    491     protected class UndoRedoAction extends AbstractAction implements IEnabledStateUpdating {
     515    protected class UndoRedoAction extends JosmAction implements IEnabledStateUpdating {
    492516        private final UndoRedoType type;
    493517        private final JTree tree;
     
    498522         */
    499523        public UndoRedoAction(UndoRedoType type) {
     524            // This is really annoying. JEP 8300786 might fix this.
     525            super(UndoRedoType.UNDO == type ? tr("Undo") : tr("Redo"),
     526                    UndoRedoType.UNDO == type ? "undo" : "redo",
     527                    UndoRedoType.UNDO == type ? tr("Undo the selected and all later commands")
     528                            : tr("Redo the selected and all earlier commands"),
     529                    UndoRedoType.UNDO == type
     530                            ? Shortcut.registerShortcut("command:stack:undo", tr("Command Stack: Undo"), KeyEvent.VK_UNDEFINED, Shortcut.NONE)
     531                            : Shortcut.registerShortcut("command:stack:redo", tr("Command Stack: Redo"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     532                    false, false);
    500533            this.type = type;
    501534            if (UndoRedoType.UNDO == type) {
    502535                tree = undoTree;
    503                 putValue(NAME, tr("Undo"));
    504                 putValue(SHORT_DESCRIPTION, tr("Undo the selected and all later commands"));
    505                 new ImageProvider("undo").getResource().attachImageIcon(this, true);
    506536            } else {
    507537                tree = redoTree;
    508                 putValue(NAME, tr("Redo"));
    509                 putValue(SHORT_DESCRIPTION, tr("Redo the selected and all earlier commands"));
    510                 new ImageProvider("redo").getResource().attachImageIcon(this, true);
    511538            }
    512539        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java

    r18556 r18715  
    2727import javax.swing.table.TableModel;
    2828
     29import org.openstreetmap.josm.actions.JosmAction;
    2930import org.openstreetmap.josm.actions.mapmode.MapMode;
    3031import org.openstreetmap.josm.actions.search.SearchAction;
     
    5253import org.openstreetmap.josm.gui.util.TableHelper;
    5354import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
    54 import org.openstreetmap.josm.tools.ImageProvider;
    5555import org.openstreetmap.josm.tools.InputMapUtils;
    5656import org.openstreetmap.josm.tools.Shortcut;
     
    119119    };
    120120
    121     private abstract class FilterAction extends AbstractAction implements IEnabledStateUpdating {
    122 
    123         FilterAction(String name, String description, String icon) {
    124             putValue(NAME, name);
    125             putValue(SHORT_DESCRIPTION, description);
    126             new ImageProvider("dialogs", icon).getResource().attachImageIcon(this, true);
     121    private abstract class FilterAction extends JosmAction implements IEnabledStateUpdating {
     122
     123        FilterAction(String name, String description, String icon, Shortcut shortcut) {
     124            super(name, "dialogs/" + icon, description, shortcut, false, false);
    127125        }
    128126
     
    135133    private class AddAction extends FilterAction {
    136134        AddAction() {
    137             super(tr("Add"), tr("Add filter."), /* ICON(dialogs/) */ "add");
     135            super(tr("Add"), tr("Add filter."), /* ICON(dialogs/) */ "add",
     136                    Shortcut.registerShortcut("filter:add", tr("Filter: Add"), KeyEvent.VK_UNDEFINED, Shortcut.NONE));
    138137        }
    139138
     
    154153    private class EditAction extends FilterAction {
    155154        EditAction() {
    156             super(tr("Edit"), tr("Edit filter."), /* ICON(dialogs/) */ "edit");
     155            super(tr("Edit"), tr("Edit filter."), /* ICON(dialogs/) */ "edit",
     156                    Shortcut.registerShortcut("filter:edit", tr("Filter: Edit"), KeyEvent.VK_UNDEFINED, Shortcut.NONE));
    157157        }
    158158
     
    171171    private class DeleteAction extends FilterAction {
    172172        DeleteAction() {
    173             super(tr("Delete"), tr("Delete filter."), /* ICON(dialogs/) */ "delete");
     173            super(tr("Delete"), tr("Delete filter."), /* ICON(dialogs/) */ "delete",
     174                    Shortcut.registerShortcut("filter:delete", tr("Filter: Delete"), KeyEvent.VK_UNDEFINED, Shortcut.NONE));
    174175        }
    175176
     
    182183    private class MoveUpAction extends FilterAction {
    183184        MoveUpAction() {
    184             super(tr("Up"), tr("Move filter up."), /* ICON(dialogs/) */ "up");
     185            super(tr("Up"), tr("Move filter up."), /* ICON(dialogs/) */ "up",
     186                    Shortcut.registerShortcut("filter:up", tr("Filter: Move up"), KeyEvent.VK_UNDEFINED, Shortcut.NONE));
    185187        }
    186188
     
    198200    private class MoveDownAction extends FilterAction {
    199201        MoveDownAction() {
    200             super(tr("Down"), tr("Move filter down."), /* ICON(dialogs/) */ "down");
     202            super(tr("Down"), tr("Move filter down."), /* ICON(dialogs/) */ "down",
     203                    Shortcut.registerShortcut("filter:down", tr("Filter: Move down"), KeyEvent.VK_UNDEFINED, Shortcut.NONE));
    201204        }
    202205
     
    214217    private class SortAction extends FilterAction {
    215218        SortAction() {
    216             super(tr("Sort"), tr("Sort filters."), /* ICON(dialogs/) */ "sort");
     219            super(tr("Sort"), tr("Sort filters."), /* ICON(dialogs/) */ "sort",
     220                    Shortcut.registerShortcut("filter:sort", tr("Filter: Sort"), KeyEvent.VK_UNDEFINED, Shortcut.NONE));
    217221        }
    218222
     
    230234    private class ReverseAction extends FilterAction {
    231235        ReverseAction() {
    232             super(tr("Reverse"), tr("Reverse the filters order."), /* ICON(dialogs/) */ "reverse");
     236            super(tr("Reverse"), tr("Reverse the filters order."), /* ICON(dialogs/) */ "reverse",
     237                    Shortcut.registerShortcut("filter:reverse", tr("Filter: Reverse"), KeyEvent.VK_UNDEFINED, Shortcut.NONE));
    233238        }
    234239
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r18311 r18715  
    311311    }
    312312
    313     protected class OnOffAction extends AbstractAction implements ListSelectionListener {
     313    protected class OnOffAction extends JosmAction implements ListSelectionListener {
    314314        /**
    315315         * Constructs a new {@code OnOffAction}.
    316316         */
    317317        public OnOffAction() {
    318             putValue(NAME, tr("On/Off"));
    319             putValue(SHORT_DESCRIPTION, tr("Turn selected styles on or off"));
    320             new ImageProvider("apply").getResource().attachImageIcon(this, true);
     318            super(tr("On/Off"), "apply", tr("Turn selected styles on or off"),
     319                    Shortcut.registerShortcut("map:paint:style:on_off", tr("Filter: Add"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     320                    false, false);
    321321            updateEnabledState();
    322322        }
    323323
     324        @Override
    324325        protected void updateEnabledState() {
    325326            setEnabled(!cbWireframe.isSelected() && tblStyles.getSelectedRowCount() > 0);
     
    342343     * The action to move down the currently selected entries in the list.
    343344     */
    344     protected class MoveUpDownAction extends AbstractAction implements ListSelectionListener {
     345    protected class MoveUpDownAction extends JosmAction implements ListSelectionListener {
    345346
    346347        private final int increment;
     
    351352         */
    352353        public MoveUpDownAction(boolean isDown) {
     354            super(isDown ? tr("Down") : tr("Up"), "dialogs/" + (isDown ? "down" : "up"),
     355                    isDown ? tr("Move the selected entry one row down.") : tr("Move the selected entry one row up."),
     356                    isDown ? Shortcut.registerShortcut("map:paint:style:down", tr("Map Paint Styles: Move selected entry down"),
     357                            KeyEvent.VK_UNDEFINED, Shortcut.NONE)
     358                    : Shortcut.registerShortcut("map:paint:style:up", tr("Map Paint Styles: Move selected entry up"),
     359                            KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     360                    false, false);
    353361            increment = isDown ? 1 : -1;
    354             putValue(NAME, isDown ? tr("Down") : tr("Up"));
    355             new ImageProvider("dialogs", isDown ? "down" : "up").getResource().attachImageIcon(this, true);
    356             putValue(SHORT_DESCRIPTION, isDown ? tr("Move the selected entry one row down.") : tr("Move the selected entry one row up."));
    357362            updateEnabledState();
    358363        }
    359364
     365        @Override
    360366        public void updateEnabledState() {
    361367            int[] sel = tblStyles.getSelectedRows();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java

    r18540 r18715  
    1919import java.util.function.Predicate;
    2020import java.util.regex.Pattern;
    21 
    22 import javax.swing.AbstractAction;
     21import java.util.stream.Collectors;
     22
    2323import javax.swing.AbstractListModel;
    2424import javax.swing.DefaultListCellRenderer;
     
    3535
    3636import org.openstreetmap.josm.actions.DownloadNotesInViewAction;
     37import org.openstreetmap.josm.actions.JosmAction;
    3738import org.openstreetmap.josm.actions.UploadNotesAction;
    3839import org.openstreetmap.josm.actions.mapmode.AddNoteAction;
     
    343344                filteredData.addAll(data);
    344345            } else {
    345                 data.stream().filter(filter).forEach(filteredData::add);
     346                filteredData.addAll(data.stream().filter(filter).collect(Collectors.toList()));
    346347            }
    347348            fireContentsChanged(this, 0, getSize());
     
    351352        }
    352353
     354        /**
     355         * Set the note data
     356         * @param noteList The notes to show
     357         */
    353358        public void setData(Collection<Note> noteList) {
    354359            data.clear();
     
    357362        }
    358363
     364        /**
     365         * Clear the note data
     366         */
    359367        public void clearData() {
    360368            displayList.clearSelection();
     
    364372    }
    365373
    366     class AddCommentAction extends AbstractAction {
     374    /**
     375     * The action to add a new comment to OSM
     376     */
     377    class AddCommentAction extends JosmAction {
    367378
    368379        /**
     
    370381         */
    371382        AddCommentAction() {
    372             putValue(SHORT_DESCRIPTION, tr("Add comment"));
    373             putValue(NAME, tr("Comment"));
    374             new ImageProvider("dialogs/notes", "note_comment").getResource().attachImageIcon(this, true);
     383            super(tr("Comment"), "dialogs/notes/note_comment", tr("Add comment"),
     384                    Shortcut.registerShortcut("notes:comment:add", tr("Notes: Add comment"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     385                    false, false);
    375386        }
    376387
     
    396407    }
    397408
    398     class CloseAction extends AbstractAction {
     409    /**
     410     * Close a note
     411     */
     412    class CloseAction extends JosmAction {
    399413
    400414        /**
     
    402416         */
    403417        CloseAction() {
    404             putValue(SHORT_DESCRIPTION, tr("Close note"));
    405             putValue(NAME, tr("Close"));
    406             new ImageProvider("dialogs/notes", "note_closed").getResource().attachImageIcon(this, true);
     418            super(tr("Close"), "dialogs/notes/note_closed", tr("Close note"),
     419                    Shortcut.registerShortcut("notes:comment:close", tr("Notes: Close note"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     420                    false, false);
    407421        }
    408422
     
    428442    }
    429443
    430     class NewAction extends AbstractAction {
     444    /**
     445     * Create a new note
     446     */
     447    class NewAction extends JosmAction {
    431448
    432449        /**
     
    434451         */
    435452        NewAction() {
    436             putValue(SHORT_DESCRIPTION, tr("Create a new note"));
    437             putValue(NAME, tr("Create"));
    438             new ImageProvider("dialogs/notes", "note_new").getResource().attachImageIcon(this, true);
     453            super(tr("Create"), "dialogs/notes/note_new", tr("Create a new note"),
     454                    Shortcut.registerShortcut("notes:comment:new", tr("Notes: New note"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     455                    false, false);
    439456        }
    440457
     
    450467    }
    451468
    452     class ReopenAction extends AbstractAction {
     469    /**
     470     * Reopen a note
     471     */
     472    class ReopenAction extends JosmAction {
    453473
    454474        /**
     
    456476         */
    457477        ReopenAction() {
    458             putValue(SHORT_DESCRIPTION, tr("Reopen note"));
    459             putValue(NAME, tr("Reopen"));
    460             new ImageProvider("dialogs/notes", "note_open").getResource().attachImageIcon(this, true);
     478            super(tr("Reopen"), "dialogs/notes/note_open", tr("Reopen note"),
     479                    Shortcut.registerShortcut("notes:comment:reopen", tr("Notes: Reopen note"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     480                    false, false);
    461481        }
    462482
     
    476496    }
    477497
    478     class SortAction extends AbstractAction {
     498    /**
     499     * Sort notes
     500     */
     501    class SortAction extends JosmAction {
    479502
    480503        /**
     
    482505         */
    483506        SortAction() {
    484             putValue(SHORT_DESCRIPTION, tr("Sort notes"));
    485             putValue(NAME, tr("Sort"));
    486             new ImageProvider("dialogs", "sort").getResource().attachImageIcon(this, true);
     507            super(tr("Sort"), "dialogs/sort", tr("Sort notes"),
     508                    Shortcut.registerShortcut("notes:comment:sort", tr("Notes: Sort notes"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     509                    false, false);
    487510        }
    488511
     
    497520    }
    498521
    499     class OpenInBrowserAction extends AbstractAction {
     522    /**
     523     * Open the note in a browser
     524     */
     525    class OpenInBrowserAction extends JosmAction {
    500526        OpenInBrowserAction() {
    501             super(tr("Open in browser"));
    502             putValue(SHORT_DESCRIPTION, tr("Open the note in an external browser"));
    503             new ImageProvider("help", "internet").getResource().attachImageIcon(this, true);
     527            super(tr("Open in browser"), "help/internet", tr("Open the note in an external browser"),
     528                    Shortcut.registerShortcut("notes:comment:open_in_browser", tr("Notes: Open note in browser"),
     529                            KeyEvent.VK_UNDEFINED, Shortcut.NONE), false, false);
    504530        }
    505531
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r18211 r18715  
    1919import java.util.stream.IntStream;
    2020
    21 import javax.swing.AbstractAction;
    2221import javax.swing.AbstractListModel;
    2322import javax.swing.DefaultListSelectionModel;
     
    3635import org.openstreetmap.josm.actions.ExpertToggleAction;
    3736import org.openstreetmap.josm.actions.HistoryInfoAction;
     37import org.openstreetmap.josm.actions.JosmAction;
    3838import org.openstreetmap.josm.actions.relation.AddSelectionToRelations;
    3939import org.openstreetmap.josm.actions.relation.DeleteRelationsAction;
     
    8989import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    9090import org.openstreetmap.josm.spi.preferences.Config;
    91 import org.openstreetmap.josm.tools.ImageProvider;
    9291import org.openstreetmap.josm.tools.InputMapUtils;
    9392import org.openstreetmap.josm.tools.PlatformManager;
     
    376375     * The action for creating a new relation.
    377376     */
    378     static class NewAction extends AbstractAction implements LayerChangeListener, ActiveLayerChangeListener {
     377    static class NewAction extends JosmAction implements LayerChangeListener, ActiveLayerChangeListener {
    379378        NewAction() {
    380             putValue(SHORT_DESCRIPTION, tr("Create a new relation"));
    381             putValue(NAME, tr("New"));
    382             new ImageProvider("dialogs", "add").getResource().attachImageIcon(this, true);
     379            super(tr("New"), "dialogs/add", tr("Create a new relation"),
     380                    Shortcut.registerShortcut("relation:new", tr("Create a new relation"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     381                    false, false);
    383382            updateEnabledState();
    384383        }
    385384
     385        /**
     386         * Make a new relation
     387         */
    386388        public void run() {
    387389            RelationEditor.getEditor(MainApplication.getLayerManager().getEditLayer(), null, null).setVisible(true);
     
    393395        }
    394396
     397        @Override
    395398        protected void updateEnabledState() {
    396399            setEnabled(MainApplication.getLayerManager().getEditLayer() != null);
     
    514517            // extract the removed relations
    515518            Set<Relation> removedRelations = removedPrimitives.stream()
    516                     .filter(p -> p instanceof Relation).map(p -> (Relation) p)
     519                    .filter(Relation.class::isInstance).map(Relation.class::cast)
    517520                    .collect(Collectors.toSet());
    518521            if (removedRelations.isEmpty())
     
    598601        }
    599602
     603        /**
     604         * Update the title for the relation list dialog
     605         */
    600606        public void updateTitle() {
    601607            if (!relations.isEmpty() && relations.size() != getSize()) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java

    r18208 r18715  
    3030
    3131import org.openstreetmap.josm.actions.AbstractInfoAction;
     32import org.openstreetmap.josm.actions.JosmAction;
    3233import org.openstreetmap.josm.data.osm.DataSelectionListener;
    3334import org.openstreetmap.josm.data.osm.IPrimitive;
     
    4647import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    4748import org.openstreetmap.josm.spi.preferences.Config;
    48 import org.openstreetmap.josm.tools.ImageProvider;
    4949import org.openstreetmap.josm.tools.Logging;
    5050import org.openstreetmap.josm.tools.OpenBrowser;
     
    164164    }
    165165
    166     class SelectUsersPrimitivesAction extends AbstractAction implements ListSelectionListener {
     166    /**
     167     * Select the primitives that a user modified <i>last</i>.
     168     */
     169    class SelectUsersPrimitivesAction extends JosmAction implements ListSelectionListener {
    167170
    168171        /**
     
    170173         */
    171174        SelectUsersPrimitivesAction() {
    172             putValue(NAME, tr("Select"));
    173             putValue(SHORT_DESCRIPTION, tr("Select objects submitted by this user"));
    174             new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true);
     175            super(tr("Select"), "dialogs/select", tr("Select objects submitted by this user"),
     176                    Shortcut.registerShortcut("user:select_primitives", tr("User: objects submitted by selected user"),
     177                            KeyEvent.VK_UNDEFINED, Shortcut.NONE), false, false);
    175178            updateEnabledState();
    176179        }
    177180
     181        /**
     182         * Select the primitives owned by the selected users
     183         */
    178184        public void select() {
    179185            int[] indexes = userTable.getSelectedRows();
     
    188194        }
    189195
     196        @Override
    190197        protected void updateEnabledState() {
    191198            setEnabled(userTable != null && userTable.getSelectedRowCount() > 0);
     
    204211
    205212        ShowUserInfoAction() {
    206             super(false);
    207             putValue(NAME, tr("Show info"));
    208             putValue(SHORT_DESCRIPTION, tr("Launches a browser with information about the user"));
    209             new ImageProvider("help/internet").getResource().attachImageIcon(this, true);
     213            super(tr("Show info"), "help/internet", tr("Launches a browser with information about the user"),
     214                    Shortcut.registerShortcut("user:open_in_browser", tr("User: Show info in browser"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     215                    false, null, false);
    210216            updateEnabledState();
    211217        }
     
    235241            if (infoObject instanceof User) {
    236242                User user = (User) infoObject;
    237                 return Config.getUrls().getBaseUserUrl() + '/' + Utils.encodeUrl(user.getName()).replaceAll("\\+", "%20");
     243                return Config.getUrls().getBaseUserUrl() + '/' + Utils.encodeUrl(user.getName()).replace("+", "%20");
    238244            } else {
    239245                return null;
Note: See TracChangeset for help on using the changeset viewer.