* @see org.eclipse.ui.texteditor.IDocumentProviderExtension4#getContentType(java.lang.Object)
* @since 3.1
*/
public IContentType getContentType(Object element) throws CoreException {
if (element instanceof IStorageEditorInput) {
IStorage storage= ((IStorageEditorInput) element).getStorage();
Reader reader= null;
InputStream stream= null;
try {
IContentDescription desc;
IDocument document= getDocument(element);
if (document != null) {
reader= new DocumentReader(document);
desc= Platform.getContentTypeManager().getDescriptionFor(reader, storage.getName(), NO_PROPERTIES);
} else {
stream= storage.getContents();
desc= Platform.getContentTypeManager().getDescriptionFor(stream, storage.getName(), NO_PROPERTIES);
}
if (desc != null && desc.getContentType() != null)
return desc.getContentType();
} catch (IOException x) {
IPath path= storage.getFullPath();
String name;
if (path != null)
name= path.toOSString();
else
name= storage.getName();
String message;
if (name != null)
message= NLSUtility.format(TextEditorMessages.StorageDocumentProvider_getContentDescriptionFor, name);
else
message= TextEditorMessages.StorageDocumentProvider_getContentDescription;