Changeset 10790 in josm
- Timestamp:
- 2016-08-12T21:07:51+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java
r10611 r10790 301 301 final DefaultAction action = new DefaultAction(dialog, pane, i); 302 302 buttons.get(i).addActionListener(action); 303 buttons.get(i).getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter"); 304 buttons.get(i).getActionMap().put("enter", action); 303 InputMapUtils.addEnterAction(buttons.get(i), action); 305 304 } 306 305 } else { 307 306 final DefaultAction action = new DefaultAction(dialog, pane, 0); 308 307 buttons.get(0).addActionListener(action); 309 buttons.get(0).getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter"); 310 buttons.get(0).getActionMap().put("enter", action); 308 InputMapUtils.addEnterAction(buttons.get(0), action); 311 309 } 312 310 -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
r10627 r10790 58 58 import org.openstreetmap.josm.io.OnlineResource; 59 59 import org.openstreetmap.josm.tools.ImageProvider; 60 import org.openstreetmap.josm.tools.InputMapUtils; 60 61 import org.openstreetmap.josm.tools.WindowGeometry; 61 62 … … 257 258 ); 258 259 tblChangesets.addMouseListener(new MouseEventHandler()); 259 tblChangesets.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "showDetails"); 260 tblChangesets.getActionMap().put("showDetails", new ShowDetailAction(model)); 260 InputMapUtils.addEnterAction(tblChangesets, new ShowDetailAction(model)); 261 261 model.getSelectionModel().addListSelectionListener(new ChangesetDetailViewSynchronizer(model)); 262 262 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r10722 r10790 496 496 497 497 // ENTER = editAction, open "edit" dialog 498 tagTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) 499 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onTableEnter"); 500 tagTable.getActionMap().put("onTableEnter", editAction); 501 membershipTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) 502 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onTableEnter"); 503 membershipTable.getActionMap().put("onTableEnter", editAction); 498 InputMapUtils.addEnterActionWhenAncestor(tagTable, editAction); 499 InputMapUtils.addEnterActionWhenAncestor(membershipTable, editAction); 504 500 505 501 // INSERT button = addAction, open "add tag" dialog -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r10629 r10790 84 84 protected final JButton btnDownload = new JButton(actDownload); 85 85 86 private void makeCheckBoxRespondToEnter(JCheckBox cb) {87 cb.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "doDownload");88 cb.getActionMap().put("doDownload", actDownload);89 }90 91 86 protected final JPanel buildMainPanel() { 92 87 JPanel pnl = new JPanel(new GridBagLayout()); … … 182 177 InputMapUtils.enableEnter(btnDownload); 183 178 184 makeCheckBoxRespondToEnter(cbDownloadGpxData);185 makeCheckBoxRespondToEnter(cbDownloadOsmData);186 makeCheckBoxRespondToEnter(cbDownloadNotes);187 makeCheckBoxRespondToEnter(cbNewLayer);179 InputMapUtils.addEnterActionWhenAncestor(cbDownloadGpxData, actDownload); 180 InputMapUtils.addEnterActionWhenAncestor(cbDownloadOsmData, actDownload); 181 InputMapUtils.addEnterActionWhenAncestor(cbDownloadNotes, actDownload); 182 InputMapUtils.addEnterActionWhenAncestor(cbNewLayer, actDownload); 188 183 189 184 // -- cancel button -
trunk/src/org/openstreetmap/josm/tools/InputMapUtils.java
r8510 r10790 67 67 public static void enableEnter(JButton b) { 68 68 b.setFocusable(true); 69 b.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter"); 70 b.getActionMap().put("enter", b.getAction()); 69 addEnterAction(b, b.getAction()); 71 70 } 72 71 … … 75 74 * @param c The Swing component 76 75 * @param a action activated with Enter key 76 * @see JComponent#WHEN_FOCUSED 77 77 */ 78 78 public static void addEnterAction(JComponent c, Action a) { 79 addEnterAction(c, a, JComponent.WHEN_FOCUSED); 80 } 81 82 /** 83 * Add an action activated with Enter key on a component or its children. 84 * @param c The Swing component 85 * @param a action activated with Enter key 86 * @see JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT 87 * @since 10790 88 */ 89 public static void addEnterActionWhenAncestor(JComponent c, Action a) { 90 addEnterAction(c, a, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); 91 } 92 93 private static void addEnterAction(JComponent c, Action a, int condition) { 79 94 c.getActionMap().put("enter", a); 80 c.getInputMap( ).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter");95 c.getInputMap(condition).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter"); 81 96 } 82 97
Note:
See TracChangeset
for help on using the changeset viewer.