Package org.eclipse.ui.texteditor

Examples of org.eclipse.ui.texteditor.IDocumentProvider


  }
 
 
  public static void doGenericValidation(IFile file) {
    try {
      IDocumentProvider provider = new WGADesignFileDocumentProvider();
      IFileEditorInput input = new FileEditorInput(file);     
      provider.connect(input);
       
      VersionCompliance versionCompliance = WGADesignStructureHelper.getWGAVersionCompliance(file);
       
      InvalidEncodingMarkingHandler handler = new InvalidEncodingMarkingHandler();
      handler.setWGAVersionCompliance(versionCompliance);             
      handler.setDocumentProvider(provider);
      handler.createMarkers(file, provider.getDocument(input));
      provider.disconnect(input);
    } catch (CoreException e) {
      Plugin.getDefault().logError("Unable to validate generic design file '" + file.getLocation().toString() + "'.", e);
    }   
  }
View Full Code Here


                IJavaModelStatusConstants.INVALID_RESOURCE_TYPE,
                "invalid input", // JavaEditorMessages.ClassFileEditor_error_invalid_input_message,
                null));
        }

        IDocumentProvider documentProvider = getDocumentProvider();
        if (documentProvider instanceof ClassFileDocumentProvider) {
            ((ClassFileDocumentProvider) documentProvider)
                .removeInputChangeListener(this);
        }
View Full Code Here

    /*
     * @see org.eclipse.ui.IWorkbenchPart#dispose()
     */
    public void dispose() {
        // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18510
        IDocumentProvider documentProvider = getDocumentProvider();
        if (documentProvider instanceof ClassFileDocumentProvider) {
            ((ClassFileDocumentProvider) documentProvider)
                .removeInputChangeListener(this);
        }

View Full Code Here

        IDocument document = getDocument();
        formEditor.getEditModel().saveChangesTo(document);
    }

    private IDocument getDocument() {
        IDocumentProvider docProvider = getDocumentProvider();
        IEditorInput input = getEditorInput();
        return new IDocumentWrapper(docProvider.getDocument(input));
    }
View Full Code Here

            } else {
                resourceName = input.getName();
            }
        }

        final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
        IDocument document = docProvider.getDocument(input);
        try {
            model.loadFrom(new IDocumentWrapper(document));
            model.setBndResourceName(resourceName);

            if (resource != null) {
                model.setBndResource(resource.getLocation().toFile());
            }
            // model.addPropertyChangeListener(modelListener);
        } catch (IOException e) {
            throw new PartInitException("Error reading editor input.", e);
        }

        // Ensure the field values are updated if the file content is replaced
        docProvider.addElementStateListener(new IElementStateListener() {
            public void elementMoved(Object originalElement, Object movedElement) {}

            public void elementDirtyStateChanged(Object element, boolean isDirty) {}

            public void elementDeleted(Object element) {}

            public void elementContentReplaced(Object element) {
                try {
                    model.loadFrom(new IDocumentWrapper(docProvider.getDocument(element)));
                } catch (IOException e) {
                    logger.logError("Error loading model from document.", e);
                }
            }
View Full Code Here

        }
        // File content updated externally => reload all pages
        else if ((delta.getKind() & IResourceDelta.CHANGED) > 0 && (delta.getFlags() & IResourceDelta.CONTENT) > 0) {
            if (!saving.get()) {
                final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
                final IDocument document = docProvider.getDocument(getEditorInput());
                SWTConcurrencyUtil.execForControl(getEditorSite().getShell(), true, new Runnable() {
                    public void run() {
                        try {
                            model.loadFrom(new IDocumentWrapper(document));
                            updatePages();
View Full Code Here

                    try
                    {
                        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                        IWorkbenchPage page = window.getActivePage();
                        IEditorPart editor = page.openEditor( input, editorId );
                        IDocumentProvider documentProvider = ( ( LdifEditor ) editor ).getDocumentProvider();
                        if ( documentProvider != null && input != null )
                        {
                            IDocument document = documentProvider.getDocument( input );
                            if ( document != null )
                            {
                                document.set( ldif.toString() );
                            }
                        }
View Full Code Here

        IDocument document = getDocument();
        formEditor.getEditModel().saveChangesTo(document);
    }

    private IDocument getDocument() {
        IDocumentProvider docProvider = getDocumentProvider();
        IEditorInput input = getEditorInput();
        return new IDocumentWrapper(docProvider.getDocument(input));
    }
View Full Code Here

            } else {
                resourceName = input.getName();
            }
        }

        final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
        IDocument document = docProvider.getDocument(input);
        try {
            model.loadFrom(new IDocumentWrapper(document));
            model.setBndResourceName(resourceName);

            if (resource != null) {
                model.setBndResource(resource.getLocation().toFile());
            }
            // model.addPropertyChangeListener(modelListener);
        } catch (IOException e) {
            throw new PartInitException("Error reading editor input.", e);
        }

        // Ensure the field values are updated if the file content is replaced
        docProvider.addElementStateListener(new IElementStateListener() {

            String savedString = null;

            public void elementMoved(Object originalElement, Object movedElement) {}

            public void elementDirtyStateChanged(Object element, boolean isDirty) {}

            public void elementDeleted(Object element) {}

            public void elementContentReplaced(Object element) {
                try {
                    IDocumentWrapper idoc = new IDocumentWrapper(docProvider.getDocument(element));
                    if (!saving.get()) {
                        model.loadFrom(idoc);
                    } else {
                        if (savedString != null) {
                            logger.logInfo("Putting back content that we almost lost!", null);
                            try {
                                idoc.replace(0, idoc.getLength(), savedString);
                            } catch (BadLocationException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                } catch (IOException e) {
                    logger.logError("Error loading model from document.", e);
                } finally {
                    savedString = null;
                }
            }

            public void elementContentAboutToBeReplaced(Object element) {
                // [cs] This check is here to attempt to save content that would be thrown away by a (misbehaving?) version control plugin.
                // Scenario: File is checked out by Perforce plugin.
                // This causes elementContentAboutToBeReplaced and elementContentReplaced callbacks to be fired.
                // However -- by the time that elementContentReplaced is called, the content inside of the IDocumentWrapper
                // is already replaced with the contents of the perforce file being checked out.
                // To avoid losing changes, we need to save the content here, then put that content BACK on to the document
                // in elementContentReplaced
                if (saving.get()) {
                    logger.logInfo("Content about to be replaced... Save it.", null);
                    savedString = new IDocumentWrapper(docProvider.getDocument(element)).get();
                }
            }
        });
    }
View Full Code Here

        }
        // File content updated externally => reload all pages
        else if ((delta.getKind() & IResourceDelta.CHANGED) > 0 && (delta.getFlags() & IResourceDelta.CONTENT) > 0) {
            if (!saving.get()) {
                final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
                final IDocument document = docProvider.getDocument(getEditorInput());
                SWTConcurrencyUtil.execForControl(getEditorSite().getShell(), true, new Runnable() {
                    public void run() {
                        try {
                            model.loadFrom(new IDocumentWrapper(document));
                            updatePages();
View Full Code Here

TOP

Related Classes of org.eclipse.ui.texteditor.IDocumentProvider

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.