Example usage for com.vaadin.ui Label Label

List of usage examples for com.vaadin.ui Label Label

Introduction

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

Prototype

public Label(String text) 

Source Link

Document

Creates a new instance with text content mode and the given text.

Usage

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

License:Open Source License

protected MHorizontalLayout createPageControls() {
    controlBarWrapper = new MHorizontalLayout().withFullWidth()
            .withMargin(new MarginInfo(false, true, false, true)).withStyleName(listControlStyle);

    pageManagement = new MHorizontalLayout().withWidth(null);

    // defined layout here ---------------------------

    if (currentPage > 1) {
        Button firstLink = new Button("1", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override/*from ww w.j  av  a2 s .  com*/
            public void buttonClick(final ClickEvent event) {
                pageChange(1);
            }
        });
        firstLink.addStyleName("buttonPaging");
        pageManagement.addComponent(firstLink);
    }
    if (currentPage >= 5) {
        final Label ss1 = new Label("...");
        ss1.addStyleName("buttonPaging");
        pageManagement.addComponent(ss1);
    }
    if (currentPage > 3) {
        Button previous2 = new Button("" + (currentPage - 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage - 2);
            }
        });
        previous2.addStyleName("buttonPaging");
        pageManagement.addComponent(previous2);
    }
    if (currentPage > 2) {
        final Button previous1 = new Button("" + (currentPage - 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage - 1);
            }
        });
        previous1.addStyleName("buttonPaging");
        pageManagement.addComponent(previous1);
    }
    // Here add current ButtonLinkLegacy
    final Button current = new Button("" + currentPage, new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            pageChange(currentPage);
        }
    });
    current.addStyleName("buttonPaging");
    current.addStyleName("current");

    pageManagement.addComponent(current);
    final int range = this.totalPage - currentPage;
    if (range >= 1) {
        final Button next1 = new Button("" + (currentPage + 1), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage + 1);
            }
        });
        next1.addStyleName("buttonPaging");
        pageManagement.addComponent(next1);
    }
    if (range >= 2) {
        Button next2 = new Button("" + (currentPage + 2), new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(currentPage + 2);
            }
        });
        next2.addStyleName("buttonPaging");
        pageManagement.addComponent(next2);
    }
    if (range >= 4) {
        Label ss2 = new Label("...");
        ss2.addStyleName("buttonPaging");
        pageManagement.addComponent(ss2);
    }
    if (range >= 3) {
        Button last = new Button("" + this.totalPage, new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                pageChange(totalPage);
            }
        });
        last.addStyleName("buttonPaging");
        pageManagement.addComponent(last);
    }

    controlBarWrapper.with(pageManagement).withAlign(pageManagement, Alignment.MIDDLE_RIGHT);
    return controlBarWrapper;
}

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

License:Open Source License

private Component msgWhenEmptyList() {
    String value = stringWhenEmptyList();
    if (StringUtils.isBlank(value)) {
        return null;
    }//from  w w  w  .j av a2 s .  c  o  m
    return new MHorizontalLayout().withMargin(true).withFullWidth().withStyleName("panel-body")
            .with(new Label(stringWhenEmptyList()));
}

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());
    }/*ww w.  ja va2s  .  c  om*/

    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.BuildCriterionComponent.java

License:Open Source License

public BuildCriterionComponent(GenericSearchPanel.SearchLayout<S> searchLayout, Param[] paramFields,
        Class<S> type, String searchCategory) {
    this.hostSearchLayout = searchLayout;
    this.paramFields = paramFields;
    this.type = type;
    this.searchCategory = searchCategory;

    MHorizontalLayout headerBox = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, true));
    headerBox.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    addComponent(headerBox);/*from  ww w  .j  a v a 2s. c  o  m*/

    Label filterLbl = new Label(AppContext.getMessage(GenericI18Enum.OPT_SAVED_FILTER));
    headerBox.with(filterLbl).withAlign(filterLbl, Alignment.TOP_LEFT);

    filterBox = new MHorizontalLayout();
    headerBox.with(filterBox).withAlign(filterBox, Alignment.TOP_LEFT);

    buildFilterBox(null);

    searchContainer = new MVerticalLayout().withMargin(false);
    searchContainer.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    MHorizontalLayout controlsBtn = new MHorizontalLayout().withMargin(true);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    CriteriaSelectionLayout newCriteriaBar = new CriteriaSelectionLayout(
                            searchContainer.getComponentCount() + 1);
                    searchContainer.addComponent(newCriteriaBar);
                }
            });
    addCriteriaBtn.setStyleName(UIConstants.BUTTON_ACTION);
    addCriteriaBtn.setIcon(FontAwesome.PLUS);

    controlsBtn.with(addCriteriaBtn);

    this.with(searchContainer, controlsBtn);
}

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

License:Open Source License

@Override
public ComponentContainer getLayout() {
    FormContainer layout = new FormContainer();
    int sectionCount = dynaForm.getSectionCount();
    sectionMappings = new HashMap<>();

    for (int i = 0; i < sectionCount; i++) {
        DynaSection section = dynaForm.getSection(i);
        if (section.isDeletedSection()) {
            continue;
        }/*from  ww  w.  j  a va  2s  . c o m*/

        if (StringUtils.isNotBlank(section.getHeader())) {
            Label header = new Label(section.getHeader());
            MCssLayout formSection = new MCssLayout(header).withStyleName(UIConstants.FORM_SECTION)
                    .withFullWidth();
            formSection.addStyleName(UIConstants.HOVER_EFFECT_NOT_BOX);
            layout.addComponent(formSection);
        }

        GridFormLayoutHelper gridLayout;

        if (section.isDeletedSection() || section.getFieldCount() == 0) {
            continue;
        }

        if (section.getLayoutType() == LayoutType.ONE_COLUMN) {
            gridLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 1);

            for (int j = 0; j < section.getFieldCount(); j++) {
                AbstractDynaField dynaField = section.getField(j);
                if (!excludeFields.contains(dynaField.getFieldName())) {
                    gridLayout.buildCell(dynaField.getDisplayName(), dynaField.getContextHelp(), 0,
                            gridLayout.getRows() - 1, 2, "100%", Alignment.TOP_LEFT);
                    if (j < section.getFieldCount() - 1) {
                        gridLayout.appendRow();
                    }

                    if (dynaField.isCustom()) {
                        fieldMappings.put("customfield." + dynaField.getFieldName(), dynaField);
                    } else {
                        fieldMappings.put(dynaField.getFieldName(), dynaField);
                    }
                }
            }
        } else if (section.getLayoutType() == LayoutType.TWO_COLUMN) {
            gridLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 1);
            int columnIndex = 0;
            for (int j = 0; j < section.getFieldCount(); j++) {
                AbstractDynaField dynaField = section.getField(j);
                if (!excludeFields.contains(dynaField.getFieldName())) {
                    if (dynaField.isColSpan()) {
                        if (columnIndex > 0) {
                            gridLayout.appendRow();
                        }
                        gridLayout.buildCell(dynaField.getDisplayName(), dynaField.getContextHelp(), 0,
                                gridLayout.getRows() - 1, 2, "100%", Alignment.TOP_LEFT);
                        columnIndex = 0;
                        if (j < section.getFieldCount() - 1) {
                            gridLayout.appendRow();
                        }
                    } else {
                        gridLayout.buildCell(dynaField.getDisplayName(), dynaField.getContextHelp(),
                                columnIndex, gridLayout.getRows() - 1);
                        columnIndex++;
                        if (columnIndex == 2) {
                            columnIndex = 0;
                            if (j < section.getFieldCount() - 1) {
                                gridLayout.appendRow();
                            }
                        }
                    }

                    if (dynaField.isCustom()) {
                        fieldMappings.put("customfield." + dynaField.getFieldName(), dynaField);
                    } else {
                        fieldMappings.put(dynaField.getFieldName(), dynaField);
                    }
                }
            }
        } else {
            throw new MyCollabException("Does not support attachForm layout except 1 or 2 columns");
        }

        layout.addComponent(gridLayout.getLayout());
        sectionMappings.put(section, gridLayout);
    }
    return layout;
}

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

License:Open Source License

public Depot(String title, ComponentContainer content) {
    this.addStyleName("depotComp");
    this.setMargin(false);
    header = new MHorizontalLayout().withHeight("40px").withStyleName("depotHeader");
    bodyContent = content;//w  ww .ja  va  2 s  . co  m
    bodyContent.setWidth("100%");
    headerContent = new MHorizontalLayout().withMargin(true).withFullHeight();
    headerContent.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    headerContent.setVisible(false);
    headerContent.setStyleName("header-elements");
    headerContent.setWidthUndefined();
    this.addComponent(header);

    headerLbl = new Label(title);
    final MHorizontalLayout headerLeft = new MHorizontalLayout(headerLbl).withStyleName("depot-title")
            .withAlign(headerLbl, Alignment.MIDDLE_LEFT).withFullWidth();
    headerLeft.addLayoutClickListener(new LayoutClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void layoutClick(final LayoutClickEvent event) {
            isOpened = !isOpened;
            if (isOpened) {
                bodyContent.setVisible(true);
                removeStyleName("collapsed");
            } else {
                bodyContent.setVisible(false);
                addStyleName("collapsed");
            }
        }
    });
    header.with(headerLeft, headerContent).withAlign(headerLeft, Alignment.MIDDLE_LEFT)
            .withAlign(headerContent, Alignment.MIDDLE_RIGHT).expand(headerLeft);

    final CustomComponent customComp = new CustomComponent(bodyContent);
    customComp.setWidth("100%");
    bodyContent.addStyleName("depotContent");

    this.addComponent(customComp);
    this.setComponentAlignment(customComp, Alignment.TOP_CENTER);
}

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

License:Open Source License

@Override
public ComponentContainer getLayout() {
    FormContainer layout = new FormContainer();
    int sectionCount = dynaForm.getSectionCount();
    sectionMappings = new HashMap<>();

    for (int i = 0; i < sectionCount; i++) {
        DynaSection section = dynaForm.getSection(i);
        if (section.isDeletedSection()) {
            continue;
        }//from w  w w . j  ava2  s .c o m

        if (StringUtils.isNotBlank(section.getHeader())) {
            Label header = new Label(section.getHeader());
            MCssLayout formSection = new MCssLayout(header).withStyleName(UIConstants.FORM_SECTION)
                    .withFullWidth();
            layout.addComponent(formSection);
        }

        GridFormLayoutHelper gridLayout;

        if (section.isDeletedSection() || section.getFieldCount() == 0) {
            continue;
        }

        if (section.getLayoutType() == LayoutType.ONE_COLUMN) {
            gridLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 1);

            for (int j = 0; j < section.getFieldCount(); j++) {
                AbstractDynaField dynaField = section.getField(j);
                if (!excludeFields.contains(dynaField.getFieldName())) {
                    gridLayout.buildCell(dynaField.getDisplayName(), 0, gridLayout.getRows() - 1, 2, "100%",
                            Alignment.TOP_LEFT);
                    if (j < section.getFieldCount() - 1) {
                        gridLayout.appendRow();
                    }

                    if (dynaField.isCustom()) {
                        fieldMappings.put("customfield." + dynaField.getFieldName(), dynaField);
                    } else {
                        fieldMappings.put(dynaField.getFieldName(), dynaField);
                    }
                }
            }
        } else if (section.getLayoutType() == LayoutType.TWO_COLUMN) {
            gridLayout = GridFormLayoutHelper.defaultFormLayoutHelper(2, 1);
            int columnIndex = 0;
            for (int j = 0; j < section.getFieldCount(); j++) {
                AbstractDynaField dynaField = section.getField(j);
                if (!excludeFields.contains(dynaField.getFieldName())) {
                    if (dynaField.isColSpan()) {
                        if (columnIndex > 0) {
                            gridLayout.appendRow();
                        }
                        gridLayout.buildCell(dynaField.getDisplayName(), 0, gridLayout.getRows() - 1, 2, "100%",
                                Alignment.TOP_LEFT);
                        columnIndex = 0;
                        if (j < section.getFieldCount() - 1) {
                            gridLayout.appendRow();
                        }
                    } else {
                        gridLayout.buildCell(dynaField.getDisplayName(), columnIndex, gridLayout.getRows() - 1);
                        columnIndex++;
                        if (columnIndex == 2) {
                            columnIndex = 0;
                            if (j < section.getFieldCount() - 1) {
                                gridLayout.appendRow();
                            }
                        }
                    }

                    if (dynaField.isCustom()) {
                        fieldMappings.put("customfield." + dynaField.getFieldName(), dynaField);
                    } else {
                        fieldMappings.put(dynaField.getFieldName(), dynaField);
                    }
                }
            }
        } else {
            throw new MyCollabException("Does not support attachForm layout except 1 or 2 columns");
        }

        layout.addComponent(gridLayout.getLayout());
        sectionMappings.put(section, gridLayout);
    }
    return layout;
}

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

License:Open Source License

@Override
protected Component initContent() {
    if (StringUtils.isBlank(url) || StringUtils.isBlank(caption)) {
        Label lbl = new Label("&nbsp;");
        lbl.setContentMode(ContentMode.HTML);
        return lbl;
    } else {//from w  ww .  ja v a 2 s  .  c  o m
        final A link = new A(url).appendText(caption).setTarget("_blank");
        return new Label(link.write(), ContentMode.HTML);
    }
}

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("&nbsp;");
        lbl.setContentMode(ContentMode.HTML);
        lbl.setWidth("100%");
        return lbl;
    } else {//from   w w w . ja v  a 2s.  co  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.esofthead.mycollab.vaadin.web.ui.LabelHTMLDisplayWidget.java

License:Open Source License

public LabelHTMLDisplayWidget(String content) {
    description = content;/* w  w  w .ja  v  a 2s  .  com*/
    if (StringUtils.isBlank(description)) {
        addComponent(new Label("<<No Description>>"));
        return;
    }
    String contentLabel = trimText(content);
    lbDes = new Label(description, ContentMode.HTML);
    if (contentLabel != null && contentLabel.length() > NUM_CUT) {
        hasShowLess = true;

        contentLabel += " " + FontAwesome.PLUS_SQUARE.getHtml();
        lbDes.setValue(contentLabel);
        lbDes.addStyleName(UIConstants.LABEL_CLICKABLE);
    }

    lbDes.setDescription(description);
    addComponent(lbDes);
    addLayoutClickListener(new LayoutClickListener() {

        @Override
        public void layoutClick(LayoutClickEvent event) {
            if (event.getClickedComponent() instanceof Label) {
                if (description != null && description.length() > NUM_CUT) {
                    if (hasShowLess) {
                        lbDes.setValue(description + " " + FontAwesome.MINUS_SQUARE.getHtml());
                    } else {
                        lbDes.setValue(trimText(description) + " " + FontAwesome.PLUS_SQUARE.getHtml());
                    }
                    lbDes.setContentMode(ContentMode.HTML);
                    hasShowLess = !hasShowLess;
                }
            }
        }
    });
}