File: MacAdapter.source

package info (click to toggle)
imagej 1.46a-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,248 kB
  • sloc: java: 89,778; sh: 311; xml: 51; makefile: 6
file content (49 lines) | stat: -rw-r--r-- 1,454 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import ij.plugin.*;
import ij.*;
import ij.io.*;
import com.apple.eawt.*;
import java.util.Vector;

/**	This Mac specific plugin handles the "About" and "Quit" items in the Apple menu and opens
	 files dropped on ImageJ and files with creator code "imgJ" that are double-clicked. */ 
public class MacAdapter implements PlugIn, ApplicationListener, Runnable {
	static Vector paths = new Vector();

	public void run(String arg) {
		Application app = new Application();
		app.setEnabledPreferencesMenu(true);
		app.addApplicationListener(this);
	}
    
	public void handleAbout(ApplicationEvent event) {
		IJ.run("About ImageJ...");
		event.setHandled(true);
	}

	public void handleOpenFile(ApplicationEvent event) {
		paths.add(event.getFilename());
		Thread thread = new Thread(this, "Open");
		thread.setPriority(thread.getPriority()-1);
		thread.start();
	}

	public void handlePreferences(ApplicationEvent event) {
		IJ.error("The ImageJ preferences are in the Edit>Options menu.");
	}

	public void handleQuit(ApplicationEvent event) {
		new Executer("Quit", null); // works with the CommandListener
		//IJ.getInstance().quit();
	}
  
    public void run() {
        if (paths.size() > 0) {
			(new Opener()).openAndAddToRecent((String) paths.remove(0));
		}
    }

	public void handleOpenApplication(ApplicationEvent event) {}
	public void handleReOpenApplication(ApplicationEvent event) {}
	public void handlePrintFile(ApplicationEvent event) {}

}