@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
if (!(input instanceof IFileEditorInput)) throw new PartInitException(new Status(IStatus.ERROR, "q_impress", "Invalid input for editor."));
// save the original editor input
this.originalInput = (IFileEditorInput)input;
// now try to load the project
IFileEditorInput specificInput = (IFileEditorInput) input;
InputStream inStream = null;
try {
inStream = specificInput.getFile().getContents();
LoadingService service = new LoadingService();
service.setInStream(inStream);
service.setLocationSolver(new WorkspaceLocationSolver());
service.initialize();
service.invoke();
IResource loadedRes = service.getLoadedResource();
if (!(loadedRes instanceof ModelingProject)) throw new PartInitException(new Status(IStatus.ERROR, "q_impress", "Invalid input for editor."));
else {
this.setInput(new ModelingProjectEditorInput((ModelingProject) loadedRes, this.originalInput));
this.projectInput = (ModelingProjectEditorInput) this.getEditorInput();
}
} catch (CoreException e) {
throw new PartInitException(new Status(IStatus.ERROR, "q_impress", "Invalid input for editor : " + e.getMessage() , e));
} catch (ServiceException e) {
throw new PartInitException(new Status(IStatus.ERROR, "q_impress", "Invalid input for editor : " + e.getMessage() , e));
} finally {
if (inStream != null) {
try {
inStream.close();
} catch (IOException e) {} // never happens