}
public static Project doOpen(Component parent,
Project baseProject, File f) {
Project proj = Projects.findProjectFor(f);
Loader loader = null;
if (proj != null) {
proj.getFrame().toFront();
loader = proj.getLogisimFile().getLoader();
if (proj.isFileDirty()) {
String message = StringUtil.format(Strings.get("openAlreadyMessage"),
proj.getLogisimFile().getName());
String[] options = {
Strings.get("openAlreadyLoseChangesOption"),
Strings.get("openAlreadyNewWindowOption"),
Strings.get("openAlreadyCancelOption"),
};
int result = JOptionPane.showOptionDialog(proj.getFrame(),
message, Strings.get("openAlreadyTitle"), 0,
JOptionPane.QUESTION_MESSAGE, null,
options, options[2]);
if (result == 0) {
; // keep proj as is, so that load happens into the window
} else if (result == 1) {
proj = null; // we'll create a new project
} else {
return proj;
}
}
}
if (proj == null && baseProject != null && baseProject.isStartupScreen()) {
proj = baseProject;
proj.setStartupScreen(false);
loader = baseProject.getLogisimFile().getLoader();
} else {
loader = new Loader(baseProject == null ? parent : baseProject.getFrame());
}
try {
LogisimFile lib = loader.openLogisimFile(f);
AppPreferences.updateRecentFile(f);
if (lib == null) return null;
if (proj == null) {
proj = new Project(lib);
} else {