}
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 = getFromLocale("openAlreadyMessage",
proj.getLogisimFile().getName());
String[] options = {
getFromLocale("openAlreadyLoseChangesOption"),
getFromLocale("openAlreadyNewWindowOption"),
getFromLocale("openAlreadyCancelOption"),
};
int result = JOptionPane.showOptionDialog(proj.getFrame(),
message, getFromLocale("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) {
// we'll create a new project
proj = null;
} 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;
}