package org.wrap;

import com.apple.eawt.*;
import java.util.Enumeration;
import java.util.Vector;
//import org.cmdline.appedit.QuitListener;

public class OSXApplication extends Application {

	Vector files = new Vector();
	boolean dropped = false;
	Vector quitListeners = new Vector();
	
	public OSXApplication() {
		addApplicationListener(new ApplicationAdapter() {
   			public void handleOpenFile(ApplicationEvent e) {
   				dropped = true;
   				String name = e.getFilename();
   				files.addElement(name);
   			}
   			public void handleQuit(ApplicationEvent evt) {
/*
   	  			if (quitListeners.size() > 0) {
   	  				Enumeration e = quitListeners.elements();
   	  				while (e.hasMoreElements()) {
   	  					QuitListener ql = (QuitListener)e.nextElement();
   	  					ql.quit();
   	  				}
   	  			}
*/
   	  			System.exit(0);
   			}
   		});
	}
	
	public boolean hasDropped() { return dropped; }
		
	public String getNextFile() {
		if (files.size() == 0) return null;
		String name = (String)files.elementAt(0);
		files.removeElementAt(0);
		return name;
	}
/*
	public void registerForQuit(QuitListener ql) {
		quitListeners.addElement(ql);
	}
*/
}