Ticket #19275: 19275.2c.patch

File 19275.2c.patch, 3.3 KB (added by GerdP, 5 years ago)

3rd alternative which enables Ctrl+H for the relation list

  • src/org/openstreetmap/josm/actions/HistoryInfoAction.java

     
    66
    77import java.awt.event.ActionEvent;
    88import java.awt.event.KeyEvent;
    9 import java.util.HashSet;
     9import java.util.LinkedHashSet;
    1010import java.util.Set;
     11import java.util.stream.Collectors;
    1112
     13import javax.swing.JList;
    1214import javax.swing.JTable;
    1315
    1416import org.openstreetmap.josm.data.osm.OsmData;
     
    4345    @Override
    4446    public void actionPerformed(ActionEvent ae) {
    4547        // Generic handling of tables displaying OSM primitives
     48        Set<PrimitiveId> sel = new LinkedHashSet<>();
    4649        if (ae.getSource() instanceof JTable) {
    4750            JTable table = (JTable) ae.getSource();
    48             Set<PrimitiveId> sel = new HashSet<>();
    4951            for (int row : table.getSelectedRows()) {
    5052                for (int col = 0; col < table.getModel().getColumnCount(); col++) {
    5153                    Object value = table.getModel().getValueAt(row, col);
     
    5557                    }
    5658                }
    5759            }
    58             if (!sel.isEmpty()) {
    59                 HistoryBrowserDialogManager.getInstance().showHistory(sel);
    60                 return;
    61             }
     60        } else if (ae.getSource() instanceof JList) {
     61            JList<?> list = (JList<?>) ae.getSource();
     62            sel = list.getSelectedValuesList()
     63                    .stream().filter(v -> v instanceof PrimitiveId)
     64                    .map(v -> (PrimitiveId) v)
     65                    .collect(Collectors.toCollection(LinkedHashSet::new));
    6266        }
     67        if (!sel.isEmpty()) {
     68            HistoryBrowserDialogManager.getInstance().showHistory(sel);
     69            return;
     70        }
    6371        // Otherwise show history for currently selected objects
    6472        OsmData<?, ?, ?, ?> set = getLayerManager().getActiveData();
    6573        if (set != null && !set.selectionEmpty()) {
  • src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

     
    3434import javax.swing.event.PopupMenuListener;
    3535
    3636import org.openstreetmap.josm.actions.ExpertToggleAction;
     37import org.openstreetmap.josm.actions.HistoryInfoAction;
    3738import org.openstreetmap.josm.actions.relation.AddSelectionToRelations;
    3839import org.openstreetmap.josm.actions.relation.DeleteRelationsAction;
    3940import org.openstreetmap.josm.actions.relation.DuplicateRelationAction;
     
    198199        displaylist.getActionMap().put("copy", MainApplication.getMenu().copy);
    199200        displaylist.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_C, PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()), "copy");
    200201
     202        HistoryInfoAction historyAction = MainApplication.getMenu().historyinfo;
     203        displaylist.getActionMap().put("historyAction", historyAction);
     204        displaylist.getInputMap().put(historyAction.getShortcut().getKeyStroke(), "historyAction");
     205
    201206        updateActionsRelationLists();
    202207    }
    203208