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();