diff options
author | Ilia Motornyi <elmot@vaadin.com> | 2018-05-03 09:49:59 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2018-05-03 09:49:59 +0300 |
commit | de4d77228308ed50e4ed6c0e1a4b43e36fd99260 (patch) | |
tree | 70f22045c2618cd3f30178a61c687a9169586a73 /server/src | |
parent | 4e228795042f2e4c41d9a5e8a3f2e336da77426c (diff) | |
download | vaadin-framework-de4d77228308ed50e4ed6c0e1a4b43e36fd99260.tar.gz vaadin-framework-de4d77228308ed50e4ed6c0e1a4b43e36fd99260.zip |
Fix using runo icons in FileTypeResolver (#10858)
This patch adds a compatibility version of FileTypeResolver.
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/main/java/com/vaadin/util/FileTypeResolver.java | 74 | ||||
-rw-r--r-- | server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java | 1 |
2 files changed, 3 insertions, 72 deletions
diff --git a/server/src/main/java/com/vaadin/util/FileTypeResolver.java b/server/src/main/java/com/vaadin/util/FileTypeResolver.java index 4606463683..c3fc5c0756 100644 --- a/server/src/main/java/com/vaadin/util/FileTypeResolver.java +++ b/server/src/main/java/com/vaadin/util/FileTypeResolver.java @@ -38,7 +38,7 @@ import com.vaadin.server.ThemeResource; * @since 3.0 */ @SuppressWarnings("serial") -public class FileTypeResolver implements Serializable { +public class FileTypeResolver { /** * Default icon given if no icon is specified for a mime-type. @@ -213,11 +213,6 @@ public class FileTypeResolver implements Serializable { */ private static final Map<String, String> EXT_TO_MIME_MAP = new ConcurrentHashMap<>(); - /** - * MIME type to Icon mapping. - */ - private static final Map<String, Resource> MIME_TO_ICON_MAP = new ConcurrentHashMap<>(); - static { // Initialize extension to MIME map @@ -233,10 +228,6 @@ public class FileTypeResolver implements Serializable { } } - // Initialize Icons - ThemeResource folder = new ThemeResource("../runo/icons/16/folder.png"); - addIcon("inode/drive", folder); - addIcon("inode/directory", folder); } /** @@ -282,45 +273,6 @@ public class FileTypeResolver implements Serializable { } /** - * Gets the descriptive icon representing file, based on the filename. First - * the mime-type for the given filename is resolved, and then the - * corresponding icon is fetched from the internal icon storage. If it is - * not found the default icon is returned. - * - * @param fileName - * the name of the file whose icon is requested. - * @return the icon corresponding to the given file - */ - public static Resource getIcon(String fileName) { - return getIconByMimeType(getMIMEType(fileName)); - } - - private static Resource getIconByMimeType(String mimeType) { - final Resource icon = MIME_TO_ICON_MAP.get(mimeType); - if (icon != null) { - return icon; - } - - // If nothing is known about the file-type, general file - // icon is used - return DEFAULT_ICON; - } - - /** - * Gets the descriptive icon representing a file. First the mime-type for - * the given file name is resolved, and then the corresponding icon is - * fetched from the internal icon storage. If it is not found the default - * icon is returned. - * - * @param file - * the file whose icon is requested. - * @return the icon corresponding to the given file - */ - public static Resource getIcon(File file) { - return getIconByMimeType(getMIMEType(file)); - } - - /** * Gets the mime-type for a file. Currently the returned file type is * resolved by the filename extension only. * @@ -364,19 +316,6 @@ public class FileTypeResolver implements Serializable { } /** - * Adds a icon for the given mime-type. If the mime-type also has a - * corresponding icon, it is replaced with the new icon. - * - * @param mimeType - * the mime-type whose icon is to be changed. - * @param icon - * the new icon to be associated with <code>MIMEType</code>. - */ - public static void addIcon(String mimeType, Resource icon) { - MIME_TO_ICON_MAP.put(mimeType, icon); - } - - /** * Gets the internal file extension to mime-type mapping. * * @return unmodifiable map containing the current file extension to @@ -386,15 +325,6 @@ public class FileTypeResolver implements Serializable { return Collections.unmodifiableMap(EXT_TO_MIME_MAP); } - /** - * Gets the internal mime-type to icon mapping. - * - * @return unmodifiable map containing the current mime-type to icon mapping - */ - public static Map<String, Resource> getMIMETypeToIconMapping() { - return Collections.unmodifiableMap(MIME_TO_ICON_MAP); - } - - private FileTypeResolver() { + protected FileTypeResolver() { } } diff --git a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java index 0827fc262c..819f0530c1 100644 --- a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java +++ b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java @@ -54,6 +54,7 @@ public class ClassesSerializableTest { "com\\.vaadin\\.ui\\.themes\\..*", // // exact class level filtering "com\\.vaadin\\.event\\.FieldEvents", // + "com\\.vaadin\\.util\\.FileTypeResolver", "com\\.vaadin\\.event\\.LayoutEvents", // "com\\.vaadin\\.event\\.MouseEvents", // "com\\.vaadin\\.event\\.UIEvents", // |