Package ag.ion.noa4e.ui.operations

Examples of ag.ion.noa4e.ui.operations.LoadDocumentOperation


          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);
View Full Code Here


   */
  protected IDocument loadDoccument(IFile file) throws CoreException {
    DocumentDescriptor documentDescriptor = new DocumentDescriptor();
    documentDescriptor.setHidden(true);
    documentDescriptor.setAsTemplate(true);
    LoadDocumentOperation loadDocumentOperation = new LoadDocumentOperation(officeApplication, file.getContents(), documentDescriptor);
    loadDocumentOperation.setIsSubTask(true);
    try {
      loadDocumentOperation.run(progressMonitor);
    }
    catch(InvocationTargetException invocationTargetException) {
      throw new CoreException(new Status(IStatus.ERROR, NOASearchPlugin.PLUGIN_ID,
          IStatus.ERROR, invocationTargetException.getCause().getMessage(),
          invocationTargetException.getCause()));
    }
    catch (InterruptedException interruptedException) {
      //aborted
    }
    return loadDocumentOperation.getDocument();
  }
View Full Code Here

   */
  private void loadDocument(String documentPath, IDocumentDescriptor documentDescriptor,
      IProgressMonitor progressMonitor) throws CoreException {
    URL url = convertToURL(documentPath);
    try {
      LoadDocumentOperation loadDocumentOperation = new LoadDocumentOperation(null,
          officeApplication,
          officeFrame,
          url,
          documentDescriptor);
      loadDocumentOperation.run(progressMonitor);
      document = loadDocumentOperation.getDocument();
    }
    catch (InvocationTargetException invocationTargetException) {
      documentLoadingOperationDone();
      throw new CoreException(new Status(IStatus.ERROR,
          NOAUIPlugin.PLUGIN_ID,
View Full Code Here

TOP

Related Classes of ag.ion.noa4e.ui.operations.LoadDocumentOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.