Example usage for com.vaadin.ui StyleGenerator StyleGenerator

List of usage examples for com.vaadin.ui StyleGenerator StyleGenerator

Introduction

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

Prototype

StyleGenerator

Source Link

Usage

From source file:org.openthinclient.web.pkgmngr.ui.view.PackageDetailsView.java

public PackageDetailsView() {

    IMessageConveyor mc = new MessageConveyor(UI.getCurrent().getLocale());

    dependencies.setDataProvider(DataProvider.ofCollection(Collections.emptyList()));
    dependencies.setSelectionMode(Grid.SelectionMode.NONE);
    dependencies.addColumn(AbstractPackageItem::getName)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_NAME));
    dependencies.addColumn(AbstractPackageItem::getDisplayVersion)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_VERSION));
    dependencies.setHeight("39px");

    dependencies.setStyleGenerator(new StyleGenerator<AbstractPackageItem>() {
        @Override/*  www . j a va 2  s.  c  o m*/
        public String apply(AbstractPackageItem item) {
            if (item != null && item instanceof MissingPackageItem) {
                return "highlight-red";
            }
            return null;
        }
    });

    // conflicts
    conflicts.setDataProvider(DataProvider.ofCollection(Collections.emptyList()));
    conflicts.setSelectionMode(Grid.SelectionMode.NONE);
    conflicts.addColumn(AbstractPackageItem::getName)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_NAME));
    conflicts.addColumn(AbstractPackageItem::getDisplayVersion)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_VERSION));
    conflicts.setHeight("39px");

    // provides
    provides.setDataProvider(DataProvider.ofCollection(Collections.emptyList()));
    provides.setSelectionMode(Grid.SelectionMode.NONE);
    provides.addColumn(AbstractPackageItem::getName)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_NAME));
    provides.addColumn(AbstractPackageItem::getDisplayVersion)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_PACKAGE_VERSION));
    provides.setHeight("39px");

    this.changeLog.setContentMode(ContentMode.PREFORMATTED);
    this.acceptLicenseCheckbox
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_LICENSE_CHECKBOX_CAPTION));

    // unfortunately this is the only way to access tabs defined in a design file.
    // we have to use the component instance to access the tab.

    // first the main tab sheet
    mainTabSheet.getTab(tabComponentCommon)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_COMMON_CAPTION));
    tabRelations = mainTabSheet.getTab(tabComponentRelations);
    tabRelations.setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_RELATIONS_CAPTION));
    mainTabSheet.getTab(tabComponentChangelog)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_CHANGELOG_CAPTION));
    mainTabSheet.getTab(tabComponentLicense)
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_LICENSE_CAPTION));

    // second the relations tab sheet.
    tabDependencies = relationsTabSheet.getTab(dependencies);
    tabDependencies.setCaption(
            mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_RELATIONS_DEPENDENCIES_CAPTION));
    tabProvides = relationsTabSheet.getTab(provides);
    tabProvides
            .setCaption(mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_RELATIONS_PROVIDES_CAPTION));
    tabConflicts = relationsTabSheet.getTab(conflicts);
    tabConflicts.setCaption(
            mc.getMessage(ConsoleWebMessages.UI_PACKAGEMANAGER_DETAILS_RELATIONS_CONFLICTS_CAPTION));

    updateRelationsTabs();
}