类com.vaadin.server.ExternalResource源码实例Demo

下面列出了怎么用com.vaadin.server.ExternalResource的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jpa-invoicer   文件: LoginWindow.java
@Override
public void attach() {
    super.attach();

    service = createService();
    String url = service.getAuthorizationUrl(null);
    
    gplusLoginButton = new Link("Login with Google", new ExternalResource(url));
    gplusLoginButton.addStyleName(ValoTheme.LINK_LARGE);

    VaadinSession.getCurrent().addRequestHandler(this);

    setContent(new MVerticalLayout(gplusLoginButton).alignAll(
            Alignment.MIDDLE_CENTER).withFullHeight());
    setModal(true);
    setWidth("300px");
    setHeight("200px");

}
 
源代码2 项目: mycollab   文件: AboutWindow.java
public AboutWindow() {
    MHorizontalLayout content = new MHorizontalLayout().withMargin(true).withFullWidth();
    this.setContent(content);

    Image about = new Image("", new ExternalResource(StorageUtils.generateAssetRelativeLink(WebResourceIds._about)));

    MVerticalLayout rightPanel = new MVerticalLayout();
    ELabel versionLbl = ELabel.h2(String.format("MyCollab Community Edition %s", Version.getVersion())).withFullWidth();
    ELabel javaNameLbl = new ELabel(String.format("%s, %s", System.getProperty("java.vm.name"),
            System.getProperty("java.runtime.version"))).withFullWidth();
    Label homeFolderLbl = new Label("Home folder: " + AppContextUtil.getSpringBean(ServerConfiguration.class).getHomeDir().getAbsolutePath());
    WebBrowser browser = Page.getCurrent().getWebBrowser();
    ELabel osLbl = new ELabel(String.format("%s, %s", System.getProperty("os.name"), browser.getBrowserApplication())).withFullWidth();
    Div licenseDiv = new Div().appendChild(new Text("Powered by: "))
            .appendChild(new A("https://www.mycollab.com")
                    .appendText("MyCollab")).appendChild(new Text(". Open source under GPL license"));
    ELabel licenseLbl = ELabel.html(licenseDiv.write()).withFullWidth();
    Label copyRightLbl = ELabel.html(String.format("© %s - %s MyCollab Ltd. All rights reserved", "2011",
            LocalDate.now().getYear() + "")).withFullWidth();
    rightPanel.with(versionLbl, javaNameLbl, osLbl, homeFolderLbl, licenseLbl, copyRightLbl).withAlign(copyRightLbl, Alignment.BOTTOM_LEFT);
    content.with(about, rightPanel).expand(rightPanel);
}
 
源代码3 项目: mycollab   文件: ProjectAssetsUtil.java
public static Component projectLogoComp(String projectShortname, Integer projectId, String projectAvatarId, int size) {
    AbstractComponent wrapper;
    if (!StringUtils.isBlank(projectAvatarId)) {
        wrapper = new Image(null, new ExternalResource(StorageUtils.getResourcePath
                (String.format("%s/%s_%d.png", PathUtils.getProjectLogoPath(AppUI.getAccountId(), projectId),
                        projectAvatarId, size))));
    } else {
        ELabel projectIcon = new ELabel(projectShortname.substring(0, 1)).withStyleName(WebThemes.TEXT_ELLIPSIS, ValoTheme.LABEL_LARGE, "center");
        projectIcon.setWidth(size, Sizeable.Unit.PIXELS);
        projectIcon.setHeight(size, Sizeable.Unit.PIXELS);
        wrapper = new MVerticalLayout(projectIcon).withAlign(projectIcon, Alignment.MIDDLE_CENTER).withMargin(false);
    }
    wrapper.setWidth(size, Sizeable.Unit.PIXELS);
    wrapper.setHeight(size, Sizeable.Unit.PIXELS);
    wrapper.addStyleName(WebThemes.CIRCLE_BOX);
    wrapper.setDescription(UserUIContext.getMessage(GenericI18Enum.OPT_CHANGE_IMAGE));
    return wrapper;
}
 
源代码4 项目: mycollab   文件: ProjectAssetsUtil.java
public static Component clientLogoComp(Client client, int size) {
    AbstractComponent wrapper;
    if (!StringUtils.isBlank(client.getAvatarid())) {
        wrapper = new Image(null, new ExternalResource(StorageUtils.getEntityLogoPath(AppUI.getAccountId(), client.getAvatarid(), 100)));
    } else {
        String clientName = client.getName();
        clientName = (clientName.length() > 3) ? clientName.substring(0, 3) : clientName;
        ELabel projectIcon = new ELabel(clientName).withStyleName(WebThemes.TEXT_ELLIPSIS, "center");
        wrapper = new VerticalLayout();
        ((VerticalLayout) wrapper).addComponent(projectIcon);
        ((VerticalLayout) wrapper).setComponentAlignment(projectIcon, Alignment.MIDDLE_CENTER);
    }
    wrapper.setWidth(size, Sizeable.Unit.PIXELS);
    wrapper.setHeight(size, Sizeable.Unit.PIXELS);
    wrapper.addStyleName(WebThemes.CIRCLE_BOX);
    wrapper.setDescription(UserUIContext.getMessage(GenericI18Enum.OPT_CHANGE_IMAGE));
    return wrapper;
}
 
源代码5 项目: mycollab   文件: AccountModuleImpl.java
public AccountModuleImpl() {
    addStyleName("module");
    ControllerRegistry.addController(new UserAccountController(this));

    MHorizontalLayout topPanel = new MHorizontalLayout().withFullWidth().withMargin(true).withStyleName(WebThemes.BORDER_BOTTOM).withId("tab-content-header");
    AccountSettingBreadcrumb breadcrumb = ViewManager.getCacheComponent(AccountSettingBreadcrumb.class);

    MButton helpBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_HELP))
            .withIcon(VaadinIcons.ACADEMY_CAP).withStyleName(WebThemes.BUTTON_LINK);
    ExternalResource helpRes = new ExternalResource("https://docs.mycollab.com/user-guide/account-management/");
    BrowserWindowOpener helpOpener = new BrowserWindowOpener(helpRes);
    helpOpener.extend(helpBtn);

    topPanel.with(breadcrumb, helpBtn).withAlign(helpBtn, Alignment.TOP_RIGHT);

    tabSheet = new VerticalTabsheet();
    tabSheet.getContentWrapper().addStyleName("content-height");
    tabSheet.setSizeFull();
    tabSheet.addToggleNavigatorControl();
    CssLayout contentWrapper = tabSheet.getContentWrapper();
    contentWrapper.addComponentAsFirst(topPanel);

    this.buildComponents();
    this.setContent(tabSheet);
}
 
源代码6 项目: RDFUnit   文件: RDFUnitDemo.java
private void initLayoutHeader() {
    headerLayout.setWidth("100%");
    headerLayout.setHeight("80px");
    headerLayout.setId("header");

    Link rdfunit = new Link("",
            new ExternalResource("http://rdfunit.aksw.org/"));
    rdfunit.setIcon(new ThemeResource("images/logo-rdfunit.png"));

    headerLayout.addComponent(rdfunit);

    Link aksw = new Link("",
            new ExternalResource("http://aksw.org/"));
    aksw.setIcon(new ThemeResource("images/logo-aksw.png"));
    aksw.addStyleName("align-right");
    headerLayout.addComponent(aksw);
}
 
源代码7 项目: cuba   文件: WebLink.java
@Override
public String getUrl() {
    Resource resource = component.getResource();
    if (resource instanceof ExternalResource)
        return ((ExternalResource) resource).getURL();

    return null;
}
 
源代码8 项目: cuba   文件: WebUrlResource.java
@Override
public void setMimeType(String mimeType) {
    this.mimeType = mimeType;

    if (resource != null) {
        ((ExternalResource) resource).setMIMEType(mimeType);
    }
}
 
源代码9 项目: cuba   文件: WebRelativePathResource.java
@Override
protected void createResource() {
    try {
        URL context = new URL(ControllerUtils.getLocationWithoutParams());
        resource = new ExternalResource(new URL(context, path));
    } catch (MalformedURLException e) {
        throw new RuntimeException("Can't create RelativePathResource", e);
    }
}
 
源代码10 项目: cuba   文件: WebRelativePathResource.java
@Override
public void setMimeType(String mimeType) {
    this.mimeType = mimeType;

    if (resource != null) {
        ((ExternalResource) resource).setMIMEType(mimeType);
    }
}
 
源代码11 项目: cia   文件: PageLinkFactoryImpl.java
@Override
public Link addCommitteePageLink(final ViewRiksdagenCommittee data) {
	final Link pageLink = new Link(COMMITTEE
			+ data.getEmbeddedId().getDetail(), new ExternalResource(PAGE_PREFIX
					+ UserViews.COMMITTEE_VIEW_NAME + PAGE_SEPARATOR + data.getEmbeddedId().getOrgCode()));
	pageLink.setId(ViewAction.VISIT_COMMITTEE_VIEW.name() + PAGE_SEPARATOR
			+ data.getEmbeddedId().getOrgCode());
	pageLink.setIcon(VaadinIcons.GROUP);
	return pageLink;
}
 
源代码12 项目: cia   文件: PageLinkFactoryImpl.java
@Override
public Link addMinistryPageLink(final ViewRiksdagenMinistry data) {
	final Link pageLink = new Link(MINISTRY + data.getNameId(),
			new ExternalResource(PAGE_PREFIX + UserViews.MINISTRY_VIEW_NAME + PAGE_SEPARATOR
					+ data.getNameId()));
	pageLink.setId(ViewAction.VISIT_MINISTRY_VIEW.name() + PAGE_SEPARATOR
			+ data.getNameId());
	pageLink.setIcon(VaadinIcons.GROUP);
	return pageLink;
}
 
源代码13 项目: cia   文件: PageLinkFactoryImpl.java
@Override
public Link addPartyPageLink(final ViewRiksdagenParty data) {
	final Link pageLink = new Link(PARTY + data.getPartyName(),
			new ExternalResource(PAGE_PREFIX + UserViews.PARTY_VIEW_NAME + PAGE_SEPARATOR
					+ data.getPartyId()));
	pageLink.setId(ViewAction.VISIT_PARTY_VIEW.name() + PAGE_SEPARATOR
			+ data.getPartyId());
	pageLink.setIcon(VaadinIcons.GROUP);
	return pageLink;
}
 
源代码14 项目: cia   文件: PageLinkFactoryImpl.java
@Override
public Link createAdminPagingLink(final String label,final String page, final String pageId, final String pageNr) {
	final Link pageLink = new Link(label,
			new ExternalResource(PAGE_PREFIX + page + PAGE_SEPARATOR
					+ "[" + pageNr + "]"));
	pageLink.setId(page +"ShowPage" + PAGE_SEPARATOR
			+ pageNr);
	pageLink.setIcon(VaadinIcons.SERVER);

	return pageLink;
}
 
源代码15 项目: cia   文件: PageLinkFactoryImpl.java
@Override
public Link createLoginPageLink() {
	final Link pageLink = new Link("Login", new ExternalResource(
			LINK_SEPARATOR + CommonsViews.MAIN_VIEW_NAME + PAGE_SEPARATOR + ApplicationPageMode.LOGIN));
	pageLink.setId(ViewAction.VISIT_LOGIN.name());
	pageLink.setIcon(VaadinIcons.SIGN_IN);
	return pageLink;
}
 
源代码16 项目: cia   文件: PageLinkFactoryImpl.java
@Override
public Link createMainViewPageLink() {
	final Link pageLink = new Link(MAIN_VIEW_LINK_TEXT, new ExternalResource(
			LINK_SEPARATOR + CommonsViews.MAIN_VIEW_NAME));
	pageLink.setId(ViewAction.VISIT_MAIN_VIEW.name());
	pageLink.setIcon(VaadinIcons.STAR);
	return pageLink;
}
 
源代码17 项目: cia   文件: PageLinkFactoryImpl.java
@Override
public Link createPoliticianPageLink(final PersonData personData) {
	final Link pageLink = new Link(POLITICIAN
			+ personData.getFirstName() + ' '
			+ personData.getLastName(), new ExternalResource(PAGE_PREFIX
					+ UserViews.POLITICIAN_VIEW_NAME + PAGE_SEPARATOR + personData.getId()));
	pageLink.setId(ViewAction.VISIT_POLITICIAN_VIEW.name() + PAGE_SEPARATOR
			+ personData.getId());
	pageLink.setIcon(VaadinIcons.BUG);
	return pageLink;
}
 
源代码18 项目: cia   文件: PageLinkFactoryImpl.java
@Override
public Link createRegisterPageLink() {
	final Link pageLink = new Link("Register", new ExternalResource(
			LINK_SEPARATOR + CommonsViews.MAIN_VIEW_NAME + PAGE_SEPARATOR + ApplicationPageMode.REGISTER));
	pageLink.setId(ViewAction.VISIT_REGISTER.name());
	pageLink.setIcon(VaadinIcons.RANDOM);
	return pageLink;
}
 
源代码19 项目: cia   文件: PageLinkFactoryImpl.java
@Override
public Link createUserHomeViewPageLink() {
	final Link pageLink = new Link("User account:", new ExternalResource(PAGE_PREFIX
			+ UserViews.USERHOME_VIEW_NAME));
		pageLink.setId(ViewAction.VISIT_USER_HOME_VIEW.name());
		pageLink.setIcon(VaadinIcons.USER);
		return pageLink;
}
 
源代码20 项目: sensorhub   文件: SOSConfigForm.java
@Override
public void build(String title, MyBeanItem<? extends Object> beanItem)
{
    super.build(title, beanItem);
    
    // add link to capabilities
    Property<?> endPointProp = beanItem.getItemProperty(PROP_ENDPOINT);
    if (endPointProp != null)
    {
        String baseUrl = ((String)endPointProp.getValue()).substring(1);
        String href = baseUrl + "?service=SOS&version=2.0&request=GetCapabilities";
        Link link = new Link("Link to capabilities", new ExternalResource(href), "_blank", 0, 0, null);
        this.addComponent(link, 0);
    }
}
 
源代码21 项目: mycollab   文件: ProjectAssetsUtil.java
public static Component editableProjectLogoComp(String projectShortname, Integer projectId, String projectAvatarId, int size) {
    MCssLayout wrapper = new MCssLayout();

    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT)) {
        wrapper.addStyleName(WebThemes.CURSOR_POINTER);
        wrapper.setDescription(UserUIContext.getMessage(GenericI18Enum.OPT_CHANGE_IMAGE));
        wrapper.addLayoutClickListener((LayoutEvents.LayoutClickListener) layoutClickEvent ->
                UI.getCurrent().addWindow(new ProjectLogoUploadWindow(projectShortname, projectId, projectAvatarId))
        );
    }

    if (!StringUtils.isBlank(projectAvatarId)) {
        Image image = new Image(null, new ExternalResource(StorageUtils.getResourcePath
                (String.format("%s/%s_%d.png", PathUtils.getProjectLogoPath(AppUI.getAccountId(), projectId),
                        projectAvatarId, size))));
        image.addStyleName(WebThemes.CIRCLE_BOX);
        wrapper.addComponent(image);
    } else {
        ELabel projectIcon = new ELabel(projectShortname.substring(0, 1)).withStyleName(WebThemes.TEXT_ELLIPSIS, ValoTheme.LABEL_LARGE, "center", WebThemes.CIRCLE_BOX).withDescription(projectShortname);
        projectIcon.setWidth(size, Sizeable.Unit.PIXELS);
        projectIcon.setHeight(size, Sizeable.Unit.PIXELS);
        wrapper.addComponent(projectIcon);
    }
    wrapper.setWidth(size, Sizeable.Unit.PIXELS);
    wrapper.setHeight(size, Sizeable.Unit.PIXELS);
    return wrapper;
}
 
源代码22 项目: RDFUnit   文件: TestGenerationView.java
@Override
public void sourceGenerationStarted(final Source source, TestGenerationType generationType) {
    UI.getCurrent().access(() -> {
        Link uriLink = new Link(source.getUri(), new ExternalResource(source.getUri()));
        uriLink.setTargetName("_blank");
        resultsTable.addItem(new Object[]{
                source.getClass().getSimpleName(), uriLink, new Label("-"), new Label("-")}, source);
        resultsTable.setCurrentPageFirstItemIndex(resultsTable.getCurrentPageFirstItemIndex() + 1);
        CommonAccessUtils.pushToClient();
    });


}
 
源代码23 项目: RDFUnit   文件: IntroTab.java
private void initLayout() {
    this.setMargin(true);
    this.addComponent(new Label("<h2>RDFUnit - A Unit Testing Suite for RDF</h2>", ContentMode.HTML));

    this.addComponent(new Label(
            "<p><strong>Welcome to the RDFUnit Demo</strong></p>" +
                    "<p>RDFUnit is a testing framework that can verify your data against a schema / vocabulary or custom SPARQL test cases.</p>" +
                    "<p>Please note that you cannot use all features of RDFUnit from this UI. For example, you cannot define your own tests cases or test SPARQL Endpoints directly. " +
                    "For more thorough testing please try the command line (CLI) version.</p>",
            ContentMode.HTML));

    Link homepage = new Link("Homepage", new ExternalResource("http://rdfunit.aksw.org/"));
    Link github = new Link("Github page", new ExternalResource("https://github.com/AKSW/RDFUnit"));
    Link report = new Link("Report", new ExternalResource("http://svn.aksw.org/papers/2014/WWW_Databugger/public.pdf"));

    HorizontalLayout links = new HorizontalLayout();
    this.addComponent(links);
    links.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT);
    links.addComponent(new Label("To learn more about RDFUnit you can navigate to our: &nbsp;", ContentMode.HTML));
    links.addComponent(homepage);
    links.addComponent(new Label(" / "));
    links.addComponent(github);
    links.addComponent(new Label(" / "));
    links.addComponent(report);


}
 
源代码24 项目: cuba   文件: WebLink.java
@Override
public void setUrl(String url) {
    component.setResource(new ExternalResource(url));
}
 
源代码25 项目: cuba   文件: WebUrlResource.java
@Override
protected void createResource() {
    resource = new ExternalResource(url);

    ((ExternalResource) resource).setMIMEType(mimeType);
}
 
源代码26 项目: hawkbit   文件: SPUIComponentProvider.java
/**
 * Method to create a link.
 *
 * @param id
 *            of the link
 * @param name
 *            of the link
 * @param resource
 *            path of the link
 * @param icon
 *            of the link
 * @param targetOpen
 *            specify how the link should be open (f. e. new windows = _blank)
 * @param style
 *            chosen style of the link. Might be {@code null} if no style should
 *            be used
 * @return a link UI component
 */
public static Link getLink(final String id, final String name, final String resource, final FontAwesome icon,
        final String targetOpen, final String style) {

    final Link link = new Link(name, new ExternalResource(resource));
    link.setId(id);
    link.setIcon(icon);
    link.setDescription(name);

    link.setTargetName(targetOpen);
    if (style != null) {
        link.setStyleName(style);
    }

    return link;

}
 
@Secured({ "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout content = createPanelContent();

	final String pageId = getPageId(parameters);

	getMenuItemFactory().createMainPageMenuBar(menuBar);

	final BrowserFrame browser = new BrowserFrame(ADMIN_MONITORING, new ExternalResource(MONITORING_CONTEXT_PATH));
	browser.setSizeFull();

	content.addComponent(browser);
	content.setExpandRatio(browser, ContentRatio.FULL_SIZE);

	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_MONITORING_VIEW, ApplicationEventGroup.ADMIN,
			NAME, null, pageId);

	return content;

}
 
源代码28 项目: mycollab   文件: GeneralSettingViewImpl.java
private void buildShortcutIconPanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true, false, true, false));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    ELabel logoDesc = ELabel.html(UserUIContext.getMessage(FileI18nEnum.OPT_FAVICON_FORMAT_DESCRIPTION)).withFullWidth();
    leftPanel.with(logoDesc).withWidth("250px");
    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    final Image favIconRes = new Image("", new ExternalResource(StorageUtils.getFavIconPath(billingAccount.getId(),
            billingAccount.getFaviconpath())));

    MHorizontalLayout buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(true, false, false, false));
    buttonControls.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT);
    final UploadField favIconUploadField = new UploadField() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateDisplayComponent() {
            byte[] imageData = this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
                imageData = ImageUtil.convertJpgToPngFormat(imageData);
                if (imageData == null) {
                    throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT));
                } else {
                    mimeType = "image/png";
                }
            }

            if (mimeType.equals("image/png")) {
                try {
                    AccountFavIconService favIconService = AppContextUtil.getSpringBean(AccountFavIconService.class);
                    BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData));
                    String newFavIconPath = favIconService.upload(UserUIContext.getUsername(), image, AppUI.getAccountId());
                    favIconRes.setSource(new ExternalResource(StorageUtils.getFavIconPath(billingAccount.getId(),
                            newFavIconPath)));
                    UIUtils.reloadPage();
                } catch (IOException e) {
                    throw new MyCollabException(e);
                }
            } else {
                throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT));
            }
        }
    };
    favIconUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE));
    favIconUploadField.addStyleName("upload-field");
    favIconUploadField.setSizeUndefined();
    favIconUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> {
        BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class);
        billingAccount.setFaviconpath(null);
        billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername());
        UIUtils.reloadPage();
    }).withStyleName(WebThemes.BUTTON_OPTION);
    resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    buttonControls.with(resetButton, favIconUploadField);
    rightPanel.with(favIconRes, buttonControls);
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Favicon", layout);
    this.with(formContainer);
}
 
源代码29 项目: mycollab   文件: UrlLink.java
public UrlLink(String urlLink) {
    this.setResource(new ExternalResource(urlLink));
    this.setCaption(urlLink);
    this.setTargetName("_blank");
}
 
源代码30 项目: hawkbit   文件: SPUIComponentProvider.java
/**
 * Generates help/documentation links from within management UI.
 *
 * @param i18n
 *            the i18n
 * @param uri
 *            to documentation site
 *
 * @return generated link
 */
public static Link getHelpLink(final VaadinMessageSource i18n, final String uri) {

    final Link link = new Link("", new ExternalResource(uri));
    link.setTargetName("_blank");
    link.setIcon(FontAwesome.QUESTION_CIRCLE);
    link.setDescription(i18n.getMessage("tooltip.documentation.link"));
    return link;

}