Example usage for com.vaadin.ui HorizontalLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

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  w w  .j a  v a2  s .c  om
    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.bug.BugReadViewImpl.java

License:Open Source License

@Override
protected ComponentContainer createBottomPanel() {
    HorizontalLayout toolbarLayout = new HorizontalLayout();
    toolbarLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    toolbarLayout.setSpacing(true);/*from   www  .  j  av  a 2  s.c  o  m*/

    relatedComments = new Button();
    relatedComments.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_MESSAGE
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.TAB_COMMENT) + "</div>");
    relatedComments.setHtmlContentAllowed(true);
    relatedComments.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -7469027678729887223L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, associateComments));
        }
    });
    toolbarLayout.addComponent(relatedComments);

    return toolbarLayout;
}

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);
    compHeader.setExpandRatio(headerLbl, 1.0f);

    compHeader.addComponent(attachmentBtn);

    content.addComponent(compHeader);/*from  w w  w . ja v  a 2  s  .  c o m*/

    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   ww  w .  java  2  s .  com*/

    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.milestone.MilestoneReadViewImpl.java

License:Open Source License

@Override
protected ComponentContainer createBottomPanel() {
    HorizontalLayout toolbarLayout = new HorizontalLayout();
    toolbarLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    toolbarLayout.setSpacing(true);/*www. j  av  a 2s  .c o  m*/

    Button relatedBugs = new Button();
    relatedBugs.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_BUG
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.VIEW_BUG) + "</div>");
    relatedBugs.setHtmlContentAllowed(true);
    relatedBugs.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 2113811477874305745L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, getRelatedBugs()));
        }
    });
    toolbarLayout.addComponent(relatedBugs);

    Button relatedTasks = new Button();
    relatedTasks.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_TASK
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TASK) + "</div>");
    relatedTasks.setHtmlContentAllowed(true);
    relatedTasks.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -9171495386840452500L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, getRelatedTasks()));
        }
    });
    toolbarLayout.addComponent(relatedTasks);

    relatedComments = new Button();
    relatedComments.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_MESSAGE
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.TAB_COMMENT) + "</div>");
    relatedComments.setHtmlContentAllowed(true);
    relatedComments.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 2206489649468573076L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, associateComments));
        }
    });
    toolbarLayout.addComponent(relatedComments);

    return toolbarLayout;
}

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

License:Open Source License

@Override
protected ComponentContainer createBottomPanel() {
    HorizontalLayout toolbarLayout = new HorizontalLayout();
    toolbarLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    toolbarLayout.setSpacing(true);//from w  w w .jav  a  2 s  .  c o m

    relatedComments = new Button();
    relatedComments.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_MESSAGE
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.TAB_COMMENT) + "</div>");
    relatedComments.setHtmlContentAllowed(true);
    relatedComments.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 2276465280812964681L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, associateComments));
        }
    });
    toolbarLayout.addComponent(relatedComments);

    return toolbarLayout;
}

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

License:Open Source License

@Override
protected ComponentContainer createBottomPanel() {
    HorizontalLayout toolbarLayout = new HorizontalLayout();
    toolbarLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    toolbarLayout.setSpacing(true);/*from  ww w.j a  va 2 s .c o m*/

    relatedComments = new Button();
    relatedComments.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_MESSAGE
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.TAB_COMMENT) + "</div>");
    relatedComments.setHtmlContentAllowed(true);
    relatedComments.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 4889821151518627676L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, associateComments));
        }
    });
    toolbarLayout.addComponent(relatedComments);

    return toolbarLayout;
}

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

License:Open Source License

private void constructUI(final String message, final String okCaption, final String cancelCaption) {
    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setHeightUndefined();/*from w  w  w. j a v a  2  s .  c o  m*/
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    VerticalLayout messageWrapper = new VerticalLayout();
    messageWrapper.setStyleName("message-wrapper");
    messageWrapper.setWidth("100%");
    messageWrapper.setMargin(true);

    final Label messageDisplay = new Label(message);
    messageDisplay.setWidth("100%");
    messageWrapper.addComponent(messageDisplay);
    layout.addComponent(messageWrapper);

    HorizontalLayout controlBtn = new HorizontalLayout();
    controlBtn.setWidth("100%");

    final Button okBtn = new Button(okCaption);
    okBtn.setWidth("100%");
    okBtn.setHeight("35px");
    final Button cancelBtn = new Button(cancelCaption);
    cancelBtn.setWidth("100%");
    cancelBtn.setHeight("35px");

    Button.ClickListener listener = new Button.ClickListener() {
        private static final long serialVersionUID = -8306231710367659086L;

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialog.this.setConfirmed(event.getButton() == okBtn);
            if (ConfirmDialog.this.getListener() != null) {
                ConfirmDialog.this.getListener().onClose(ConfirmDialog.this);
            }
            ConfirmDialog.this.close();
        }

    };

    okBtn.addClickListener(listener);
    cancelBtn.addClickListener(listener);

    controlBtn.addComponent(cancelBtn);
    controlBtn.addComponent(okBtn);

    layout.addComponent(controlBtn);
    this.setContent(layout);
}

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);
        captionWrapper.setComponentAlignment(l, alignment);
        captionWrapper.setStyleName("gridform-caption");
        captionWrapper.setMargin(true);/*from  w  w  w .  ja va 2 s  .co m*/
        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);
        captionWrapper.setComponentAlignment(l, alignment);
        captionWrapper.setWidth(this.defaultCaptionWidth);
        captionWrapper.setHeight("100%");
        captionWrapper.setStyleName("gridform-caption");
        captionWrapper.setMargin(true);/*from   w  w  w.ja v a2 s  . com*/
        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;
}