Java Code Examples for com.vaadin.ui.Component#addStyleName()

The following examples show how to use com.vaadin.ui.Component#addStyleName() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: cuba   File: WebAppWorkArea.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setInitialLayout(VBoxLayout initialLayout) {
    checkNotNullArgument(initialLayout);

    if (state == State.WINDOW_CONTAINER) {
        throw new IllegalStateException("Unable to change AppWorkArea initial layout in WINDOW_CONTAINER state");
    }

    if (this.initialLayout != null) {
        component.removeComponent(this.initialLayout.unwrapComposition(com.vaadin.ui.Component.class));
    }

    this.initialLayout = initialLayout;

    initialLayout.setParent(this);
    initialLayout.setSizeFull();

    Component vInitialLayout = initialLayout.unwrapComposition(com.vaadin.ui.Component.class);
    vInitialLayout.addStyleName(INITIAL_LAYOUT_STYLENAME);
    component.addComponent(vInitialLayout);
}
 
Example 2
Source Project: cia   File: RowUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates the row component.
 *
 * @param row         the row
 * @param component   the component
 * @param description the description
 */
public static void createRowComponent(final ResponsiveRow row, final Component component,
		final String description) {
	final CssLayout layout = new CssLayout();
	layout.addStyleName(".v-layout-content-pagemode-panel-level2");
	Responsive.makeResponsive(layout);
	layout.setSizeUndefined();

	final Label descriptionLabel = new Label(description);
	descriptionLabel.addStyleName(ITEMBOX);
	Responsive.makeResponsive(descriptionLabel);
	descriptionLabel.setWidth(100, Unit.PERCENTAGE);
	layout.addComponent(descriptionLabel);

	component.addStyleName(ITEMBOX);
	component.addStyleName(TITLE);
	Responsive.makeResponsive(component);
	component.setWidth(100, Unit.PERCENTAGE);
	layout.addComponent(component);

	row.addColumn().withDisplayRules(DISPLAY_SIZE_XS_DEVICE, DISPLAYS_SIZE_XM_DEVICE, DISPLAY_SIZE_MD_DEVICE,
			DISPLAY_SIZE_LG_DEVICE).withComponent(layout);
}
 
Example 3
Source Project: hawkbit   File: DashboardMenu.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the wrapper which contains the menu item and the adjacent label
 * for displaying the occurred events
 * 
 * @param menuItemButton
 *            the menu item
 * @param notificationLabel
 *            the label for displaying the occurred events
 * @return Component of type CssLayout
 */
private static Component buildLabelWrapper(final ValoMenuItemButton menuItemButton,
        final Component notificationLabel) {
    final CssLayout dashboardWrapper = new CssLayout(menuItemButton);
    dashboardWrapper.addStyleName("labelwrapper");
    dashboardWrapper.addStyleName(ValoTheme.MENU_ITEM);
    notificationLabel.addStyleName(ValoTheme.MENU_BADGE);
    notificationLabel.setWidthUndefined();
    notificationLabel.setVisible(false);
    notificationLabel.setId(UIComponentIdProvider.NOTIFICATION_MENU_ID + menuItemButton.getCaption().toLowerCase());
    dashboardWrapper.addComponent(notificationLabel);
    return dashboardWrapper;
}
 
Example 4
Source Project: designer-tutorials   File: MainLayout.java    License: Apache License 2.0 5 votes vote down vote up
private void adjustStyleByData(Component component, Object data) {
    if (component instanceof Button) {
        if (data != null && data.equals(((Button) component).getData())) {
            component.addStyleName(MyTheme.SELECTED);
        } else {
            component.removeStyleName(MyTheme.SELECTED);
        }
    }
}
 
Example 5
Source Project: designer-tutorials   File: MainLayout.java    License: Apache License 2.0 5 votes vote down vote up
private void adjustStyleByData(Component component, Object data) {
    if (component instanceof Button) {
        if (data != null && data.equals(((Button) component).getData())) {
            component.addStyleName(STYLE_SELECTED);
        } else {
            component.removeStyleName(STYLE_SELECTED);
        }
    }
}
 
Example 6
public void selectService(int index) {
    Iterator<Component> iterator = this.iterator();

    int i = 0;
    while (iterator.hasNext()) {
        Component comp = iterator.next();
        if (i == index) {
            comp.addStyleName(SELECTED_STYLENAME);
        } else {
            comp.removeStyleName(SELECTED_STYLENAME);
        }
        i++;
    }
}
 
Example 7
public void setSelectedRow(Component row) {
    for (int i = 0; i < this.getComponentCount(); i++) {
        this.getComponent(i).removeStyleName("selected");
    }
    row.addStyleName("selected");
}