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:de.fatalix.timeline.web.root.block.TimelineConfigLayout.java

private Layout createRightSide() {
    status = new Label("STATUS");

    timelineURL = new Link("Timeline Link", new ExternalResource("http://"));
    timelineURL.setTargetName("_blank");
    saveTimeline = new Button("Save Timeline", new Button.ClickListener() {

        @Override//w w w .  j  a va 2 s . c  o  m
        public void buttonClick(Button.ClickEvent event) {

            saveEvent.select(new AnnotationLiteral<RootViewPresenter.Save>() {
            }).fire(new TimelineCallback.SaveTimeline() {

                @Override
                public void showResult(String message) {
                    status.setValue(message);
                }

                @Override
                public Timeline getTimelineData() {
                    data.setHeadline(headline.getValue());
                    data.setText(text.getValue());
                    data.setStartDate(startDate.getValue());
                    Collection<TimelineEvent> events = new ArrayList<>();
                    for (TimelineEventLayout eventLayout : eventLayouts) {
                        events.add(eventLayout.getTimelineEventData());
                    }
                    data.setEvents(events);
                    return data;
                }
            });

            loadEvent.select(new AnnotationLiteral<RootViewPresenter.Load>() {
            }).fire(new TimelineCallback.LoadTimeline() {
                @Override
                public void loadTimeline(Timeline data) {
                    loadTimelineData(data);
                }

                @Override
                public int getTimelineId() {
                    return data.getId();
                }
            });
        }
    });

    exportTimeline = new Button("export", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            exportEvent.select(new AnnotationLiteral<RootViewPresenter.Export>() {
            }).fire(new TimelineCallback.ExportTimeline() {

                @Override
                public int getTimelineId() {
                    return data.getId();
                }

                @Override
                public void showJsonResult(String json) {
                    Window dialog = new Window("JSON Format", new Label(json, ContentMode.PREFORMATTED));
                    dialog.setModal(true);
                    UI.getCurrent().addWindow(dialog);
                }
            });
        }
    });

    return new VerticalLayout(saveTimeline, status, timelineURL, exportTimeline);
}

From source file:de.fatalix.timeline.web.root.block.TimelineConfigLayout.java

public void loadTimelineData(Timeline data) {
    this.data = data;
    headline.setValue(data.getHeadline());
    text.setValue(data.getText());//  w w w.  ja  v  a2  s  .  c  om
    startDate.setValue(data.getStartDate());
    timelineURL.setResource(new ExternalResource("#!timeline/" + data.getId()));
    if (eventLayouts == null) {
        eventLayouts = new ArrayList<>();
    }
    eventLayouts.clear();
    eventGridContainer.removeAllComponents();
    for (TimelineEvent eventData : data.getEvents()) {
        addTimelineEvent(eventData);
    }
}

From source file:de.gedoplan.webclients.vaadin.views.CustomersView.java

@Override
protected void configureTable() {
    table.addGeneratedColumn(Customer_.customerID.getName(),
            (source, itemId, columnId) -> new Link(itemId.toString(),
                    new ExternalResource("#!" + Konstanten.VAADIN_VIEW_CUSTOMER_DETAILS + "/" + itemId)));
    //        table.getColumn(Customer_.customerID.getName()).setRenderer(new ButtonRenderer(e -> navigator.navigateTo(Konstanten.VAADIN_VIEW_CUSTOMER_DETAILS + "/" + e.getItemId())));
}

From source file:de.metas.procurement.webui.ui.view.LoginView.java

License:Open Source License

public LoginView() {
    super();//from   w  w  w . j a  va2  s  .c o m
    Application.autowire(this);

    addStyleName(STYLE);

    //
    // Content
    {
        final VerticalComponentGroup content = new VerticalComponentGroup();

        final Resource logoResource = getLogoResource();
        final Image logo = new Image(null, logoResource);
        logo.addStyleName(STYLE_Logo);
        content.addComponent(logo);

        this.email = new EmailField(i18n.get("LoginView.fields.email"));
        email.addStyleName(STYLE_LoginEmail);
        email.setIcon(FontAwesome.USER);
        content.addComponent(email);

        this.password = new PasswordField(i18n.get("LoginView.fields.password"));
        password.addStyleName(STYLE_LoginPassword);
        password.setIcon(FontAwesome.LOCK);
        content.addComponent(password);

        final Button loginButton = new Button(i18n.get("LoginView.fields.loginButton"));
        loginButton.addStyleName(STYLE_LoginButton);
        loginButton.setClickShortcut(KeyCode.ENTER);
        loginButton.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onUserLogin(email.getValue(), password.getValue());
            }
        });

        final Button forgotPasswordButton = new Button(i18n.get("LoginView.fields.forgotPasswordButton"));
        forgotPasswordButton.setStyleName(STYLE_ForgotPasswordButton);
        forgotPasswordButton.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                onForgotPassword(email.getValue());
            }
        });

        final CssLayout contentWrapper = new CssLayout(content, loginButton, forgotPasswordButton);
        contentWrapper.addStyleName(STYLE_LoginFormWrapper);
        setContent(contentWrapper);
    }

    //
    // Bottom:
    {
        //
        // Powered-by logo resource
        // Use the configured one if any; fallback to default embedded powered-by logo
        final Resource poweredByLogoResource;
        if (poweredByLogoUrl != null && !poweredByLogoUrl.trim().isEmpty()) {
            poweredByLogoResource = new ExternalResource(poweredByLogoUrl.trim());
        } else {
            poweredByLogoResource = Constants.RESOURCE_PoweredBy;
        }

        //
        // Powered-by component:
        final Component poweredByComponent;
        if (poweredByLinkUrl != null && !poweredByLinkUrl.trim().isEmpty()) {
            final Link link = new Link();
            link.setIcon(poweredByLogoResource);
            link.setResource(new ExternalResource(poweredByLinkUrl.trim()));
            link.setTargetName("_blank");
            poweredByComponent = link;
        } else {
            final Image image = new Image(null, poweredByLogoResource);
            poweredByComponent = image;
        }
        //
        poweredByComponent.addStyleName(STYLE_PoweredBy);
        setToolbar(poweredByComponent);
    }
}

From source file:de.symeda.sormas.ui.AboutView.java

License:Open Source License

public AboutView() {
    CustomLayout aboutContent = new CustomLayout("aboutview");
    aboutContent.setStyleName("about-content");

    // Info section
    VerticalLayout infoLayout = new VerticalLayout();
    infoLayout.setSpacing(false);/* w  w  w  .j  a  v a 2 s  .  c om*/
    infoLayout.setMargin(false);
    aboutContent.addComponent(infoLayout, "info");

    Label versionLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " "
            + I18nProperties.getCaption(Captions.aboutSormasVersion) + ": " + InfoProvider.get().getVersion(),
            ContentMode.HTML);
    infoLayout.addComponent(versionLabel);

    Link whatsNewLink = new Link(I18nProperties.getCaption(Captions.aboutWhatsNew),
            new ExternalResource(
                    "https://github.com/hzi-braunschweig/SORMAS-Project/releases/tag/releases%2Fversion-"
                            + InfoProvider.get().getBaseVersion()));
    whatsNewLink.setTargetName("_blank");
    infoLayout.addComponent(whatsNewLink);

    Link sormasWebsiteLink = new Link(I18nProperties.getCaption(Captions.aboutSormasWebsite),
            new ExternalResource("https://sormasorg.helmholtz-hzi.de/"));
    sormasWebsiteLink.setTargetName("_blank");
    infoLayout.addComponent(sormasWebsiteLink);

    Link sormasGithubLink = new Link("SORMAS Github",
            new ExternalResource("https://github.com/hzi-braunschweig/SORMAS-Project"));
    sormasGithubLink.setTargetName("_blank");
    infoLayout.addComponent(sormasGithubLink);

    Link changelogLink = new Link(I18nProperties.getCaption(Captions.aboutChangelog),
            new ExternalResource("https://github.com/hzi-braunschweig/SORMAS-Project/releases"));
    changelogLink.setTargetName("_blank");
    infoLayout.addComponent(changelogLink);

    // Documents section
    VerticalLayout documentsLayout = new VerticalLayout();
    documentsLayout.setSpacing(false);
    documentsLayout.setMargin(false);
    aboutContent.addComponent(documentsLayout, "documents");

    Button classificationDocumentButton = new Button(
            I18nProperties.getCaption(Captions.aboutCaseClassificationRules));
    CssStyles.style(classificationDocumentButton, ValoTheme.BUTTON_LINK, CssStyles.BUTTON_COMPACT);
    documentsLayout.addComponent(classificationDocumentButton);

    try {
        String serverUrl = new URL(((VaadinServletRequest) VaadinService.getCurrentRequest())
                .getHttpServletRequest().getRequestURL().toString()).getAuthority();
        StreamResource classificationResource = DownloadUtil.createStringStreamResource(
                ClassificationHtmlRenderer.createHtmlForDownload(serverUrl,
                        FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases()),
                "classification_rules.html", "text/html");
        new FileDownloader(classificationResource).extend(classificationDocumentButton);
    } catch (MalformedURLException e) {

    }

    Button dataDictionaryButton = new Button(I18nProperties.getCaption(Captions.aboutDataDictionary));
    CssStyles.style(dataDictionaryButton, ValoTheme.BUTTON_LINK, CssStyles.BUTTON_COMPACT);
    documentsLayout.addComponent(dataDictionaryButton);
    FileDownloader dataDictionaryDownloader = new FileDownloader(
            new ClassResource("/doc/SORMAS_Data_Dictionary.xlsx"));
    dataDictionaryDownloader.extend(dataDictionaryButton);

    Link technicalManualLink = new Link(I18nProperties.getCaption(Captions.aboutTechnicalManual),
            new ExternalResource(
                    "https://github.com/hzi-braunschweig/SORMAS-Project/files/2585973/SORMAS_Technical_Manual_Webversion_20180911.pdf"));
    technicalManualLink.setTargetName("_blank");
    documentsLayout.addComponent(technicalManualLink);

    setSizeFull();
    setStyleName("about-view");
    addComponent(aboutContent);
    setComponentAlignment(aboutContent, Alignment.MIDDLE_CENTER);
}

From source file:de.symeda.sormas.ui.caze.CaseController.java

License:Open Source License

public Link createLinkToData(String caseUuid, String caption) {
    Link link = new Link(caption, new ExternalResource("#!" + CaseDataView.VIEW_NAME + "/" + caseUuid));
    return link;// ww w. j a v a  2 s  .  co  m
}

From source file:de.symeda.sormas.ui.dashboard.map.DashboardMapComponent.java

License:Open Source License

public static HorizontalLayout buildMapIconLegendEntry(String iconName, String labelCaption) {
    Image icon = new Image(null, new ExternalResource("VAADIN/map/marker/" + iconName + ".png"));
    icon.setWidth(12.375f, Unit.PIXELS);
    icon.setHeight(16.875f, Unit.PIXELS);
    return buildLegendEntry(icon, labelCaption);
}

From source file:de.symeda.sormas.ui.SubMenu.java

License:Open Source License

public void addView(final String name, String caption, String params, boolean isBackNavigation) {
    String target = "#!" + name + (params != null ? "/" + params : "");

    CssLayout tabItemCell = new CssLayout();
    tabItemCell.setSizeUndefined();//w  w  w  .  j av  a2 s. c  o  m
    tabItemCell.setPrimaryStyleName("v-tabsheet-tabitemcell");

    CssLayout tabItem = new CssLayout();
    tabItem.setSizeUndefined();
    tabItem.setPrimaryStyleName("v-tabsheet-tabitem");
    if (isBackNavigation) {
        tabItem.addStyleName("back");
    }
    tabItemCell.addComponent(tabItem);

    Link link = new Link(caption, new ExternalResource(target));
    link.addStyleName("v-caption");
    if (isBackNavigation)
        link.setIcon(VaadinIcons.ARROW_CIRCLE_LEFT);
    tabItem.addComponent(link);

    menuItemsLayout.addComponent(tabItemCell);
    viewMenuItemMap.put(name, tabItem);
}

From source file:de.unioninvestment.eai.portal.portlet.crud.CrudUI.java

License:Apache License

private ComponentContainer initializeHelpPage() {

    DatasourceInfos datasourceInfos = new DatasourceInfos();
    DatasourceInfoView datasourceInfoView = new DatasourceInfoView(datasourceInfos.getContainer());
    this.datasourceInfo = new DatasourceInfoPresenter(datasourceInfoView, datasourceInfos);

    VerticalLayout help = new VerticalLayout();
    help.setSpacing(true);//from w w  w  .  j av  a  2s  .c  om
    help.addComponent(new Link(Context.getMessage("portlet.crud.page.help.message"),
            new ExternalResource(settings.getHelpUrl())));
    help.addComponent(new Label(
            Context.getMessage("portlet.crud.page.help.buildNumberLabel", settings.getBuildNumber())));
    help.addComponent(this.datasourceInfo.getView());

    return help;
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.configuration.DefaultPortletRolesView.java

License:Apache License

@Override
public void display(List<PortletRoleTO> roles) {
    for (PortletRoleTO portletRole : roles) {
        ExternalResource res = new ExternalResource(permissionsUrl(portletRole));
        rolesLayout.addComponent(new Link(portletRole.getName(), res));
    }//from www  .  jav a  2s . com
}