Changeset 3252 in josm for trunk/src/org/openstreetmap/josm/Main.java
- Timestamp:
- 15.05.2010 18:59:10 (2 years ago)
- File:
-
- 1 edited
-
trunk/src/org/openstreetmap/josm/Main.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r3071 r3252 27 27 import java.util.regex.Pattern; 28 28 29 import javax.swing.Action; 30 import javax.swing.InputMap; 29 31 import javax.swing.JComponent; 30 32 import javax.swing.JFrame; 31 33 import javax.swing.JOptionPane; 32 34 import javax.swing.JPanel; 35 import javax.swing.KeyStroke; 33 36 import javax.swing.UIManager; 34 37 … … 198 201 isOpenjdk = System.getProperty("java.vm.name").toUpperCase().indexOf("OPENJDK") != -1; 199 202 platform.startupHook(); 200 contentPane .add(panel, BorderLayout.CENTER);203 contentPanePrivate.add(panel, BorderLayout.CENTER); 201 204 panel.add(gettingStarted, BorderLayout.CENTER); 202 205 menu = new MainMenu(); … … 205 208 206 209 // creating toolbar 207 contentPane.add(toolbar.control, BorderLayout.NORTH); 208 209 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) 210 .put(Shortcut.registerShortcut("system:help", tr("Help"), 211 KeyEvent.VK_F1, Shortcut.GROUP_DIRECT).getKeyStroke(), "Help"); 212 contentPane.getActionMap().put("Help", menu.help); 210 contentPanePrivate.add(toolbar.control, BorderLayout.NORTH); 211 212 registerActionShortcut(menu.help, Shortcut.registerShortcut("system:help", tr("Help"), 213 KeyEvent.VK_F1, Shortcut.GROUP_DIRECT)); 213 214 214 215 TaggingPresetPreference.initialize(); … … 218 219 219 220 toolbar.control.updateUI(); 220 contentPane .updateUI();221 contentPanePrivate.updateUI(); 221 222 } 222 223 … … 226 227 public final void addLayer(final Layer layer) { 227 228 if (map == null) { 228 final MapFrame mapFrame = new MapFrame( );229 final MapFrame mapFrame = new MapFrame(contentPanePrivate); 229 230 setMapFrame(mapFrame); 230 231 mapFrame.selectMapMode((MapMode)mapFrame.getDefaultButtonAction()); … … 281 282 } 282 283 283 /** 284 * Use this to register shortcuts to 285 */ 286 public static final JPanel contentPane = new JPanel(new BorderLayout()); 284 protected static JPanel contentPanePrivate = new JPanel(new BorderLayout()); 285 286 /** 287 * @deprecated If you just need to register shortcut for action, use registerActionShortcut instead of accessing InputMap directly 288 */ 289 @Deprecated 290 public static final JPanel contentPane = contentPanePrivate; 291 292 public static void registerActionShortcut(Action action, Shortcut shortcut) { 293 registerActionShortcut(action, shortcut.getKeyStroke()); 294 } 295 296 public static void registerActionShortcut(Action action, KeyStroke keyStroke) { 297 if (keyStroke == null) 298 return; 299 300 InputMap inputMap = contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); 301 Object existing = inputMap.get(keyStroke); 302 if (existing != null && !existing.equals(action)) { 303 System.out.println(String.format("Keystroke is already assigned to %s, will be overridden by %s", existing, action)); 304 } 305 inputMap.put(keyStroke, action); 306 307 contentPanePrivate.getActionMap().put(action, action); 308 } 309 310 public static void unregisterActionShortcut(Shortcut shortcut) { 311 contentPanePrivate.getInputMap().remove(shortcut.getKeyStroke()); 312 } 287 313 288 314 /////////////////////////////////////////////////////////////////////////// … … 324 350 } 325 351 toolbar = new ToolbarPreferences(); 326 contentPane .updateUI();352 contentPanePrivate.updateUI(); 327 353 panel.updateUI(); 328 354 } catch (final Exception e) {
Note: See TracChangeset
for help on using the changeset viewer.
