Example usage for com.vaadin.ui Label addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:fr.univlorraine.mondossierweb.views.windows.SignificationsMobileWindow.java

License:Apache License

/**
 * Cre une fentre/*w  w  w .ja  va 2s .  c  om*/
 */
public SignificationsMobileWindow(boolean afficherSignificationIndicateurProfondeur) {

    setWidth("95%");
    setHeight("95%");

    setCaption(applicationContext.getMessage("significationsWindow.title", null, getLocale()));
    setModal(true);
    setResizable(false);
    setClosable(false);
    setStyleName("v-popover-blank");

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    setContent(layout);

    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setWidth("100%");
    panelLayout.setStyleName("v-scrollableelement");
    panelLayout.setSpacing(true);
    panelLayout.setMargin(true);

    if (MdwTouchkitUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {

        Panel panelSignificationResultats = new Panel();
        panelSignificationResultats.setCaption(
                applicationContext.getMessage(NAME + ".info.significations.resultats", null, getLocale()));
        panelSignificationResultats.addStyleName("significationpanel");
        panelSignificationResultats.setWidth("100%");

        VerticalLayout significationLayout = new VerticalLayout();
        significationLayout.setWidth("100%");
        significationLayout.setMargin(true);
        significationLayout.setSpacing(true);

        Set<String> ss = MdwTouchkitUI.getCurrent().getEtudiant().getSignificationResultats().keySet();
        for (String k : ss) {
            if (k != null && !k.equals("") && !k.equals(" ")) {
                HorizontalLayout signLayout = new HorizontalLayout();
                signLayout.setSizeFull();
                signLayout.setMargin(true);
                signLayout.setSpacing(true);
                Label codeLabel = new Label(k);
                codeLabel.setStyleName(ValoTheme.LABEL_BOLD);
                codeLabel.addStyleName("v-label-align-right");
                signLayout.addComponent(codeLabel);
                Label valueLabel = new Label(
                        "" + MdwTouchkitUI.getCurrent().getEtudiant().getSignificationResultats().get(k));
                signLayout.addComponent(valueLabel);
                significationLayout.addComponent(signLayout);
            }
        }

        panelSignificationResultats.setContent(significationLayout);
        panelLayout.addComponent(panelSignificationResultats);

    }

    if (afficherSignificationIndicateurProfondeur) {

        Panel panelSignificationIndicateurs = new Panel();
        panelSignificationIndicateurs.setCaption(
                applicationContext.getMessage(NAME + ".info.significations.indicateurs", null, getLocale()));
        panelSignificationIndicateurs.addStyleName("significationpanel");
        panelSignificationIndicateurs.setWidth("100%");

        VerticalLayout significationLayout = new VerticalLayout();
        significationLayout.setMargin(true);
        significationLayout.setSpacing(true);
        significationLayout.setWidth("100%");

        //1er NIVEAU
        HorizontalLayout levelLayout1 = new HorizontalLayout();
        levelLayout1.setWidth("100%");
        HorizontalLayout levelMainLayout1 = new HorizontalLayout();
        levelMainLayout1.setWidth("100%");
        levelMainLayout1.setSpacing(true);
        levelMainLayout1.setStyleName("level-indicator-layout");
        int k = 0;
        for (int i = 0; i < 1; i++) {
            //Ajout d'un level
            k++;
            Label libLevelLayout = new Label();
            libLevelLayout.setSizeFull();
            libLevelLayout.setHeight("8px");
            libLevelLayout.setStyleName("layout-level-green-indicator");
            levelMainLayout1.addComponent(libLevelLayout);
        }
        //On pense avoir 7 level maxi 
        for (int j = k; j < 8; j++) {
            Label libLevelSpaceLayout = new Label();
            libLevelSpaceLayout.setSizeFull();
            libLevelSpaceLayout.setHeight("8px");
            levelMainLayout1.addComponent(libLevelSpaceLayout);
        }

        levelLayout1.addComponent(levelMainLayout1);
        levelLayout1.addComponent(new Label("1er niveau"));
        significationLayout.addComponent(levelLayout1);

        //2em NIVEAU
        HorizontalLayout levelLayout2 = new HorizontalLayout();
        levelLayout2.setSizeFull();
        HorizontalLayout levelMainLayout2 = new HorizontalLayout();
        levelMainLayout2.setSizeFull();
        levelMainLayout2.setSpacing(true);
        levelMainLayout2.setStyleName("level-indicator-layout");
        k = 0;
        for (int i = 0; i < 2; i++) {
            //Ajout d'un level
            k++;
            Label libLevelLayout = new Label();
            libLevelLayout.setSizeFull();
            libLevelLayout.setHeight("8px");
            libLevelLayout.setStyleName("layout-level-green-indicator");
            levelMainLayout2.addComponent(libLevelLayout);
        }
        //On pense avoir 7 level maxi 
        for (int j = k; j < 8; j++) {
            Label libLevelSpaceLayout = new Label();
            libLevelSpaceLayout.setSizeFull();
            libLevelSpaceLayout.setHeight("8px");
            levelMainLayout2.addComponent(libLevelSpaceLayout);
        }

        levelLayout2.addComponent(levelMainLayout2);
        levelLayout2.addComponent(new Label("2em niveau"));
        significationLayout.addComponent(levelLayout2);

        //3em NIVEAU
        HorizontalLayout levelLayout3 = new HorizontalLayout();
        levelLayout3.setSizeFull();
        HorizontalLayout levelMainLayout3 = new HorizontalLayout();
        levelMainLayout3.setSizeFull();
        levelMainLayout3.setSpacing(true);
        levelMainLayout3.setStyleName("level-indicator-layout");
        k = 0;
        for (int i = 0; i < 3; i++) {
            //Ajout d'un level
            k++;
            Label libLevelLayout = new Label();
            libLevelLayout.setSizeFull();
            libLevelLayout.setHeight("8px");
            libLevelLayout.setStyleName("layout-level-green-indicator");
            levelMainLayout3.addComponent(libLevelLayout);
        }
        //On pense avoir 7 level maxi 
        for (int j = k; j < 8; j++) {
            Label libLevelSpaceLayout = new Label();
            libLevelSpaceLayout.setSizeFull();
            libLevelSpaceLayout.setHeight("8px");
            levelMainLayout3.addComponent(libLevelSpaceLayout);
        }

        levelLayout3.addComponent(levelMainLayout3);
        levelLayout3.addComponent(new Label("3em niveau"));
        significationLayout.addComponent(levelLayout3);

        //4em NIVEAU
        HorizontalLayout levelLayout4 = new HorizontalLayout();
        levelLayout4.setSizeFull();
        HorizontalLayout levelMainLayout4 = new HorizontalLayout();
        levelMainLayout4.setSizeFull();
        levelMainLayout4.setSpacing(true);
        levelMainLayout4.setStyleName("level-indicator-layout");
        k = 0;
        for (int i = 0; i < 4; i++) {
            //Ajout d'un level
            k++;
            Label libLevelLayout = new Label();
            libLevelLayout.setSizeFull();
            libLevelLayout.setHeight("8px");
            libLevelLayout.setStyleName("layout-level-green-indicator");
            levelMainLayout4.addComponent(libLevelLayout);
        }
        //On pense avoir 7 level maxi 
        for (int j = k; j < 8; j++) {
            Label libLevelSpaceLayout = new Label();
            libLevelSpaceLayout.setSizeFull();
            libLevelSpaceLayout.setHeight("8px");
            levelMainLayout4.addComponent(libLevelSpaceLayout);
        }

        levelLayout4.addComponent(levelMainLayout4);
        levelLayout4.addComponent(new Label("4em niveau"));
        significationLayout.addComponent(levelLayout4);

        //ETC
        HorizontalLayout levelLayoutEtc = new HorizontalLayout();
        levelLayoutEtc.setSizeFull();

        levelLayoutEtc.addComponent(new Label("..."));
        levelLayoutEtc.addComponent(new Label(""));
        significationLayout.addComponent(levelLayoutEtc);

        panelSignificationIndicateurs.setContent(significationLayout);
        panelLayout.addComponent(panelSignificationIndicateurs);

    }

    layout.addComponent(panelLayout);

    // close button
    HorizontalLayout bLayout = new HorizontalLayout();
    bLayout.setSizeFull();
    bLayout.setHeight("50px");

    Button closeButton = new Button();
    //closeButton.setCaption(applicationContext.getMessage("significationsWindow.btnFermer", null, getLocale()));
    closeButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    closeButton.addStyleName("v-popover-button");
    closeButton.setIcon(FontAwesome.CHECK);
    closeButton.addClickListener(e -> {
        close();

    });

    bLayout.addComponent(closeButton);
    bLayout.setComponentAlignment(closeButton, Alignment.MIDDLE_CENTER);
    layout.addComponent(bLayout);

    layout.setExpandRatio(panelLayout, 1);

}

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);/* w  w w. j  av  a 2s  . co m*/
    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.about.app.AboutViewImpl.java

License:Open Source License

private Component createInstallationSection() {

    // build and bind fields
    Component mgnlEdition = buildAndBind(AboutView.MAGNOLIA_EDITION_KEY,
            i18n.translate("about.app.main.mgnledition"));
    Component mgnlVersion = buildAndBind(AboutView.MAGNOLIA_VERSION_KEY,
            i18n.translate("about.app.main.mgnlversion"));
    Component mgnlInstance = buildAndBind(AboutView.MAGNOLIA_INSTANCE_KEY,
            i18n.translate("about.app.main.instance"));

    Component osInfo = buildAndBind(AboutView.OS_INFO_KEY, i18n.translate("about.app.main.os"));
    Component javaInfo = buildAndBind(AboutView.JAVA_INFO_KEY, i18n.translate("about.app.main.java"));
    Component serverInfo = buildAndBind(AboutView.SERVER_INFO_KEY, i18n.translate("about.app.main.server"));
    Component dbInfo = buildAndBind(AboutView.DB_INFO_KEY, i18n.translate("about.app.main.dbinfo"));
    Component dbDriverInfo = buildAndBind(AboutView.DB_DRIVER_INFO_KEY,
            i18n.translate("about.app.main.dbdriverinfo"));
    Component jcrInfo = buildAndBind(AboutView.JCR_INFO_KEY, i18n.translate("about.app.main.repository"));

    // layout/*from w w w.  java  2s. c  o  m*/
    FormLayout layout = new FormLayout();

    Label sectionTitle = new Label(i18n.translate("about.app.main.installation.title"));
    sectionTitle.addStyleName("section-title");
    layout.addComponent(sectionTitle);

    layout.addComponent(createFieldsetTitle(i18n.translate("about.app.main.magnolia.title")));
    layout.addComponent(mgnlEdition);
    layout.addComponent(mgnlVersion);
    layout.addComponent(mgnlInstance);

    Component environmentTitle = createFieldsetTitle(i18n.translate("about.app.main.environment.title"));
    environmentTitle.addStyleName("spacer");
    layout.addComponent(environmentTitle);
    layout.addComponent(osInfo);
    layout.addComponent(javaInfo);
    layout.addComponent(serverInfo);
    layout.addComponent(dbInfo);
    layout.addComponent(dbDriverInfo);
    layout.addComponent(jcrInfo);

    return layout;
}

From source file:info.magnolia.configuration.app.overview.toolbar.ToolbarViewImpl.java

License:Open Source License

private Component decorateComponent(String caption, Component toWrap) {
    final HorizontalLayout result = new HorizontalLayout();
    result.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    result.setSpacing(true);/*from   ww w. j av a 2 s. c  o m*/
    result.setSizeUndefined();

    final Label captionLabel = new Label(caption);
    captionLabel.setSizeUndefined();
    captionLabel.addStyleName("caption-label");

    result.addComponent(captionLabel);
    result.addComponent(toWrap);

    return result;
}

From source file:info.magnolia.messages.app.MessagesViewImpl.java

License:Open Source License

@Inject
public MessagesViewImpl(SimpleTranslator i18n) {

    this.i18n = i18n;

    // create form and data item
    final Message message = new Message(); // message POJO
    BeanItem<Message> messageItem = new BeanItem<Message>(message);

    final FieldGroup form = new FieldGroup();
    form.setItemDataSource(messageItem);

    Field<String> subjectField = createSubjectTextField();
    Field<String> messageBodyField = createMessageBodyTextField();
    Field<?> typeField = createTypeSelectionField();
    Field<?> scopeField = createScopeSelectionField();
    userOrGroupIdField = createUserOrGroupIdTextField();

    // disable user/group field if not necessary
    scopeField.addValueChangeListener(new ValueChangeListener() {

        @Override/*from  ww  w  . jav  a  2s  .co m*/
        public void valueChange(ValueChangeEvent event) {
            updateUserOrGroupField((String) event.getProperty().getValue());
        }
    });

    form.bind(subjectField, "title");
    form.bind(messageBodyField, "content");
    form.bind(typeField, "type");
    form.bind(scopeField, "scope");
    form.bind(userOrGroupIdField, "user");
    // FieldGroup overrides fields' own enabled property with its own.
    updateUserOrGroupField(message.getScope());

    FormLayout layout = new FormLayout();
    layout.addComponent(subjectField);
    layout.addComponent(messageBodyField);
    layout.addComponent(typeField);
    layout.addComponent(scopeField);
    layout.addComponent(userOrGroupIdField);

    layout.setSpacing(true);
    layout.setMargin(false);
    layout.setWidth("100%");

    // send button
    NativeButton sendButton = new NativeButton(i18n.translate("messages-app.app.button.sendMessage"),
            new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    try {
                        form.commit();
                        String subject = message.getTitle();
                        String content = message.getContent();
                        MessageType type = message.getType();
                        String scope = message.getScope();

                        if (MESSAGE_SCOPE_LOCAL.equals(scope)) {
                            listener.handleLocalMessage(type, subject, content);
                        } else if (MESSAGE_SCOPE_GLOBAL.equals(scope)) {
                            listener.handleGlobalMessage(type, subject, content);
                        } else if (MESSAGE_SCOPE_GROUP.equals(scope)) {
                            // message is bound to FieldGroup - hence the group name is to be retrieved from the user field of the message
                            final String groupName = message.getUser();
                            listener.handleGroupMessage(groupName, type, subject, content);
                        } else {
                            // User...
                            final String userName = message.getUser();
                            listener.handleUserMessage(userName, type, subject, content);
                        }
                    } catch (CommitException e) {

                    }
                }
            });
    sendButton.addStyleName("btn-dialog");
    sendButton.addStyleName("commit");

    // reset button
    NativeButton resetButton = new NativeButton(i18n.translate("messages-app.app.button.reset"),
            new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    message.reset();
                    form.discard();
                }
            });
    resetButton.addStyleName("btn-dialog");
    resetButton.addStyleName("cancel");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.addStyleName("buttons");
    buttons.setSpacing(true);
    buttons.addComponent(sendButton);
    buttons.addComponent(resetButton);
    layout.addComponent(buttons);

    // intro text
    Label intro = new Label(i18n.translate("messages-app.app.label.intro"), ContentMode.HTML);
    intro.addStyleName("intro");

    CssLayout container = new CssLayout();
    container.setSizeFull();
    container.addStyleName("small-app-panel");
    container.addComponent(layout);

    CssLayout root = new CssLayout();
    root.setSizeFull();
    root.setWidth("900px");
    root.setStyleName("small-app");
    root.addComponent(intro);
    root.addComponent(container);

    component = root;
}

From source file:info.magnolia.photoreview.app.config.PhotoReviewConfigViewImpl.java

License:Open Source License

private Component createFormLayout() {

    formLayout = new FormLayout();

    Label sectionTitle = new Label(i18n.translate("photoreview.config.title"));
    sectionTitle.addStyleName("section-title");
    formLayout.addComponent(sectionTitle);

    Button saveButton = new Button(i18n.translate("photoreview.main.saveSettings.label"));
    saveButton.addStyleName("commit");
    saveButton.addClickListener(new ClickListener() {

        @Override//w  w  w.  j av  a2  s . c  o  m
        public void buttonClick(ClickEvent event) {
            listener.saveSettings(dataSource);
        }
    });
    formLayout.addComponent(saveButton);

    return formLayout;
}

From source file:info.magnolia.ui.admincentral.shellapp.favorites.FavoritesForm.java

License:Open Source License

private void init() {
    addStyleName("favorites-form");
    final VerticalLayout favoriteForm = new VerticalLayout();
    favoriteEntryForm = new InternalFavoriteEntryForm();
    favoriteGroupForm = new InternalFavoriteGroupForm();

    tabsheet = new TabSheet();
    tabsheet.addStyleName("favorites-tabs");
    tabsheet.addTab(favoriteEntryForm, i18n.translate("favorites.form.favorite.add"));
    tabsheet.addTab(favoriteGroupForm, i18n.translate("favorites.form.group.add"));

    tabsheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        @Override//from   ww  w  .  ja va2  s . c om
        public void selectedTabChange(SelectedTabChangeEvent event) {
            if (event.getTabSheet().getSelectedTab() instanceof InternalFavoriteEntryForm) {
                favoriteGroupForm.removeEnterKeyShortcutListener();
                favoriteEntryForm.addEnterKeyShortcutListener();
            } else {
                favoriteEntryForm.removeEnterKeyShortcutListener();
                favoriteGroupForm.addEnterKeyShortcutListener();
            }
        }
    });

    final CssLayout header = new CssLayout();
    header.addStyleName("dialog-header");
    header.setSizeFull();
    header.addLayoutClickListener(new LayoutClickListener() {
        @Override
        public void layoutClick(LayoutClickEvent event) {
            // change the visibility of the group- and favorite-items
            if (event.getClickedComponent() == editIcon || event.getChildComponent() == editLabel) {
                if (!listener.hasItems() || listener.itemsAreEditable()) {
                    listener.setToInitialState();
                } else {
                    listener.setItemsEditable(true);
                }
            } else {
                // just open || close the FavoritesForm
                if (isOpen()) {
                    close();
                } else {
                    open();
                }
            }
        }
    });

    // add
    final Label addNewIcon = new Label();
    addNewIcon.setSizeUndefined();
    addNewIcon.addStyleName("icon");
    addNewIcon.addStyleName("icon-add-fav");
    final Label addNewLabel = new Label(i18n.translate("favorites.form.add"));
    addNewLabel.setSizeUndefined();
    addNewLabel.addStyleName("title");

    // edit
    editIcon = new Label();
    editIcon.setSizeUndefined();
    editIcon.addStyleName(EDIT_ACTION_STYLENAME);
    editIcon.addStyleName("icon");
    editIcon.addStyleName("icon-edit");

    editLabel = new Label(i18n.translate("favorites.form.favorite.edit"));
    editLabel.setSizeUndefined();
    editLabel.addStyleName("title");
    editLabel.addStyleName(EDIT_ACTION_STYLENAME);

    // arrow
    arrowIcon = new Label();
    arrowIcon.setSizeUndefined();
    arrowIcon.addStyleName("icon");
    arrowIcon.addStyleName("arrow");
    arrowIcon.addStyleName("icon-arrow2_n");

    // assemble
    header.addComponent(addNewIcon);
    header.addComponent(addNewLabel);
    header.addComponent(editIcon);
    header.addComponent(editLabel);
    header.addComponent(arrowIcon);
    favoriteForm.addComponent(header);
    favoriteForm.addComponent(tabsheet);

    // form is closed initially
    close();
    setCompositionRoot(favoriteForm);
}

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();// ww  w.j a v a2s. c om
    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

/**
 * Main entry point to create the Empty Layout.
 * This Basic implementation of Empty layout is composed of <br>
 * - An Upload button <br>//from w  ww . j av  a  2  s .c  o m
 * - A Label inviting to Drag files <br>
 */
@Override
protected void buildEmptyLayout() {
    layout.removeAllComponents();
    if (isReadOnly()) {
        return;
    }
    // Add Upload Button
    getUpload().setButtonCaption(getCaption(selectNewCaption, null));
    layout.addComponent(getUpload());
    // Add DropZone Label
    Label uploadText = new Label(getCaption(dropZoneCaption, null), ContentMode.HTML);
    uploadText.addStyleName("upload-text");
    layout.addComponent(uploadText);

    // Update Style Name
    getRootLayout().removeStyleName("start");
    getRootLayout().removeStyleName("done");
    getRootLayout().removeStyleName("in-progress");
    getRootLayout().addStyleName("upload");
    getRootLayout().addStyleName("initial");

    log.debug("buildEmptyLayout() called ...");
}

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

License:Open Source License

/**
 * @return Thumbnail Component./*from   w w  w .jav  a2s  .  c  o  m*/
 */
protected Component createThumbnailComponent() {
    Label thumbnail = new Label("", ContentMode.HTML);
    thumbnail.setSizeUndefined();
    thumbnail.addStyleName("preview-image");
    thumbnail.addStyleName("file-preview");
    thumbnail.addStyleName(createIconStyleName());
    return thumbnail;
}