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.ui.AbstractBeanPagedList.java

License:Open Source License

protected CssLayout createPageControls() {
    this.controlBarWrapper = new CssLayout();
    this.controlBarWrapper.setStyleName(listControlStyle);
    this.controlBarWrapper.setWidth("100%");

    final HorizontalLayout controlBar = new HorizontalLayout();
    controlBar.setWidth("100%");
    this.controlBarWrapper.addComponent(controlBar);

    this.pageManagement = new HorizontalLayout();

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

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

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

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

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

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

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

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

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

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

    this.pageManagement.setWidth(null);
    this.pageManagement.setSpacing(true);
    controlBar.addComponent(this.pageManagement);
    controlBar.setComponentAlignment(this.pageManagement, Alignment.MIDDLE_RIGHT);

    return this.controlBarWrapper;
}

From source file:com.esofthead.mycollab.vaadin.ui.AddViewLayout.java

License:Open Source License

public void setTitle(final String title) {
    if (title != null) {
        CssLayout titleWrap = new CssLayout();
        titleWrap.setStyleName("addViewTitle");
        titleWrap.setWidth("100%");
        titleWrap.addComponent(new Label(title));
        this.addComponent(titleWrap, "addViewTitle");
    } else {//w  w  w.  j  a va  2s.c o m
        this.removeComponent("addViewTitle");
    }
}

From source file:com.esofthead.mycollab.vaadin.ui.AttachmentDisplayComponent.java

License:Open Source License

public static Component constructAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }/* ww  w  .  j  a v  a2s  .  c o m*/

    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");

    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.setDescription(docName);
    thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    thumbnailWrap.addComponent(thumbnail);

    attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;");

    if (MimeTypesUtil.isImageType(docName)) {
        thumbnail.addClickListener(new MouseEvents.ClickListener() {
            private static final long serialVersionUID = -2853211588120500523L;

            @Override
            public void click(MouseEvents.ClickEvent event) {
                Resource previewResource = VaadinResourceManager.getResourceManager()
                        .getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE);
                UI.getCurrent().addWindow(new AttachmentPreviewWindow(previewResource));
            }
        });
    }

    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, SiteConfiguration.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 = ApplicationContextUtil
                                        .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(
            VaadinResourceManager.getResourceManager().getStreamResource(attachment.getPath()));
    fileDownloader.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;");
    return attachmentLayout;
}

From source file:com.esofthead.mycollab.vaadin.ui.BeanList.java

License:Open Source License

public void loadItems(List<T> currentListData) {
    contentLayout.removeAllComponents();

    try {/* w  w  w . j a  v a 2  s. co m*/
        if (CollectionUtils.isEmpty(currentListData) && isDisplayEmptyListText) {
            Label noItemLbl = new Label(AppContext.getMessage(GenericI18Enum.EXT_NO_ITEM));
            final VerticalLayout widgetFooter = new VerticalLayout();
            widgetFooter.addStyleName("widget-footer");
            widgetFooter.setWidth("100%");
            widgetFooter.addComponent(noItemLbl);
            widgetFooter.setComponentAlignment(noItemLbl, Alignment.MIDDLE_CENTER);
            contentLayout.addComponent(widgetFooter);
        } else {
            int i = 0;
            for (T item : currentListData) {
                RowDisplayHandler<T> rowHandler = constructRowDisplayHandler();

                Component row = rowHandler.generateRow(item, i);
                if (row != null) {
                    row.setWidth("100%");
                    contentLayout.addComponent(row);
                }

                i++;
            }
        }

    } catch (Exception e) {
        LOG.error("Error while generate column display", e);
    }
}

From source file:com.esofthead.mycollab.vaadin.ui.DateRangeField.java

License:Open Source License

@Override
protected Component initContent() {
    MHorizontalLayout container = new MHorizontalLayout();
    container.setSpacing(true);//w ww  .ja  v  a 2  s .  c  om
    Label dateStartLb = new Label("From:");
    Label dateEndLb = new Label("To:");

    container.with(dateStartLb, dateEndLb).withAlign(dateStartLb, Alignment.MIDDLE_CENTER).withAlign(dateEndLb,
            Alignment.MIDDLE_CENTER);

    setDateWidth(120);
    setDefaultValue();

    return container;
}

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

License:Open Source License

public Depot(final String title, final AbstractOrderedLayout headerElement,
        final ComponentContainer component) {
    this(new Label(title), headerElement, component, "100%", "100%");
}

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

License:Open Source License

public Depot(final String title, final AbstractOrderedLayout headerElement, final ComponentContainer component,
        final String headerWidth, final String headerLeftWidth) {
    this(new Label(title), headerElement, component, headerWidth, headerLeftWidth);
}

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

License:Open Source License

public Depot(final String title, final ComponentContainer component, final String headerWidth) {
    this(new Label(title), null, component, headerWidth, "250px");
}

From source file:com.esofthead.mycollab.vaadin.ui.FeedbackWindow.java

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(2, 5);
    mainLayout.setMargin(true);//w w w .  ja v  a2s .  c  o m
    mainLayout.setSpacing(true);

    emailNameTextField = new TextField();
    emailNameTextField.setWidth("500px");
    Label emailName = new Label("Your name: ");

    mainLayout.addComponent(emailName, 0, 0);
    mainLayout.addComponent(emailNameTextField, 1, 0);

    emailTextField = new TextField();
    emailTextField.setWidth("500px");
    emailTextField.setRequired(true);
    Label emailLbl = new Label("Your email: ");

    mainLayout.addComponent(emailLbl, 0, 1);
    mainLayout.addComponent(emailTextField, 1, 1);

    subjectTextField = new TextField();
    subjectTextField.setWidth("500px");
    subjectTextField.setRequired(true);
    Label subjectLbl = new Label("Subject: ");

    mainLayout.addComponent(subjectLbl, 0, 2);
    mainLayout.addComponent(subjectTextField, 1, 2);

    final RichTextArea contentArea = new RichTextArea();
    contentArea.setImmediate(true);
    contentArea.setWidth(500, Sizeable.Unit.PIXELS);
    contentArea.setHeight(200, Sizeable.Unit.PIXELS);
    Label contentLbl = new Label("Your feedback: ");

    mainLayout.addComponent(contentLbl, 0, 3);
    mainLayout.addComponent(contentArea, 1, 3);

    initDefaultData();

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

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("350px");

    MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments);
    uploadExt.addComponent(attachments);

    // Panel attachedFilepanel = new Panel();
    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setHeight("80px");
    contentLayout.setStyleName("noneBorder-panel");
    contentLayout.setSizeUndefined();

    contentLayout.addComponent(uploadExt);

    // attachedFilepanel.setContent(contentLayout);

    controlsLayout.addComponent(contentLayout);
    controlsLayout.setComponentAlignment(contentLayout, Alignment.BOTTOM_LEFT);
    controlsLayout.setExpandRatio(contentLayout, 1.0f);

    controlsLayout.setSpacing(true);

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

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

    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    controlsLayout.addComponent(cancelBtn);
    controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);

    Button sendBtn = new Button("Send", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            String email = emailTextField.getValue().toString().trim();
            String subject = subjectTextField.getValue().toString().trim();
            if (!StringUtils.isValidEmail(email)) {
                NotificationUtil.showWarningNotification("The email is not valid, please check it again!");
                return;
            }
            if (!email.equals("") && !subject.equals("")) {
                ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class);
                List<File> listFile = attachments.getListFile();
                List<EmailAttachementSource> emailAttachmentSource = null;

                if (CollectionUtils.isNotEmpty(listFile)) {
                    emailAttachmentSource = new ArrayList<EmailAttachementSource>();
                    for (File file : listFile) {
                        emailAttachmentSource.add(new FileEmailAttachmentSource(file));
                    }
                }

                String nameEmailFrom = emailNameTextField.getValue().toString().trim();
                nameEmailFrom = nameEmailFrom.equals("") ? email : nameEmailFrom;
                String toEmail = SiteConfiguration.getSendErrorEmail();

                FeedbackWindow.this.close();

                systemMailService.sendHTMLMail(email, nameEmailFrom,
                        Arrays.asList(new MailRecipientField(toEmail, toEmail)), null, null, subject,
                        contentArea.getValue().toString(), emailAttachmentSource);

            } else {
                NotificationUtil.showWarningNotification(
                        "The email field and subject field must be not empty! Please fulfil them before pressing enter button.");
            }
        }
    });
    sendBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 4, 1, 4);

    this.setContent(mainLayout);
}

From source file:com.esofthead.mycollab.vaadin.ui.form.field.RichTextViewField.java

License:Open Source License

@Override
protected Component initContent() {
    if (org.apache.commons.lang3.StringUtils.isBlank(value)) {
        Label lbl = new Label("&nbsp;");
        lbl.setContentMode(ContentMode.HTML);
        lbl.setWidth("100%");
        return lbl;
    } else {/*w ww . j  a v  a 2s  .  com*/
        final Label link = new Label(StringUtils.formatRichText(value), ContentMode.HTML);
        link.setWidth("100%");
        return link;
    }
}