Changeset 10791 in josm for trunk/src/org
- Timestamp:
- 2016-08-12T21:08:00+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r10680 r10791 23 23 import javax.swing.Icon; 24 24 import javax.swing.JButton; 25 import javax.swing.JComponent;26 25 import javax.swing.JDialog; 27 26 import javax.swing.JLabel; … … 41 40 import org.openstreetmap.josm.tools.GBC; 42 41 import org.openstreetmap.josm.tools.ImageProvider; 42 import org.openstreetmap.josm.tools.InputMapUtils; 43 43 import org.openstreetmap.josm.tools.Utils; 44 44 import org.openstreetmap.josm.tools.WindowGeometry; … … 473 473 }; 474 474 475 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) 476 .put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); 477 getRootPane().getActionMap().put("ESCAPE", actionListener); 475 InputMapUtils.addEscapeAction(getRootPane(), actionListener); 478 476 } 479 477 -
trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java
r10790 r10791 8 8 import java.awt.GraphicsEnvironment; 9 9 import java.awt.event.ActionEvent; 10 import java.awt.event.KeyEvent;11 10 import java.awt.event.WindowAdapter; 12 11 import java.awt.event.WindowEvent; … … 20 19 import javax.swing.Icon; 21 20 import javax.swing.JButton; 22 import javax.swing.JComponent;23 21 import javax.swing.JDialog; 24 22 import javax.swing.JOptionPane; 25 import javax.swing.KeyStroke;26 23 import javax.swing.event.ChangeEvent; 27 24 import javax.swing.event.ChangeListener; … … 287 284 } 288 285 }); 289 dialog.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 290 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close"); 291 dialog.getRootPane().getActionMap().put("close", new AbstractAction() { 286 InputMapUtils.addEscapeAction(dialog.getRootPane(), new AbstractAction() { 292 287 @Override 293 288 public void actionPerformed(ActionEvent e) { -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
r10762 r10791 49 49 import org.openstreetmap.josm.tools.CheckParameterUtil; 50 50 import org.openstreetmap.josm.tools.ImageProvider; 51 import org.openstreetmap.josm.tools.InputMapUtils; 51 52 import org.openstreetmap.josm.tools.StreamUtils; 52 53 import org.openstreetmap.josm.tools.UserCancelException; … … 170 171 addWindowListener(new AdjustDividerLocationAction()); 171 172 HelpUtil.setHelpContext(getRootPane(), ht("/")); 173 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 172 174 } 173 175 -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java
r10737 r10791 41 41 import org.openstreetmap.josm.gui.util.GuiHelper; 42 42 import org.openstreetmap.josm.tools.ImageProvider; 43 import org.openstreetmap.josm.tools.InputMapUtils; 43 44 import org.openstreetmap.josm.tools.WindowGeometry; 44 45 … … 104 105 gc.weighty = 0.0; 105 106 getContentPane().add(buildButtonPanel(), gc); 107 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 108 106 109 } 107 110 -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
r10790 r10791 291 291 292 292 // make the dialog respond to ESC 293 getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 294 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelAndClose"); 295 getRootPane().getActionMap().put("cancelAndClose", new CancelAction()); 293 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 296 294 297 295 // install a window event handler -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialog.java
r10627 r10791 10 10 import java.awt.Window; 11 11 import java.awt.event.ActionEvent; 12 import java.awt.event.KeyEvent;13 12 import java.awt.event.WindowAdapter; 14 13 import java.awt.event.WindowEvent; … … 16 15 import javax.swing.AbstractAction; 17 16 import javax.swing.JButton; 18 import javax.swing.JComponent;19 17 import javax.swing.JDialog; 20 18 import javax.swing.JOptionPane; 21 19 import javax.swing.JPanel; 22 20 import javax.swing.JTabbedPane; 23 import javax.swing.KeyStroke;24 21 25 22 import org.openstreetmap.josm.Main; … … 29 26 import org.openstreetmap.josm.io.ChangesetQuery; 30 27 import org.openstreetmap.josm.tools.ImageProvider; 28 import org.openstreetmap.josm.tools.InputMapUtils; 31 29 import org.openstreetmap.josm.tools.WindowGeometry; 32 30 … … 90 88 91 89 // cancel on ESC 92 getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); 93 getRootPane().getActionMap().put("cancel", new CancelAction()); 90 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 94 91 95 92 // context sensitive help -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/CancelAction.java
r10424 r10791 6 6 import java.awt.event.ActionEvent; 7 7 8 import javax.swing.JComponent;9 8 import javax.swing.JOptionPane; 10 import javax.swing.JRootPane;11 import javax.swing.KeyStroke;12 9 import javax.swing.RootPaneContainer; 13 10 … … 23 20 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 24 21 import org.openstreetmap.josm.tools.ImageProvider; 22 import org.openstreetmap.josm.tools.InputMapUtils; 25 23 26 24 /** … … 47 45 48 46 if (editor instanceof RootPaneContainer) { 49 JRootPane root = ((RootPaneContainer) editor).getRootPane(); 50 root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); 51 root.getActionMap().put("ESCAPE", this); 47 InputMapUtils.addEscapeAction(((RootPaneContainer) editor).getRootPane(), this); 52 48 } 53 49 setEnabled(true); -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r10790 r10791 190 190 191 191 // -- cancel on ESC 192 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); 193 getRootPane().getActionMap().put("cancel", actCancel); 192 InputMapUtils.addEscapeAction(getRootPane(), actCancel); 194 193 195 194 // -- help button -
trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java
r10627 r10791 12 12 import java.awt.Rectangle; 13 13 import java.awt.event.ActionEvent; 14 import java.awt.event.KeyEvent;15 14 import java.awt.event.WindowAdapter; 16 15 import java.awt.event.WindowEvent; … … 24 23 import javax.swing.AbstractAction; 25 24 import javax.swing.JButton; 26 import javax.swing.JComponent;27 25 import javax.swing.JDialog; 28 26 import javax.swing.JMenuItem; … … 32 30 import javax.swing.JSeparator; 33 31 import javax.swing.JToolBar; 34 import javax.swing.KeyStroke;35 32 import javax.swing.SwingUtilities; 36 33 import javax.swing.event.ChangeEvent; … … 54 51 import org.openstreetmap.josm.gui.widgets.JosmHTMLEditorKit; 55 52 import org.openstreetmap.josm.tools.ImageProvider; 53 import org.openstreetmap.josm.tools.InputMapUtils; 56 54 import org.openstreetmap.josm.tools.LanguageInfo.LocaleType; 57 55 import org.openstreetmap.josm.tools.OpenBrowser; … … 195 193 196 194 p.add(buildToolBar(), BorderLayout.NORTH); 197 help.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Close"); 198 help.getActionMap().put("Close", new AbstractAction() { 195 InputMapUtils.addEscapeAction(getRootPane(), new AbstractAction() { 199 196 @Override 200 197 public void actionPerformed(ActionEvent e) { -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialog.java
r10481 r10791 9 9 import java.awt.FlowLayout; 10 10 import java.awt.event.ActionEvent; 11 import java.awt.event.KeyEvent;12 11 import java.awt.event.WindowAdapter; 13 12 import java.awt.event.WindowEvent; … … 15 14 import javax.swing.AbstractAction; 16 15 import javax.swing.JButton; 17 import javax.swing.JComponent;18 16 import javax.swing.JDialog; 19 17 import javax.swing.JLabel; 20 18 import javax.swing.JPanel; 21 import javax.swing.KeyStroke;22 19 23 20 import org.openstreetmap.josm.Main; … … 30 27 import org.openstreetmap.josm.gui.util.GuiHelper; 31 28 import org.openstreetmap.josm.tools.ImageProvider; 29 import org.openstreetmap.josm.tools.InputMapUtils; 32 30 33 31 /** … … 107 105 btn = new JButton(closeAction); 108 106 final String closeHistoryBrowserDialogKey = "CloseHistoryBrowserDialog"; 109 KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);110 getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escapeKey, closeHistoryBrowserDialogKey);111 getRootPane().getActionMap().put(closeHistoryBrowserDialogKey, closeAction);112 107 btn.setName("btn.close"); 113 108 pnl.add(btn); 109 InputMapUtils.addEscapeAction(getRootPane(), closeAction); 114 110 115 111 btn = new JButton(new ContextSensitiveHelpAction(ht("/Action/ObjectHistory"))); -
trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetDialog.java
r10179 r10791 8 8 import java.awt.FlowLayout; 9 9 import java.awt.event.ActionEvent; 10 import java.awt.event.KeyEvent;11 10 import java.awt.event.WindowAdapter; 12 11 import java.awt.event.WindowEvent; … … 18 17 import javax.swing.BorderFactory; 19 18 import javax.swing.DefaultListModel; 20 import javax.swing.JComponent;21 19 import javax.swing.JDialog; 22 20 import javax.swing.JLabel; … … 24 22 import javax.swing.JPanel; 25 23 import javax.swing.JScrollPane; 26 import javax.swing.KeyStroke;27 24 import javax.swing.event.ListSelectionEvent; 28 25 import javax.swing.event.ListSelectionListener; … … 91 88 getContentPane().add(buildSouthPanel(), BorderLayout.SOUTH); 92 89 93 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape"); 94 getRootPane().getActionMap().put("escape", new CancelAction()); 90 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 95 91 addWindowListener(new WindowEventHandler()); 96 92 } -
trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java
r10627 r10791 23 23 import javax.swing.BorderFactory; 24 24 import javax.swing.JCheckBox; 25 import javax.swing.JComponent;26 25 import javax.swing.JDialog; 27 26 import javax.swing.JLabel; 28 27 import javax.swing.JPanel; 29 28 import javax.swing.JTextField; 30 import javax.swing.KeyStroke;31 29 32 30 import org.openstreetmap.josm.Main; … … 40 38 import org.openstreetmap.josm.io.OsmApi; 41 39 import org.openstreetmap.josm.tools.ImageProvider; 40 import org.openstreetmap.josm.tools.InputMapUtils; 42 41 import org.openstreetmap.josm.tools.WindowGeometry; 43 42 … … 97 96 98 97 addWindowListener(new WindowEventHander()); 99 getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 100 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape"); 101 getRootPane().getActionMap().put("escape", new CancelAction()); 98 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 102 99 103 100 getRootPane().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r10627 r10791 30 30 import javax.swing.ImageIcon; 31 31 import javax.swing.JButton; 32 import javax.swing.JComponent;33 32 import javax.swing.JDialog; 34 33 import javax.swing.JLabel; … … 37 36 import javax.swing.JPanel; 38 37 import javax.swing.JScrollPane; 39 import javax.swing.KeyStroke;40 38 import javax.swing.ListCellRenderer; 41 39 import javax.swing.WindowConstants; … … 54 52 import org.openstreetmap.josm.tools.GBC; 55 53 import org.openstreetmap.josm.tools.ImageProvider; 54 import org.openstreetmap.josm.tools.InputMapUtils; 56 55 import org.openstreetmap.josm.tools.UserCancelException; 57 56 import org.openstreetmap.josm.tools.Utils; … … 299 298 putValue(SHORT_DESCRIPTION, tr("Close this dialog and resume editing in JOSM")); 300 299 putValue(SMALL_ICON, ImageProvider.get("cancel")); 301 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) 302 .put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); 303 getRootPane().getActionMap().put("ESCAPE", this); 300 InputMapUtils.addEscapeAction(getRootPane(), this); 304 301 } 305 302 -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r10783 r10791 12 12 import java.awt.GridBagLayout; 13 13 import java.awt.event.ActionEvent; 14 import java.awt.event.KeyEvent;15 14 import java.awt.event.WindowAdapter; 16 15 import java.awt.event.WindowEvent; … … 31 30 import javax.swing.Icon; 32 31 import javax.swing.JButton; 33 import javax.swing.JComponent;34 32 import javax.swing.JOptionPane; 35 33 import javax.swing.JPanel; 36 34 import javax.swing.JTabbedPane; 37 import javax.swing.KeyStroke;38 35 39 36 import org.openstreetmap.josm.Main; … … 189 186 CancelAction cancelAction = new CancelAction(this); 190 187 pnl.add(new JButton(cancelAction)); 191 getRootPane().registerKeyboardAction( 192 cancelAction, 193 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), 194 JComponent.WHEN_IN_FOCUSED_WINDOW 195 ); 188 InputMapUtils.addEscapeAction(getRootPane(), cancelAction); 196 189 pnl.add(new JButton(new ContextSensitiveHelpAction(ht("/Dialog/Upload")))); 197 190 HelpUtil.setHelpContext(getRootPane(), ht("/Dialog/Upload")); -
trunk/src/org/openstreetmap/josm/gui/io/UploadSelectionDialog.java
r10680 r10791 20 20 import javax.swing.Action; 21 21 import javax.swing.BorderFactory; 22 import javax.swing.JComponent;23 22 import javax.swing.JDialog; 24 23 import javax.swing.JLabel; … … 27 26 import javax.swing.JScrollPane; 28 27 import javax.swing.JSplitPane; 29 import javax.swing.KeyStroke;30 28 import javax.swing.ListSelectionModel; 31 29 import javax.swing.event.ListSelectionEvent; … … 42 40 import org.openstreetmap.josm.gui.util.GuiHelper; 43 41 import org.openstreetmap.josm.tools.ImageProvider; 42 import org.openstreetmap.josm.tools.InputMapUtils; 44 43 import org.openstreetmap.josm.tools.WindowGeometry; 45 44 … … 258 257 putValue(Action.NAME, tr("Cancel")); 259 258 new ImageProvider("cancel").getResource().attachImageIcon(this); 260 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) 261 .put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); 262 getRootPane().getActionMap().put("ESCAPE", this); 259 InputMapUtils.addEscapeAction(getRootPane(), this); 263 260 setEnabled(true); 264 261 } -
trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
r10378 r10791 17 17 import java.awt.event.ItemEvent; 18 18 import java.awt.event.ItemListener; 19 import java.awt.event.KeyEvent;20 19 import java.awt.event.WindowAdapter; 21 20 import java.awt.event.WindowEvent; … … 27 26 import javax.swing.BorderFactory; 28 27 import javax.swing.JButton; 29 import javax.swing.JComponent;30 28 import javax.swing.JDialog; 31 29 import javax.swing.JLabel; 32 30 import javax.swing.JPanel; 33 31 import javax.swing.JScrollPane; 34 import javax.swing.KeyStroke;35 32 import javax.swing.UIManager; 36 33 import javax.swing.event.HyperlinkEvent; … … 51 48 import org.openstreetmap.josm.tools.CheckParameterUtil; 52 49 import org.openstreetmap.josm.tools.ImageProvider; 50 import org.openstreetmap.josm.tools.InputMapUtils; 53 51 import org.openstreetmap.josm.tools.OpenBrowser; 54 52 import org.openstreetmap.josm.tools.UserCancelException; … … 232 230 233 231 addWindowListener(new WindowEventHandler()); 234 getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); 235 getRootPane().getActionMap().put("cancel", new CancelAction()); 232 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 236 233 237 234 refreshAuthorisationProcedurePanel(); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r10611 r10791 12 12 import java.awt.Insets; 13 13 import java.awt.event.ActionEvent; 14 import java.awt.event.KeyEvent;15 14 import java.awt.event.WindowAdapter; 16 15 import java.awt.event.WindowEvent; … … 20 19 import javax.swing.JButton; 21 20 import javax.swing.JCheckBox; 22 import javax.swing.JComponent;23 21 import javax.swing.JDialog; 24 22 import javax.swing.JPanel; 25 import javax.swing.KeyStroke;26 23 27 24 import org.openstreetmap.josm.actions.ExpertToggleAction; … … 32 29 import org.openstreetmap.josm.tools.GBC; 33 30 import org.openstreetmap.josm.tools.ImageProvider; 31 import org.openstreetmap.josm.tools.InputMapUtils; 34 32 import org.openstreetmap.josm.tools.WindowGeometry; 35 33 … … 79 77 addWindowListener(new WindowEventHandler()); 80 78 81 getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); 82 getRootPane().getActionMap().put("cancel", new CancelAction()); 79 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 83 80 HelpUtil.setHelpContext(getRootPane(), HelpUtil.ht("/Action/Preferences")); 84 81 } -
trunk/src/org/openstreetmap/josm/tools/InputMapUtils.java
r10790 r10791 105 105 c.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "spacebar"); 106 106 } 107 108 /** 109 * Add an action activated with ESCAPE key on a component or its children. 110 * @param c The Swing component 111 * @param a action activated with ESCAPE key 112 * @see JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT 113 * @since 10791 114 */ 115 public static void addEscapeAction(JComponent c, Action a) { 116 c.getActionMap().put("escape", a); 117 c.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape"); 118 } 107 119 } -
trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportDialog.java
r10720 r10791 9 9 import java.awt.GridBagLayout; 10 10 import java.awt.event.ActionEvent; 11 import java.awt.event.KeyEvent;12 11 13 12 import javax.swing.AbstractAction; … … 16 15 import javax.swing.JButton; 17 16 import javax.swing.JCheckBox; 18 import javax.swing.JComponent;19 17 import javax.swing.JDialog; 20 18 import javax.swing.JLabel; 21 19 import javax.swing.JPanel; 22 import javax.swing.KeyStroke;23 20 import javax.swing.UIManager; 24 21 … … 29 26 import org.openstreetmap.josm.tools.GBC; 30 27 import org.openstreetmap.josm.tools.ImageProvider; 28 import org.openstreetmap.josm.tools.InputMapUtils; 31 29 32 30 /** … … 72 70 setDefaultCloseOperation(DISPOSE_ON_CLOSE); 73 71 74 getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape"); 75 getRootPane().getActionMap().put("escape", new AbstractAction() { 72 InputMapUtils.addEscapeAction(getRootPane(), new AbstractAction() { 76 73 @Override 77 74 public void actionPerformed(ActionEvent e) {
Note:
See TracChangeset
for help on using the changeset viewer.