Example usage for com.vaadin.ui Label setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.anphat.list.ui.DialogAddMapStaffCustomer.java

private void buildSearchLayout(boolean isCustInfo) {
    // common part: create layout
    searchLayout = new GridLayout();
    searchLayout.setImmediate(true);//from  www.j av  a 2  s. c o m
    searchLayout.setStyleName("custom-feildset");
    searchLayout.setCaption(MakeURL.makeURLForGrid(BundleUtils.getString("common.searchLabel")));
    searchLayout.setCaptionAsHtml(true);
    searchLayout.setWidth("100.0%");
    searchLayout.setHeight("-1px");
    searchLayout.setMargin(true);
    searchLayout.setSpacing(true);

    // lblCustCode
    Label lblCustCode = new Label();
    lblCustCode.setImmediate(true);
    lblCustCode.setWidth("100.0%");
    lblCustCode.setHeight("-1px");

    // tfCustCode
    txtStaffCode = new TextField();
    txtStaffCode.setImmediate(true);
    txtStaffCode.setWidth("100.0%");
    txtStaffCode.setHeight("-1px");

    // lblCustName
    Label lblCustName = new Label();
    lblCustName.setImmediate(true);
    lblCustName.setWidth("100.0%");
    lblCustName.setHeight("-1px");

    // tfCustName
    txtStaffName = new TextField();
    txtStaffName.setImmediate(true);
    txtStaffName.setWidth("100.0%");
    txtStaffName.setHeight("-1px");
    // lblCustCode
    Label lblEmail = new Label();
    lblEmail.setImmediate(true);
    lblEmail.setWidth("100.0%");
    lblEmail.setHeight("-1px");

    // tfCustCode
    txtEmail = new TextField();
    txtEmail.setImmediate(true);
    txtEmail.setWidth("100.0%");
    txtEmail.setHeight("-1px");

    // lblCustName
    Label lblTelephone = new Label();
    lblTelephone.setImmediate(true);
    lblTelephone.setWidth("100.0%");
    lblTelephone.setHeight("-1px");

    // tfCustName
    txtTelephone = new TextField();
    txtTelephone.setImmediate(true);
    txtTelephone.setWidth("100.0%");
    txtTelephone.setHeight("-1px");
    // lblCustName
    Label lblStaffType = new Label();
    lblStaffType.setImmediate(true);
    lblStaffType.setWidth("100.0%");
    lblStaffType.setHeight("-1px");

    // tfCustName
    cboStaffType = new ComboBox();
    cboStaffType.setImmediate(true);
    cboStaffType.setWidth("100.0%");
    cboStaffType.setHeight("-1px");

    if (isCustInfo) {
        lblCustCode.setValue(BundleUtils.getString("map.staff.customer.staffCode"));
        lblCustName.setValue(BundleUtils.getString("map.staff.customer.staffName"));
        lblEmail.setValue(BundleUtils.getString("goods.list.label.email"));
        lblTelephone.setValue(BundleUtils.getString("lb.deptstaff.common.phone"));
        lblStaffType.setValue(BundleUtils.getString("map.staff.customer.staffType"));
        searchLayout.setColumns(6);
        searchLayout.setRows(2);
        searchLayout.addComponent(lblCustCode, 0, 0);
        searchLayout.addComponent(txtStaffCode, 1, 0);
        searchLayout.addComponent(lblCustName, 2, 0);
        searchLayout.addComponent(txtStaffName, 3, 0);
        searchLayout.addComponent(lblEmail, 4, 0);
        searchLayout.addComponent(txtEmail, 5, 0);
        searchLayout.addComponent(lblStaffType, 0, 1);
        searchLayout.addComponent(cboStaffType, 1, 1);
        searchLayout.addComponent(lblTelephone, 2, 1);
        searchLayout.addComponent(txtTelephone, 3, 1);
    } else {
        lblCustCode.setValue(BundleUtils.getString("map.staff.customer.custCode"));
        lblCustName.setValue(BundleUtils.getString("map.staff.customer.custName"));
        lblEmail.setValue(BundleUtils.getString("goods.list.label.email"));
        lblTelephone.setValue(BundleUtils.getString("lb.deptstaff.common.phone"));
        searchLayout.setColumns(4);
        searchLayout.setRows(2);
        searchLayout.addComponent(lblCustCode, 0, 0);
        searchLayout.addComponent(txtStaffCode, 1, 0);
        searchLayout.addComponent(lblCustName, 2, 0);
        searchLayout.addComponent(txtStaffName, 3, 0);
        searchLayout.addComponent(lblEmail, 0, 1);
        searchLayout.addComponent(txtEmail, 1, 1);
        searchLayout.addComponent(lblTelephone, 2, 1);
        searchLayout.addComponent(txtTelephone, 3, 1);
    }
}

From source file:com.cavisson.gui.dashboard.components.controls.Dragging.java

License:Apache License

private List<Component> createComponents() {
    final List<Component> components = new ArrayList<Component>();

    final Label label = new Label("This is a long text block that will wrap.");
    label.setWidth("120px");
    components.add(label);/*from   ww  w .jav a2 s  .  co  m*/

    final Embedded image = new Embedded("", new ThemeResource("../runo/icons/64/document.png"));
    components.add(image);

    final CssLayout documentLayout = new CssLayout();
    documentLayout.setWidth("19px");
    for (int i = 0; i < 5; ++i) {
        final Embedded e = new Embedded(null, new ThemeResource("../runo/icons/16/document.png"));
        e.setHeight("16px");
        e.setWidth("16px");
        documentLayout.addComponent(e);
    }
    components.add(documentLayout);

    final VerticalLayout buttonLayout = new VerticalLayout();
    final Button button = new Button("Button");
    button.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            Notification.show("Button clicked");
        }
    });
    buttonLayout.addComponent(button);
    buttonLayout.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
    components.add(buttonLayout);

    return components;
}

From source file:com.cavisson.gui.dashboard.components.controls.Panels.java

License:Apache License

Component panelContent() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from w  ww. j ava  2s.co m
    layout.setMargin(true);
    layout.setSpacing(true);
    Label content = new Label(
            "Suspendisse dictum feugiat nisl ut dapibus. Mauris iaculis porttitor posuere. Praesent id metus massa, ut blandit odio.");
    content.setWidth("10em");
    layout.addComponent(content);
    Button button = new Button("Button");
    button.setSizeFull();
    layout.addComponent(button);
    return layout;
}

From source file:com.cavisson.gui.dashboard.components.controls.Panels.java

License:Apache License

Component panelContentScroll() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//w ww  .jav a 2s  .co m
    layout.setSpacing(true);
    Label content = new Label(
            "Suspendisse dictum feugiat nisl ut dapibus. Mauris iaculis porttitor posuere. Praesent id metus massa, ut blandit odio. Suspendisse dictum feugiat nisl ut dapibus. Mauris iaculis porttitor posuere. Praesent id metus massa, ut blandit odio.");
    content.setWidth("10em");
    layout.addComponent(content);
    Button button = new Button("Button");
    layout.addComponent(button);
    return layout;
}

From source file:com.cms.component.CustomPageTable.java

public HorizontalLayout createControls(String pageSizeDefault) {
    this.pageSizeDefault = pageSizeDefault;
    separatorTotal.setImmediate(true);/* w  w  w  .  j  ava 2s .com*/
    Label itemsPerPageLabel = new Label(BundleUtils.getString("common.table.numberRecord"));

    for (String numberSize : Constants.PAGE_SIZE_LIST) {
        itemsPerPageSelect.addItem(numberSize);
    }
    itemsPerPageSelect.setImmediate(true);
    itemsPerPageSelect.setNullSelectionAllowed(false);
    itemsPerPageSelect.setWidth("50px");
    itemsPerPageSelect.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            setPageLength(Integer.valueOf(String.valueOf(event.getProperty().getValue())));
            firePagedChangedEvent();
        }
    });
    itemsPerPageSelect.select(pageSizeDefault);
    Label pageLabel = new Label(BundleUtils.getString("common.table.page"), ContentMode.HTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.setConverter(Integer.class);
    currentPageTextField
            .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages()));
    Label separatorLabel = new Label("&nbsp;/&nbsp;", ContentMode.HTML);
    final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), ContentMode.HTML);
    currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL);
    currentPageTextField.setImmediate(true);
    currentPageTextField.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            currentPageTextField.removeAllValidators();
            currentPageTextField
                    .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages()));
            if (Integer.valueOf(String.valueOf(currentPageTextField.getValue())) <= getTotalAmountOfPages()) {
                int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue()));
                setCurrentPage(page);
            }
        }
    });
    pageLabel.setWidth(null);
    currentPageTextField.setWidth("30px");
    separatorLabel.setWidth(null);
    totalPagesLabel.setWidth(null);

    HorizontalLayout controlBar = new HorizontalLayout();
    HorizontalLayout pageSize = new HorizontalLayout();
    HorizontalLayout pageManagement = new HorizontalLayout();
    final Button first = new Button("<<", new Button.ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setCurrentPage(0);
        }
    });
    previous = new Button("<", new Button.ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            previousPage();
        }
    });
    final Button next = new Button(">", new Button.ClickListener() {
        private static final long serialVersionUID = -1927138212640638452L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            nextPage();
        }
    });
    final Button last = new Button(">>", new Button.ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setCurrentPage(getTotalAmountOfPages());
        }
    });
    first.setStyleName(Reindeer.BUTTON_LINK);
    previous.setStyleName(Reindeer.BUTTON_LINK);
    next.setStyleName(Reindeer.BUTTON_LINK);
    last.setStyleName(Reindeer.BUTTON_LINK);

    itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption");
    itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox");
    pageLabel.addStyleName("pagedtable-pagecaption");
    currentPageTextField.addStyleName("pagedtable-pagefield");
    separatorLabel.addStyleName("pagedtable-separator");
    separatorTotal.addStyleName("pagedtable-separator");
    totalPagesLabel.addStyleName("pagedtable-total");
    first.addStyleName("pagedtable-first");
    previous.addStyleName("pagedtable-previous");
    next.addStyleName("pagedtable-next");
    last.addStyleName("pagedtable-last");

    itemsPerPageLabel.addStyleName("pagedtable-label");
    itemsPerPageSelect.addStyleName("pagedtable-combobox");
    pageLabel.addStyleName("pagedtable-label");
    currentPageTextField.addStyleName("pagedtable-label");
    separatorLabel.addStyleName("pagedtable-label");
    separatorTotal.addStyleName("pagedtable-label");
    totalPagesLabel.addStyleName("pagedtable-label");
    first.addStyleName("pagedtable-button");
    previous.addStyleName("pagedtable-button");
    next.addStyleName("pagedtable-button");
    last.addStyleName("pagedtable-button");

    pageSize.addComponent(itemsPerPageLabel);
    pageSize.addComponent(itemsPerPageSelect);
    Label separator = new Label("&nbsp;/&nbsp;", ContentMode.HTML);
    pageSize.addComponent(separator);
    pageSize.addComponent(separatorTotal);
    pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT);
    pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT);
    pageSize.setComponentAlignment(separator, Alignment.MIDDLE_LEFT);
    pageSize.setComponentAlignment(separatorTotal, Alignment.MIDDLE_LEFT);
    pageSize.setSpacing(true);
    pageManagement.addComponent(first);
    pageManagement.addComponent(previous);
    pageManagement.addComponent(pageLabel);
    pageManagement.addComponent(currentPageTextField);
    pageManagement.addComponent(separatorLabel);
    pageManagement.addComponent(totalPagesLabel);
    pageManagement.addComponent(next);
    pageManagement.addComponent(last);
    pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT);
    pageManagement.setWidth(null);
    pageManagement.setSpacing(true);
    controlBar.addComponent(pageSize);
    controlBar.addComponent(pageManagement);
    controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER);
    controlBar.setWidth("100%");
    controlBar.setExpandRatio(pageSize, 1);
    addListener(new PageChangeListener() {
        @Override
        public void pageChanged(PagedTableChangeEvent event) {
            int abc = event.getCurrentPage();
            first.setEnabled(container.getStartIndex() > 0);
            previous.setEnabled(container.getStartIndex() > 0);
            next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
            last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
            currentPageTextField.setValue(String.valueOf(getCurrentPage()));
            totalPagesLabel.setValue(String.valueOf(getTotalAmountOfPages()));
            if (resizePage) {
                int lenght = getPageLength();
                int a = lenght % 5;
                int b = lenght / 5;
                if (a != 0) {
                    int pageLenght = 5 * (b + 1);
                    itemsPerPageSelect.setValue(pageLenght);
                }
            }
            separatorTotal.setValue(String.valueOf(container.getRealSize()));
        }
    });
    return controlBar;
}

From source file:com.cms.utils.CommonUtils.java

/**
 * Build label//from  ww  w .  j a  v  a  2 s .com
 *
 * @param value caption of label
 * @param isBold if bold --> label will have bold style
 * @return
 */
public static Label buildLabel(String value, boolean isBold) {
    Label label = new Label();
    label.setWidth("100%");
    label.setHeight("-1px");
    label.setValue(value);
    label.setImmediate(true);
    if (isBold) {
        label.addStyleName("v-label-bold");
    }
    return label;
}

From source file:com.cms.utils.InitDateTime.java

public InitDateTime() {
    date.setWidth("100.0%");
    date.setHeight("-1px");
    final PopupDateField popupDateField = new PopupDateField();
    float dateWidth = date.getWidth() - 14;
    popupDateField.setWidth(String.valueOf(dateWidth));
    popupDateField.setId("date");
    //        popupDateField.addStyleName("v-textfield v-widget v-textfield-required v-required v-has-width");
    popupDateField.setLocale(new Locale("vi"));
    popupDateField.setImmediate(false);/*from   w w  w. j a v  a2s .c  o  m*/
    popupDateField.setValidationVisible(false);
    popupDateField.addBlurListener(new FieldEvents.BlurListener() {
        @Override
        public void blur(FieldEvents.BlurEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("setValueDate();");
        }
    });
    popupDateField.addFocusListener(new FieldEvents.FocusListener() {

        @Override
        public void focus(FieldEvents.FocusEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("focusDate();");
        }
    });
    Label label = new Label(
            "<div id=\"error-date\" class=\"v-errorindicator\" onmouseover=\"showError()\" onmouseout=\"hideError()\" aria-hidden=\"true\" style=\"display: none;\">&nbsp;</div>",
            ContentMode.HTML);
    label.setId("label");
    //        label.addStyleName("v-required-field-indicator");
    label.setWidth("14px");
    //        label.setWidth("10px");
    //        label.setHeight("10px");
    label.setDescription(
            "<span id=\"notification-date\" style=\" background:#fff;color:red;padding:0\">Ngy thng cha ng nh dng</span>");
    date.addComponent(popupDateField);
    //        Page.getCurrent().getJavaScript().execute("addCsstotip()");
    date.addComponent(label);
    date.setExpandRatio(popupDateField, 3);
    date.setExpandRatio(label, 1);
    //        layoutMain.addComponent(date);
}

From source file:com.esofthead.mycollab.mobile.module.crm.view.CrmLoginViewImpl.java

License:Open Source License

private void initUI() {
    this.setStyleName("login-view");
    this.setSizeFull();

    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setStyleName("content-wrapper");
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    contentLayout.setMargin(true);/* ww w .  j  av a  2  s . co  m*/
    contentLayout.setSpacing(true);
    contentLayout.setWidth("320px");

    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%");
    Label welcomeText = new Label("Login to CRM");
    welcomeText.setWidth("150px");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeTextWrapper);

    final EmailField emailField = new EmailField();
    emailField.setWidth("100%");
    emailField.setInputPrompt("E-mail Address");
    emailField.setStyleName("email-input");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    pwdField.setInputPrompt("Password");
    pwdField.setStyleName("password-input");
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox();
    rememberPassword.setWidth("100%");
    rememberPassword.setCaption("Remember password");
    rememberPassword.setValue(true);
    contentLayout.addComponent(rememberPassword);

    Button signInBtn = new Button("Sign In");
    signInBtn.setWidth("100%");
    signInBtn.addStyleName(UIConstants.BUTTON_BIG);
    signInBtn.addStyleName(UIConstants.COLOR_BLUE);
    signInBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new CrmEvent.PlainLogin(this, new String[] {
                    emailField.getValue(), pwdField.getValue(), String.valueOf(rememberPassword.getValue()) }));
        }
    });
    contentLayout.addComponent(signInBtn);

    Button createAccountBtn = new Button("Create Account");
    createAccountBtn.setWidth("100%");
    createAccountBtn.addStyleName(UIConstants.BUTTON_BIG);
    createAccountBtn.addStyleName(UIConstants.COLOR_GRAY);
    contentLayout.addComponent(createAccountBtn);

    this.addComponent(contentLayout);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.form.field.ProjectFormAttachmentDisplayField.java

License:Open Source License

@Override
protected Component initContent() {
    ResourceService resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = resourceService.getContents(
            AttachmentUtils.getProjectEntityAttachmentPath(AppContext.getAccountId(), projectid, type, typeid));
    if (CollectionUtils.isNotEmpty(attachments)) {
        VerticalLayout comp = new VerticalLayout();
        comp.setStyleName("attachment-view-panel");

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

            if (MimeTypesUtil.isImageType(docName)) {
                Button b = new Button(attachment.getTitle(), new Button.ClickListener() {

                    private static final long serialVersionUID = 293396615972447886L;

                    @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%");
                comp.addComponent(b);
            } else {
                Label l = new Label(attachment.getTitle());
                l.setWidth("100%");
                comp.addComponent(l);
            }
        }

        return comp;
    }
    return new Label("&nbsp;", ContentMode.HTML);
}

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 .j a v a  2  s .  co m*/
                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;
}