Handle menu events.
(ActionEvent e)
| 442 | |
| 443 | /** Handle menu events. */ |
| 444 | public void actionPerformed(ActionEvent e) { |
| 445 | if ((e.getSource() instanceof MenuItem)) { |
| 446 | MenuItem item = (MenuItem)e.getSource(); |
| 447 | String cmd = e.getActionCommand(); |
| 448 | Frame frame = WindowManager.getFrontWindow(); |
| 449 | if (frame!=null && (frame instanceof Fitter)) { |
| 450 | ((Fitter)frame).actionPerformed(e); |
| 451 | return; |
| 452 | } |
| 453 | commandName = cmd; |
| 454 | ImagePlus imp = null; |
| 455 | if (item.getParent()==Menus.getOpenRecentMenu()) { |
| 456 | new RecentOpener(cmd); // open image in separate thread |
| 457 | return; |
| 458 | } else if (item.getParent()==Menus.getPopupMenu()) { |
| 459 | Object parent = Menus.getPopupMenu().getParent(); |
| 460 | if (parent instanceof ImageCanvas) |
| 461 | imp = ((ImageCanvas)parent).getImage(); |
| 462 | } |
| 463 | int flags = e.getModifiers(); |
| 464 | hotkey = false; |
| 465 | actionPerformedTime = System.currentTimeMillis(); |
| 466 | long ellapsedTime = actionPerformedTime-keyPressedTime; |
| 467 | if (cmd!=null && (ellapsedTime>=200L||!cmd.equals(lastKeyCommand))) { |
| 468 | if ((flags & Event.ALT_MASK)!=0) |
| 469 | IJ.setKeyDown(KeyEvent.VK_ALT); |
| 470 | if ((flags & Event.SHIFT_MASK)!=0) |
| 471 | IJ.setKeyDown(KeyEvent.VK_SHIFT); |
| 472 | new Executer(cmd, imp); |
| 473 | } |
| 474 | lastKeyCommand = null; |
| 475 | if (IJ.debugMode) IJ.log("actionPerformed: time="+ellapsedTime+", "+e); |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | /** Handles CheckboxMenuItem state changes. */ |
| 480 | public void itemStateChanged(ItemEvent e) { |
nothing calls this directly
no test coverage detected