projectResource.load(null);
} catch (IOException e1) {
// resource doesn't exist. That is ok.
}
Project incomingProject = null;
if (projectResource.getContents().isEmpty()) {
// new file being created!
if (projectURI.isFile()) {
// check to see if it exists; we don't like empty existing files
File file = new File(projectURI.toFileString());
if (file.exists()) {
if (!file.delete())
throw new NullPointerException("Unable to load " + uri
+ " file was empty");
}
}
// creating a new project from the new project wizard
incomingProject = createProject(uri, projectResource);
} else {
// Go through list of resources
EList<EObject> contents = projectResource.getContents();
for (EObject eObject : contents) {
if (eObject instanceof Project) {
incomingProject = (Project) eObject;
break;
}
}
if (incomingProject == null) {
// this project was not saved with a project file?
// (does it represent an individial map? we are not sure)
throw new NullPointerException("Unable to load " + uri
+ " - does not contain a project");
}
// if (incomingProject == null) {
// incomingProject = createProject(uri, resource);
// List<ProjectElement> eContents = incomingProject.getElementsInternal();
// for( EObject eObject : contents ) {
// if (eObject instanceof MapImpl) {
// MapImpl tmpMap = (MapImpl) eObject;
// eContents.add(tmpMap);
// }
// }
// }
}
final Project newProject = incomingProject;
PlatformGIS.syncInDisplayThread(new Runnable() {
public void run() {
try {
setCurrentProject(newProject);
registry.getProjects().add(newProject);