Example usage for com.vaadin.ui HorizontalLayout setStyleName

List of usage examples for com.vaadin.ui HorizontalLayout setStyleName

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectCommentInput.java

License:Open Source License

private Component createAttachmentRow(String fileName) {
    final HorizontalLayout uploadSucceedLayout = new HorizontalLayout();
    uploadSucceedLayout.setWidth("100%");
    Label uploadResult = new Label(fileName);
    uploadResult.setWidth("100%");
    uploadSucceedLayout.addComponent(uploadResult);
    uploadSucceedLayout.setExpandRatio(uploadResult, 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/*from  w  w w . ja va  2s .c  om*/
                public void buttonClick(ClickEvent event) {
                    statusWrapper.removeComponent(uploadSucceedLayout);
                }

            });
    removeAttachment.setHtmlContentAllowed(true);
    removeAttachment.setStyleName("link");
    uploadSucceedLayout.addComponent(removeAttachment);
    uploadSucceedLayout.setStyleName("upload-succeed-layout");
    uploadSucceedLayout.setSpacing(true);
    return uploadSucceedLayout;
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.TimeLogComp.java

License:Open Source License

public void displayTime(final V bean) {
    this.removeAllComponents();

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);//  w  ww.j  a va  2 s.  com
    header.setStyleName("info-hdr");
    header.addStyleName("timelog-comp-hdr");
    header.setWidth("100%");
    Label dateInfoHeader = new Label(AppContext.getMessage(TimeTrackingI18nEnum.SUB_INFO_TIME));
    dateInfoHeader.setWidthUndefined();
    header.addComponent(dateInfoHeader);
    header.setExpandRatio(dateInfoHeader, 1.0f);

    if (hasEditPermission()) {
        Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        showEditTimeView(bean);

                    }
                });
        editBtn.setStyleName("link");
        editBtn.setHtmlContentAllowed(true);
        header.addComponent(editBtn);
        header.setComponentAlignment(editBtn, Alignment.BOTTOM_LEFT);
    }

    this.addComponent(header);

    GridFormLayoutHelper layout = new GridFormLayoutHelper(1, 3, "100%", "150px", Alignment.TOP_RIGHT);
    layout.getLayout().setWidth("100%");
    layout.getLayout().setMargin(false);

    double billableHours = getTotalBillableHours(bean);
    double nonBillableHours = getTotalNonBillableHours(bean);
    double remainHours = getRemainedHours(bean);
    layout.addComponent(new Label(billableHours + ""),
            AppContext.getMessage(TimeTrackingI18nEnum.M_FORM_BILLABLE_HOURS), 0, 0);
    layout.addComponent(new Label(nonBillableHours + ""),
            AppContext.getMessage(TimeTrackingI18nEnum.M_FORM_NON_BILLABLE_HOURS), 0, 1);
    layout.addComponent(new Label(remainHours + ""),
            AppContext.getMessage(TimeTrackingI18nEnum.M_FORM_REMAIN_HOURS), 0, 2);
    this.addComponent(layout.getLayout());
}

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

License:Open Source License

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

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

    HorizontalLayout compHeader = new HorizontalLayout();
    compHeader.setWidth("100%");
    compHeader.setStyleName("attachment-field-header");

    Label headerLbl = new Label(AppContext.getMessage(GenericI18Enum.M_FORM_ATTACHMENT));
    headerLbl.setStyleName("field-caption");

    compHeader.addComponent(headerLbl);/*from www  .j a va 2s . c o m*/
    compHeader.setExpandRatio(headerLbl, 1.0f);

    compHeader.addComponent(attachmentBtn);

    content.addComponent(compHeader);

    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   w  w  w. j  a  va2  s  . c o  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.ui.GridFormLayoutHelper.java

License:Open Source License

public Component addComponent(final Component field, final String caption, final int columns, final int rows,
        final int colspan, final String width, final Alignment alignment) {
    if (caption != null) {
        final Label l = new Label(caption);
        final HorizontalLayout captionWrapper = new HorizontalLayout();
        captionWrapper.addComponent(l);//w w  w.j  ava  2s. com
        captionWrapper.setComponentAlignment(l, alignment);
        captionWrapper.setStyleName("gridform-caption");
        captionWrapper.setMargin(true);
        captionWrapper.setWidth(this.defaultCaptionWidth);
        if (columns == 0) {
            captionWrapper.addStyleName("first-col");
        }
        if (rows == 0) {
            captionWrapper.addStyleName("first-row");
        }
        if ((rows + 1) % 2 == 0)
            captionWrapper.addStyleName("even-row");

        this.layout.addComponent(captionWrapper, 2 * columns, rows);
        captionWrapper.setHeight("100%");
    }
    final HorizontalLayout fieldWrapper = new HorizontalLayout();
    fieldWrapper.setStyleName("gridform-field");
    fieldWrapper.setMargin(true);
    fieldWrapper.addComponent(field);

    if (!(field instanceof Button))
        field.setCaption(null);

    field.setWidth(width);

    fieldWrapper.setWidth("100%");
    if (rows == 0) {
        fieldWrapper.addStyleName("first-row");
    }
    if ((rows + 1) % 2 == 0) {
        fieldWrapper.addStyleName("even-row");
    }
    this.layout.addComponent(fieldWrapper, 2 * columns + 1, rows, 2 * (columns + colspan - 1) + 1, rows);
    this.layout.setColumnExpandRatio(2 * columns + 1, 1.0f);
    return field;
}

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

License:Open Source License

public Component addComponent(final Component field, final String caption, final int columns, final int rows,
        final String width, final Alignment alignment) {
    if (caption != null) {
        final Label l = new Label(caption);
        // l.setHeight("100%");
        final HorizontalLayout captionWrapper = new HorizontalLayout();
        captionWrapper.addComponent(l);/*  ww w .  j  a v a  2 s. c  om*/
        captionWrapper.setComponentAlignment(l, alignment);
        captionWrapper.setWidth(this.defaultCaptionWidth);
        captionWrapper.setHeight("100%");
        captionWrapper.setStyleName("gridform-caption");
        captionWrapper.setMargin(true);
        if (columns == 0) {
            captionWrapper.addStyleName("first-col");
        }
        if (rows == 0) {
            captionWrapper.addStyleName("first-row");
        }
        this.layout.addComponent(captionWrapper, 2 * columns, rows);
    }
    final HorizontalLayout fieldWrapper = new HorizontalLayout();
    fieldWrapper.setStyleName("gridform-field");
    if (!(field instanceof Button))
        field.setCaption(null);
    fieldWrapper.addComponent(field);

    field.setWidth(width);

    fieldWrapper.setWidth("100%");
    fieldWrapper.setMargin(true);
    if (rows == 0) {
        fieldWrapper.addStyleName("first-row");
    }
    this.layout.addComponent(fieldWrapper, 2 * columns + 1, rows);
    this.layout.setColumnExpandRatio(2 * columns + 1, 1.0f);
    return field;
}

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

License:Open Source License

public Component addComponent(Component fieldValue, Component fieldCaption, String defaultCaptionWidth,
        String fieldValueWidth, int columns, int rows, Alignment alignment) {
    final HorizontalLayout captionWrapper = new HorizontalLayout();
    captionWrapper.addComponent(fieldCaption);
    captionWrapper.setComponentAlignment(fieldCaption, alignment);
    captionWrapper.setWidth(defaultCaptionWidth);
    captionWrapper.setHeight("100%");
    captionWrapper.setMargin(true);//  ww w.ja  v a  2s.  c o m
    captionWrapper.setStyleName("gridform-caption");
    if (columns == 0) {
        captionWrapper.addStyleName("first-col");
    }
    if (rows == 0) {
        captionWrapper.addStyleName("first-row");
    }
    this.layout.addComponent(captionWrapper, 2 * columns, rows);
    final HorizontalLayout fieldWrapper = new HorizontalLayout();
    fieldWrapper.setStyleName("gridform-field");
    if (!(fieldValue instanceof Button))
        fieldValue.setCaption(null);
    fieldWrapper.addComponent(fieldValue);

    fieldValue.setWidth(fieldValueWidth);

    fieldWrapper.setWidth("100%");
    fieldWrapper.setMargin(true);
    if (rows == 0) {
        fieldWrapper.addStyleName("first-row");
    }
    this.layout.addComponent(fieldWrapper, 2 * columns + 1, rows);
    this.layout.setColumnExpandRatio(2 * columns + 1, 1.0f);
    return fieldValue;
}

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);//from ww  w.j a  va2 s.  c o m
    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());
    }/*from ww w . jav a 2s.  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;
}

From source file:com.esofthead.mycollab.module.crm.view.lead.LeadConvertInfoWindow.java

License:Open Source License

private ComponentContainer createButtonControls() {
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);// www .  ja v a  2s  .  co m
    layout.setStyleName("addNewControl");

    Button convertButton = new Button(AppContext.getMessage(LeadI18nEnum.BUTTON_CONVERT_LEAD),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    LeadService leadService = ApplicationContextUtil.getSpringBean(LeadService.class);
                    lead.setStatus("Converted");
                    leadService.updateWithSession(lead, AppContext.getUsername());
                    Opportunity opportunity = null;
                    if (opportunityForm != null && opportunityForm.isVisible()) {
                        if (opportunityForm.validateForm()) {
                            opportunity = opportunityForm.getBean();
                        }
                    }

                    leadService.convertLead(lead, opportunity, AppContext.getUsername());
                    LeadConvertInfoWindow.this.close();
                    EventBusFactory.getInstance()
                            .post(new LeadEvent.GotoRead(LeadConvertInfoWindow.this, lead.getId()));
                }
            });
    convertButton.setStyleName(UIConstants.THEME_GREEN_LINK);
    layout.addComponent(convertButton);
    layout.setComponentAlignment(convertButton, Alignment.MIDDLE_CENTER);

    Button cancelButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    LeadConvertInfoWindow.this.close();

                }
            });
    cancelButton.setStyleName(UIConstants.THEME_GRAY_LINK);
    layout.addComponent(cancelButton);
    layout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);
    return layout;
}