Changeset 8359 in josm for trunk


Ignore:
Timestamp:
2015-05-16T01:44:28+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #11422 - Help for keyboard shortcut should consider the operating system + do not display unrelevant messages if recent added tags are disabled

File:
1 edited

Legend:

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

    r8330 r8359  
    636636        @Override
    637637        public void setContentPane(Container contentPane) {
    638             final String text = "<html>" + Utils.join("<br>", Arrays.asList(
    639                     tr("<code>Ctrl-1</code> to apply first suggestion"),
    640                     tr("<code>Shift-Enter</code> to add without closing the dialog"),
    641                     tr("<code>Shift-Ctrl-1</code> to add first suggestion without closing the dialog")
    642             ));
    643             final JLabel helpLabel = new JLabel(text);
     638            final int commandDownMask = GuiHelper.getMenuShortcutKeyMaskEx();
     639            ArrayList<String> lines = new ArrayList<>();
     640            Shortcut sc = Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask);
     641            if (sc != null) {
     642                lines.add("<code>"+sc.getKeyText()+"</code> "+tr("to apply first suggestion"));
     643            }
     644            lines.add("<code>"+KeyEvent.getKeyModifiersText(KeyEvent.SHIFT_MASK)+"+"+KeyEvent.getKeyText(KeyEvent.VK_ENTER)+"</code> "
     645                    +tr("to add without closing the dialog"));
     646            sc = Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask|KeyEvent.SHIFT_DOWN_MASK);
     647            if (sc != null) {
     648                lines.add("<code>"+sc.getKeyText()+"</code> "+tr("to add first suggestion without closing the dialog"));
     649            }
     650            final JLabel helpLabel = new JLabel("<html>" + Utils.join("<br>", lines) + "</html>");
    644651            helpLabel.setFont(helpLabel.getFont().deriveFont(Font.PLAIN));
    645652            contentPane.add(helpLabel, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(1, 2, 1, 2));
     
    672679            int count = 1;
    673680            // We store the maximum number (9) of recent tags to allow dynamic change of number of tags shown in the preferences.
    674             // This implies to iterate in descending order, as the oldest elements will only be removed after we reach the maximum numbern and not the number of tags to show.
     681            // This implies to iterate in descending order, as the oldest elements will only be removed after we reach the maximum number and not the number of tags to show.
    675682            // However, as Set does not allow to iterate in descending order, we need to copy its elements into a List we can access in reverse order.
    676683            List<Tag> tags = new LinkedList<>(recentTags.keySet());
Note: See TracChangeset for help on using the changeset viewer.