Changeset 16495 in josm for trunk


Ignore:
Timestamp:
2020-05-24T21:27:18+02:00 (4 years ago)
Author:
GerdP
Message:

see #19257: reduce number of ShowHistoryAction implementations
Add AbstractShowHistoryAction with common texts "History" and "Download and show the history of the selected objects" to reduce number of I18N strings. To be used with popup menus and side buttons where selected objects are known.

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
4 edited

Legend:

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

    r16438 r16495  
    3838import javax.swing.event.PopupMenuEvent;
    3939
     40import org.openstreetmap.josm.actions.AbstractShowHistoryAction;
    4041import org.openstreetmap.josm.actions.AbstractSelectAction;
    4142import org.openstreetmap.josm.actions.AutoScaleAction;
     
    348349     * The action for showing history information of the current history item.
    349350     */
    350     class ShowHistoryAction extends AbstractAction implements ListSelectionListener, DataSelectionListener {
     351    class ShowHistoryAction extends AbstractShowHistoryAction implements ListSelectionListener, DataSelectionListener {
    351352        /**
    352353         * Constructs a new {@code ShowHistoryAction}.
    353354         */
    354355        ShowHistoryAction() {
    355             putValue(NAME, tr("History"));
    356             putValue(SHORT_DESCRIPTION, tr("Display the history of the selected objects."));
    357             new ImageProvider("dialogs", "history").getResource().attachImageIcon(this, true);
     356            super();
    358357            updateEnabledState(model.getSize());
    359358        }
     
    371370
    372371        protected void updateEnabledState(int osmSelectionSize) {
    373             // See #10830 - allow to click on history button is a single object is selected, even if not selected again in the list
     372            // See #10830 - allow to click on history button if a single object is selected, even if not selected again in the list
    374373            setEnabled(!model.isSelectionEmpty() || osmSelectionSize == 1);
    375374        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java

    r16469 r16495  
    3535import javax.swing.event.ListSelectionListener;
    3636
     37import org.openstreetmap.josm.actions.AbstractShowHistoryAction;
    3738import org.openstreetmap.josm.actions.AutoScaleAction;
    3839import org.openstreetmap.josm.actions.HistoryInfoAction;
     
    223224    }
    224225
    225     class ShowHistoryAction extends AbstractAction implements ListSelectionListener {
     226    class ShowHistoryAction extends AbstractShowHistoryAction implements ListSelectionListener {
    226227
    227228        ShowHistoryAction() {
    228             putValue(NAME, tr("Show history"));
    229             new ImageProvider("dialogs", "history").getResource().attachImageIcon(this);
    230             putValue(SHORT_DESCRIPTION, tr("Download and show the history of the selected objects"));
     229            super();
    231230            updateEnabledState();
    232231        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java

    r16489 r16495  
    2222import javax.swing.event.ListSelectionListener;
    2323
     24import org.openstreetmap.josm.actions.AbstractShowHistoryAction;
    2425import org.openstreetmap.josm.actions.AutoScaleAction;
    2526import org.openstreetmap.josm.actions.AutoScaleAction.AutoScaleMode;
     
    106107        menu.add(new SelectPreviousGapAction());
    107108        menu.add(new SelectNextGapAction());
    108         menu.add(new HistoryInfoAction() {
     109        menu.add(new AbstractShowHistoryAction() {
    109110            @Override
    110111            public void actionPerformed(ActionEvent ae) {
  • trunk/src/org/openstreetmap/josm/gui/history/ShowHistoryAction.java

    r16461 r16495  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.history;
    3 
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    53
    64import java.awt.event.ActionEvent;
     
    108import java.util.function.Function;
    119
    12 import javax.swing.AbstractAction;
    13 
     10import org.openstreetmap.josm.actions.AbstractShowHistoryAction;
    1411import org.openstreetmap.josm.data.osm.PrimitiveId;
    15 import org.openstreetmap.josm.tools.ImageProvider;
    1612
    1713/**
    1814 * Open a history browser with the history of an object.
    1915 */
    20 class ShowHistoryAction extends AbstractAction {
     16class ShowHistoryAction extends AbstractShowHistoryAction {
    2117    private transient PrimitiveId primitiveId;
    22 
    23     /**
    24      * Constructs a new {@code ShowHistoryAction}.
    25      */
    26     ShowHistoryAction() {
    27         putValue(NAME, tr("Show history"));
    28         putValue(SHORT_DESCRIPTION, tr("Display the history of the selected object."));
    29         new ImageProvider("dialogs", "history").getResource().attachImageIcon(this, true);
    30     }
    3118
    3219    @Override
Note: See TracChangeset for help on using the changeset viewer.