Example usage for com.vaadin.ui Component setStyleName

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

Introduction

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

Prototype

public void setStyleName(String style);

Source Link

Document

Sets one or more user-defined style names of the component, replacing any previous user-defined styles.

Usage

From source file:com.esofthead.mycollab.vaadin.ui.NotificationButton.java

License:Open Source License

@Override
public void popupVisibilityChange(PopupVisibilityEvent event) {
    notificationContainer.removeAllComponents();

    if (notificationItems.size() > 0) {
        for (AbstractNotification item : notificationItems) {
            Component comp = item.renderContent();
            comp.setStyleName("notification-type");
            comp.addStyleName("notification-type-" + item.getType());
            notificationContainer.addComponent(comp);
        }//w w w.  j  a v  a  2s.com
    } else {
        Label noItemLbl = new Label("There is no notification right now");
        notificationContainer.addComponent(noItemLbl);
        notificationContainer.setComponentAlignment(noItemLbl, Alignment.MIDDLE_CENTER);
    }
}

From source file:com.esofthead.mycollab.vaadin.web.ui.NotificationComponent.java

License:Open Source License

@Override
public void popupVisibilityChange(PopupVisibilityEvent event) {
    notificationContainer.removeAllComponents();

    if (notificationItems.size() > 0) {
        for (int i = 0; i < notificationItems.size(); i++) {
            AbstractNotification item = notificationItems.get(i);
            Component comp = buildComponentFromNotification(item);
            comp.setStyleName("notification-type");
            comp.addStyleName("notification-type-" + item.getType());
            notificationContainer.addComponent(comp);
            if (i < notificationItems.size() - 1) {
                notificationContainer.addComponent(ELabel.hr());
            }//  ww w . j av  a 2  s .  c o  m
        }
    } else {
        Label noItemLbl = new Label(AppContext.getMessage(ShellI18nEnum.OPT_NO_NOTIFICATION));
        notificationContainer.addComponent(noItemLbl);
        notificationContainer.setComponentAlignment(noItemLbl, Alignment.MIDDLE_CENTER);
    }
}

From source file:com.github.wolfie.detachedtabs.DetachedTabs.java

License:Open Source License

private void adjustTabStyles() {
    if (!tabs.isEmpty()) {
        final Component first = tabs.get(0);
        Component last = first;/*from   w w  w  .j  a va 2 s  .  c  o m*/

        for (final Component tab : tabs) {
            tab.setStyleName(TAB_CLASS);
            last = tab;
        }

        first.addStyleName(TAB_FIRST_CLASS);
        last.addStyleName(TAB_LAST_CLASS);

        if (shownTab != null) {
            shownTab.addStyleName(TAB_SELECTED_CLASS);
        }
    }
}

From source file:com.mycollab.vaadin.web.ui.NotificationComponent.java

License:Open Source License

@Override
public void popupVisibilityChange(PopupVisibilityEvent event) {
    notificationContainer.removeAllComponents();

    if (notificationItems.size() > 0) {
        for (AbstractNotification item : notificationItems) {
            Component comp = buildComponentFromNotification(item);
            comp.setStyleName("notification-type");
            comp.addStyleName("notification-type-" + item.getType());
            notificationContainer.addComponent(comp);
        }//from w  w  w  . ja  va2 s .  co  m
    } else {
        Label noItemLbl = new Label(UserUIContext.getMessage(ShellI18nEnum.OPT_NO_NOTIFICATION));
        notificationContainer.addComponent(noItemLbl);
        notificationContainer.setComponentAlignment(noItemLbl, Alignment.MIDDLE_CENTER);
    }
}

From source file:org.escidoc.browser.ui.mainpage.HeaderContainer.java

License:Open Source License

public void setUser(final CurrentUser user) {
    Component name;
    if (user.getLoginName().equals(ViewConstants.GUEST)) {
        name = new Label(ViewConstants.GUEST);
    } else {/*from w w w.  j  a  v a 2  s .c  om*/
        name = new Button(user.getRealName());
        name.setStyleName(BaseTheme.BUTTON_LINK);
        name.addStyleName("paddingright10");

        ((Button) name).addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                ResourceProxy userProxy;
                try {
                    userProxy = repositories.user().findById(user.getUserId());
                    UserAccountController controller = new UserAccountController(repositories, router,
                            userProxy);
                    router.openControllerView(controller, Boolean.FALSE);
                } catch (EscidocClientException e) {
                    LOG.error("Can not find user " + e.getMessage());
                    router.getMainWindow().showNotification(ViewConstants.ERROR + "Can not find user ",
                            e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
                }
            }
        });
    }

    Label lblCurrentUser = new Label("<b>" + ViewConstants.CURRENT_USER + "</b>", Label.CONTENT_XHTML);
    lblCurrentUser.addStyleName("paddingright10");
    hl.addComponent(lblCurrentUser);
    hl.setComponentAlignment(lblCurrentUser, Alignment.MIDDLE_RIGHT);

    name.addStyleName("paddingright10");
    hl.addComponent(name);
    hl.addComponent(new Label(" &nbsp;", Label.CONTENT_RAW));
    hl.setComponentAlignment(name, Alignment.MIDDLE_RIGHT);

    if (user.isGuest()) {
        hl.removeComponent(logout);
        hl.addComponent(login);
        hl.setComponentAlignment(login, Alignment.MIDDLE_RIGHT);

    } else {
        logout.addStyleName("paddingright10");
        hl.addComponent(logout);
        hl.setComponentAlignment(logout, Alignment.MIDDLE_RIGHT);

    }
}

From source file:org.hip.vif.forum.usersettings.ui.ShowCompletedRatingView.java

License:Open Source License

private void addComponentSized(final Component inComponent, final GridLayout inLayout) {
    inComponent.setWidth(110, Unit.PIXELS);
    inComponent.setStyleName("vif-colhead vif-center"); //$NON-NLS-1$
    inLayout.addComponent(inComponent);/*w  ww  . j a v  a 2  s .c om*/
    inLayout.setComponentAlignment(inComponent, Alignment.MIDDLE_CENTER);
}

From source file:org.jdal.vaadin.auth.LoginView.java

License:Apache License

@Override
protected Component buildPanel() {
    Label greeting = new Label(getMessage("loginView.greeting"));
    greeting.addStyleName("jd-login-greeting");
    greeting.addStyleName(Reindeer.LABEL_H2);
    Label applicationNameLabel = new Label(getMessage(applicationName));
    applicationNameLabel.addStyleName("jd-login-appname");
    applicationNameLabel.addStyleName(Reindeer.LABEL_H2);
    applicationNameLabel.setSizeUndefined();

    loginButton.addClickListener(this);
    loginButton.setCaption(getMessage("loginView.loginButtonCaption"));
    loginButton.addStyleName("jd-login-button");

    // add shortcut listener for enter key
    loginButton.addShortcutListener(new ShortcutListener("Sign In", KeyCode.ENTER, null) {
        @Override/*  www. jav a  2  s . c  o m*/
        public void handleAction(Object sender, Object target) {
            loginButton.click();
        }
    });

    Image image = null;
    HorizontalLayout imageWrapper = null;

    if (applicationIcon != null) {
        image = new Image(null, applicationIcon);
        image.setSizeUndefined();
        image.setStyleName("jd-login-icon");
        imageWrapper = new HorizontalLayout();
        imageWrapper.setMargin(false);
        imageWrapper.addComponent(image);
        imageWrapper.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
    }

    BoxFormBuilder fb = new BoxFormBuilder();
    fb.setDefaultWidth(BoxFormBuilder.SIZE_FULL);
    fb.row();
    fb.startBox();
    fb.setFixedHeight();
    fb.row(false);
    fb.add(greeting, Alignment.TOP_LEFT);
    fb.add(applicationNameLabel, Alignment.TOP_RIGHT);
    fb.endBox();
    // add application icon
    if (image != null) {
        fb.row(BoxFormBuilder.SIZE_FULL);
        fb.add(imageWrapper, BoxFormBuilder.SIZE_FULL, Alignment.MIDDLE_CENTER);
    }
    fb.row();
    fb.startBox();
    fb.row(30);
    fb.add(errorLabel, BoxFormBuilder.SIZE_FULL, Alignment.BOTTOM_CENTER);
    fb.endBox();
    fb.row();
    fb.startBox();
    fb.setFixedHeight();
    fb.row();
    fb.add(username, getMessage("loginView.username"), Alignment.BOTTOM_CENTER);
    fb.add(password, getMessage("loginView.password"), Alignment.BOTTOM_CENTER);
    fb.add(loginButton, 100, Alignment.BOTTOM_CENTER);
    fb.endBox();

    Component form = fb.getForm();
    form.setWidth(this.getWidth(), Unit.PIXELS);
    form.setHeight(getHeight(), Unit.PIXELS);
    form.setStyleName("jd-login");

    return form;
}

From source file:org.ripla.web.util.AbstractFormCreator.java

License:Open Source License

/**
 * Factory method: creates the form.//from ww w . ja v a2s .  c  om
 * 
 * @return {@link Component} the form component to add to the layout
 */
public Component createForm() {
    final Component out = createTable();
    out.setStyleName("ripla-form"); //$NON-NLS-1$
    return out;
}

From source file:org.semanticsoft.vaaclipse.presentation.renderers.PartRenderer.java

License:Open Source License

@Override
public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) {
    VerticalLayout pane = new VerticalLayout();
    pane.setSizeFull();/*from   www .j  a v a2 s . co m*/
    final MPart part = (MPart) element;

    CssLayout toolbarArea = new CssLayout();
    toolbarArea.setStyleName("mparttoolbararea");
    toolbarArea.setSizeUndefined();
    toolbarArea.setWidth("100%");
    pane.addComponent(toolbarArea);

    //create toolbar
    MToolBar toolbar = part.getToolbar();
    if (toolbar != null && toolbar.isToBeRendered()) {
        Component toolbarWidget = (Component) renderingEngine.createGui(toolbar);
        ((AbstractLayout) toolbarWidget).setSizeUndefined();
        toolbarWidget.setStyleName("mparttoolbar");
        toolbarArea.addComponent(toolbarWidget);
    }

    VerticalLayout contributionArea = new VerticalLayout();
    contributionArea.setSizeFull();
    pane.addComponent(contributionArea);
    pane.setExpandRatio(contributionArea, 100);

    pane.setStyleName("part");
    element.setWidget(pane);

    IEclipseContext localContext = part.getContext();
    localContext.set(Component.class, contributionArea);
    localContext.set(ComponentContainer.class, contributionArea);
    localContext.set(VerticalLayout.class, contributionArea);
    localContext.set(MPart.class, part);
    SavePromptSetup savePromptProvider = new SavePromptSetup();
    savePrompts.put(part, savePromptProvider);
    localContext.set(SavePromptSetup.class, savePromptProvider);
    if (part instanceof MInputPart)
        localContext.set(MInputPart.class, (MInputPart) part);

    IContributionFactory contributionFactory = (IContributionFactory) localContext
            .get(IContributionFactory.class.getName());
    Object newPart = contributionFactory.create(part.getContributionURI(), localContext);

    part.setObject(newPart);
}

From source file:org.vaadin.melodion.Melodion.java

License:Open Source License

/**
 * Adds a spacer to this melodion.//from w w  w .j a  va 2  s  . c o m
 * 
 * @return The new spacer.
 */
public Component addSpacer() {
    Component spacer = new Label();
    spacer.setStyleName("spacer");
    addComponent(spacer);
    return spacer;
}