Example usage for com.vaadin.ui Component addStyleName

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

Introduction

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

Prototype

public void addStyleName(String style);

Source Link

Document

Adds one or more style names to this component.

Usage

From source file:com.peergreen.webconsole.vaadin.DefaultWindow.java

License:Open Source License

/**
 * Create a default window//from  w  w  w  . ja va2s .c  o  m
 * @param caption window caption
 * @param content window content. Vaadin component
 * @param footerButtons list of buttons in footer
 */
public DefaultWindow(String caption, Component content, Button... footerButtons) {
    setCaption(caption);
    setClosable(false);
    setResizable(false);
    addStyleName("edit-dashboard");

    VerticalLayout main = new VerticalLayout();
    main.setSpacing(true);
    main.setMargin(true);
    main.setStyleName("default-window");

    content.addStyleName("default-window-content");
    main.addComponent(content);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setStyleName("footer");
    footer.setWidth("100%");
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);

    for (Button button : footerButtons) {
        buttons.addComponent(button);
    }
    footer.addComponent(buttons);
    footer.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);

    main.addComponent(footer);
    setContent(main);
}

From source file:com.selzlein.lojavirtual.vaadin.page.TodoListView.java

License:Open Source License

@SuppressWarnings("serial")
@Override/*  w w  w  .  ja v a 2  s  . c  o m*/
protected Component createHeader(Component titleComponent) {
    LspsUI ui = (LspsUI) getUI();

    actionBtn = new MenuBar();
    actionBtn.addStyleName("menu-button-action");
    actionBtn.setVisible(false); //initially hidden
    MenuItem actions = actionBtn.addItem("", null, null);

    final ViewAction refreshTodos = new ViewAction() {

        @Override
        public void invoke() {
            toggleSelectionMode(false);
            container.refresh();
        }
    };

    actions.addItem(ui.getMessage("action.lock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            lock();
        }
    });
    actions.addItem(ui.getMessage("action.annotate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoAnnotation(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addSeparator();
    actions.addItem(ui.getMessage("action.unlock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            unlock();
        }
    });
    actions.addItem(ui.getMessage("action.reject") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoRejection(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addItem(ui.getMessage("action.delegate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoDelegation(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addItem(ui.getMessage("action.escalate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoEscalation(getSelectedTodoIds(), refreshTodos));
        }
    });

    selectBtn = new Button(ui.getMessage("action.select"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            toggleSelectionMode(true);
        }
    });
    selectBtn.addStyleName("menu-button");

    cancelBtn = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            toggleSelectionMode(false);
        }
    });
    cancelBtn.setVisible(false); //initially hidden
    cancelBtn.addStyleName("menu-button");

    titleComponent.addStyleName("l-content-title");

    HorizontalLayout layout = new HorizontalLayout();
    HorizontalLayout btnLayout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.addComponent(titleComponent);
    layout.addComponent(btnLayout);
    layout.setSpacing(true);
    btnLayout.addComponent(actionBtn);
    btnLayout.addComponent(cancelBtn);
    btnLayout.addComponent(selectBtn);
    layout.setComponentAlignment(btnLayout, Alignment.MIDDLE_RIGHT);
    return layout;
}

From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java

private Component buildBadgeWrapper(final Component menuItemButton, final Component badgeLabel) {
    CssLayout dashboardWrapper = new CssLayout(menuItemButton);
    dashboardWrapper.addStyleName("badgewrapper");
    dashboardWrapper.addStyleName(ValoTheme.MENU_ITEM);
    badgeLabel.addStyleName(ValoTheme.MENU_BADGE);
    badgeLabel.setWidthUndefined();/*from   w ww .ja v a  2s  .  com*/
    badgeLabel.setVisible(false);
    dashboardWrapper.addComponent(badgeLabel);
    return dashboardWrapper;
}

From source file:de.metas.procurement.webui.model.Trend.java

License:Open Source License

public static void applyStyleName(final Component comp, final Trend trend) {
    if (comp == null) {
        return;//from  w  w w.  ja  va 2 s  .c  o  m
    }

    for (final Trend t : values()) {
        comp.removeStyleName(t.getCssStyleName());
    }
    //
    if (trend != null) {
        comp.addStyleName(trend.getCssStyleName());
    }
}

From source file:de.metas.procurement.webui.ui.view.LoginView.java

License:Open Source License

public LoginView() {
    super();/*w  w  w . j a  va 2 s.  co m*/
    Application.autowire(this);

    addStyleName(STYLE);

    //
    // Content
    {
        final VerticalComponentGroup content = new VerticalComponentGroup();

        final Resource logoResource = getLogoResource();
        final Image logo = new Image(null, logoResource);
        logo.addStyleName(STYLE_Logo);
        content.addComponent(logo);

        this.email = new EmailField(i18n.get("LoginView.fields.email"));
        email.addStyleName(STYLE_LoginEmail);
        email.setIcon(FontAwesome.USER);
        content.addComponent(email);

        this.password = new PasswordField(i18n.get("LoginView.fields.password"));
        password.addStyleName(STYLE_LoginPassword);
        password.setIcon(FontAwesome.LOCK);
        content.addComponent(password);

        final Button loginButton = new Button(i18n.get("LoginView.fields.loginButton"));
        loginButton.addStyleName(STYLE_LoginButton);
        loginButton.setClickShortcut(KeyCode.ENTER);
        loginButton.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onUserLogin(email.getValue(), password.getValue());
            }
        });

        final Button forgotPasswordButton = new Button(i18n.get("LoginView.fields.forgotPasswordButton"));
        forgotPasswordButton.setStyleName(STYLE_ForgotPasswordButton);
        forgotPasswordButton.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                onForgotPassword(email.getValue());
            }
        });

        final CssLayout contentWrapper = new CssLayout(content, loginButton, forgotPasswordButton);
        contentWrapper.addStyleName(STYLE_LoginFormWrapper);
        setContent(contentWrapper);
    }

    //
    // Bottom:
    {
        //
        // Powered-by logo resource
        // Use the configured one if any; fallback to default embedded powered-by logo
        final Resource poweredByLogoResource;
        if (poweredByLogoUrl != null && !poweredByLogoUrl.trim().isEmpty()) {
            poweredByLogoResource = new ExternalResource(poweredByLogoUrl.trim());
        } else {
            poweredByLogoResource = Constants.RESOURCE_PoweredBy;
        }

        //
        // Powered-by component:
        final Component poweredByComponent;
        if (poweredByLinkUrl != null && !poweredByLinkUrl.trim().isEmpty()) {
            final Link link = new Link();
            link.setIcon(poweredByLogoResource);
            link.setResource(new ExternalResource(poweredByLinkUrl.trim()));
            link.setTargetName("_blank");
            poweredByComponent = link;
        } else {
            final Image image = new Image(null, poweredByLogoResource);
            poweredByComponent = image;
        }
        //
        poweredByComponent.addStyleName(STYLE_PoweredBy);
        setToolbar(poweredByComponent);
    }
}

From source file:de.symeda.sormas.ui.utils.CssStyles.java

License:Open Source License

public static void style(Component component, String... styles) {
    for (String style : styles)
        component.addStyleName(style);
}

From source file:de.symeda.sormas.ui.utils.CssStyles.java

License:Open Source License

public static void style(String style, Component... components) {
    for (Component component : components) {
        component.addStyleName(style);
    }/*from  w  w  w .  j a  v a 2 s .c  o m*/
}

From source file:de.symeda.sormas.ui.utils.CssStyles.java

License:Open Source License

public static void stylePrimary(Component component, String primaryStyle, String... styles) {
    component.setPrimaryStyleName(primaryStyle);
    for (String style : styles)
        component.addStyleName(style);
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.ui.CrudTableColumnGenerator.java

License:Apache License

/**
 * Erstellt ein Label. Die Spaltenhhe wird bei Multiline-Spalten oder bei
 * der ersten Spalte gesetzt, so dass mindestens eine Spalte die Zeilehhe
 * vorgibt.//from   ww  w  .  j a  v  a2  s . c om
 * 
 * @param columnId
 * @param value
 * @return
 */
private Component buildLabel(Object columnId, String value) {
    Component component = new Label(value);
    if (multilineCols.contains(columnId)) {
        component.addStyleName("wordwrap");
    }
    return wrapForCustomHeight(component);
}

From source file:fr.amapj.view.samples.test003.Segment.java

License:Open Source License

private void updateButtonStyles() {
    int i = 0;//from   w  ww. j  a  va2  s .  c  o  m
    Component c = null;
    for (Iterator<Component> iterator = getComponentIterator(); iterator.hasNext();) {
        c = iterator.next();
        c.removeStyleName("first");
        c.removeStyleName("last");
        if (i == 0) {
            c.addStyleName("first");
        }
        i++;
    }
    if (c != null) {
        c.addStyleName("last");
    }
}