Example usage for com.vaadin.ui CssLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.m4gik.views.component.LicenseScreen.java

/**
 * Method builds license layout with texts.
 * /*from  w w  w .  j a  v  a2s  .  co m*/
 * @return The VerticalLayout with texts.
 * 
 * @see com.m4gik.views.component.ViewScreen#build()
 */
@Override
public Layout build() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setCaption("Welcome");

    Panel welcome = new Panel("License");
    welcome.setSizeFull();
    welcome.addStyleName(Runo.PANEL_LIGHT);
    layout.addComponent(welcome);
    layout.setExpandRatio(welcome, 1);

    CssLayout margin = new CssLayout();
    // margin.setMargin(true);
    margin.setWidth("100%");
    welcome.setContent(margin);

    Label title = new Label("Music player");
    title.addStyleName(Runo.LABEL_H1);
    // margin.addComponent(title);

    HorizontalLayout texts = new HorizontalLayout();
    texts.setSpacing(true);
    texts.setWidth("100%");
    margin.addComponent(texts);

    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);
    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);
    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);

    layout.addComponent(new Label("<hr />", Label.CONTENT_XHTML));

    return layout;
}

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

License:Open Source License

private void displayItem() {
    mainLayout.removeAllComponents();//  w  ww.  j  a v  a2  s  .c o  m
    MHorizontalLayout messageBlock = new MHorizontalLayout().withSpacing(false).withFullWidth()
            .withStyleName("message-block");
    Image userAvatarImg = UserAvatarControlFactory
            .createUserAvatarEmbeddedComponent(bean.getPostedUserAvatarId(), 32);
    userAvatarImg.addStyleName(UIConstants.CIRCLE_BOX);
    messageBlock.addComponent(userAvatarImg);

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

    MHorizontalLayout metadataRow = new MHorizontalLayout().withFullWidth();

    ELabel userNameLbl = new ELabel(bean.getFullPostedUserName()).withStyleName(UIConstants.META_INFO);
    userNameLbl.addStyleName(UIConstants.TEXT_ELLIPSIS);
    CssLayout userNameWrap = new CssLayout(userNameLbl);

    ELabel messageTimePost = new ELabel().prettyDateTime(bean.getPosteddate())
            .withStyleName(UIConstants.META_INFO).withWidthUndefined();
    metadataRow.with(userNameWrap, messageTimePost).withAlign(messageTimePost, Alignment.TOP_RIGHT)
            .expand(userNameWrap);

    rightCol.addComponent(metadataRow);

    CssLayout titleRow = new CssLayout();
    titleRow.setWidth("100%");
    titleRow.setStyleName("title-row");
    Label messageTitle = new Label(bean.getTitle());
    messageTitle.setStyleName("message-title");
    titleRow.addComponent(messageTitle);
    rightCol.addComponent(titleRow);

    Label messageContent = new Label(StringUtils.trimHtmlTags(bean.getMessage()));
    rightCol.addComponent(messageContent);

    ResourceService attachmentService = AppContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = attachmentService.getContents(AttachmentUtils.getProjectEntityAttachmentPath(
            MyCollabUI.getAccountId(), bean.getProjectid(), ProjectTypeConstants.MESSAGE, "" + bean.getId()));
    if (CollectionUtils.isNotEmpty(attachments)) {
        CssLayout attachmentPanel = new CssLayout();
        attachmentPanel.setStyleName("attachment-panel");
        attachmentPanel.setWidth("100%");

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

    messageBlock.with(rightCol).expand(rightCol);
    mainLayout.addComponent(messageBlock);

    Label commentTitleLbl = new Label();
    Component section = FormSectionBuilder.build(FontAwesome.COMMENT, commentTitleLbl);
    MessageCommentListDisplay commentDisplay = new MessageCommentListDisplay(ProjectTypeConstants.MESSAGE,
            bean.getId() + "", bean.getProjectid(), true);
    int numComments = commentDisplay.getNumComments();
    commentTitleLbl.setValue(UserUIContext.getMessage(GenericI18Enum.OPT_COMMENTS_VALUE, numComments));

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

From source file:com.mycollab.mobile.shell.view.MainView.java

License:Open Source License

public MainView() {
    super();//from  w ww.  ja  v  a  2  s. c o  m
    this.setSizeFull();

    MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth();
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    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");
    contentLayout.addComponent(welcomeTextWrapper);

    Button crmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM),
            clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)));
    crmButton.addStyleName(MobileUIConstants.BUTTON_ACTION);
    crmButton.setWidth("100%");

    contentLayout.addComponent(crmButton);

    Button pmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT),
            clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null)));
    pmButton.setWidth("100%");
    pmButton.addStyleName(MobileUIConstants.BUTTON_ACTION);
    contentLayout.addComponent(pmButton);

    this.addComponent(contentLayout);
}

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

License:Open Source License

public static Component renderAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    MHorizontalLayout attachmentRow = new MHorizontalLayout().withSpacing(false).withFullWidth()
            .withStyleName("attachment-row");
    attachmentRow.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

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

    Component thumbnail;/*from www. j av a  2  s .co  m*/

    if (StringUtils.isNotBlank(attachment.getThumbnail())) {
        thumbnail = new Image(null, VaadinResourceFactory.getResource(attachment.getThumbnail()));
    } else {
        thumbnail = new ELabel(FileAssetsUtil.getFileIconResource(attachment.getName()).getHtml(),
                ContentMode.HTML);
    }
    thumbnail.setWidth("100%");
    thumbnailWrap.addComponent(thumbnail);
    attachmentRow.addComponent(thumbnailWrap);

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

    if (MimeTypesUtil.isImageType(docName)) {
        MButton b = new MButton(attachment.getTitle(), clickEvent -> {
            AttachmentPreviewView previewView = new AttachmentPreviewView(
                    VaadinResourceFactory.getResource(attachment.getPath()));
            EventBusFactory.getInstance().post(new ShellEvent.PushView(attachment, previewView));
        }).withStyleName(UIConstants.TEXT_ELLIPSIS);
        b.setWidth("100%");
        attachmentRow.with(b).expand(b);
    } else {
        Label l = new Label(attachment.getTitle());
        l.setWidth("100%");
        attachmentRow.addComponent(l);
        attachmentRow.setExpandRatio(l, 1.0f);
    }
    return attachmentRow;
}

From source file:com.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. j a va  2 s.co  m*/

    final MHorizontalLayout attachmentLayout = new MHorizontalLayout().withStyleName("attachment-row")
            .withFullWidth();
    attachmentLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

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

    Component thumbnail;
    if (StringUtils.isNotBlank(attachment.getThumbnail())) {
        thumbnail = new Image(null, VaadinResourceFactory.getResource(attachment.getThumbnail()));
    } else {
        thumbnail = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(attachment.getName()));
    }
    thumbnail.setWidth("100%");
    thumbnailWrap.addComponent(thumbnail);
    attachmentLayout.addComponent(thumbnailWrap);

    ELabel attachmentLink = new ELabel(docName).withStyleName(UIConstants.META_INFO, UIConstants.TEXT_ELLIPSIS);
    attachmentLayout.with(attachmentLink).expand(attachmentLink);

    MButton removeAttachment = new MButton("", clickEvent -> {
        ConfirmDialog.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), dialog -> {
                    if (dialog.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(MobileUIConstants.BUTTON_LINK);
    if (additionalListener != null) {
        removeAttachment.addClickListener(additionalListener);
    }
    removeAttachment.setHtmlContentAllowed(true);
    attachmentLayout.addComponent(removeAttachment);

    return attachmentLayout;
}

From source file:com.mycollab.module.crm.ui.components.AbstractPreviewItemComp.java

License:Open Source License

public AbstractPreviewItemComp(FontAwesome iconResource) {
    setSizeFull();//from   w  ww  . j  ava2s. co  m
    this.iconResource = iconResource;
    tabSheet = new VerticalTabsheet();
    tabSheet.setSizeFull();
    tabSheet.setNavigatorWidth("100%");
    tabSheet.setNavigatorStyleName("sidebar-menu");
    tabSheet.addToggleNavigatorControl();

    headerTitle = ELabel.h2("");
    header = new MHorizontalLayout(headerTitle).withStyleName("hdr-view").withFullWidth()
            .withMargin(new MarginInfo(true, false, true, false)).expand(headerTitle);
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    addComponent(tabSheet);

    CssLayout navigatorWrapper = tabSheet.getNavigatorWrapper();
    navigatorWrapper.setWidth("200px");

    tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            Tab tab = ((VerticalTabsheet) event.getSource()).getSelectedTab();
            tabSheet.selectTab(((TabImpl) tab).getTabId());
        }
    });

    tabContent = tabSheet.getContentWrapper();
    tabContent.addComponent(header, 0);

    previewForm = initPreviewForm();
    ComponentContainer actionControls = createButtonControls();
    if (actionControls != null) {
        header.with(actionControls).withAlign(actionControls, Alignment.TOP_RIGHT);
    }

    previewLayout = new DefaultReadViewLayout("");
    RightSidebarLayout bodyContainer = new RightSidebarLayout();
    bodyContainer.addStyleName(WebThemes.CONTENT_WRAPPER);

    MVerticalLayout bodyContent = new MVerticalLayout(previewForm).withSpacing(false).withMargin(false)
            .withFullWidth();
    bodyContainer.setContent(bodyContent);
    sidebarContent = new MVerticalLayout().withWidth("250px").withStyleName("readview-sidebar");
    bodyContainer.setSidebar(sidebarContent);
    previewLayout.addBody(bodyContainer);

    tabContent.addComponent(previewLayout);

    initRelatedComponents();
    ComponentContainer bottomPanel = createBottomPanel();
    if (bottomPanel != null) {
        if (bodyContent.getComponentCount() >= 2) {
            bodyContent.replaceComponent(bodyContent.getComponent(bodyContent.getComponentCount() - 1),
                    bottomPanel);
        } else {
            bodyContent.addComponent(bottomPanel);
        }
    }
}

From source file:com.mycollab.module.crm.ui.components.CommentRowDisplayHandler.java

License:Open Source License

@Override
public Component generateRow(IBeanList<SimpleComment> host, final SimpleComment comment, int rowIndex) {
    final MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(true, true, true, false))
            .withFullWidth();/*w  ww. j  a va2  s  . c o  m*/

    UserBlock memberBlock = new UserBlock(comment.getCreateduser(), comment.getOwnerAvatarId(),
            comment.getOwnerFullName());
    layout.addComponent(memberBlock);

    CssLayout rowLayout = new CssLayout();
    rowLayout.setStyleName(WebThemes.MESSAGE_CONTAINER);
    rowLayout.setWidth("100%");

    MHorizontalLayout messageHeader = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, true, false, true)).withFullWidth();
    messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    ELabel timePostLbl = new ELabel(UserUIContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT,
            comment.getOwnerFullName(), UserUIContext.formatPrettyTime(comment.getCreatedtime())),
            ContentMode.HTML).withDescription(UserUIContext.formatDateTime(comment.getCreatedtime()));

    timePostLbl.setSizeUndefined();
    timePostLbl.setStyleName(UIConstants.META_INFO);
    messageHeader.with(timePostLbl).expand(timePostLbl);

    // Message delete button
    if (hasDeletePermission(comment)) {
        MButton msgDeleteBtn = new MButton("", clickEvent -> {
            ConfirmDialogExt.show(UI.getCurrent(),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                    UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                        if (confirmDialog.isConfirmed()) {
                            CommentService commentService = AppContextUtil.getSpringBean(CommentService.class);
                            commentService.removeWithSession(comment, UserUIContext.getUsername(),
                                    MyCollabUI.getAccountId());
                            ((BeanList) host).removeRow(layout);
                        }
                    });
        }).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_ICON_ONLY);
        messageHeader.addComponent(msgDeleteBtn);
    }

    rowLayout.addComponent(messageHeader);

    Label messageContent = new SafeHtmlLabel(comment.getComment());
    rowLayout.addComponent(messageContent);

    List<Content> attachments = comment.getAttachments();
    if (!CollectionUtils.isEmpty(attachments)) {
        MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withFullWidth();
        AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments);
        messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT);
        rowLayout.addComponent(messageFooter);
    }

    layout.with(rowLayout).expand(rowLayout);
    return layout;
}

From source file:com.mycollab.module.crm.view.account.AccountCaseListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    MHorizontalLayout controlsBtnWrap = new MHorizontalLayout().withFullWidth();

    MHorizontalLayout notesWrap = new MHorizontalLayout().withFullWidth();
    Label noteLbl = new Label(UserUIContext.getMessage(GenericI18Enum.OPT_NOTE));
    noteLbl.setSizeUndefined();//  w  ww.  jav  a  2 s  .  c  o  m
    noteLbl.setStyleName("list-note-lbl");
    notesWrap.addComponent(noteLbl);

    CssLayout noteBlock = new CssLayout();
    noteBlock.setWidth("100%");
    noteBlock.setStyleName("list-note-block");
    for (CaseStatus status : CrmDataTypeFactory.getCasesStatusList()) {
        ELabel note = new ELabel(UserUIContext.getMessage(status))
                .withStyleName("note-label", colorsMap.get(status.name())).withWidthUndefined();
        noteBlock.addComponent(note);
    }
    notesWrap.with(noteBlock).expand(noteBlock);
    controlsBtnWrap.addComponent(notesWrap);

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_CASE)) {
        MButton createBtn = new MButton(UserUIContext.getMessage(CaseI18nEnum.NEW),
                clickEvent -> fireNewRelatedItem("")).withIcon(FontAwesome.PLUS)
                        .withStyleName(WebThemes.BUTTON_ACTION);
        controlsBtnWrap.with(createBtn).withAlign(createBtn, Alignment.TOP_RIGHT);
    }

    return controlsBtnWrap;
}

From source file:com.mycollab.module.crm.view.account.AccountOpportunityListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    MHorizontalLayout controlsBtnWrap = new MHorizontalLayout().withFullWidth();

    MHorizontalLayout notesWrap = new MHorizontalLayout().withFullWidth();
    ELabel noteLbl = new ELabel(UserUIContext.getMessage(GenericI18Enum.OPT_NOTE)).withWidthUndefined();
    notesWrap.addComponent(noteLbl);//from w  w  w .j a  va 2  s. c o  m

    CssLayout noteBlock = new CssLayout();
    noteBlock.setWidth("100%");
    noteBlock.setStyleName("list-note-block");
    for (OpportunitySalesStage stage : CrmDataTypeFactory.getOpportunitySalesStageList()) {
        ELabel note = new ELabel(UserUIContext.getMessage(stage))
                .withStyleName("note-label", colormap.get(stage.name())).withWidthUndefined();
        noteBlock.addComponent(note);
    }
    notesWrap.with(noteBlock).expand(noteBlock);
    controlsBtnWrap.with(notesWrap).expand(notesWrap);

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY)) {
        MButton createBtn = new MButton(UserUIContext.getMessage(OpportunityI18nEnum.NEW),
                clickEvent -> fireNewRelatedItem("")).withIcon(FontAwesome.PLUS)
                        .withStyleName(WebThemes.BUTTON_ACTION);

        controlsBtnWrap.with(createBtn).withAlign(createBtn, Alignment.TOP_RIGHT);
    }

    return controlsBtnWrap;
}

From source file:com.mycollab.module.crm.view.activity.ActivityRootView.java

License:Open Source License

public ActivityRootView() {
    super();/*from www.j  av a 2s.  c  o  m*/
    this.setSizeFull();

    final CssLayout contentWrapper = new CssLayout();
    contentWrapper.setStyleName("verticalTabView");
    contentWrapper.setWidth("100%");
    this.addComponent(contentWrapper);

    HorizontalLayout root = new HorizontalLayout();
    root.setStyleName("menuContent");

    activityTabs = new VerticalTabsheet();
    activityTabs.setSizeFull();
    activityTabs.setNavigatorWidth("170px");
    activityTabs.setNavigatorStyleName("sidebar-menu");
    activityTabs.setHeight(null);

    root.addComponent(activityTabs);
    root.setWidth("100%");
    buildComponents();
    contentWrapper.addComponent(root);
}