Changeset 11341 in josm for trunk


Ignore:
Timestamp:
2016-11-28T21:19:04+01:00 (3 years ago)
Author:
simon04
Message:

Search menu items: display shortcut

File:
1 edited

Legend:

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

    r11040 r11341  
    88import java.awt.event.ActionEvent;
    99import java.awt.event.KeyEvent;
     10import java.util.Optional;
    1011
    1112import javax.swing.DefaultListCellRenderer;
    12 import javax.swing.JLabel;
    1313import javax.swing.JList;
    1414import javax.swing.JMenuItem;
     
    9494        public Component getListCellRendererComponent(JList<? extends JMenuItem> list, JMenuItem value, int index,
    9595                                                      boolean isSelected, boolean cellHasFocus) {
    96             final JLabel label = (JLabel) def.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    97             label.setText(value.getText());
    98             label.setIcon(value.getIcon());
    99             label.setEnabled(value.isEnabled());
    10096            final JMenuItem item = new JMenuItem(value.getText());
    10197            item.setAction(value.getAction());
     98            Optional.ofNullable(value.getAction())
     99                    .filter(JosmAction.class::isInstance)
     100                    .map(JosmAction.class::cast)
     101                    .map(JosmAction::getShortcut)
     102                    .map(Shortcut::getKeyStroke)
     103                    .ifPresent(item::setAccelerator);
    102104            if (isSelected) {
    103105                item.setBackground(list.getSelectionBackground());
Note: See TracChangeset for help on using the changeset viewer.