FileBrowserView extends Panel implements View, FileUploadView { static Resource resolveIcon(Bookmark bookmark) { if (!Strings.isNullOrEmpty(bookmark.getIcon())) { if (bookmark.getIcon().startsWith(ICON_PREFIX_VAADIN)) { final String icon = bookmark.getIcon().substring(ICON_PREFIX_VAADIN.length()); try { return VaadinIcons.valueOf(icon.toUpperCase().replace('-', '_')); } catch (IllegalArgumentException e) { LOGGER.info("Non existing icon requested: " + icon, e); } } } return null; } FileBrowserView(EventBus.SessionEventBus eventBus, DashboardNotificationService notificationService); static boolean isMimeTypeSupported(String mimeType); void refresh(Path expand); @Override void enter(ViewChangeEvent event); @Override void uploadSucceed(Path file); @Override void uploadFailed(Exception exception); @Override void attach(); @Override void detach(); static final String ICON_PREFIX_VAADIN; }
@Test public void testResolveIcon() { assertEquals(VaadinIcons.COG, FileBrowserView.resolveIcon(createBookmark("vaadin:cog"))); assertEquals(VaadinIcons.TRASH, FileBrowserView.resolveIcon(createBookmark("vaadin:trash"))); assertNull(FileBrowserView.resolveIcon(createBookmark("vaadin:non_existing"))); assertEquals(VaadinIcons.TREE_TABLE, FileBrowserView.resolveIcon(createBookmark("vaadin:tree-table"))); }