Example usage for com.vaadin.ui CssLayout setStyleName

List of usage examples for com.vaadin.ui CssLayout setStyleName

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

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

License:Apache License

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

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

        /* 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);

        if (MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {

            FormLayout formAdresseAnnuelleLayout = new FormLayout();
            formAdresseAnnuelleLayout.setSpacing(true);
            formAdresseAnnuelleLayout.setMargin(true);

            Panel panelAdresseAnnuelle = new Panel(
                    applicationContext.getMessage(NAME + ".adresseannuelle.title", null, getLocale()) + " "
                            + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee());

            String captionAdresseAnnuelle = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseAnnuelle = new Label();
            formatLabel(fieldAdresseAnnuelle, captionAdresseAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse1());
            formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle);

            String annuelle2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse3());
            if (annuelle2 != null) {
                Label fieldAdresseAnnuelle2 = new Label();
                formatLabel(fieldAdresseAnnuelle2, null, annuelle2);
                formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle2);
            }
            String captionVilleAnnuelle = applicationContext.getMessage(NAME + ".ville.title", null,
                    getLocale());
            Label fieldVilleAnnuelle = new Label();
            formatLabel(fieldVilleAnnuelle, captionVilleAnnuelle,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getVille()));
            formAdresseAnnuelleLayout.addComponent(fieldVilleAnnuelle);

            String captionPaysAnnuelle = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysAnnuelle = new Label();
            formatLabel(fieldPaysAnnuelle, captionPaysAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getPays());
            formAdresseAnnuelleLayout.addComponent(fieldPaysAnnuelle);

            String captionTelephoneAnnuelle = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneAnnuelle = new Label();
            formatLabel(fieldTelephoneAnnuelle, captionTelephoneAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getNumerotel());
            formAdresseAnnuelleLayout.addComponent(fieldTelephoneAnnuelle);

            panelAdresseAnnuelle.setContent(formAdresseAnnuelleLayout);

            HorizontalLayout adresseAnnuelleGlobalLayout = new HorizontalLayout();
            adresseAnnuelleGlobalLayout.setSizeUndefined();
            adresseAnnuelleGlobalLayout.setStyleName("firstitembox");
            adresseAnnuelleGlobalLayout.addComponent(panelAdresseAnnuelle);
            adresseAnnuelleGlobalLayout.setExpandRatio(panelAdresseAnnuelle, 1);
            idLayout.addComponent(adresseAnnuelleGlobalLayout);
        }

        if (MainUI.getCurrent().getEtudiant().getAdresseFixe() != null) {
            FormLayout formAdresseFixeLayout = new FormLayout();
            formAdresseFixeLayout.setSpacing(true);
            formAdresseFixeLayout.setMargin(true);

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

            String captionAdresseFixe = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseFixe = new Label();
            formatLabel(fieldAdresseFixe, captionAdresseFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse1());
            formAdresseFixeLayout.addComponent(fieldAdresseFixe);

            String adfixe2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse3());
            if (adfixe2 != null) {
                Label fieldAdresseFixe2 = new Label();
                formatLabel(fieldAdresseFixe2, null, adfixe2);
                formAdresseFixeLayout.addComponent(fieldAdresseFixe2);
            }

            String captionVilleFixe = applicationContext.getMessage(NAME + ".ville.title", null, getLocale());
            Label fieldVilleFixe = new Label();
            formatLabel(fieldVilleFixe, captionVilleFixe,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getVille()));
            formAdresseFixeLayout.addComponent(fieldVilleFixe);

            String captionPaysFixe = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysFixe = new Label();
            formatLabel(fieldPaysFixe, captionPaysFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getPays());
            formAdresseFixeLayout.addComponent(fieldPaysFixe);

            String captionTelephoneFixe = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneFixe = new Label();
            formatLabel(fieldTelephoneFixe, captionTelephoneFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getNumerotel());
            formAdresseFixeLayout.addComponent(fieldTelephoneFixe);

            panelAdresseFixe.setContent(formAdresseFixeLayout);

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

        }

        addComponent(globalLayout);

        if (userController.isEtudiant() && configController.isModificationAdressesAutorisee()
                && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {
            HorizontalLayout btnLayout = new HorizontalLayout();
            btnLayout.setSizeFull();
            btnLayout.setSpacing(true);

            Button btnModifAdresses = new Button(
                    applicationContext.getMessage(NAME + ".bouton.modifieradresses", null, getLocale()));
            btnModifAdresses.setStyleName(ValoTheme.BUTTON_PRIMARY);
            btnModifAdresses.setIcon(FontAwesome.EDIT);
            btnModifAdresses.addClickListener(e -> {
                ModificationAdressesWindow maw = new ModificationAdressesWindow(
                        MainUI.getCurrent().getEtudiant());
                maw.addCloseListener(f -> {
                    init();
                });
                UI.getCurrent().addWindow(maw);
            });
            btnLayout.addComponent(btnModifAdresses);
            btnLayout.setComponentAlignment(btnModifAdresses, Alignment.MIDDLE_LEFT);
            addComponent(btnLayout);
        }
    }
}

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

License:Apache License

/**
 * Initialise la vue//from w ww  . j  av  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: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 w w w . j a va 2 s . c om*/
        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.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();/*from w  w w  .j a v  a  2  s .  c o 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:module.pandabox.presentation.PandaBox.java

License:Open Source License

private void initView() {
    setCompositionRoot(root);/*from  w ww.j a v  a2s.  c o m*/
    root.setSizeFull();
    root.setSplitPosition(15);
    root.setStyleName("small previews");

    previewArea.setWidth("100%");
    previewTabs = new VerticalLayout();
    previewTabs.setSizeFull();
    previewTabs.setHeight(null);

    compoundTabs = new VerticalLayout();
    compoundTabs.setSizeFull();
    compoundTabs.setHeight(null);

    bennuStylesTabs = new VerticalLayout();
    bennuStylesTabs.setSizeFull();
    bennuStylesTabs.setHeight(null);

    VerticalLayout menu = new VerticalLayout();
    menu.setSizeFull();
    menu.setStyleName("sidebar-menu");

    Button syncThemes = new Button("Sync Themes", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            syncThemes();
        }
    });
    menu.addComponent(syncThemes);
    menu.addComponent(new Label("Single Components"));
    menu.addComponent(previewTabs);
    menu.addComponent(new Label("Compound Styles"));
    menu.addComponent(compoundTabs);

    menu.addComponent(new Label("Bennu Styles"));
    menu.addComponent(bennuStylesTabs);

    root.setFirstComponent(menu);

    CssLayout toolbar = new CssLayout();
    toolbar.setWidth("100%");
    toolbar.setStyleName("toolbar");
    toolbar.addComponent(editorToggle);

    final Window downloadWindow = new Window("Download Theme");
    GridLayout l = new GridLayout(3, 2);
    l.setSizeUndefined();
    l.setMargin(true);
    l.setSpacing(true);
    downloadWindow.setContent(l);
    downloadWindow.setModal(true);
    downloadWindow.setResizable(false);
    downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null);
    downloadWindow.addStyleName("opaque");
    Label caption = new Label("Theme Name");
    l.addComponent(caption);
    l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    final TextField name = new TextField();
    name.setValue("my-chameleon");
    name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed"));
    name.setRequired(true);
    name.setRequiredError("Please give a name for the theme");
    downloadWindow.addComponent(name);
    Label info = new Label(
            "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.",
            Label.CONTENT_XHTML);
    info.addStyleName("tiny");
    info.setWidth("200px");
    l.addComponent(info, 1, 1, 2, 1);

    Button download = new Button(null, new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(downloadWindow);
            name.focus();
        }
    });
    download.setDescription("Donwload the current theme");
    download.setIcon(new ThemeResource("download.png"));
    download.setStyleName("icon-only");
    toolbar.addComponent(download);

    menu.addComponent(toolbar);
    menu.setExpandRatio(toolbar, 1);
    menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER);

}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getCompoundMenus() {
    Layout grid = getPreviewLayout("Compound Menus");

    Label title = new Label("Sidebar Menu");
    title.setStyleName("h1");
    grid.addComponent(title);//from   w  w  w. ja va 2  s . c om
    ((GridLayout) grid).newLine();

    Label menus = new Label(
            "<strong>The sidebar menu</strong> control is just a set of labels and buttons inside a CssLayout or a VerticalLayout. Use the structure shown on the right, <strong>and remember that you need to implement all logic yourself</strong>. This theme just provides suitable stylenames for you to use.<br><br>You can also use the <a href=\"http://vaadin.com/forum/-/message_boards/message/119172\">DetachedTabs add-on</a> inside the sidebar-menu, it will style automatically.<br><br><strong>Note: only NativeButtons are styled inside the menu, normal buttons are left untouched.</strong>",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label(
            "CssLayout.setStyleName(\"sidebar-menu\")\n  +  Label\n  +  NativeButton\n  +  NativeButton\n\t...\n  +  Label\n  +  DetachedTabs\n\t...",
            Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    SidebarMenu sidebar = new SidebarMenu();
    sidebar.setWidth("200px");
    sidebar.addComponent(new Label("Fruits"));
    NativeButton b = new NativeButton("Apples");
    b.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    sidebar.addButton(b);
    sidebar.setSelected(b);
    sidebar.addButton(new NativeButton("Oranges"));
    sidebar.addButton(new NativeButton("Bananas"));
    sidebar.addButton(new NativeButton("Grapes"));
    sidebar.addComponent(new Label("Vegetables"));
    sidebar.addButton(new NativeButton("Tomatoes"));
    sidebar.addButton(new NativeButton("Cabbages"));
    sidebar.addButton(new NativeButton("Potatoes"));
    sidebar.addButton(new NativeButton("Carrots"));
    grid.addComponent(sidebar);
    ((GridLayout) grid).setColumnExpandRatio(0, 1);
    ((GridLayout) grid).setColumnExpandRatio(1, 1);

    title = new Label("Toolbar");
    title.setStyleName("h1");
    grid.addComponent(title);
    ((GridLayout) grid).newLine();

    CssLayout toolbars = new CssLayout();

    menus = new Label(
            "<strong>Toolbar</strong> is a simple CssLayout with a stylename. It provides the background and a little padding for its contents. Normally you will want to put buttons inside it, but segment controls fit in nicely as well.",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label("CssLayout.setStyleName(\"toolbar\")", Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    CssLayout toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    Button b2 = new Button("Action");
    b2.setStyleName("small");
    toolbar.addComponent(b2);

    Segment segment = new Segment();
    segment.addStyleName("segment-alternate");
    b2 = new Button("Apples");
    b2.setStyleName("small");
    b2.addStyleName("down");
    segment.addButton(b2);
    b2 = new Button("Oranges");
    b2.setStyleName("small");
    segment.addButton(b2);
    toolbar.addComponent(segment);

    b2 = new Button("Notes");
    b2.setStyleName("small borderless");
    b2.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    b2 = new Button("Action");
    b2.setIcon(new ThemeResource("../runo/icons/32/document.png"));
    b2.setStyleName("borderless");
    toolbar.addComponent(b2);

    b2 = new Button("Action 2");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/user.png"));
    toolbar.addComponent(b2);

    b2 = new Button("Action 3");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    grid.addComponent(toolbars);

    return grid;
}

From source file:my.vaadin.app.MyUI.java

@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout layout = new VerticalLayout();

    filterText.setPlaceholder("filter by name...");
    filterText.addValueChangeListener(e -> updateList());
    filterText.setValueChangeMode(ValueChangeMode.LAZY);

    Button clearFilterTextBtn = new Button(FontAwesome.TIMES);
    clearFilterTextBtn.setDescription("Clear the current filter");
    clearFilterTextBtn.addClickListener(e -> filterText.clear());

    CssLayout filtering = new CssLayout();
    filtering.addComponents(filterText, clearFilterTextBtn);
    filtering.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);

    Button addCustomerBtn = new Button("Add new customer");
    addCustomerBtn.addClickListener(e -> {
        grid.asSingleSelect().clear();//from   w ww.  jav a2 s  .c  o m
        form.setCustomer(new Customer());
    });

    HorizontalLayout toolbar = new HorizontalLayout(filtering, addCustomerBtn);

    grid.setColumns("firstName", "lastName", "email");

    HorizontalLayout main = new HorizontalLayout(grid, form);
    main.setSizeFull();
    grid.setSizeFull();
    main.setExpandRatio(grid, 1);

    layout.addComponents(toolbar, main);

    // fetch list of Customers from service and assign it to Grid
    updateList();

    setContent(layout);

    form.setVisible(false);

    grid.asSingleSelect().addValueChangeListener(event -> {
        if (event.getValue() == null) {
            form.setVisible(false);
        } else {
            form.setCustomer(event.getValue());
        }
    });
}

From source file:org.bubblecloud.ilves.module.content.RenderFlowlet.java

License:Apache License

@Override
public void enter() {
    final EntityManager entityManager = Site.getCurrent().getSiteContext().getObject(EntityManager.class);
    final String html;
    try {//w  w  w .ja v a  2s. c om
        html = new Markdown4jProcessor().process(escapeHtml(content.getMarkup()));
    } catch (IOException e) {
        throw new SiteException("Error processing markdown.", e);
    }

    ((AbstractFlowViewlet) getFlow()).getTopRightLayout().removeComponent(topEditButton);
    ((AbstractFlowViewlet) getFlow()).getTopRightLayout().addComponent(topEditButton);
    ((AbstractFlowViewlet) getFlow()).refreshPathLabels();

    final CssLayout layout = new CssLayout();
    //layout.addComponent(topEditButton);
    layout.setStyleName("wiki-content");
    layout.addComponent(new Label(html, ContentMode.HTML));

    setCompositionRoot(layout);
}

From source file:org.eclipse.hawkbit.ui.AbstractHawkbitUI.java

License:Open Source License

private Component buildHeader() {
    final CssLayout cssLayout = new CssLayout();
    cssLayout.setStyleName("view-header");
    return cssLayout;
}

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

License:Open Source License

private static Component buildHeader() {
    final CssLayout cssLayout = new CssLayout();
    cssLayout.setStyleName("view-header");
    return cssLayout;
}