Search in sources :

Example 6 with IDocumentProvider

use of org.eclipse.ui.texteditor.IDocumentProvider in project bndtools by bndtools.

the class BndEditor method loadEditModel.

private void loadEditModel() throws Exception {
    // Create the bnd edit model and workspace
    Workspace ws = Central.getWorkspaceIfPresent();
    Project bndProject = Run.createRun(ws, inputFile);
    model.setWorkspace(bndProject.getWorkspace());
    model.setProject(bndProject);
    // Load content into the edit model
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        public void run() {
            final IDocumentProvider docProvider = sourcePage.getDocumentProvider();
            // #1625: Ensure the IDocumentProvider is not null.
            if (docProvider != null) {
                IDocument document = docProvider.getDocument(getEditorInput());
                try {
                    model.loadFrom(new IDocumentWrapper(document));
                    model.setBndResource(inputFile);
                } catch (IOException e) {
                    logger.logError("Unable to load edit model", e);
                }
                for (int i = 0; i < getPageCount(); i++) {
                    Control control = getControl(i);
                    if (control instanceof ScrolledForm) {
                        ScrolledForm form = (ScrolledForm) control;
                        if (SYNC_MESSAGE.equals(form.getMessage())) {
                            form.setMessage(null, IMessageProvider.NONE);
                        }
                    }
                }
            }
        }
    });
}
Also used : Project(aQute.bnd.build.Project) Control(org.eclipse.swt.widgets.Control) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) IOException(java.io.IOException) IDocumentWrapper(bndtools.editor.model.IDocumentWrapper) IDocument(org.eclipse.jface.text.IDocument) Workspace(aQute.bnd.build.Workspace)

Example 7 with IDocumentProvider

use of org.eclipse.ui.texteditor.IDocumentProvider in project bndtools by bndtools.

the class BndSourceEditorPage method getDocument.

private IDocument getDocument() {
    IDocumentProvider docProvider = getDocumentProvider();
    IEditorInput input = getEditorInput();
    return new IDocumentWrapper(docProvider.getDocument(input));
}
Also used : IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) IDocumentWrapper(bndtools.editor.model.IDocumentWrapper) IEditorInput(org.eclipse.ui.IEditorInput)

Example 8 with IDocumentProvider

use of org.eclipse.ui.texteditor.IDocumentProvider in project eclipse.platform.text by eclipse.

the class TextFileDocumentProvider method getContentType.

@Override
public IContentType getContentType(Object element) throws CoreException {
    FileInfo info = fFileInfoMap.get(element);
    if (info != null)
        return info.fTextFileBuffer.getContentType();
    IDocumentProvider parent = getParentProvider();
    if (parent instanceof IDocumentProviderExtension4)
        return ((IDocumentProviderExtension4) parent).getContentType(element);
    return null;
}
Also used : IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) IFileInfo(org.eclipse.core.filesystem.IFileInfo) IDocumentProviderExtension4(org.eclipse.ui.texteditor.IDocumentProviderExtension4)

Example 9 with IDocumentProvider

use of org.eclipse.ui.texteditor.IDocumentProvider in project eclipse.platform.text by eclipse.

the class LastSaveReferenceProvider method setActiveEditor.

@Override
public void setActiveEditor(ITextEditor targetEditor) {
    IDocumentProvider provider = null;
    IEditorInput input = null;
    if (targetEditor != null) {
        provider = targetEditor.getDocumentProvider();
        input = targetEditor.getEditorInput();
    }
    // note that they may serve multiple editors
    if (provider != fDocumentProvider || input != fEditorInput) {
        dispose();
        synchronized (fLock) {
            fEditor = targetEditor;
            fDocumentProvider = provider;
            fEditorInput = input;
        }
    }
}
Also used : IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) IEditorInput(org.eclipse.ui.IEditorInput)

Example 10 with IDocumentProvider

use of org.eclipse.ui.texteditor.IDocumentProvider in project eclipse.platform.text by eclipse.

the class LastSaveReferenceProvider method dispose.

@Override
public void dispose() {
    IProgressMonitor monitor = fProgressMonitor;
    if (monitor != null) {
        monitor.setCanceled(true);
    }
    IDocumentProvider provider = fDocumentProvider;
    synchronized (fLock) {
        if (provider != null)
            provider.removeElementStateListener(this);
        fEditorInput = null;
        fDocumentProvider = null;
        fReference = null;
        fDocumentRead = false;
        fProgressMonitor = null;
        fEditor = null;
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider)

Aggregations

IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)42 IDocument (org.eclipse.jface.text.IDocument)20 IEditorInput (org.eclipse.ui.IEditorInput)14 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)12 IEditorPart (org.eclipse.ui.IEditorPart)10 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)9 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)9 IFile (org.eclipse.core.resources.IFile)6 CoreException (org.eclipse.core.runtime.CoreException)6 BadLocationException (org.eclipse.jface.text.BadLocationException)6 IAnnotationModelExtension (org.eclipse.jface.text.source.IAnnotationModelExtension)6 PartInitException (org.eclipse.ui.PartInitException)6 AbstractTextEditor (org.eclipse.ui.texteditor.AbstractTextEditor)6 IOException (java.io.IOException)4 IPath (org.eclipse.core.runtime.IPath)4 IDocumentWrapper (bndtools.editor.model.IDocumentWrapper)3 IResource (org.eclipse.core.resources.IResource)3 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)3 Workspace (aQute.bnd.build.Workspace)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2