Example usage for com.vaadin.ui Label setCaption

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

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:fr.univlorraine.mondossierweb.views.EtatCivilView.java

License:Apache License

/**
 * Initialise la vue//from w w w.  ja v a 2 s  .  c o  m
 */
@PostConstruct
public void init() {

    LOG.debug(userController.getCurrentUserName() + " EtatCivilView");

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant())) {
        if (MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) {

            LOG.debug(userController.getCurrentUserName() + " init EtatCivilView");

            /* Style */
            setMargin(true);
            setSpacing(true);

            /* Titre */
            Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
            title.addStyleName(ValoTheme.LABEL_H1);
            addComponent(title);

            VerticalLayout globalLayout = new VerticalLayout();
            globalLayout.setSizeFull();
            globalLayout.setSpacing(true);

            //Layout avec les infos etatcivil et contact
            CssLayout idLayout = new CssLayout();
            idLayout.setSizeFull();
            idLayout.setStyleName("flexwrap");

            globalLayout.addComponent(idLayout);
            // Enable Responsive CSS selectors for the layout
            Responsive.makeResponsive(idLayout);

            /* Generalites */
            FormLayout formGeneralitesLayout = new FormLayout();
            formGeneralitesLayout.setSpacing(true);
            formGeneralitesLayout.setMargin(true);

            Panel panelGeneralites = new Panel(
                    applicationContext.getMessage(NAME + ".generalites.title", null, getLocale()));

            String captionNumDossier = applicationContext.getMessage(NAME + ".numdossier.title", null,
                    getLocale());
            Label fieldNumDossier = new Label();
            formatLabel(fieldNumDossier, captionNumDossier, MainUI.getCurrent().getEtudiant().getCod_etu());
            formGeneralitesLayout.addComponent(fieldNumDossier);

            String captionNNE = applicationContext.getMessage(NAME + ".nne.title", null, getLocale());
            Label fieldNNE = new Label();
            formatLabel(fieldNNE, captionNNE, MainUI.getCurrent().getEtudiant().getCod_nne());
            formGeneralitesLayout.addComponent(fieldNNE);

            String captionNom = applicationContext.getMessage(NAME + ".nom.title", null, getLocale());
            Label fieldNom = new Label();
            formatLabel(fieldNom, captionNom, MainUI.getCurrent().getEtudiant().getNom());
            formGeneralitesLayout.addComponent(fieldNom);

            String captionMail = applicationContext.getMessage(NAME + ".mail.title", null, getLocale());
            Label mailLabel = new Label();
            mailLabel.setCaption(captionMail);
            String mail = MainUI.getCurrent().getEtudiant().getEmail();
            if (StringUtils.hasText(mail)) {
                mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>";
                mailLabel.setValue(mail);
                mailLabel.setContentMode(ContentMode.HTML);
            }
            mailLabel.setSizeFull();
            formGeneralitesLayout.addComponent(mailLabel);

            String captionNationalite = applicationContext.getMessage(NAME + ".nationalite.title", null,
                    getLocale());
            Label fieldNationalite = new Label();
            formatLabel(fieldNationalite, captionNationalite,
                    MainUI.getCurrent().getEtudiant().getNationalite());
            formGeneralitesLayout.addComponent(fieldNationalite);

            String captionDateNaissance = applicationContext.getMessage(NAME + ".naissance.title", null,
                    getLocale());
            Label fieldDateNaissance = new Label();
            formatLabel(fieldDateNaissance, captionDateNaissance,
                    MainUI.getCurrent().getEtudiant().getDatenaissance());
            formGeneralitesLayout.addComponent(fieldDateNaissance);

            String captionLieuNaissance = applicationContext.getMessage(NAME + ".lieunaissance.title", null,
                    getLocale());
            Label fieldLieuNaissance = new Label();
            formatLabel(fieldLieuNaissance, captionLieuNaissance,
                    MainUI.getCurrent().getEtudiant().getLieunaissance());
            formGeneralitesLayout.addComponent(fieldLieuNaissance);

            String captionDepNaissance = applicationContext.getMessage(NAME + ".depnaissance.title", null,
                    getLocale());
            Label fieldDepNaissance = new Label();
            formatLabel(fieldDepNaissance, captionDepNaissance,
                    MainUI.getCurrent().getEtudiant().getDepartementnaissance());
            formGeneralitesLayout.addComponent(fieldDepNaissance);

            panelGeneralites.setContent(formGeneralitesLayout);

            HorizontalLayout generalitesGlobalLayout = new HorizontalLayout();
            generalitesGlobalLayout.setSizeUndefined();
            generalitesGlobalLayout.setStyleName("firstitembox");
            generalitesGlobalLayout.addComponent(panelGeneralites);
            generalitesGlobalLayout.setExpandRatio(panelGeneralites, 1);
            idLayout.addComponent(generalitesGlobalLayout);

            /* Bac */

            Panel panelBac = new Panel(applicationContext.getMessage(NAME + ".bac.title", null, getLocale()));

            //Si plusieurs bac
            if (MainUI.getCurrent().getEtudiant().getListeBac() != null
                    && MainUI.getCurrent().getEtudiant().getListeBac().size() > 1) {
                panelBac.setCaption(applicationContext.getMessage(NAME + ".bacs.title", null, getLocale()));
                TabSheet bacTabSheet = new TabSheet();
                VerticalLayout vBacLayout = new VerticalLayout();
                vBacLayout.setSizeFull();
                bacTabSheet.setSizeFull();
                bacTabSheet.addStyleName(ValoTheme.TABSHEET_FRAMED);
                for (BacEtatCivil bec : MainUI.getCurrent().getEtudiant().getListeBac()) {

                    FormLayout tabBacLayout = new FormLayout();
                    tabBacLayout.setSizeFull();
                    tabBacLayout.setMargin(false);
                    ajouterBacToView(tabBacLayout, bec);
                    bacTabSheet.addTab(tabBacLayout, bec.getCod_bac(), FontAwesome.GRADUATION_CAP);

                }
                vBacLayout.addComponent(bacTabSheet);
                panelBac.setContent(vBacLayout);
            } else {
                //Si un seul bac
                FormLayout formBacLayout = new FormLayout();
                formBacLayout.setSizeFull();
                if (MainUI.getCurrent().getEtudiant().getListeBac() != null
                        && MainUI.getCurrent().getEtudiant().getListeBac().size() == 1) {
                    formBacLayout.setSpacing(true);
                    formBacLayout.setMargin(true);
                    ajouterBacToView(formBacLayout, MainUI.getCurrent().getEtudiant().getListeBac().get(0));
                }
                panelBac.setContent(formBacLayout);
            }

            HorizontalLayout bacGlobalLayout = new HorizontalLayout();
            bacGlobalLayout.setSizeUndefined();
            bacGlobalLayout.setStyleName("itembox");
            bacGlobalLayout.addComponent(panelBac);
            bacGlobalLayout.setExpandRatio(panelBac, 1);
            idLayout.addComponent(bacGlobalLayout);

            /* Info de contact */
            panelContact = new Panel(applicationContext.getMessage(NAME + ".contact.title", null, getLocale()));
            renseignerPanelContact();
            globalLayout.addComponent(panelContact);

            addComponent(globalLayout);

        } else {
            /* Erreur */
            addComponent(new BasicErreurMessageLayout(applicationContext));
        }
    }
}

From source file:helpers.Utils.java

License:Open Source License

public static HorizontalLayout questionize(Component c, final String info, final String header) {
    final HorizontalLayout res = new HorizontalLayout();
    res.setSpacing(true);/*from   w w  w.  j ava2  s  .  c  om*/
    if (c instanceof CustomVisibilityComponent) {
        CustomVisibilityComponent custom = (CustomVisibilityComponent) c;
        c = custom.getInnerComponent();
        custom.addListener(new VisibilityChangeListener() {

            @Override
            public void setVisible(boolean b) {
                res.setVisible(b);
            }
        });
    }

    res.setVisible(c.isVisible());
    res.setCaption(c.getCaption());
    c.setCaption(null);
    res.addComponent(c);

    PopupView pv = new PopupView(new Content() {

        @Override
        public Component getPopupComponent() {
            Label l = new Label(info, ContentMode.HTML);
            l.setCaption(header);
            l.setIcon(FontAwesome.INFO);
            l.setWidth("250px");
            l.addStyleName("info");
            return new VerticalLayout(l);
        }

        @Override
        public String getMinimizedValueAsHTML() {
            return "[?]";
        }
    });
    pv.setHideOnMouseOut(false);

    res.addComponent(pv);

    return res;
}

From source file:info.magnolia.ui.form.field.factory.AbstractFieldFactory.java

License:Open Source License

@Override
public View getView() {
    final CssLayout fieldView = new CssLayout();
    fieldView.setStyleName("field-view");

    Label label = new Label();
    label.setSizeUndefined();/* www  . j  a va 2s  . co  m*/
    label.setCaption(getFieldDefinition().getLabel());

    if (getFieldDefinition().getClass().isAssignableFrom(TextFieldDefinition.class)) {
        final TextFieldDefinition textFieldDefinition = (TextFieldDefinition) getFieldDefinition();
        if (textFieldDefinition.getRows() > 0) {
            label.addStyleName("textarea");
        }
    }
    if (definition.getConverterClass() != null) {
        Converter converter = initializeConverter(definition.getConverterClass());
        label.setConverter(converter);
    }

    Property<?> property = initializeProperty();

    label.setPropertyDataSource(property);

    fieldView.addComponent(label);

    return new View() {
        @Override
        public Component asVaadinComponent() {
            return fieldView;
        }
    };
}

From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java

License:Open Source License

/**
 * Add File Name.<br>/*from w w w .j a  v a  2s.  c  o  m*/
 * If editFileName is true, display an Input Text Field. <br>
 * Else display a simple label.
 */
protected Component getFileDetailFileName() {
    // Build the file name without the extension
    final boolean hasExtension = StringUtils.isNotBlank(getValue().getExtension());
    final String extension = hasExtension ? "." + getValue().getExtension() : "";
    String fileName = StringUtils.removeEnd(getValue().getFileName(), extension);

    if (this.editFileName && !isReadOnly()) {
        TextField textField = new TextField(i18n.translate(fileDetailNameCaption), fileName);
        textField.setNullRepresentation("");
        textField.setCaption(i18n.translate(fileDetailNameCaption));
        textField.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                Object newFileNameObject = event.getProperty().getValue();
                String newFileName = (newFileNameObject != null
                        && StringUtils.isNotBlank(newFileNameObject.toString())) ? newFileNameObject.toString()
                                : UploadReceiver.INVALID_FILE_NAME;
                getValue().setFileName(newFileName + extension);
                getPropertyDataSource().setValue(getValue());
            }
        });
        return textField;
    } else {
        Label label = new Label("", ContentMode.HTML);
        label.setCaption(i18n.translate(fileDetailNameCaption));
        label.setValue(fileName);
        return label;
    }
}

From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java

License:Open Source License

/**
 * Add File Info./*from ww w  .j  a  va  2s  .  c  o  m*/
 */
protected Component getFileDetailSize() {
    Label label = new Label("", ContentMode.HTML);
    label.setCaption(i18n.translate(fileDetailSizeCaption));
    label.setValue(FileUtils.byteCountToDisplaySize(getValue().getFileSize()));
    return label;
}

From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java

License:Open Source License

/**
 * Add File Format.<br>//from   w w w .  j  a  v  a2s. co  m
 * If editFileFormat is true, display an Input Text Field. <br>
 * Else display a simple label.
 */
protected Component getFileDetailFileFormat() {
    if (this.editFileFormat && !isReadOnly()) {
        TextField textField = new TextField(i18n.translate(fileDetailFormatCaption), getValue().getExtension());
        textField.setNullRepresentation("");
        textField.setCaption(i18n.translate(fileDetailFormatCaption));
        return textField;
    } else {
        Label label = new Label("", ContentMode.HTML);
        label.setValue(getValue().getExtension());
        label.setCaption(i18n.translate(fileDetailFormatCaption));
        return label;
    }
}

From source file:org.eclipse.emf.ecp.controls.vaadin.AbstractVaadinSimpleControlRenderer.java

License:Open Source License

protected void createSetOrUnsetComponent(final Component component, final HorizontalLayout horizontalLayout,
        final Setting setting) {
    final Label unsetLabel = getUnsetComponent();
    final Button setButton = getUnsetButton(component, horizontalLayout, setting);
    setButton.setEnabled(getVElement().isEnabled());
    setButton.setVisible(getVElement().isVisible());
    setButton.setReadOnly(getVElement().isReadonly());
    horizontalLayout.addStyleName("textheight");
    horizontalLayout.removeAllComponents();
    Component addComponent = component;
    if (setting.isSet()) {
        setButton.setCaption(VaadinRendererMessages.AbstractVaadinSimpleControlRenderer_Set);
        unsetLabel.setCaption(getUnsetLabel());
        addComponent = unsetLabel;//from   w  ww  .j  a  va 2  s. c om

    } else {
        setButton.setCaption(VaadinRendererMessages.AbstractVaadinSimpleControlRenderer_Unset);

    }
    horizontalLayout.setData(addComponent);
    horizontalLayout.addComponent(addComponent);
    horizontalLayout.setExpandRatio(addComponent, 1f);
    horizontalLayout.addComponent(setButton);
    horizontalLayout.setComponentAlignment(setButton, Alignment.BOTTOM_RIGHT);

}

From source file:org.eclipse.emf.ecp.view.core.vaadin.internal.ECPVaadinViewRendererImpl.java

License:Open Source License

@Override
public ECPVaadinView render(ViewModelContext viewModelContext) {
    final Component resultSet = factory.render(viewModelContext.getViewModel(), viewModelContext);
    if (resultSet == null) {
        final Label label = new Label();
        label.setCaption("Rendering went wrong!"); //$NON-NLS-1$
        final VerticalLayout verticalLayout = new VerticalLayout(new com.vaadin.ui.Label());
        return new ECPVaadinViewImpl(verticalLayout, viewModelContext, factory);
    }//from w w  w .  j av  a2 s . com
    return new ECPVaadinViewImpl(resultSet, viewModelContext, factory);
}

From source file:org.eclipse.hawkbit.ui.common.builder.LabelBuilder.java

License:Open Source License

/**
 * Build label./*from   w w w  .  j  av  a 2s.co m*/
 * 
 * @return Label
 */
public Label buildLabel() {
    final Label label = createLabel();
    label.setImmediate(false);
    label.setWidth("-1px");
    label.setHeight("-1px");
    if (StringUtils.hasText(caption)) {
        label.setCaption(caption);
    }

    return label;
}

From source file:org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI.java

License:Open Source License

private Component buildDisclaimer() {
    final HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);// w  w w.  ja va 2 s  .  c  o m
    fields.addStyleName("disclaimer");

    final Label disclaimer = new Label(uiProperties.getDemo().getDisclaimer(), ContentMode.HTML);
    disclaimer.setCaption(i18n.getMessage("label.login.disclaimer"));
    disclaimer.setIcon(FontAwesome.EXCLAMATION_CIRCLE);
    disclaimer.setId("login-disclaimer");
    disclaimer.setWidth("525px");

    fields.addComponent(disclaimer);

    return fields;
}