Example usage for com.vaadin.ui Link setIcon

List of usage examples for com.vaadin.ui Link setIcon

Introduction

In this page you can find the example usage for com.vaadin.ui Link setIcon.

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

From source file:com.hack23.cia.web.impl.ui.application.views.common.pagelinks.impl.PageLinkFactoryImpl.java

License:Apache License

@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(FontAwesome.GROUP);
    return pageLink;
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.pagelinks.impl.PageLinkFactoryImpl.java

License:Apache License

@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(FontAwesome.BUG);
    return pageLink;
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.pagelinks.impl.PageLinkFactoryImpl.java

License:Apache License

@Override
public Link createSearchDocumentViewPageLink() {
    final Link pageLink = new Link(SEARCH,
            new ExternalResource(PAGE_PREFIX + UserViews.SEARCH_DOCUMENT_VIEW_NAME));
    pageLink.setId(ViewAction.VISIT_DOCUMENT_VIEW.name());
    pageLink.setIcon(FontAwesome.SEARCH);

    return pageLink;
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.pagelinks.impl.PageLinkFactoryImpl.java

License:Apache License

@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(FontAwesome.SERVER);

    return pageLink;
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.pagelinks.impl.PageLinkFactoryImpl.java

License:Apache License

@Override
public Link createUserHomeViewPageLink() {
    final Link pageLink = new Link("User account:" + UserContextUtil.getUserNameFromSecurityContext(),
            new ExternalResource(PAGE_PREFIX + UserViews.USERHOME_VIEW_NAME));
    pageLink.setId(ViewAction.VISIT_USER_HOME_VIEW.name());
    pageLink.setIcon(FontAwesome.USER);
    return pageLink;
}

From source file:com.klwork.explorer.ui.content.file.ImageAttachmentRenderer.java

License:Apache License

@Override
public Component getDetailComponent(Attachment attachment) {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeUndefined();/*from ww  w .ja  v  a  2s.c  om*/
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);

    Label description = new Label(attachment.getDescription());
    description.setSizeUndefined();
    verticalLayout.addComponent(description);

    // Image
    TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();

    String mimeType = extractMineType(attachment.getType());

    InputStream imageStream = ImageUtil.resizeImage(taskService.getAttachmentContent(attachment.getId()),
            mimeType, 900, 550);
    Resource resource = new StreamResource(new InputStreamStreamSource(imageStream),
            attachment.getName() + extractExtention(attachment.getType()));
    Embedded image = new Embedded(null, resource);
    verticalLayout.addComponent(image);

    // Linke
    HorizontalLayout LinkLayout = new HorizontalLayout();
    LinkLayout.setSpacing(true);
    verticalLayout.addComponent(LinkLayout);
    verticalLayout.setComponentAlignment(LinkLayout, Alignment.MIDDLE_CENTER);

    Label fullSizeLabel = new Label(
            ViewToolManager.getI18nManager().getMessage(Messages.RELATED_CONTENT_SHOW_FULL_SIZE));
    LinkLayout.addComponent(fullSizeLabel);

    Link link = null;
    if (attachment.getUrl() != null) {
        link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
        taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
        Resource res = new StreamResource(
                new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())),
                attachment.getName() + extractExtention(attachment.getType()));

        link = new Link(attachment.getName(), res);
    }

    link.setIcon(Images.RELATED_CONTENT_PICTURE);
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    LinkLayout.addComponent(link);

    return verticalLayout;
}

From source file:com.liferay.mail.vaadin.PreferencesView.java

License:Open Source License

public PreferencesView(final Controller controller) {

    this.controller = controller;

    setSpacing(true);/*from  w w  w .  j  a  va2 s  .  co  m*/

    accountPanel = new Panel(Lang.get("your-email-accounts"));
    updateAccountList();
    addComponent(accountPanel);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    addComponent(buttons);

    Button createAccountButton = new Button(Lang.get("create-account"));
    createAccountButton.addListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            editAccount(null);
        }
    });
    buttons.addComponent(createAccountButton);

    Button createGmailButton = new Button("Create GMail account");
    createGmailButton.addListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            editGmailAccount(null);

        }
    });
    buttons.addComponent(createGmailButton);

    Link poweredByVaadin = new Link("", new ExternalResource("http://vaadin.com"));
    poweredByVaadin.setIcon(new PortletResource("images/vaadin/powered-by-vaadin.png"));
    poweredByVaadin.setDescription("Mail portlet interface created using Vaadin - RIA's with pure Java.");
    addComponent(poweredByVaadin);
}

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 .  j  a va  2 s .co  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:de.catma.ui.CatmaApplication.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    backgroundService = new UIBackgroundService(true);

    storeParameters(request.getParameterMap());

    Page.getCurrent().setTitle("CATMA 5.0 " + MINORVERSION);

    mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();/*from w ww .ja va 2 s .  com*/

    menuPanel = new Panel();
    menuPanel.addStyleName("menuPanel");
    mainLayout.addComponent(menuPanel);

    contentPanel = new Panel();
    contentPanel.setHeight("100%");
    contentPanel.addStyleName("contentPanel");

    defaultContentPanelLabel = new Label("Please log in to get started");
    defaultContentPanelLabel.addStyleName("defaultContentPanelLabel");
    contentPanel.setContent(defaultContentPanelLabel);

    mainLayout.addComponent(contentPanel);
    mainLayout.setExpandRatio(contentPanel, 1.0f);

    menuLayout = new HorizontalLayout();
    menuLayout.setMargin(true);
    menuLayout.setSpacing(true);

    logoResource = new ThemeResource("catma-logo.png");
    Link logoImage = new Link(null, new ExternalResource("http://www.catma.de"));
    logoImage.setIcon(logoResource);
    logoImage.setTargetName("_blank");
    menuLayout.addComponent(logoImage);

    MenuFactory menuFactory = new MenuFactory();
    try {

        initTempDirectory();
        tagManager = new TagManager();

        repositoryManagerView = new RepositoryManagerView(
                new RepositoryManager(this, tagManager, RepositoryProperties.INSTANCE.getProperties()));

        tagManagerView = new TagManagerView(tagManager);

        taggerManagerView = new TaggerManagerView();

        analyzerManagerView = new AnalyzerManagerView();

        visualizationManagerView = new VisualizationManagerView();

        menu = menuFactory.createMenu(menuLayout, contentPanel,
                new MenuFactory.MenuEntryDefinition("Repository Manager", repositoryManagerView),
                new MenuFactory.MenuEntryDefinition("Tag Type Manager", tagManagerView),
                new MenuFactory.MenuEntryDefinition("Tagger", taggerManagerView),
                new MenuFactory.MenuEntryDefinition("Analyzer", analyzerManagerView),
                new MenuFactory.MenuEntryDefinition("Visualizer", visualizationManagerView));
        addPropertyChangeListener(CatmaApplicationEvent.userChange, menu.userChangeListener);

        Link latestFeaturesLink = new Link("Latest Features",
                new ExternalResource("http://www.catma.de/latestfeatures"));
        latestFeaturesLink.setTargetName("_blank");
        menuLayout.addComponent(latestFeaturesLink);
        menuLayout.setComponentAlignment(latestFeaturesLink, Alignment.TOP_RIGHT);
        menuLayout.setExpandRatio(latestFeaturesLink, 1.0f);

        Link aboutLink = new Link("About", new ExternalResource("http://www.catma.de"));
        aboutLink.setTargetName("_blank");
        menuLayout.addComponent(aboutLink);
        menuLayout.setComponentAlignment(aboutLink, Alignment.TOP_RIGHT);

        Link termsOfUseLink = new Link("Terms of Use", new ExternalResource("http://www.catma.de/termsofuse"));
        termsOfUseLink.setTargetName("_blank");
        menuLayout.addComponent(termsOfUseLink);
        menuLayout.setComponentAlignment(termsOfUseLink, Alignment.TOP_RIGHT);

        Link manualLink = new Link("Manual", new ExternalResource(request.getContextPath() + "/manual/"));
        manualLink.setTargetName("_blank");
        menuLayout.addComponent(manualLink);
        menuLayout.setComponentAlignment(manualLink, Alignment.TOP_RIGHT);

        Link helpLink = new Link("Helpdesk", new ExternalResource("http://www.catma.de/helpdesk/"));
        helpLink.setTargetName("_blank");
        menuLayout.addComponent(helpLink);
        menuLayout.setComponentAlignment(helpLink, Alignment.TOP_RIGHT);
        helpLink.setVisible(false);

        btHelp = new Button(FontAwesome.QUESTION_CIRCLE);
        btHelp.addStyleName("help-button");
        btHelp.addStyleName("application-help-button");

        menuLayout.addComponent(btHelp);

        btHelp.addClickListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {

                if (uiHelpWindow.getParent() == null) {
                    UI.getCurrent().addWindow(uiHelpWindow);
                } else {
                    UI.getCurrent().removeWindow(uiHelpWindow);
                }

            }
        });

        LoginLogoutCommand loginLogoutCommand = new LoginLogoutCommand(menu, repositoryManagerView);
        Button btloginLogout = new Button("Sign in", event -> loginLogoutCommand.menuSelected(null));
        btloginLogout.setStyleName(BaseTheme.BUTTON_LINK);
        btloginLogout.addStyleName("application-loginlink");

        loginLogoutCommand.setLoginLogoutButton(btloginLogout);

        menuLayout.addComponent(btloginLogout);
        menuLayout.setComponentAlignment(btloginLogout, Alignment.TOP_RIGHT);
        menuLayout.setWidth("100%");

        menuPanel.setContent(menuLayout);

        setContent(mainLayout);

        if (getParameter(Parameter.USER_IDENTIFIER) != null) {
            btloginLogout.click();
        }

        setPollInterval(10000);

        if ((getParameter(Parameter.AUTOLOGIN) != null) && (getUser() == null)) {
            getPage().setLocation(repositoryManagerView.createAuthenticationDialog().createLogInClick(this,
                    RepositoryPropertyKey.CATMA_oauthAuthorizationCodeRequestURL.getValue(),
                    RepositoryPropertyKey.CATMA_oauthAccessTokenRequestURL.getValue(),
                    RepositoryPropertyKey.CATMA_oauthClientId.getValue(),
                    RepositoryPropertyKey.CATMA_oauthClientSecret.getValue(), URLEncoder.encode("/", "UTF-8")));
        }

    } catch (Exception e) {
        showAndLogError("The system could not be initialized!", e);
    }

}

From source file:de.catma.ui.repository.AuthenticationDialog.java

License:Open Source License

private Link createLogInLink(final Application application) {
    try {//from   w ww  . j  a  v a 2  s . c o  m
        ConsumerManager consumerManager = new ConsumerManager();

        String returnURL = application.getURL().toString() + new IDGenerator().generate();
        logger.info("return url in login link creation " + returnURL);

        @SuppressWarnings("rawtypes")
        List discoveries = consumerManager.discover(this.providerIdent);
        final DiscoveryInformation discovered = consumerManager.associate(discoveries);
        logger.info("endpoint from consumer manager: " + discovered.getOPEndpoint().toString());
        Association assoc = consumerManager.getAssociations().load(discovered.getOPEndpoint().toString());
        final String handle = assoc.getHandle();
        logger.info("handle from consumer manager: " + handle);

        AuthRequest authReq = consumerManager.authenticate(discovered, returnURL);
        FetchRequest fetch = FetchRequest.createFetchRequest();
        fetch.addAttribute("email",
                // attribute alias
                "http://schema.openid.net/contact/email", // type URI
                true); // required

        // attach the extension to the authentication request
        authReq.addExtension(fetch);

        ClassResource icon = new ClassResource("ui/repository/resources/google.png", application);
        Link logInLink = new Link("Log in via Google", new ExternalResource(authReq.getDestinationUrl(true)));
        logInLink.setIcon(icon);

        final AuthenticationParamHandler authenticationParamHandler = new AuthenticationParamHandler(
                application, returnURL, consumerManager, discovered, repositoryReference, repositoryManager,
                dialogWindow, handle);

        application.getMainWindow().addParameterHandler(authenticationParamHandler);
        application.getMainWindow().addURIHandler(authenticationParamHandler);

        btCancel.addListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {
                application.getMainWindow().removeParameterHandler(authenticationParamHandler);
                application.getMainWindow().removeURIHandler(authenticationParamHandler);
                application.getMainWindow().removeWindow(dialogWindow);
            }
        });

        return logInLink;
    } catch (Exception e) {
        e.printStackTrace(); //TODO: handle
    }
    return null;
}