Search in sources :

Example 1 with IDocumentProviderExtension4

use of org.eclipse.ui.texteditor.IDocumentProviderExtension4 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 2 with IDocumentProviderExtension4

use of org.eclipse.ui.texteditor.IDocumentProviderExtension4 in project webtools.sourceediting by eclipse.

the class ToggleBreakpointAction method getContentType.

protected String getContentType(IDocument document) {
    IModelManager mgr = StructuredModelManager.getModelManager();
    String contentType = null;
    IDocumentProvider provider = fTextEditor.getDocumentProvider();
    if (provider instanceof IDocumentProviderExtension4) {
        try {
            IContentType type = ((IDocumentProviderExtension4) provider).getContentType(fTextEditor.getEditorInput());
            if (type != null)
                contentType = type.getId();
        } catch (CoreException e) {
        /*
				 * A failure accessing the underlying store really isn't
				 * interesting, although it can be a problem for
				 * IStorageEditorInputs.
				 */
        }
    }
    if (contentType == null) {
        IStructuredModel model = null;
        try {
            model = mgr.getExistingModelForRead(document);
            if (model != null) {
                contentType = model.getContentTypeIdentifier();
            }
        } finally {
            if (model != null) {
                model.releaseFromRead();
            }
        }
    }
    return contentType;
}
Also used : IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) CoreException(org.eclipse.core.runtime.CoreException) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IDocumentProviderExtension4(org.eclipse.ui.texteditor.IDocumentProviderExtension4) IContentType(org.eclipse.core.runtime.content.IContentType) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 3 with IDocumentProviderExtension4

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

the class RulerColumnDescriptor method getContentType.

/**
 * Returns the content type of the editor's input, <code>null</code> if the editor input or
 * the document provider is <code>null</code> or the content type cannot be determined.
 *
 * @param editor the editor to get the content type from
 * @return the content type of the editor's input, <code>null</code> if it cannot be
 *         determined
 */
private IContentType getContentType(ITextEditor editor) {
    IEditorInput input = editor.getEditorInput();
    if (input == null)
        return null;
    IDocumentProvider provider = editor.getDocumentProvider();
    if (provider instanceof IDocumentProviderExtension4) {
        IDocumentProviderExtension4 ext = (IDocumentProviderExtension4) provider;
        try {
            return ext.getContentType(input);
        } catch (CoreException x) {
        // ignore and return null;
        }
    }
    return null;
}
Also used : IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) CoreException(org.eclipse.core.runtime.CoreException) IDocumentProviderExtension4(org.eclipse.ui.texteditor.IDocumentProviderExtension4) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)3 IDocumentProviderExtension4 (org.eclipse.ui.texteditor.IDocumentProviderExtension4)3 CoreException (org.eclipse.core.runtime.CoreException)2 IFileInfo (org.eclipse.core.filesystem.IFileInfo)1 IContentType (org.eclipse.core.runtime.content.IContentType)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1