()
| 411 | |
| 412 | |
| 413 | public void rebuildMenu() { |
| 414 | //System.out.println("rebuilding"); |
| 415 | if (menu != null) { |
| 416 | menu.removeAll(); |
| 417 | |
| 418 | } else { |
| 419 | menu = new JMenu(); |
| 420 | popup = menu.getPopupMenu(); |
| 421 | add(popup); |
| 422 | popup.setLightWeightPopupEnabled(true); |
| 423 | |
| 424 | /* |
| 425 | popup.addPopupMenuListener(new PopupMenuListener() { |
| 426 | public void popupMenuCanceled(PopupMenuEvent e) { |
| 427 | // on redraw, the isVisible() will get checked. |
| 428 | // actually, a repaint may be fired anyway, so this |
| 429 | // may be redundant. |
| 430 | repaint(); |
| 431 | } |
| 432 | public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } |
| 433 | public void popupMenuWillBecomeVisible(PopupMenuEvent e) { } |
| 434 | }); |
| 435 | */ |
| 436 | } |
| 437 | JMenuItem item; |
| 438 | final JRootPane rootPane = editor.getRootPane(); |
| 439 | InputMap inputMap = |
| 440 | rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); |
| 441 | ActionMap actionMap = rootPane.getActionMap(); |
| 442 | |
| 443 | Action action; |
| 444 | String mapKey; |
| 445 | KeyStroke keyStroke; |
| 446 | |
| 447 | item = Toolkit.newJMenuItemShift(Language.text("editor.header.new_tab"), KeyEvent.VK_N); |
| 448 | action = new AbstractAction() { |
| 449 | @Override |
| 450 | public void actionPerformed(ActionEvent e) { |
| 451 | editor.getSketch().handleNewCode(); |
| 452 | } |
| 453 | }; |
| 454 | mapKey = "editor.header.new_tab"; |
| 455 | keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.SHORTCUT_SHIFT_KEY_MASK); |
| 456 | inputMap.put(keyStroke, mapKey); |
| 457 | actionMap.put(mapKey, action); |
| 458 | item.addActionListener(action); |
| 459 | menu.add(item); |
| 460 | |
| 461 | item = new JMenuItem(Language.text("editor.header.rename")); |
| 462 | action = new AbstractAction() { |
| 463 | @Override |
| 464 | public void actionPerformed(ActionEvent e) { |
| 465 | editor.getSketch().handleRenameCode(); |
| 466 | } |
| 467 | }; |
| 468 | item.addActionListener(action); |
| 469 | menu.add(item); |
| 470 |
no test coverage detected