Example usage for com.vaadin.server ExternalResource ExternalResource

List of usage examples for com.vaadin.server ExternalResource ExternalResource

Introduction

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

Prototype

public ExternalResource(String sourceURL) 

Source Link

Document

Creates a new download component for downloading directly from given URL.

Usage

From source file:org.vaadin.alump.fancylayouts.demo.PanelDemo.java

License:Apache License

/**
 * Sample content with more stuff/*from  ww  w. j  a va2s  . c om*/
 * 
 * @return
 */
private ComponentContainer createPanelContentB() {

    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setMargin(true);
    layout.setSpacing(true);

    Label label = new Label(BECON_STR);
    layout.addComponent(label);

    Embedded image = new Embedded();
    image.setSource(new ExternalResource("http://misc.siika.fi/kaljanhimo.jpg"));
    image.setWidth("300px");
    image.setHeight("187px");
    layout.addComponent(image);
    layout.setComponentAlignment(image, Alignment.MIDDLE_CENTER);

    Label label2 = new Label(BECON_STR);
    layout.addComponent(label2);

    return layout;

}

From source file:org.vaadin.alump.masonry.demo.MainMenuView.java

License:Open Source License

public MainMenuView() {
    setWidth("100%");
    setMargin(true);//w ww.j  av  a  2s .c  om
    setSpacing(true);

    VerticalLayout infoLayout = new VerticalLayout();
    infoLayout.setWidth("100%");
    addComponent(infoLayout);

    Label label = new Label("Masonry addon adds cascading grid layout to Vaadin.");
    infoLayout.addComponent(label);

    Link link = new Link("This addon is based on David DeSandro's Masonry JavaScript library (MIT license).",
            new ExternalResource("http://masonry.desandro.com/"));
    infoLayout.addComponent(link);

    link = new Link("Source code and issue tracker, of this addon, are available in GitHub.",
            new ExternalResource("https://github.com/alump/Masonry"));
    infoLayout.addComponent(link);

    Button basicTests = new Button("Basic Demo", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo(BasicTestsView.VIEW_NAME);
        }
    });
    addComponent(basicTests);

    Button dndTests = new Button("Drag and Drop Reordering Demo", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo(DnDTestsView.VIEW_NAME);
        }
    });
    addComponent(dndTests);

    Button sizerTests = new Button("Dynamic styles Grid Size Demo", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().getNavigator().navigateTo(GridSizerTestsView.VIEW_NAME);
        }
    });
    addComponent(sizerTests);

}

From source file:org.vaadin.alump.offlinebuilder.demo.DemoUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {

    OfflineUIExtension offlineExtension = OfflineUIExtension.get(this);

    // As Panel is half legacy component, using OfflineCssLayout to make content scrollable
    OfflineCssLayout panel = new OfflineCssLayout();
    panel.addStyleName("scrollable-wrapper");
    panel.setSizeFull();//from ww  w .j  av a2 s.co m
    setContent(panel);
    offlineExtension.setOfflineRoot(panel);

    VerticalLayout layout = new OfflineVerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addStyleName("main-layout");
    panel.addComponent(layout);

    Label header = new OfflineLabel("OfflineBuilder");
    header.addStyleName("header-label");
    layout.addComponent(header);

    Label info = new OfflineLabel("OfflineBuilder allows to define offline UI without need of writing GWT"
            + " code. Add-on offers offline extended versions of basic Vaadin UI components and layouts. This way"
            + " your server defined UI can be used on offline mode too.");
    info.addStyleName("info-label");
    layout.addComponent(info);

    info = new OfflineLabel(
            "To test offline functionality. Turn on flight mode on your device or just disconnect"
                    + " from your network connection. Offline UI should look identical with online UI.");
    info.addStyleName("info-label");
    layout.addComponent(info);

    Image image = new OfflineImage();
    image.setWidth("300px");
    image.addStyleName("extra-stylename-image");
    image.setSource(new ThemeResource("img/offline.png"));
    image.setDescription("Example image");
    layout.addComponent(image);

    HorizontalLayout buttonLayout = new OfflineHorizontalLayout();
    buttonLayout.setSpacing(true);
    layout.addComponent(buttonLayout);

    OfflineButton pingButton = new OfflineButton("Ping server");
    pingButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("Server says pong!");
        }
    });
    pingButton.setDescription("Button that will be automatically disabled on offline mode");
    buttonLayout.addComponent(pingButton);

    OfflineButton writeButton = new OfflineButton("Store value (TODO)");
    writeButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("No need to store, in online mode.");
        }
    });
    buttonLayout.addComponent(writeButton);

    /*
    OfflineFormLayout formTest = new OfflineFormLayout();
    OfflineCheckBox checkbox = new OfflineCheckBox("Flag me");
    checkbox.setOfflineValueKey("flag");
    formTest.addComponent(checkbox);
    layout.addComponent(formTest);
    */

    Link link = new OfflineLink("Open project's GitHub page",
            new ExternalResource("https://github.com/alump/OfflineBuilder"));
    link.addStyleName("github-link");
    layout.addComponent(link);
}

From source file:org.vaadin.tori.component.Breadcrumbs.java

License:Apache License

private Component getDashboardLink() {
    Link link = new Link(getDashboardTitle(),
            new ExternalResource("#" + ToriNavigator.ApplicationView.DASHBOARD.getUrl()));
    link.setHeight(100.0f, Unit.PERCENTAGE);
    return link;/*from  w w w .  jav a2 s.c om*/
}

From source file:org.vaadin.tori.component.Breadcrumbs.java

License:Apache License

private Component getCategoryLink(final Category category) {
    HorizontalLayout result = new HorizontalLayout();
    result.setSpacing(true);/*w  ww .  ja v a 2  s. com*/
    result.setHeight(100.0f, Unit.PERCENTAGE);
    result.addStyleName("categorylink");
    final Link crumb = new Link(category.getName(), new ExternalResource(
            "#" + ToriNavigator.ApplicationView.CATEGORIES.getUrl() + "/" + category.getId()));
    crumb.setHeight(100.0f, Unit.PERCENTAGE);
    result.addComponent(crumb);
    result.setComponentAlignment(crumb, Alignment.MIDDLE_CENTER);
    Component siblingMenu = getSiblingMenuBar(category);
    siblingMenu.setHeight(100.0f, Unit.PERCENTAGE);
    result.addComponent(siblingMenu);
    result.setComponentAlignment(siblingMenu, Alignment.MIDDLE_CENTER);
    return result;
}

From source file:org.vaadin.tori.component.RecentBar.java

License:Apache License

private void addMyPostsLink(final HorizontalLayout barLayout) {
    Link link = new Link("My Posts",
            new ExternalResource("#" + ToriNavigator.ApplicationView.CATEGORIES.getUrl() + "/"
                    + SpecialCategory.MY_POSTS.getId().toLowerCase()));
    link.addStyleName("mypostslink");
    barLayout.addComponent(link);/*from   ww  w. ja  v  a2  s  .c o m*/
    barLayout.setComponentAlignment(link, Alignment.MIDDLE_RIGHT);
}

From source file:org.vaadin.tori.component.RecentBar.java

License:Apache License

private void addRecentLink(final HorizontalLayout barLayout) {
    Link link = new Link("Recent Posts",
            new ExternalResource("#" + ToriNavigator.ApplicationView.CATEGORIES.getUrl() + "/"
                    + SpecialCategory.RECENT_POSTS.getId().toLowerCase()));
    link.addStyleName("recentlink");
    barLayout.addComponent(link);/* w w w .  j a v  a  2 s . c  om*/
    barLayout.setComponentAlignment(link, Alignment.MIDDLE_RIGHT);
}

From source file:probe.com.view.body.quantcompare.PieChart.java

public PieChart(String title, double full, double found, final String notfound) {

    this.setWidth(200 + "px");
    this.setHeight(200 + "px");
    defaultKeyColorMap.put("Found", new Color(110, 177, 206));
    defaultKeyColorMap.put("Not found", new Color(219, 169, 1));
    otherSymbols.setGroupingSeparator('.');
    this.setStyleName("click");

    labels = new String[] { "Found", "Not found" };

    double foundPercent = ((found / full) * 100.0);
    df = new DecimalFormat("#.##", otherSymbols);
    valuesMap.put("Found", ((int) found) + " (" + df.format(foundPercent) + "%)");
    values = new Double[] { foundPercent, 100.0 - foundPercent };
    valuesMap.put("Not found", ((int) (full - found)) + " (" + df.format(100.0 - foundPercent) + "%)");

    String defaultImgURL = initPieChart(200, 200, title);
    chartImg.setSource(new ExternalResource(defaultImgURL));
    this.addComponent(chartImg);
    this.addLayoutClickListener(PieChart.this);

    popupLayout = new PopupView(null, popupBody);
    popupLayout.setHideOnMouseOut(false);
    popupBody.setWidth("300px");
    popupBody.setStyleName(Reindeer.LAYOUT_WHITE);
    popupBody.setHeightUndefined();/*from  w w  w.  j a v a  2 s. c o  m*/
    this.addComponent(popupLayout);
    this.notfound = notfound.replace(" ", "").replace(",", "/n");

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setHeight("20px");

    Label header = new Label("<b>Not Found (New Proteins)</b>");
    header.setStyleName(Reindeer.LABEL_SMALL);
    topLayout.addComponent(header);
    header.setContentMode(ContentMode.HTML);

    VerticalLayout closeBtn = new VerticalLayout();
    closeBtn.setWidth("10px");
    closeBtn.setHeight("10px");
    closeBtn.setStyleName("closebtn");
    topLayout.addComponent(closeBtn);
    topLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT);
    closeBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            popupLayout.setPopupVisible(false);
        }
    });
    popupBody.addComponent(topLayout);
    popupBody.addComponent(textArea);
    textArea.setWidth("100%");
    textArea.setHeight("150px");
    textArea.setValue(this.notfound);
    textArea.setReadOnly(true);
    popupBody.setSpacing(true);

    HorizontalLayout bottomLayout = new HorizontalLayout();
    bottomLayout.setWidth("100%");
    bottomLayout.setHeight("40px");
    bottomLayout.setMargin(new MarginInfo(false, true, true, true));
    popupBody.addComponent(bottomLayout);

    Button exportTableBtn = new Button("");
    exportTableBtn.setHeight("24px");
    exportTableBtn.setWidth("24px");
    exportTableBtn.setPrimaryStyleName("exportxslbtn");
    exportTableBtn.setDescription("Export table data");
    exportTableBtn.addClickListener(new Button.ClickListener() {

        private Table table;

        @Override
        public void buttonClick(Button.ClickEvent event) {

            if (table == null) {
                table = new Table();
                table.addContainerProperty("Index", Integer.class, null, "", null, Table.Align.RIGHT);
                table.addContainerProperty("Accession", String.class, Table.Align.CENTER);
                table.setVisible(false);
                addComponent(table);
                int i = 1;
                for (String str : notfound.replace(" ", "").replace(",", "\n").split("\n")) {
                    table.addItem(new Object[] { i, str }, i++);
                }

            }

            ExcelExport csvExport = new ExcelExport(table, "Not found protein accessions (New proteins)");
            //                csvExport.setReportTitle("CSF-PR /  Not found protein accessions (New proteins) ");
            csvExport.setExportFileName("CSF-PR - Not found protein accessions" + ".xls");
            csvExport.setMimeType(CsvExport.EXCEL_MIME_TYPE);
            csvExport.setDisplayTotals(false);
            csvExport.setExcelFormatOfProperty("Index", "#0;[Red] #0");
            csvExport.export();

        }
    });

    bottomLayout.addComponent(exportTableBtn);
    bottomLayout.setComponentAlignment(exportTableBtn, Alignment.MIDDLE_RIGHT);

}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.ComparisonsSelectionOverviewBubbleChart.java

/**
 *
 */
public final void redrawChart() {

    chartImage.setSource(new ExternalResource(defaultImgURL));

}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.heatmap.HeatMapComponent.java

public void updateHideShowThumbImg(String imgUrl) {
    if (imgUrl == null) {
        icon.setSource(defaultResource);
        hideShowBtnLabel.setValue("CSF-PR v2.0");
        return;/*from   www .  j a  va 2s .c  om*/
    }
    if (imgUrl.equalsIgnoreCase("defaultResource")) {

        String url = gen.generateHeatmap(rowsColors, columnsColors, dataColors);
        icon.setSource(new ExternalResource(url));
        //            icon.setSource(defaultResource);
    } else {
        icon.setSource(new ExternalResource(imgUrl));
    }
}