Example usage for com.vaadin.server FontAwesome DOWNLOAD

List of usage examples for com.vaadin.server FontAwesome DOWNLOAD

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome DOWNLOAD.

Prototype

FontAwesome DOWNLOAD

To view the source code for com.vaadin.server FontAwesome DOWNLOAD.

Click Source Link

Usage

From source file:com.mycollab.reporting.CustomizeReportOutputWindow.java

License:Open Source License

public CustomizeReportOutputWindow(final String viewId, final String reportTitle, final Class<B> beanCls,
        final ISearchableService<S> searchableService, final VariableInjector<S> variableInjector) {
    super(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    MVerticalLayout contentLayout = new MVerticalLayout();
    this.withModal(true).withResizable(false).withWidth("1000px").withCenter().withContent(contentLayout);
    this.viewId = viewId;
    this.variableInjector = variableInjector;

    final OptionGroup optionGroup = new OptionGroup();
    optionGroup.addStyleName("sortDirection");
    optionGroup.addItems(UserUIContext.getMessage(FileI18nEnum.CSV), UserUIContext.getMessage(FileI18nEnum.PDF),
            UserUIContext.getMessage(FileI18nEnum.EXCEL));
    optionGroup.setValue(UserUIContext.getMessage(FileI18nEnum.CSV));
    contentLayout.with(new MHorizontalLayout(ELabel.h3(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT)),
            optionGroup).alignAll(Alignment.MIDDLE_LEFT));

    contentLayout.with(ELabel.h3(UserUIContext.getMessage(GenericI18Enum.ACTION_SELECT_COLUMNS)));
    listBuilder = new ListBuilder();
    listBuilder.setImmediate(true);// ww w. j av a  2  s . c o m
    listBuilder.setColumns(0);
    listBuilder.setLeftColumnCaption(UserUIContext.getMessage(GenericI18Enum.OPT_AVAILABLE_COLUMNS));
    listBuilder.setRightColumnCaption(UserUIContext.getMessage(GenericI18Enum.OPT_VIEW_COLUMNS));
    listBuilder.setWidth(100, Sizeable.Unit.PERCENTAGE);
    listBuilder.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT);
    final BeanItemContainer<TableViewField> container = new BeanItemContainer<>(TableViewField.class,
            this.getAvailableColumns());
    listBuilder.setContainerDataSource(container);
    for (TableViewField field : getAvailableColumns()) {
        listBuilder.setItemCaption(field, UserUIContext.getMessage(field.getDescKey()));
    }
    final Collection<TableViewField> viewColumnIds = this.getViewColumns();
    listBuilder.setValue(viewColumnIds);
    contentLayout.with(listBuilder).withAlign(listBuilder, Alignment.TOP_CENTER);

    contentLayout.with(ELabel.h3(UserUIContext.getMessage(GenericI18Enum.ACTION_PREVIEW)));
    sampleTableDisplay = new Table();
    for (TableViewField field : getAvailableColumns()) {
        sampleTableDisplay.addContainerProperty(field.getField(), String.class, "",
                UserUIContext.getMessage(field.getDescKey()), null, Table.Align.LEFT);
        sampleTableDisplay.setColumnWidth(field.getField(), field.getDefaultWidth());
    }
    sampleTableDisplay.setWidth("100%");
    sampleTableDisplay.addItem(buildSampleData(), 1);
    sampleTableDisplay.setPageLength(1);
    contentLayout.with(sampleTableDisplay);
    filterColumns();

    listBuilder.addValueChangeListener(valueChangeEvent -> filterColumns());

    MButton resetBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> {
        listBuilder.setValue(getDefaultColumns());
        filterColumns();
    }).withStyleName(WebThemes.BUTTON_LINK);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    final MButton exportBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT))
            .withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.DOWNLOAD);
    OnDemandFileDownloader pdfFileDownloader = new OnDemandFileDownloader(new LazyStreamSource() {
        @Override
        protected StreamResource.StreamSource buildStreamSource() {
            return (StreamResource.StreamSource) () -> {
                Collection<TableViewField> columns = (Collection<TableViewField>) listBuilder.getValue();
                // Save custom table view def
                CustomViewStoreService customViewStoreService = AppContextUtil
                        .getSpringBean(CustomViewStoreService.class);
                CustomViewStore viewDef = new CustomViewStore();
                viewDef.setSaccountid(MyCollabUI.getAccountId());
                viewDef.setCreateduser(UserUIContext.getUsername());
                viewDef.setViewid(viewId);
                viewDef.setViewinfo(FieldDefAnalyzer.toJson(new ArrayList<>(columns)));
                customViewStoreService.saveOrUpdateViewLayoutDef(viewDef);

                SimpleReportTemplateExecutor reportTemplateExecutor = new SimpleReportTemplateExecutor.AllItems<>(
                        reportTitle, new RpFieldsBuilder(columns), exportType, beanCls, searchableService);
                ReportStreamSource streamSource = new ReportStreamSource(reportTemplateExecutor) {
                    @Override
                    protected void initReportParameters(Map<String, Object> parameters) {
                        parameters.put(SimpleReportTemplateExecutor.CRITERIA, variableInjector.eval());
                    }
                };
                return streamSource.getStream();
            };
        }

        @Override
        public String getFilename() {
            String exportTypeVal = (String) optionGroup.getValue();
            if (UserUIContext.getMessage(FileI18nEnum.CSV).equals(exportTypeVal)) {
                exportType = ReportExportType.CSV;
            } else if (UserUIContext.getMessage(FileI18nEnum.EXCEL).equals(exportTypeVal)) {
                exportType = ReportExportType.EXCEL;
            } else {
                exportType = ReportExportType.PDF;
            }
            return exportType.getDefaultFileName();
        }
    });
    pdfFileDownloader.extend(exportBtn);

    MHorizontalLayout buttonControls = new MHorizontalLayout(resetBtn, cancelBtn, exportBtn);
    contentLayout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT);
}

From source file:com.mycollab.vaadin.web.ui.AttachmentDisplayComponent.java

License:Open Source License

private void addAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }//w  w w.ja v a2s  .c  o  m

    final AbsoluteLayout attachmentLayout = new AbsoluteLayout();
    attachmentLayout.setWidth(WebUIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentLayout.setHeight(WebUIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT);
    attachmentLayout.setStyleName("attachment-block");

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setSizeFull();
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Link thumbnail = new Link();
    if (StringUtils.isBlank(attachment.getThumbnail())) {
        thumbnail.setIcon(FileAssetsUtil.getFileIconResource(attachment.getName()));
    } else {
        thumbnail.setIcon(VaadinResourceFactory.getResource(attachment.getThumbnail()));
    }

    if (MimeTypesUtil.isImageType(docName)) {
        thumbnail.setResource(VaadinResourceFactory.getResource(attachment.getPath()));
        new Fancybox(thumbnail).setPadding(0).setVersion("2.1.5").setEnabled(true).setDebug(true);
    }

    Div contentTooltip = new Div().appendChild(new Span().appendText(docName).setStyle("font-weight:bold"));
    Ul ul = new Ul().appendChild(new Li().appendText(UserUIContext.getMessage(FileI18nEnum.OPT_SIZE_VALUE,
            FileUtils.getVolumeDisplay(attachment.getSize())))).setStyle("line-height:1.5em");
    ul.appendChild(new Li().appendText(UserUIContext.getMessage(GenericI18Enum.OPT_LAST_MODIFIED,
            UserUIContext.formatPrettyTime(attachment.getLastModified().getTime()))));
    contentTooltip.appendChild(ul);
    thumbnail.setDescription(contentTooltip.write());
    thumbnail.setWidth(WebUIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    thumbnailWrap.addComponent(thumbnail);

    attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;");

    MCssLayout attachmentNameWrap = new MCssLayout()
            .withWidth(WebUIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH).withStyleName("attachment-name-wrap");

    Label attachmentName = new ELabel(docName).withStyleName(UIConstants.TEXT_ELLIPSIS);
    attachmentNameWrap.addComponent(attachmentName);
    attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;");

    MButton trashBtn = new MButton("", clickEvent -> {
        ConfirmDialogExt.show(UI.getCurrent(),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()),
                UserUIContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                    if (confirmDialog.isConfirmed()) {
                        ResourceService attachmentService = AppContextUtil.getSpringBean(ResourceService.class);
                        attachmentService.removeResource(attachment.getPath(), UserUIContext.getUsername(),
                                true, MyCollabUI.getAccountId());
                        ((ComponentContainer) attachmentLayout.getParent()).removeComponent(attachmentLayout);
                    }
                });
    }).withIcon(FontAwesome.TRASH_O).withStyleName("attachment-control");
    attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;");

    MButton downloadBtn = new MButton().withIcon(FontAwesome.DOWNLOAD).withStyleName("attachment-control");
    FileDownloader fileDownloader = new FileDownloader(
            VaadinResourceFactory.getInstance().getStreamResource(attachment.getPath()));
    fileDownloader.extend(downloadBtn);
    attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;");
    this.addComponent(attachmentLayout);
}

From source file:com.saax.gestorweb.presenter.ChatPresenter.java

/**
 * Cria botao para download de anexo//  w  w  w.  j a v a  2s  .  c  o m
 */
private Button buildButtonDownload(Anexo anexos) {
    Button exportar = new Button();
    exportar.setIcon(FontAwesome.DOWNLOAD);
    exportar.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    exportar.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    FileDownloader fd = new FileDownloader(new FileResource(new File(anexos.getCaminhoCompleto())));
    fd.extend(exportar);
    return exportar;

}

From source file:de.fatalix.bookery.view.common.BookDetailLayout.java

License:Open Source License

private HorizontalLayout createImageLayout() {
    image = new Image();
    image.setImmediate(true);/*from w  w  w . j  a  va  2  s .  c  o  m*/
    image.setHeight("200px");
    image.setWidth("130px");

    downloadButton = new Button("download", FontAwesome.DOWNLOAD);
    downloadButton.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    downloadButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                loadData(presenter.updateShared(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString()));
            } catch (SolrServerException | IOException ex) {
                Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                logger.error(ex, ex);
            }
        }
    });

    fileDownloader = new FileDownloader(new StreamResource(new BookStreamSource(null), "blbla.epub"));
    fileDownloader.extend(downloadButton);

    sendToKindleButton = new Button("Kindle", FontAwesome.BOOK);
    sendToKindleButton.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    sendToKindleButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                presenter.shareBookWithKindle(bookEntry, SecurityUtils.getSubject().getPrincipal().toString());
                Notification.show("Book is sent to kindle", Notification.Type.HUMANIZED_MESSAGE);
                loadData(presenter.updateShared(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString()));
            } catch (SolrServerException | IOException | MessagingException ex) {
                Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                logger.error(ex, ex);
            }
        }
    });

    likeButton = new Button("0 likes", FontAwesome.THUMBS_O_UP);
    likeButton.addStyleName(ValoTheme.BUTTON_LINK);
    likeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                BookEntry updatedEntry = presenter.updateLike(bookEntry,
                        SecurityUtils.getSubject().getPrincipal().toString());
                loadData(updatedEntry);
            } catch (SolrServerException | IOException ex) {
                Notification.show("Unexpected Error!\n" + ex.getMessage(), Notification.Type.ERROR_MESSAGE);
                logger.error(ex, ex);
            }
        }
    });

    watchListButton = new Button("merken", FontAwesome.STAR_O);
    watchListButton.addStyleName(ValoTheme.BUTTON_LINK);
    watchListButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            presenter.addRemoveFromWatchList(bookEntry, SecurityUtils.getSubject().getPrincipal().toString());
            loadData(bookEntry);
        }
    });
    downloadCount = new Label("0 downloads");

    VerticalLayout rightLayout = new VerticalLayout(sendToKindleButton, downloadButton, watchListButton,
            likeButton, downloadCount);
    rightLayout.setComponentAlignment(downloadCount, Alignment.MIDDLE_CENTER);
    rightLayout.setSpacing(true);

    HorizontalLayout layout = new HorizontalLayout(image, rightLayout);
    layout.setSpacing(true);
    return layout;
}

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  ww w.  ja v  a 2  s.c om
    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;
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.BiologicalSamplesComponent.java

License:Open Source License

/**
 * // w ww .j  a  v  a 2  s  .c om
 */
private void initUI() {
    vert = new VerticalLayout();
    sampleBioGrid = new Grid();
    sampleEntityGrid = new Grid();

    vert.setMargin(new MarginInfo(false, true, false, false));

    sampleEntityGrid.addSelectionListener(new SelectionListener() {

        @Override
        public void select(SelectionEvent event) {
            BeanItem<BiologicalEntitySampleBean> selectedBean = samplesEntity
                    .getItem(sampleEntityGrid.getSelectedRow());

            if (selectedBean == null) {
                TextField filterField = (TextField) sampleBioGrid.getHeaderRow(1).getCell("biologicalEntity")
                        .getComponent();
                filterField.setValue("");
            } else {
                TextField filterField = (TextField) sampleBioGrid.getHeaderRow(1).getCell("biologicalEntity")
                        .getComponent();
                filterField.setValue(selectedBean.getBean().getCode());
                // samplesBio.addContainerFilter("biologicalEntity",
                // selectedBean.getBean().getSecondaryName(), false, false);
            }
        }

    });

    mainLayout = new VerticalLayout(vert);
    mainLayout.setResponsive(true);
    setResponsive(true);

    exportSources.setIcon(FontAwesome.DOWNLOAD);
    exportSamples.setIcon(FontAwesome.DOWNLOAD);

    // this.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS);
    this.setCompositionRoot(mainLayout);
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.DatasetComponent.java

License:Open Source License

/**
 * Precondition: {DatasetView#table} has to be initialized. e.g. with
 * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the
 * Layout of this view./* w  w  w.  j a  va 2  s  .c o  m*/
 */
private void buildLayout() {
    this.vert.removeAllComponents();
    this.vert.setSizeFull();

    vert.setResponsive(true);

    // Table (containing datasets) section
    VerticalLayout tableSection = new VerticalLayout();
    HorizontalLayout tableSectionContent = new HorizontalLayout();
    tableSection.setResponsive(true);
    tableSectionContent.setResponsive(true);

    // tableSectionContent.setCaption("Datasets");
    // tableSectionContent.setIcon(FontAwesome.FLASK);
    // tableSection.addComponent(new Label(String.format("This project contains %s dataset(s).",
    // numberOfDatasets)));
    tableSectionContent.setMargin(new MarginInfo(true, false, true, false));

    tableSection.addComponent(headerLabel);
    tableSectionContent.addComponent(this.table);
    vert.setMargin(new MarginInfo(false, true, false, false));

    tableSection.setMargin(new MarginInfo(true, false, false, true));
    // tableSectionContent.setMargin(true);
    // tableSection.setMargin(true);

    tableSection.addComponent(tableSectionContent);
    this.vert.addComponent(tableSection);

    table.setSizeFull();
    tableSection.setSizeFull();
    tableSectionContent.setSizeFull();

    // this.table.setSizeFull();

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setMargin(new MarginInfo(false, false, true, true));
    buttonLayout.setHeight(null);
    // buttonLayout.setWidth("100%");
    buttonLayout.setSpacing(true);
    buttonLayout.setResponsive(true);

    // final Button visualize = new Button(VISUALIZE_BUTTON_CAPTION);

    Button checkAll = new Button("Select all datasets");
    checkAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : table.getItemIds()) {
                ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(true);
            }
        }
    });

    Button uncheckAll = new Button("Unselect all datasets");
    uncheckAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : table.getItemIds()) {
                ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(false);
            }
        }
    });

    String content = "<p> In case of multiple file selections, Project Browser will create a tar archive.</p>"
            + "<hr>" + "<p> If you need help on extracting a tar archive file, follow the tips below: </p>"
            + "<p>" + FontAwesome.WINDOWS.getHtml() + " Windows </p>"
            + "<p> To open/extract TAR file on Windows, you can use 7-Zip, Easy 7-Zip, PeaZip.</p>" + "<hr>"
            + "<p>" + FontAwesome.APPLE.getHtml() + " MacOS </p>"
            + "<p> To open/extract TAR file on Mac, you can use Mac OS built-in utility Archive Utility,<br> or third-party freeware. </p>"
            + "<hr>" + "<p>" + FontAwesome.LINUX.getHtml() + " Linux </p>"
            + "<p> You need to use command tar. The tar is the GNU version of tar archiving utility. <br> "
            + "To extract/unpack a tar file, type: $ tar -xvf file.tar</p>";

    export.setIcon(FontAwesome.DOWNLOAD);

    PopupView tooltip = new PopupView(new helpers.ToolTip(content));
    tooltip.setHeight("44px");

    HorizontalLayout help = new HorizontalLayout();
    help.setSizeFull();
    HorizontalLayout helpContent = new HorizontalLayout();
    // helpContent.setSizeFull();

    help.setMargin(new MarginInfo(false, false, false, true));
    Label helpText = new Label("Attention: Click here before Download!");
    helpContent.addComponent(new Label(FontAwesome.QUESTION_CIRCLE.getHtml(), ContentMode.HTML));
    helpContent.addComponent(helpText);
    helpContent.addComponent(tooltip);
    helpContent.setSpacing(true);

    help.addComponent(helpContent);
    help.setComponentAlignment(helpContent, Alignment.TOP_CENTER);

    buttonLayout.addComponent(export);
    buttonLayout.addComponent(checkAll);
    buttonLayout.addComponent(uncheckAll);
    // buttonLayout.addComponent(visualize);
    buttonLayout.addComponent(this.download);

    /**
     * prepare download.
     */
    download.setEnabled(false);
    download.setResource(new ExternalResource("javascript:"));
    // visualize.setEnabled(false);

    for (final Object itemId : this.table.getItemIds()) {
        setCheckedBox(itemId, (String) this.table.getItem(itemId).getItemProperty("CODE").getValue());
    }

    this.table.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (!event.isDoubleClick()
                    & !((boolean) table.getItem(event.getItemId()).getItemProperty("isDirectory").getValue())) {
                String datasetCode = (String) table.getItem(event.getItemId()).getItemProperty("CODE")
                        .getValue();
                String datasetFileName = (String) table.getItem(event.getItemId()).getItemProperty("File Name")
                        .getValue();
                URL url;
                try {
                    Resource res = null;
                    Object parent = table.getParent(event.getItemId());
                    if (parent != null) {
                        String parentDatasetFileName = (String) table.getItem(parent)
                                .getItemProperty("File Name").getValue();
                        url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode,
                                parentDatasetFileName + "/" + datasetFileName);
                    } else {
                        url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, datasetFileName);
                    }

                    Window subWindow = new Window();
                    VerticalLayout subContent = new VerticalLayout();
                    subContent.setMargin(true);
                    subContent.setSizeFull();
                    subWindow.setContent(subContent);
                    QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent();
                    Boolean visualize = false;

                    if (datasetFileName.endsWith(".pdf")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("application/pdf");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".png")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        // streamres.setMIMEType("application/png");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".qcML")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/xml");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".alleles")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/plain");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".tsv")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/plain");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".GSvar")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/plain");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".log")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/plain");
                        res = streamres;
                        visualize = true;
                    }

                    if (datasetFileName.endsWith(".html")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("text/html");
                        res = streamres;
                        visualize = true;
                    }

                    if (visualize) {
                        // LOGGER.debug("Is resource null?: " + String.valueOf(res == null));
                        BrowserFrame frame = new BrowserFrame("", res);

                        subContent.addComponent(frame);

                        // Center it in the browser window
                        subWindow.center();
                        subWindow.setModal(true);
                        subWindow.setSizeUndefined();
                        subWindow.setHeight("75%");
                        subWindow.setWidth("75%");
                        subWindow.setResizable(false);

                        frame.setSizeFull();
                        frame.setHeight("100%");
                        // frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.9), Unit.PIXELS);

                        // Open it in the UI
                        ui.addWindow(subWindow);
                    }

                } catch (MalformedURLException e) {
                    LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s",
                            datasetCode));
                    Notification.show(
                            "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data",
                            Notification.Type.ERROR_MESSAGE);
                }
            }
        }
    });

    this.vert.addComponent(buttonLayout);
    this.vert.addComponent(help);

}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.ExperimentComponent.java

License:Open Source License

private void initUI() {
    expSteps = new VerticalLayout();
    expSteps.setWidth(100.0f, Unit.PERCENTAGE);

    expSteps.setMargin(new MarginInfo(true, true, true, true));
    expSteps.setSpacing(true);/* w w w . j a v  a 2s .c  o m*/

    export = new Button("Export as TSV");
    export.setIcon(FontAwesome.DOWNLOAD);
    VerticalLayout buttonLayoutSection = new VerticalLayout();
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setHeight(null);
    buttonLayout.setWidth("100%");
    buttonLayout.addComponent(this.export);
    buttonLayout.setMargin(new MarginInfo(false, false, false, false));
    buttonLayoutSection.addComponent(buttonLayout);
    buttonLayoutSection.setSpacing(true);
    buttonLayoutSection.setMargin(new MarginInfo(false, false, false, false));

    experiments = new Grid();
    experiments.setReadOnly(true);
    experiments.setWidth(100.0f, Unit.PERCENTAGE);
    experiments.setCaption("Registered Experimental Steps");

    // experiments.setContainerDataSource(new
    // BeanItemContainer<ExperimentBean>(ExperimentBean.class));

    expSteps.addComponent(new Label(
            "This view shows the experimental steps which have been registered for this project. Experimental steps contain real biological experiments as well as executed computational workflows on project data",
            ContentMode.HTML));

    expSteps.addComponent(experiments);
    expSteps.addComponent(buttonLayoutSection);

    setCompositionRoot(expSteps);

}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.HomeView.java

License:Open Source License

void buildLayout(int browserHeight, int browserWidth, WebBrowser browser) {
    // clean up first
    // homeview_content.removeAllComponents();
    removeAllComponents();/*ww w .j a  v  a  2s  .co  m*/
    setSpacing(true);

    // updateView(browserWidth, browserWidth, browser);

    // view overall statistics
    // VerticalLayout homeViewDescription = new VerticalLayout();

    /*
     * Label statContent; if (numberOfProjects > 0) { statContent = new
     * Label(String.format("You have %s Sub-Project(s)", numberOfProjects));
     * setHeader(String.format("Total number of Sub-Projects: %s", numberOfProjects)); } else {
     * statContent = new Label(
     * String.format("You have no projects so far. Please contact your project manager."));
     * statContent.addStyleName(ValoTheme.LABEL_FAILURE);
     * statContent.addStyleName(ValoTheme.LABEL_LARGE); }
     */

    // homeViewDescription.setWidth("100%");
    // homeview_content.addComponent(homeViewDescription);

    // table
    // VerticalLayout tableSection = new VerticalLayout();
    // VerticalLayout tableSectionContent = new VerticalLayout();

    // tableSectionContent.setCaption("Sub-Projects");
    // tableSectionContent.setIcon(FontAwesome.TABLE);
    // tableSectionContent.addComponent(this.table);
    addComponent(projectGrid);
    addComponent(buttonLayoutSection);
    setExportButton();

    setCaption("Sub-Projects");
    setIcon(FontAwesome.TABLE);

    // tableSection.setMargin(new MarginInfo(false, false, false, false));

    projectGrid.setWidth(100, Unit.PERCENTAGE);
    projectGrid.setSelectionMode(SelectionMode.SINGLE);
    projectGrid.setResponsive(true);

    export.setIcon(FontAwesome.DOWNLOAD);

    // tableSection.setWidth("100%");
    // tableSectionContent.setWidth("100%");

    // tableSection.addComponent(tableSectionContent);
    // homeview_content.addComponent(tableSection);
    setWidth(100, Unit.PERCENTAGE);
    setResponsive(true);
    // this.addComponent(homeview_content);
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.LevelComponent.java

License:Open Source License

private void initUI() {
    vert = new VerticalLayout();
    datasetTable = buildFilterTable();/*ww  w .ja v a  2s .  co m*/
    sampleGrid = new Grid();

    mainLayout = new VerticalLayout(vert);
    mainLayout.setResponsive(true);
    vert.setResponsive(true);
    vert.setMargin(new MarginInfo(false, true, false, false));

    setResponsive(true);

    exportData.setIcon(FontAwesome.DOWNLOAD);
    exportSamples.setIcon(FontAwesome.DOWNLOAD);

    // this.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS);
    this.setCompositionRoot(mainLayout);
}