Example usage for com.vaadin.ui Link setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.esofthead.mycollab.vaadin.ui.form.field.UrlLinkViewField.java

License:Open Source License

@Override
protected Component initContent() {
    if (StringUtils.isBlank(url)) {
        Label lbl = new Label(" ");
        lbl.setContentMode(ContentMode.HTML);
        lbl.setWidth("100%");
        return lbl;
    } else {/*www.  ja  v  a 2 s .  c  om*/
        final Link link = new UrlLink(url);
        link.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH);
        return link;
    }
}

From source file:com.esofthead.mycollab.vaadin.ui.form.field.UrlSocialNetworkLinkViewField.java

License:Open Source License

@Override
protected Component initContent() {
    if (StringUtils.isBlank(caption)) {
        Label lbl = new Label(" ");
        lbl.setContentMode(ContentMode.HTML);
        lbl.setWidth("100%");
        return lbl;
    } else {// ww  w . j  av  a 2s. c o  m
        linkAccount = (linkAccount == null) ? "" : linkAccount;
        final Link link = new SocialNetworkLink(caption, linkAccount);
        link.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH);
        return link;
    }
}

From source file:com.esofthead.mycollab.vaadin.web.ui.AttachmentDisplayComponent.java

License:Open Source License

public void addAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }//from   w  ww  .  j a v  a  2  s. com

    final AbsoluteLayout attachmentLayout = new AbsoluteLayout();
    attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentLayout.setHeight(UIConstants.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.getInstance().getResource(attachment.getThumbnail()));
    }

    if (MimeTypesUtil.isImageType(docName)) {
        thumbnail.setResource(VaadinResourceFactory.getInstance().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("Size: " + FileUtils.getVolumeDisplay(attachment.getSize())))
            .setStyle("line-height:1.5em");
    ul.appendChild(new Li().appendText(
            "Last modified: " + AppContext.formatPrettyTime(attachment.getLastModified().getTime())));
    contentTooltip.appendChild(ul);
    thumbnail.setDescription(contentTooltip.write());
    thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    thumbnailWrap.addComponent(thumbnail);

    attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;");

    CssLayout attachmentNameWrap = new CssLayout();
    attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentNameWrap.setStyleName("attachment-name-wrap");

    Label attachmentName = new Label(StringUtils.trim(docName, 60, true));
    attachmentName.setStyleName("attachment-name");
    attachmentNameWrap.addComponent(attachmentName);
    attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;");

    Button trashBtn = new Button(null, new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()),
                    AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                    AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                ResourceService attachmentService = AppContextUtil
                                        .getSpringBean(ResourceService.class);
                                attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(),
                                        AppContext.getAccountId());
                                ((ComponentContainer) attachmentLayout.getParent())
                                        .removeComponent(attachmentLayout);
                            }
                        }
                    });

        }
    });
    trashBtn.setIcon(FontAwesome.TRASH_O);
    trashBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;");

    Button downloadBtn = new Button();
    FileDownloader fileDownloader = new FileDownloader(
            VaadinResourceFactory.getInstance().getStreamResource(attachment.getPath()));
    fileDownloader.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;");
    this.addComponent(attachmentLayout);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.field.UrlSocialNetworkLinkViewField.java

License:Open Source License

@Override
protected Component initContent() {
    if (StringUtils.isBlank(caption)) {
        Label lbl = new Label(" ");
        lbl.setContentMode(ContentMode.HTML);
        lbl.setWidth("100%");
        return lbl;
    } else {//from  w  w w  .  j  a v a 2s .  c o  m
        linkAccount = (linkAccount == null) ? "" : linkAccount;
        final Link link = new Link();
        link.setResource(new ExternalResource(linkAccount));
        link.setCaption(caption);
        link.setTargetName("_blank");
        link.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH);
        return link;
    }
}

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());
    }//from  w  ww. j a v a  2  s  .c  om

    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:fr.amapj.view.engine.tools.table.complex.ComplexTableBuilder.java

License:Open Source License

private Link createLink(String msg, int taille, ToGenerator<T> generator, T t) {
    Link l = LinkCreator.createLink(generator.getGenerator(t));

    l.setCaption(msg);/*from   w w  w  .j av a  2 s .  c o m*/
    l.addStyleName("align-center");
    l.setWidth(taille + "px");
    l.setImmediate(true);

    return l;
}