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;
}
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;
}
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;
}
Aggregations