This Mac-specific plugin is designed to handle the "About ImageJ" command in the ImageJ menu, to open files dropped on ImageJ.app and to open double-clicked files with creator code "imgJ". With Java 9 or newer, we use java.awt.desktop instead of the previous com.apple.eawt. classes. @author Alan Bro
| 14 | * @author Alan Brooks |
| 15 | */ |
| 16 | public class MacAdapter9 implements PlugIn, AboutHandler, OpenFilesHandler, QuitHandler, Runnable { |
| 17 | static Vector<String> paths = new Vector<String>(); |
| 18 | |
| 19 | public void run(String arg) { |
| 20 | Desktop dtop = Desktop.getDesktop(); |
| 21 | dtop.setOpenFileHandler(this); |
| 22 | dtop.setAboutHandler(this); |
| 23 | dtop.setQuitHandler(this); |
| 24 | } |
| 25 | |
| 26 | @Override |
| 27 | public void handleAbout(AboutEvent e) { |
| 28 | IJ.doCommand("About AstroImageJ..."); |
| 29 | } |
| 30 | |
| 31 | @Override |
| 32 | public void openFiles(OpenFilesEvent e) { |
| 33 | for (File file: e.getFiles()) { |
| 34 | paths.add(file.getPath()); |
| 35 | Thread thread = new Thread(this, "Open"); |
| 36 | thread.setPriority(thread.getPriority()-1); |
| 37 | thread.start(); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public void handleQuitRequestWith(QuitEvent e, QuitResponse response) { |
| 43 | new Executer("Quit", null); // works with the CommandListener |
| 44 | } |
| 45 | |
| 46 | // Not adding preference handling |
| 47 | // because we don't have the equivalent of app.setEnabledPreferencesMenu(true); |
| 48 | // @Override |
| 49 | // public void handlePreferences(PreferencesEvent e) { |
| 50 | // IJ.error("The ImageJ preferences are in the Edit>Options menu."); |
| 51 | // } |
| 52 | |
| 53 | public void run() { |
| 54 | if (paths.size() > 0) { |
| 55 | (new Opener()).openAndAddToRecent(paths.remove(0)); |
| 56 | } |
| 57 | } |
| 58 | } |
nothing calls this directly
no outgoing calls
no test coverage detected