Example usage for com.vaadin.ui CssLayout addComponent

List of usage examples for com.vaadin.ui CssLayout addComponent

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.esofthead.mycollab.common.ui.components.CommentRowDisplayHandler.java

License:Open Source License

@Override
public Component generateRow(final SimpleComment comment, int rowIndex) {
    final MHorizontalLayout layout = new MHorizontalLayout().withSpacing(true).withMargin(false)
            .withWidth("100%").withStyleName("message");

    MVerticalLayout userBlock = new MVerticalLayout().withSpacing(true).withMargin(false).withWidth("80px");
    userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    ClickListener gotoUser = new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//  w  w  w. j  a v  a2 s  .  c o m
        public void buttonClick(ClickEvent event) {
            EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoRead(this, comment.getCreateduser()));
        }
    };
    Button userAvatarBtn = UserAvatarControlFactory.createUserAvatarButtonLink(comment.getOwnerAvatarId(),
            comment.getOwnerFullName());
    userAvatarBtn.addClickListener(gotoUser);
    userBlock.addComponent(userAvatarBtn);

    Button userName = new Button(comment.getOwnerFullName());
    userName.setStyleName("user-name");
    userName.addStyleName("link");
    userName.addStyleName(UIConstants.WORD_WRAP);
    userName.addClickListener(gotoUser);
    userBlock.addComponent(userName);
    layout.addComponent(userBlock);

    CssLayout rowLayout = new CssLayout();
    rowLayout.setStyleName("message-container");
    rowLayout.setWidth("100%");

    MHorizontalLayout messageHeader = new MHorizontalLayout().withSpacing(true)
            .withMargin(new MarginInfo(true, true, false, true)).withWidth("100%")
            .withStyleName("message-header");
    messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    Label timePostLbl = new Label(
            AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(),
                    DateTimeUtils.getPrettyDateValue(comment.getCreatedtime(), AppContext.getUserLocale())),
            ContentMode.HTML);
    timePostLbl.setDescription(AppContext.formatDateTime(comment.getCreatedtime()));

    timePostLbl.setSizeUndefined();
    timePostLbl.setStyleName("time-post");
    messageHeader.addComponent(timePostLbl);
    messageHeader.setExpandRatio(timePostLbl, 1.0f);

    // Message delete button
    Button msgDeleteBtn = new Button();
    msgDeleteBtn.setIcon(FontAwesome.TRASH_O);
    msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY);
    messageHeader.addComponent(msgDeleteBtn);

    if (hasDeletePermission(comment)) {
        msgDeleteBtn.setVisible(true);
        msgDeleteBtn.addClickListener(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,
                                SiteConfiguration.getSiteName()),
                        AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                        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()) {
                                    CommentService commentService = ApplicationContextUtil
                                            .getSpringBean(CommentService.class);
                                    commentService.removeWithSession(comment.getId(), AppContext.getUsername(),
                                            AppContext.getAccountId());
                                    CommentRowDisplayHandler.this.owner.removeRow(layout);
                                }
                            }
                        });
            }
        });
    } else {
        msgDeleteBtn.setVisible(false);
    }

    rowLayout.addComponent(messageHeader);

    Label messageContent = new UrlDetectableLabel(comment.getComment());
    messageContent.setStyleName("message-body");
    rowLayout.addComponent(messageContent);

    List<Content> attachments = comment.getAttachments();
    if (!CollectionUtils.isEmpty(attachments)) {
        MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withMargin(true)
                .withWidth("100%").withStyleName("message-footer");
        AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments);
        attachmentDisplay.setWidth("100%");
        messageFooter.addComponent(attachmentDisplay);
        messageFooter.setComponentAlignment(attachmentDisplay, Alignment.MIDDLE_RIGHT);
        rowLayout.addComponent(messageFooter);
    }

    layout.addComponent(rowLayout);
    layout.setExpandRatio(rowLayout, 1.0f);
    return layout;
}

From source file:com.esofthead.mycollab.community.ui.chart.GenericChartWrapper.java

License:Open Source License

public void setSearchCriteria(final S criteria) {
    this.searchCriteria = criteria;

    final JFreeChart chart = createChart();
    final JFreeChartWrapper chartWrapper = new JFreeChartWrapper(chart);

    removeAllComponents();/*from  w w w  .ja v  a  2 s  .  c o m*/
    final CssLayout borderWrap = new CssLayout();
    borderWrap.addComponent(chartWrapper);
    borderWrap.setStyleName("chart-wrapper");
    borderWrap.setHeight(height + "px");
    borderWrap.setWidth(width + "px");
    chartWrapper.setHeight(height + "px");
    chartWrapper.setWidth(width + "px");
    chartWrapper.setGraphHeight(height);
    chartWrapper.setGraphWidth(width);
    this.addComponent(borderWrap);
    this.setComponentAlignment(borderWrap, Alignment.MIDDLE_CENTER);
    final Component legendBox = createLegendBox();
    this.addComponent(legendBox);
    this.setComponentAlignment(legendBox, Alignment.MIDDLE_CENTER);
}

From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java

License:Open Source License

@Override
protected final ComponentContainer createLegendBox() {
    final CustomLayout boxWrapper = CustomLayoutExt.createLayout("legendBox");
    final CssLayout mainLayout = new CssLayout();

    mainLayout.setSizeUndefined();//from  w  ww .  ja v a 2s .co  m
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        final HorizontalLayout layout = new HorizontalLayout();
        layout.setMargin(new MarginInfo(false, false, false, true));
        layout.addStyleName("inline-block");
        final Comparable key = (Comparable) keys.get(i);
        final String color = "<div style = \" width:8px;height:8px;border-radius:5px;background: #"
                + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length] + "\" />";
        final Label lblCircle = new Label(color);
        lblCircle.setContentMode(ContentMode.HTML);

        String btnCaption;
        if (enumKeyCls == null) {
            btnCaption = String.format("%s(%d)", key, pieDataSet.getValue(key).intValue());
        } else {
            btnCaption = String.format("%s(%d)", AppContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        final Button btnLink = new Button(btnCaption, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                PieChartWrapper.this.onClickedDescription(key.toString());
            }
        });
        btnLink.addStyleName("link");
        layout.addComponent(lblCircle);
        layout.setComponentAlignment(lblCircle, Alignment.MIDDLE_CENTER);
        layout.addComponent(btnLink);
        layout.setComponentAlignment(btnLink, Alignment.MIDDLE_CENTER);
        layout.setSizeUndefined();
        mainLayout.addComponent(layout);
    }
    boxWrapper.setWidth("100%");
    boxWrapper.addComponent(mainLayout, "legendBoxContent");
    return boxWrapper;
}

From source file:com.esofthead.mycollab.mobile.module.crm.view.CrmLoginViewImpl.java

License:Open Source License

private void initUI() {
    this.setStyleName("login-view");
    this.setSizeFull();

    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setStyleName("content-wrapper");
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    contentLayout.setMargin(true);/*from ww w.ja  v  a  2s  . c om*/
    contentLayout.setSpacing(true);
    contentLayout.setWidth("320px");

    Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png"));
    contentLayout.addComponent(mainLogo);

    Label introText = new Label(
            "MyCollab helps you do all your office jobs on the computers, phones and tablets you use");
    introText.setStyleName("intro-text");
    contentLayout.addComponent(introText);

    CssLayout welcomeTextWrapper = new CssLayout();
    welcomeTextWrapper.setStyleName("welcometext-wrapper");
    welcomeTextWrapper.setWidth("100%");
    Label welcomeText = new Label("Login to CRM");
    welcomeText.setWidth("150px");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeTextWrapper);

    final EmailField emailField = new EmailField();
    emailField.setWidth("100%");
    emailField.setInputPrompt("E-mail Address");
    emailField.setStyleName("email-input");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    pwdField.setInputPrompt("Password");
    pwdField.setStyleName("password-input");
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox();
    rememberPassword.setWidth("100%");
    rememberPassword.setCaption("Remember password");
    rememberPassword.setValue(true);
    contentLayout.addComponent(rememberPassword);

    Button signInBtn = new Button("Sign In");
    signInBtn.setWidth("100%");
    signInBtn.addStyleName(UIConstants.BUTTON_BIG);
    signInBtn.addStyleName(UIConstants.COLOR_BLUE);
    signInBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new CrmEvent.PlainLogin(this, new String[] {
                    emailField.getValue(), pwdField.getValue(), String.valueOf(rememberPassword.getValue()) }));
        }
    });
    contentLayout.addComponent(signInBtn);

    Button createAccountBtn = new Button("Create Account");
    createAccountBtn.setWidth("100%");
    createAccountBtn.addStyleName(UIConstants.BUTTON_BIG);
    createAccountBtn.addStyleName(UIConstants.COLOR_GRAY);
    contentLayout.addComponent(createAccountBtn);

    this.addComponent(contentLayout);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.form.field.ProjectFormAttachmentUploadField.java

License:Open Source License

protected void constructUI() {
    content = new VerticalLayout();
    content.setStyleName("attachment-field");

    rowWrap = new VerticalLayout();
    rowWrap.setWidth("100%");
    rowWrap.setStyleName("attachment-row-wrap");

    Label compHeader = new Label(AppContext.getMessage(GenericI18Enum.M_FORM_ATTACHMENT));
    compHeader.setStyleName("h2");

    content.addComponent(compHeader);// ww w .  j  a  v  a  2 s  .  c  o m

    CssLayout btnWrap = new CssLayout();
    btnWrap.setWidth("100%");
    btnWrap.setStyleName("attachment-row");
    btnWrap.addComponent(attachmentBtn);

    content.addComponent(btnWrap);

    content.addComponent(rowWrap);
}

From source file:com.esofthead.mycollab.mobile.module.project.view.message.MessageReadViewImpl.java

License:Open Source License

@Override
public void previewItem(SimpleMessage message) {
    this.bean = message;
    mainLayout.removeAllComponents();/*from www  .j a  v  a 2s .co  m*/

    HorizontalLayout messageBlock = new HorizontalLayout();
    messageBlock.setStyleName("message-block");
    Image userAvatarImg = UserAvatarControlFactory
            .createUserAvatarEmbeddedComponent(message.getPostedUserAvatarId(), 32);
    userAvatarImg.setStyleName("user-avatar");
    messageBlock.addComponent(userAvatarImg);

    CssLayout rightCol = new CssLayout();
    rightCol.setWidth("100%");

    HorizontalLayout metadataRow = new HorizontalLayout();
    metadataRow.setWidth("100%");
    metadataRow.setStyleName("metadata-row");
    Label userNameLbl = new Label(message.getFullPostedUserName());
    userNameLbl.setStyleName("user-name");
    metadataRow.addComponent(userNameLbl);
    metadataRow.setExpandRatio(userNameLbl, 1.0f);

    Label messageTimePost = new Label(
            DateTimeUtils.getPrettyDateValue(message.getPosteddate(), AppContext.getUserLocale()));
    messageTimePost.setStyleName("time-post");
    messageTimePost.setWidthUndefined();
    metadataRow.addComponent(messageTimePost);
    rightCol.addComponent(metadataRow);

    HorizontalLayout titleRow = new HorizontalLayout();
    titleRow.setWidth("100%");
    titleRow.setStyleName("title-row");
    Label messageTitle = new Label(message.getTitle());
    messageTitle.setStyleName("message-title");
    titleRow.addComponent(messageTitle);
    titleRow.setExpandRatio(messageTitle, 1.0f);

    if (message.getCommentsCount() > 0) {
        Label msgCommentCount = new Label(String.valueOf(message.getCommentsCount()));
        msgCommentCount.setStyleName("comment-count");
        msgCommentCount.setWidthUndefined();
        titleRow.addComponent(msgCommentCount);
        titleRow.addStyleName("has-comment");
        titleRow.setComponentAlignment(messageTitle, Alignment.MIDDLE_LEFT);
    }
    rightCol.addComponent(titleRow);

    Label messageContent = new Label(
            StringUtils.trim(StringUtils.trimHtmlTags(message.getMessage()), 150, true));
    messageContent.setStyleName("message-content");
    rightCol.addComponent(messageContent);

    ResourceService attachmentService = ApplicationContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = attachmentService
            .getContents(AttachmentUtils.getProjectEntityAttachmentPath(AppContext.getAccountId(),
                    message.getProjectid(), AttachmentType.PROJECT_MESSAGE, message.getId()));
    if (attachments != null && !attachments.isEmpty()) {
        CssLayout attachmentPanel = new CssLayout();
        attachmentPanel.setStyleName("attachment-panel");
        attachmentPanel.setWidth("100%");

        for (Content attachment : attachments) {
            attachmentPanel.addComponent(MobileAttachmentUtils.renderAttachmentRow(attachment));
        }
        rightCol.addComponent(attachmentPanel);
    }

    messageBlock.addComponent(rightCol);
    messageBlock.setExpandRatio(rightCol, 1.0f);
    messageBlock.setWidth("100%");

    mainLayout.addComponent(messageBlock);

    MessageCommentListDisplay commentDisplay = new MessageCommentListDisplay(CommentType.PRJ_MESSAGE,
            CurrentProjectVariables.getProjectId(), true, true, MessageRelayEmailNotificationAction.class);
    commentDisplay.loadComments("" + message.getId());

    this.setToolbar(commentDisplay.getCommentBox());
    mainLayout.addComponent(commentDisplay);
}

From source file:com.esofthead.mycollab.mobile.module.project.view.ProjectLoginViewImpl.java

License:Open Source License

private void initUI() {
    this.setStyleName("login-view");
    this.setSizeFull();

    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setStyleName("content-wrapper");
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    contentLayout.setMargin(true);// www  .  j a v  a 2s  . c  om
    contentLayout.setSpacing(true);
    contentLayout.setWidth("320px");

    Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png"));
    contentLayout.addComponent(mainLogo);

    Label introText = new Label(
            "MyCollab helps you do all your office jobs on the computers, phones and tablets you use");
    introText.setStyleName("intro-text");
    contentLayout.addComponent(introText);

    CssLayout welcomeTextWrapper = new CssLayout();
    welcomeTextWrapper.setStyleName("welcometext-wrapper");
    welcomeTextWrapper.setWidth("100%");
    Label welcomeText = new Label("Login to Projects");
    welcomeText.setWidth("150px");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeTextWrapper);

    final EmailField emailField = new EmailField();
    emailField.setWidth("100%");
    emailField.setInputPrompt("E-mail Address");
    emailField.setStyleName("email-input");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    pwdField.setInputPrompt("Password");
    pwdField.setStyleName("password-input");
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox();
    rememberPassword.setWidth("100%");
    rememberPassword.setCaption("Remember password");
    rememberPassword.setValue(true);
    contentLayout.addComponent(rememberPassword);

    Button signInBtn = new Button("Sign In");
    signInBtn.setWidth("100%");
    signInBtn.addStyleName(UIConstants.BUTTON_BIG);
    signInBtn.addStyleName(UIConstants.COLOR_BLUE);
    signInBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new ProjectEvent.PlainLogin(this, new String[] {
                    emailField.getValue(), pwdField.getValue(), String.valueOf(rememberPassword.getValue()) }));
        }
    });
    contentLayout.addComponent(signInBtn);

    Button createAccountBtn = new Button("Create Account");
    createAccountBtn.setWidth("100%");
    createAccountBtn.addStyleName(UIConstants.BUTTON_BIG);
    createAccountBtn.addStyleName(UIConstants.COLOR_GRAY);
    contentLayout.addComponent(createAccountBtn);

    this.addComponent(contentLayout);
}

From source file:com.esofthead.mycollab.mobile.module.user.view.LoginViewImpl.java

License:Open Source License

private void initUI() {
    this.setStyleName("login-view");
    this.setSizeFull();

    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setStyleName("content-wrapper");
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    contentLayout.setMargin(true);/*from  ww w.  ja v a 2 s . c o m*/
    contentLayout.setSpacing(true);
    contentLayout.setWidth("320px");

    Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png"));
    contentLayout.addComponent(mainLogo);

    Label introText = new Label(
            "MyCollab helps you do all your office jobs on the computers, phones and tablets you use");
    introText.setStyleName("intro-text");
    contentLayout.addComponent(introText);

    CssLayout welcomeTextWrapper = new CssLayout();
    welcomeTextWrapper.setStyleName("welcometext-wrapper");
    welcomeTextWrapper.setWidth("100%");
    welcomeTextWrapper.setHeight("15px");
    Label welcomeText = new Label("Welcome Back!");
    welcomeText.setWidth("150px");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeTextWrapper);

    final EmailField emailField = new EmailField();
    emailField.setWidth("100%");
    emailField.setInputPrompt("E-mail Address");
    emailField.setStyleName("email-input");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    pwdField.setInputPrompt("Password");
    pwdField.setStyleName("password-input");
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox();
    rememberPassword.setWidth("100%");
    rememberPassword.setCaption("Remember password");
    rememberPassword.setValue(true);
    contentLayout.addComponent(rememberPassword);

    Button signInBtn = new Button("Sign In");
    signInBtn.setWidth("100%");
    signInBtn.addStyleName(UIConstants.BUTTON_BIG);
    signInBtn.addStyleName(UIConstants.COLOR_BLUE);
    signInBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            ShellController.doLogin(emailField.getValue(), pwdField.getValue(), rememberPassword.getValue());
        }
    });
    contentLayout.addComponent(signInBtn);

    Button createAccountBtn = new Button("Create Account");
    createAccountBtn.setWidth("100%");
    createAccountBtn.addStyleName(UIConstants.BUTTON_BIG);
    createAccountBtn.addStyleName(UIConstants.COLOR_GRAY);
    contentLayout.addComponent(createAccountBtn);

    this.addComponent(contentLayout);
}

From source file:com.esofthead.mycollab.mobile.ui.MobileAttachmentUtils.java

License:Open Source License

public static Component renderAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    HorizontalLayout attachmentRow = new HorizontalLayout();
    attachmentRow.setStyleName("attachment-row");
    attachmentRow.setWidth("100%");
    attachmentRow.setSpacing(true);//w w w  . j a  v a2 s  .c om
    attachmentRow.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setWidth("25px");
    thumbnailWrap.setHeight("40px");
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Image thumbnail = new Image(null);
    if (org.apache.commons.lang3.StringUtils.isBlank(attachment.getThumbnail())) {
        thumbnail.setSource(DEFAULT_SOURCE);
    } else {
        thumbnail.setSource(VaadinResourceManager.getResourceManager()
                .getImagePreviewResource(attachment.getThumbnail(), DEFAULT_SOURCE));
    }
    thumbnail.setWidth("100%");
    thumbnailWrap.addComponent(thumbnail);
    attachmentRow.addComponent(thumbnailWrap);

    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }

    if (MimeTypesUtil.isImageType(docName)) {
        Button b = new Button(attachment.getTitle(), new Button.ClickListener() {

            private static final long serialVersionUID = -1713187920922886934L;

            @Override
            public void buttonClick(Button.ClickEvent event) {
                AttachmentPreviewView previewView = new AttachmentPreviewView(VaadinResourceManager
                        .getResourceManager().getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE));
                EventBusFactory.getInstance().post(new ShellEvent.PushView(this, previewView));
            }
        });
        b.setWidth("100%");
        attachmentRow.addComponent(b);
        attachmentRow.setExpandRatio(b, 1.0f);
    } else {
        Label l = new Label(attachment.getTitle());
        l.setWidth("100%");
        attachmentRow.addComponent(l);
        attachmentRow.setExpandRatio(l, 1.0f);
    }
    return attachmentRow;
}

From source file:com.esofthead.mycollab.mobile.ui.MobileAttachmentUtils.java

License:Open Source License

public static Component renderAttachmentFieldRow(final Content attachment,
        Button.ClickListener additionalListener) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }/*  w w w.ja  va 2 s .  c om*/

    final HorizontalLayout attachmentLayout = new HorizontalLayout();
    attachmentLayout.setSpacing(true);
    attachmentLayout.setStyleName("attachment-row");
    attachmentLayout.setWidth("100%");
    attachmentLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setWidth("25px");
    thumbnailWrap.setHeight("40px");
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Image thumbnail = new Image(null);
    if (org.apache.commons.lang3.StringUtils.isBlank(attachment.getThumbnail())) {
        thumbnail.setSource(DEFAULT_SOURCE);
    } else {
        thumbnail.setSource(VaadinResourceManager.getResourceManager()
                .getImagePreviewResource(attachment.getThumbnail(), DEFAULT_SOURCE));
    }
    thumbnail.setWidth("100%");
    thumbnailWrap.addComponent(thumbnail);
    attachmentLayout.addComponent(thumbnailWrap);

    Label attachmentLink = new Label(docName);
    attachmentLayout.addComponent(attachmentLink);
    attachmentLayout.setExpandRatio(attachmentLink, 1.0f);

    Button removeAttachment = new Button(
            "<span aria-hidden=\"true\" data-icon=\"" + IconConstants.DELETE + "\"></span>",
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {

                    ConfirmDialog.show(UI.getCurrent(),
                            AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                            AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                            AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.CloseListener() {
                                private static final long serialVersionUID = 1L;

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

                }
            });
    if (additionalListener != null) {
        removeAttachment.addClickListener(additionalListener);
    }
    removeAttachment.setHtmlContentAllowed(true);
    removeAttachment.setStyleName("link");
    attachmentLayout.addComponent(removeAttachment);

    return attachmentLayout;
}