working on handleOpen() problems

This commit is contained in:
benfry
2009-08-11 20:07:29 +00:00
parent 8b0c9dd766
commit beabd3af12
2 changed files with 25 additions and 5 deletions

View File

@@ -43,14 +43,14 @@ public class Base {
static final int REVISION = 168;
static String VERSION_NAME = "0168";
static HashMap<Integer, String> platformNames = new HashMap();
static HashMap<Integer, String> platformNames = new HashMap<Integer, String>();
static {
platformNames.put(PConstants.WINDOWS, "windows");
platformNames.put(PConstants.MACOSX, "macosx");
platformNames.put(PConstants.LINUX, "linux");
}
static HashMap<String, Integer> platformIndices = new HashMap();
static HashMap<String, Integer> platformIndices = new HashMap<String, Integer>();
static {
platformIndices.put("windows", PConstants.WINDOWS);
platformIndices.put("macosx", PConstants.MACOSX);
@@ -733,13 +733,17 @@ public class Base {
protected Editor handleOpen(String path, int[] location) {
// System.err.println("entering handleOpen " + path);
File file = new File(path);
if (!file.exists()) return null;
// System.err.println(" editors: " + editors);
// Cycle through open windows to make sure that it's not already open.
for (Editor editor : editors) {
if (editor.getSketch().getMainFilePath().equals(path)) {
editor.toFront();
// System.err.println(" handleOpen: already opened");
return editor;
}
}
@@ -758,10 +762,23 @@ public class Base {
// }
// }
// System.err.println(" creating new editor");
Editor editor = new Editor(this, path, location);
// Editor editor = null;
// try {
// editor = new Editor(this, path, location);
// } catch (Exception e) {
// e.printStackTrace();
// System.err.flush();
// System.out.flush();
// System.exit(1);
// }
// System.err.println(" done creating new editor");
// EditorConsole.systemErr.println(" done creating new editor");
// Make sure that the sketch actually loaded
if (editor.getSketch() == null) {
// System.err.println("sketch was null, getting out of handleOpen");
return null; // Just walk away quietly
}
@@ -785,6 +802,8 @@ public class Base {
// (don't do earlier, cuz we might move it based on a window being closed)
editor.setVisible(true);
// System.err.println("exiting handleOpen");
return editor;
}

View File

@@ -86,13 +86,14 @@ public class ThinkDifferent implements ApplicationListener {
throw new IllegalStateException("handlePreferences: Base instance detached from listener");
}
}
public void handleOpenApplication(ApplicationEvent ae) {
}
public void handleOpenFile(ApplicationEvent ae) {
// System.out.println("got open file event " + ae.getFilename());
String filename = ae.getFilename();
base.handleOpen(filename);
ae.setHandled(true);