Example usage for com.vaadin.ui Link Link

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

Introduction

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

Prototype

public Link(String caption, Resource resource) 

Source Link

Document

Creates a new instance of Link.

Usage

From source file:com.klwork.explorer.ui.business.social.QQWeiboDisplayPage.java

License:Apache License

/**
 * ?/*from   w  w w  . j a va 2  s .c o m*/
 * @param userWeibo
 * @return
 */
public Link initUserScreenName(final SocialUserWeibo userWeibo) {
    Link goToMain = new Link(userWeibo.getUserScreenName() + ":",
            new ExternalResource(getWeiboMainUrl() + userWeibo.getUserName()));
    goToMain.setTargetName("_blank");
    return goToMain;
}

From source file:com.klwork.explorer.ui.business.social.QQWeiboDisplayPage.java

License:Apache License

/**
 * ?/* www  .  ja v a2s .  co  m*/
 * @param orginWeibo
 * @return
 */
@Override
public Link initRetweetedUserScreenName(final SocialUserWeibo orginWeibo) {
    Link link = new Link("@" + orginWeibo.getUserScreenName(),
            new ExternalResource(getWeiboMainUrl() + orginWeibo.getUserName()));
    link.setTargetName("_blank");
    return link;
}

From source file:com.klwork.explorer.ui.business.social.SinaWeiboDisplayPage.java

License:Apache License

/**
 * ?/* w w  w  .j a v a 2 s  .c  o  m*/
 * @param userWeibo
 * @return
 */
@Override
public Link initUserScreenName(final SocialUserWeibo userWeibo) {
    Link goToMain = new Link(userWeibo.getUserScreenName() + ":",
            new ExternalResource(getWeiboMainUrl() + userWeibo.getWeiboUid()));
    goToMain.setTargetName("_blank");
    return goToMain;
}

From source file:com.klwork.explorer.ui.business.social.SinaWeiboDisplayPage.java

License:Apache License

/**
 * ?/*from w w  w.  j a v  a2s . c o  m*/
 * @param orginWeibo
 * @return
 */
@Override
public Link initRetweetedUserScreenName(final SocialUserWeibo orginWeibo) {
    Link link = new Link("@" + orginWeibo.getUserScreenName(),
            new ExternalResource(getWeiboMainUrl() + orginWeibo.getWeiboId()));
    link.setTargetName("_blank");
    return link;
}

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  w ww .j  ava 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.klwork.explorer.ui.content.GenericAttachmentRenderer.java

License:Apache License

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

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

    HorizontalLayout linkLayout = new HorizontalLayout();
    linkLayout.setSpacing(true);
    verticalLayout.addComponent(linkLayout);

    // Image
    linkLayout.addComponent(new Embedded(null, getImage(attachment)));

    // Link
    Link link = null;
    if (attachment.getUrl() != null) {
        link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
        TaskService 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);
    }

    // Set generic image and external window 
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    linkLayout.addComponent(link);

    return verticalLayout;
}

From source file:com.klwork.explorer.ui.content.url.UrlAttachmentRenderer.java

License:Apache License

public Component getOverviewComponent(final Attachment attachment, final RelatedContentComponent parent) {

    // If the attachment has no description, overview link is link to actual page
    // instead of showing popup with details.
    if (attachment.getDescription() != null && !"".equals(attachment.getDescription())) {
        Button attachmentLink = new Button(attachment.getName());
        attachmentLink.addStyleName(Reindeer.BUTTON_LINK);

        attachmentLink.addListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                parent.showAttachmentDetail(attachment);
            }//  w  w  w. ja  v a  2  s. co m
        });
        return attachmentLink;
    } else {
        return new Link(attachment.getName(), new ExternalResource(attachment.getUrl()));
    }
}

From source file:com.klwork.explorer.ui.content.url.UrlAttachmentRenderer.java

License:Apache License

public Component getDetailComponent(Attachment attachment) {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);/*from   ww  w . ja va2 s .  c  om*/
    verticalLayout.setMargin(true);

    verticalLayout.addComponent(new Label(attachment.getDescription()));

    HorizontalLayout linkLayout = new HorizontalLayout();
    linkLayout.setSpacing(true);
    verticalLayout.addComponent(linkLayout);

    // Icon
    linkLayout.addComponent(new Embedded(null, Images.RELATED_CONTENT_URL));

    // Link
    Link link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    linkLayout.addComponent(link);

    return verticalLayout;
}

From source file:com.klwork.explorer.ui.main.views.AuthenticatedView.java

License:Apache License

@PostConstruct
public void PostConstruct() {
    setSizeFull();//from   w  w w  .  j av a 2 s.  co  m
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    layout.addComponent(new Label("@RequiresAuthentication"));
    layout.addComponent(new Link("Go back", new ExternalResource("#!" + MainView.NAME)));

    setContent(layout);
}

From source file:com.klwork.explorer.ui.main.views.GuestView.java

License:Apache License

@PostConstruct
public void PostConstruct() {
    setSizeFull();/*from  www .j  a v  a2  s .c om*/
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    layout.addComponent(new Label("@RequiresGuest"));
    layout.addComponent(new Link("Go back", new ExternalResource("#!" + MainView.NAME)));

    setContent(layout);
}