Example usage for com.vaadin.ui Layout setPrimaryStyleName

List of usage examples for com.vaadin.ui Layout setPrimaryStyleName

Introduction

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

Prototype

public void setPrimaryStyleName(String style);

Source Link

Document

Changes the primary style name of the component.

Usage

From source file:com.haulmont.cuba.web.sys.WindowBreadCrumbs.java

License:Apache License

protected Layout createEnclosingLayout() {
    Layout enclosingLayout = new CssLayout();
    enclosingLayout.setPrimaryStyleName("c-breadcrumbs-container");
    return enclosingLayout;
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

protected Layout createNewTabLayout(final Window window, final boolean multipleOpen,
        WindowBreadCrumbs breadCrumbs, Component... additionalComponents) {
    Layout layout = new CssLayout();
    layout.setPrimaryStyleName("c-app-window-wrap");
    layout.setSizeFull();//from   w w w  .  j ava 2 s  .c o m

    layout.addComponent(breadCrumbs);
    if (additionalComponents != null) {
        for (final Component c : additionalComponents) {
            layout.addComponent(c);
        }
    }

    final Component component = WebComponentsHelper.getComposition(window);
    component.setSizeFull();
    layout.addComponent(component);

    WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));

    if (workArea.getMode() == Mode.TABBED) {
        layout.addStyleName("c-app-tabbed-window");
        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();

        String tabId;
        Integer hashCode = getWindowHashCode(window);
        ComponentContainer tab = null;
        if (hashCode != null) {
            tab = findTab(hashCode);
        }
        if (tab != null && !multipleOpen) {
            tabSheet.replaceComponent(tab, layout);
            tabSheet.removeComponent(tab);
            tabs.put(layout, breadCrumbs);
            tabId = tabSheet.getTab(layout);
        } else {
            tabs.put(layout, breadCrumbs);

            tabId = "tab_" + uuidSource.createUuid();

            tabSheet.addTab(layout, tabId);

            if (ui.isTestMode()) {
                String id = "tab_" + window.getId();

                tabSheet.setTabTestId(tabId, ui.getTestIdManager().getTestId(id));
                tabSheet.setTabCubaId(tabId, id);
            }
        }
        String windowContentSwitchMode = window.getContentSwitchMode().name();
        ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(windowContentSwitchMode);
        tabSheet.setContentSwitchMode(tabId, contentSwitchMode);

        String formattedCaption = formatTabCaption(window.getCaption(), window.getDescription());
        tabSheet.setTabCaption(tabId, formattedCaption);
        String formattedDescription = formatTabDescription(window.getCaption(), window.getDescription());
        if (!Objects.equals(formattedCaption, formattedDescription)) {
            tabSheet.setTabDescription(tabId, formattedDescription);
        } else {
            tabSheet.setTabDescription(tabId, null);
        }

        tabSheet.setTabIcon(tabId, WebComponentsHelper.getIcon(window.getIcon()));
        tabSheet.setTabClosable(tabId, true);
        tabSheet.setTabCloseHandler(layout, (targetTabSheet, tabContent) -> {
            //noinspection SuspiciousMethodCalls
            WindowBreadCrumbs breadCrumbs1 = tabs.get(tabContent);

            if (!canWindowBeClosed(breadCrumbs1.getCurrentWindow())) {
                return;
            }

            Runnable closeTask = new TabCloseTask(breadCrumbs1);
            closeTask.run();

            // it is needed to force redraw tabsheet if it has a lot of tabs and part of them are hidden
            targetTabSheet.markAsDirty();
        });
        tabSheet.setSelectedTab(layout);
    } else {
        tabs.put(layout, breadCrumbs);
        layout.addStyleName("c-app-single-window");

        VerticalLayout mainLayout = workArea.getSingleWindowContainer();
        mainLayout.removeAllComponents();
        mainLayout.addComponent(layout);
    }

    return layout;
}