Examples of IDocumentProvider


Examples of org.eclipse.ui.texteditor.IDocumentProvider

            } 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

Examples of org.eclipse.ui.texteditor.IDocumentProvider

        }
        // 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

Examples of org.eclipse.ui.texteditor.IDocumentProvider

    return getDocument(getActiveEditor());
  }
 
  public static IDocument getDocument(IEditorPart editor) {
    if (editor != null) {
      IDocumentProvider dp = null;
      if (editor instanceof ITextEditor)
        dp = ((ITextEditor) editor).getDocumentProvider();
     
      if (dp == null)
        dp = DocumentProviderRegistry.getDefault().getDocumentProvider(editor.getEditorInput());
     
      if (dp != null)
        return (IDocument) dp.getDocument(editor.getEditorInput());
    }
   
    return null;
  }
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

    final RunScript runScript = context.mock(RunScript.class);
    final IFile file = context.mock(IFile.class);
    final IWorkbenchWindow window = context.mock(IWorkbenchWindow.class);
    final ITextEditor editor = context.mock(ITextEditor.class);
    final IFileEditorInput editorInput = context.mock(IFileEditorInput.class);
    final IDocumentProvider documentProvider = context.mock(IDocumentProvider.class);
    final IDocument document = context.mock(IDocument.class);
   
    ExecutionEvent event = new ExecutionEvent();
    final String contents = "contents";
    final String filename = "filename";
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

                .getAdapter(ProjectionAnnotationModel.class);
        if (model == null) {
            return;
        }

        final IDocumentProvider provider = fEditor.getDocumentProvider();

        try {
            fCachedModel = model;
            fCachedDocument = provider.getDocument(fEditor.getEditorInput());
            if (fCachedDocument.getNumberOfLines() > PerformanceTuning.get()
                    .getFoldingLimit()) {
                // disable folding for files larger than this
                model.removeAllAnnotations();
                return;
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

    @Override
    public void elementChanged(final IErlElement element) {
        if (fEditor == null) {
            return;
        }
        final IDocumentProvider provider = fEditor.getDocumentProvider();
        if (provider == null) {
            return;
        }
        final IEditorInput input = fEditor.getEditorInput();
        if (input == null) {
            return;
        }
        fCachedDocument = provider.getDocument(input);
        if (fCachedDocument == null) {
            return;
        }
        // fFirstType= null;
        // fHasHeaderComment = false;
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

    void removeOccurrenceAnnotations() {
        fMarkOccurrenceModificationStamp = IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
        fMarkOccurrenceTargetRegion = null;

        final IDocumentProvider documentProvider = editor.getDocumentProvider();
        if (documentProvider == null) {
            return;
        }

        final IAnnotationModel annotationModel = documentProvider
                .getAnnotationModel(editor.getEditorInput());
        if (annotationModel == null || fOccurrenceAnnotations == null) {
            return;
        }
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

            final IDocument document = textViewer.getDocument();
            if (document == null) {
                return Status.CANCEL_STATUS;
            }

            final IDocumentProvider documentProvider = editor.getDocumentProvider();
            if (documentProvider == null) {
                return Status.CANCEL_STATUS;
            }

            final IAnnotationModel annotationModel = documentProvider
                    .getAnnotationModel(editor.getEditorInput());
            if (annotationModel == null) {
                return Status.CANCEL_STATUS;
            }
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

            final ISourceViewer sourceViewer = editor.getViewer();
            if (sourceViewer != null) {
                sourceViewer.removeTextInputListener(this);
            }

            final IDocumentProvider documentProvider = editor.getDocumentProvider();
            if (documentProvider != null) {
                final IDocument document = documentProvider.getDocument(editor
                        .getEditorInput());
                if (document != null) {
                    document.removeDocumentListener(this);
                }
            }
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

        }
    }

    @Override
    protected void doSetInput(final IEditorInput input) throws CoreException {
        final IDocumentProvider provider = getDocumentProvider();
        if (input != getEditorInput()) {
            disposeModule();
            resetReconciler();
        }

        super.doSetInput(input);

        final IDocument document = provider.getDocument(input);
        if (!(input instanceof IPathEditorInput) && document != null) {
            final ErlangDocumentSetupParticipant setupParticipant = new ErlangDocumentSetupParticipant();
            setupParticipant.setup(document);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.