documentDescriptor.setBaseURL(documentURL.toString());
}
isSaveAsAllowed = true;
InputStream inputStream = null;
LoadDocumentOperation loadTextDocumentOperation = null;
//Load document with input stream if it is not a base document
if(!isBaseDocumentURL(documentURL) && editorInput instanceof IStorageEditorInput) {
IStorageEditorInput storageEditorInput = (IStorageEditorInput)editorInput;
boolean readOnly = false;
IStorage storage = storageEditorInput.getStorage();
if(storage == null || storage.isReadOnly())
readOnly = true;
documentDescriptor.setReadOnly(readOnly);
inputStream = storageEditorInput.getStorage().getContents();
if(documentURL != null && documentURL.getFile().endsWith(".xml")) { //$NON-NLS-1$
setXMLLoadFilter(composite.getShell(),documentDescriptor);
}
loadTextDocumentOperation = new LoadDocumentOperation(null, officeApplication, officeFrame, inputStream, documentDescriptor);
}
else if(documentURL != null) {
loadTextDocumentOperation = new LoadDocumentOperation(null,officeApplication, officeFrame, documentURL, documentDescriptor);
}
try {
if(loadTextDocumentOperation == null)
throw new CoreException(
new Status(
IStatus.ERROR,
EditorUIPlugin.PLUGIN_ID,
IStatus.ERROR,
Messages.OfficeEditorAdvisor_error_invalid_editor_input + editorInput.getClass().getName(),
null));
EditorUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().run(true, true, loadTextDocumentOperation);
}
catch(InterruptedException interruptedException) {
//do not consume
//TODO: clear the document in the office system
officeFrame.close();
frame.dispose();
composite.dispose();
composite = new Composite(parent, SWT.EMBEDDED);
return composite;
}
Exception exception = loadTextDocumentOperation.getException();
if(exception != null)
throw new CoreException(new Status(IStatus.ERROR, EditorUIPlugin.PLUGIN_ID, IStatus.OK, exception.getMessage(), exception));
IDocument document = loadTextDocumentOperation.getDocument();
configureOfficeFrame(officeFrame, document);
setDocument(document);
return composite;
}
return new Composite(parent, SWT.EMBEDDED);