Ticket #15089: 15089.patch

File 15089.patch, 2.6 KB (added by simon04, 3 months ago)
  • src/org/openstreetmap/josm/gui/io/UploadDialog.java

    diff --git a/src/org/openstreetmap/josm/gui/io/UploadDialog.java b/src/org/openstreetmap/josm/gui/io/UploadDialog.java
    index f74b84ac4..4062b87ff 100644
    a b  
    1111import java.awt.GraphicsEnvironment;
    1212import java.awt.GridBagLayout;
    1313import java.awt.event.ActionEvent;
     14import java.awt.event.InputEvent;
     15import java.awt.event.KeyEvent;
    1416import java.awt.event.WindowAdapter;
    1517import java.awt.event.WindowEvent;
    1618import java.beans.PropertyChangeEvent;
     
    2830import java.util.concurrent.TimeUnit;
    2931
    3032import javax.swing.AbstractAction;
     33import javax.swing.Action;
    3134import javax.swing.BorderFactory;
    3235import javax.swing.Icon;
    3336import javax.swing.JButton;
     37import javax.swing.JComponent;
    3438import javax.swing.JOptionPane;
    3539import javax.swing.JPanel;
    3640import javax.swing.JTabbedPane;
     41import javax.swing.KeyStroke;
    3742
    3843import org.openstreetmap.josm.Main;
    3944import org.openstreetmap.josm.data.APIDataSet;
    protected JPanel buildActionPanel() { 
    177182        pnl.add(btnUpload);
    178183        btnUpload.setFocusable(true);
    179184        InputMapUtils.enableEnter(btnUpload);
     185        bindCtrlEnterToAction(getRootPane(), btnUpload.getAction());
    180186
    181187        // -- cancel button
    182188        CancelAction cancelAction = new CancelAction(this);
    protected boolean warnUploadTag(final String title, final String message, final 
    475481                return false;
    476482            }
    477483
    478             ExtendedDialog dlg = new ExtendedDialog((Component) dialog, title, buttonTexts);
     484            ExtendedDialog dlg = new ExtendedDialog((Component) dialog, title, buttonTexts) {
     485                @Override
     486                public void setupDialog() {
     487                    super.setupDialog();
     488                    bindCtrlEnterToAction(getRootPane(), buttons.get(buttons.size() - 1).getAction());
     489                }
     490            };
    479491            dlg.setContent("<html>" + message + "</html>");
    480492            dlg.setButtonIcons(buttonIcons);
    481493            dlg.setToolTipTexts(tooltips);
    public void handleMissingSource() { 
    684696    public void handleIllegalChunkSize() {
    685697        tpConfigPanels.setSelectedIndex(0);
    686698    }
     699
     700    private static void bindCtrlEnterToAction(JComponent component, Action actionToBind) {
     701        final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK);
     702        component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "ctrl_enter");
     703        component.getActionMap().put("ctrl_enter", actionToBind);
     704    }
    687705}