Example usage for com.vaadin.util FileTypeResolver DEFAULT_ICON

List of usage examples for com.vaadin.util FileTypeResolver DEFAULT_ICON

Introduction

In this page you can find the example usage for com.vaadin.util FileTypeResolver DEFAULT_ICON.

Prototype

Resource DEFAULT_ICON

To view the source code for com.vaadin.util FileTypeResolver DEFAULT_ICON.

Click Source Link

Document

Default icon given if no icon is specified for a mime-type.

Usage

From source file:info.magnolia.filesystembrowser.app.imageprovider.FSImageProvider.java

License:Open Source License

@Override
public Object getThumbnailResource(Object itemId, String generator) {
    if (itemId instanceof File) {
        File file = (File) itemId;
        if (file.exists()) {
            String mimeType = FileTypeResolver.getMIMEType(file);
            if (mimeType != null && mimeType.matches("image.*")) {
                Resource imageResource = scaleImage(file);
                return imageResource;
            } else {
                Resource resolvedThumbnail = FileTypeResolver.getIcon(file);
                return resolvedThumbnail == null ? FileTypeResolver.DEFAULT_ICON : resolvedThumbnail;
            }// w w  w  .  j a  v a  2s  . c o  m
        }
    }
    return null;
}