private static Frame getParentFrame() { Frame parent = WindowManager.getCurrentImage() != null ? (Frame) WindowManager.getCurrentImage().getWindow() : IJ.getInstance() != null ? IJ.getInstance() : new Frame(); if (IJ.isMacOSX() && IJ.isJava18()) { ImageJ ij = IJ.getInstance(); if (ij != null && ij.isActive()) parent = ij; else parent = null; } return parent; }
public void runMacro(String name, Editor editor) { if (anonymousName != null && name.equals(anonymousName)) { ImageJ.setCommandName(name); new MacroRunner(pgm, 0, anonymousName, editor); return; } for (int i = 0; i < nMacros; i++) if (name.equals(macroNames[i])) { ImageJ.setCommandName(name); new MacroRunner(pgm, macroStarts[i], name, editor); return; } }
public void actionPerformed(ActionEvent evt) { String cmd = evt.getActionCommand(); ImageJ.setCommandName(cmd); MenuItem item = (MenuItem) evt.getSource(); MenuContainer parent = item.getParent(); if (parent instanceof PopupMenu) { for (int i = 0; i < nMacros; i++) { if (macroNames[i].equals("Popup Menu")) { new MacroRunner(pgm, macroStarts[i], "Popup Menu", cmd); return; } } } runMacro(cmd); }