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/src/org/openstreetmap/josm/gui/io/UploadDialog.java +++ b/src/org/openstreetmap/josm/gui/io/UploadDialog.java @@ -11,6 +11,8 @@ import java.awt.GraphicsEnvironment; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; @@ -28,12 +30,15 @@ import java.util.concurrent.TimeUnit; import javax.swing.AbstractAction; +import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; +import javax.swing.KeyStroke; import org.openstreetmap.josm.Main; import org.openstreetmap.josm.data.APIDataSet; @@ -177,6 +182,7 @@ protected JPanel buildActionPanel() { pnl.add(btnUpload); btnUpload.setFocusable(true); InputMapUtils.enableEnter(btnUpload); + bindCtrlEnterToAction(getRootPane(), btnUpload.getAction()); // -- cancel button CancelAction cancelAction = new CancelAction(this); @@ -475,7 +481,13 @@ protected boolean warnUploadTag(final String title, final String message, final return false; } - ExtendedDialog dlg = new ExtendedDialog((Component) dialog, title, buttonTexts); + ExtendedDialog dlg = new ExtendedDialog((Component) dialog, title, buttonTexts) { + @Override + public void setupDialog() { + super.setupDialog(); + bindCtrlEnterToAction(getRootPane(), buttons.get(buttons.size() - 1).getAction()); + } + }; dlg.setContent("" + message + ""); dlg.setButtonIcons(buttonIcons); dlg.setToolTipTexts(tooltips); @@ -684,4 +696,10 @@ public void handleMissingSource() { public void handleIllegalChunkSize() { tpConfigPanels.setSelectedIndex(0); } + + private static void bindCtrlEnterToAction(JComponent component, Action actionToBind) { + final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK); + component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "ctrl_enter"); + component.getActionMap().put("ctrl_enter", actionToBind); + } }