List of usage examples for com.vaadin.server FontAwesome STAR
FontAwesome STAR
To view the source code for com.vaadin.server FontAwesome STAR.
Click Source Link
From source file:de.fatalix.bookery.view.common.BookDetailLayout.java
License:Open Source License
public void loadData(BookEntry bookEntry) { this.bookEntry = bookEntry; titleLabel.setValue(bookEntry.getTitle() + "-" + bookEntry.getAuthor()); descriptionLabel.setValue(bookEntry.getDescription()); StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getCover()); image.setSource(new StreamResource(source, bookEntry.getId() + ".png")); likeButton.setCaption(bookEntry.getLikes() + " likes"); downloadCount.setValue(bookEntry.getDownloads() + " downloads"); try {/*from w w w . j a v a 2s . c o m*/ byte[] data = presenter.getEbookFile(bookEntry.getId()); fileDownloader.setFileDownloadResource(new StreamResource(new BookStreamSource(data), bookEntry.getTitle() + "-" + bookEntry.getAuthor() + ".epub")); } catch (SolrServerException ex) { logger.error(ex, ex); } if (presenter.isOnWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString())) { watchListButton.setCaption("vergessen"); watchListButton.setIcon(FontAwesome.STAR); } else { watchListButton.setCaption("merken"); watchListButton.setIcon(FontAwesome.STAR_O); } }
From source file:de.fatalix.bookery.view.common.BookSearchLayout.java
License:Open Source License
private VerticalLayout createBookCoverLayout(final BookEntry bookEntry) { Image image = new Image(); image.setDescription(bookEntry.getTitle() + " von " + bookEntry.getAuthor()); image.setHeight("200px"); image.setWidth("130px"); image.setImmediate(true);/*from w w w .j a v a 2 s. c o m*/ if (bookEntry.getThumbnail() != null) { StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getThumbnail()); image.setSource(new StreamResource(source, bookEntry.getId() + "_thumb.png")); } else if (bookEntry.getCover() != null) { StreamResource.StreamSource source = new ByteStreamResource(bookEntry.getCover()); image.setSource(new StreamResource(source, bookEntry.getId() + ".png")); } final MButton watchListButton = new MButton() .withIcon(presenter.isOnWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString()) ? FontAwesome.STAR : FontAwesome.STAR_O) .withStyleName(ValoTheme.BUTTON_LINK); watchListButton.addStyleName("quick-action"); watchListButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { watchListButton.setIcon(presenter.addRemoveFromWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString()) ? FontAwesome.STAR : FontAwesome.STAR_O); } }); final MButton likeButton = new MButton().withCaption("" + bookEntry.getLikes()) .withIcon(FontAwesome.THUMBS_O_UP).withStyleName(ValoTheme.BUTTON_LINK); likeButton.addStyleName("quick-action"); likeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { BookEntry updatedBook = presenter.updateLike(bookEntry, SecurityUtils.getSubject().getPrincipal().toString()); bookEntry.setLikes(updatedBook.getLikes()); bookEntry.setLikedby(updatedBook.getLikedby()); likeButton.setCaption("" + bookEntry.getLikes()); } catch (SolrServerException | IOException ex) { java.util.logging.Logger.getLogger(BookSearchLayout.class.getName()).log(Level.SEVERE, null, ex); } } }); final MButton downloadsButton = new MButton().withCaption("" + bookEntry.getDownloads()) .withIcon(FontAwesome.DOWNLOAD).withStyleName(ValoTheme.BUTTON_LINK); downloadsButton.addStyleName("quick-action"); HorizontalLayout quickActionLayout = new HorizontalLayout(watchListButton, likeButton, downloadsButton); quickActionLayout.addStyleName("quick-action-layout"); VerticalLayout result = new VerticalLayout(image, quickActionLayout); //result.setHeight("210px"); //result.setWidth("140px"); result.addStyleName("pointer-cursor"); result.addStyleName("book-card"); result.setComponentAlignment(image, Alignment.MIDDLE_CENTER); result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { bookDetailLayout.loadData(bookEntry); bookDetailLayout.setLayoutVisible(true); //BookDetailDialog dialogInstance = bookDetail.get(); //dialogInstance.loadData(bookEntry); //UI.getCurrent().addWindow(dialogInstance); } }); return result; }