package org.reldb.dbrowser.hooks;

import java.util.ArrayList;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.reldb.dbrowser.DBrowser;

public class OpenDocumentEventProcessor implements Listener {
	private ArrayList<String> filesToOpen = new ArrayList<String>(1);
	private boolean retrieved = false;
	
	public synchronized void handleEvent(Event event) {
		if (event.text != null)
			if (retrieved)
				DBrowser.openFile(event.text);
			else
				filesToOpen.add(event.text);
	}

	public synchronized String[] retrieveFilesToOpen() {
		try {
			return filesToOpen.toArray(new String[filesToOpen.size()]);
		} finally {
			filesToOpen.clear();
			retrieved = true;
		}
	}
}

@@ -516,16 +516,17 @@
 xt);%0A%09%7D%0A
+%09
 %0A%09public
@@ -708,11 +708,143 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%0A%09public synchronized void addFilesToOpen(String%5B%5D fileNames) %7B%0A%09%09for (String argument: fileNames)%0A%09%09%09filesToOpen.add(argument);%0A%09%7D
 %0A%7D%0A

Support explicit adding of file names.