Example usage for com.vaadin.ui VerticalLayout setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

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

License:Apache License

@Override
public void showOptionDialog(String title, String message, MessageType messageType, Action[] actions) {
    backgroundWorker.checkUIAccess();/*from  w  ww  .j  av a2s. com*/

    final com.vaadin.ui.Window window = new CubaWindow(title);

    if (ui.isTestMode()) {
        window.setCubaId("optionDialog");
        window.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }
    window.setClosable(false);

    Label messageLab = new CubaLabel();
    messageLab.setValue(message);
    if (MessageType.isHTML(messageType)) {
        messageLab.setContentMode(ContentMode.HTML);
    } else {
        messageLab.setContentMode(ContentMode.TEXT);
    }
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        messageLab.setWidthUndefined();
    }

    float width;
    SizeUnit unit;
    if (messageType.getWidth() != null) {
        width = messageType.getWidth();
        unit = messageType.getWidthUnit();
    } else if (getDialogParams().getWidth() != null) {
        width = getDialogParams().getWidth();
        unit = getDialogParams().getWidthUnit();
    } else {
        SizeWithUnit size = SizeWithUnit
                .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.optionDialog.width"));
        width = size.getSize();
        unit = size.getUnit();
    }

    if (messageType.getModal() != null) {
        log.warn("MessageType.modal is not supported for showOptionDialog");
    }

    getDialogParams().reset();

    window.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS);
    window.setResizable(false);
    window.setModal(true);

    boolean closeOnClickOutside = false;
    if (window.isModal()) {
        if (messageType.getCloseOnClickOutside() != null) {
            closeOnClickOutside = messageType.getCloseOnClickOutside();
        }
    }
    ((CubaWindow) window).setCloseOnClickOutside(closeOnClickOutside);

    if (messageType.getMaximized() != null) {
        if (messageType.getMaximized()) {
            window.setWindowMode(WindowMode.MAXIMIZED);
        } else {
            window.setWindowMode(WindowMode.NORMAL);
        }
    }

    VerticalLayout layout = new VerticalLayout();
    layout.setStyleName("c-app-option-dialog");
    layout.setSpacing(true);
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        layout.setWidthUndefined();
    }
    window.setContent(layout);

    HorizontalLayout buttonsContainer = new HorizontalLayout();
    buttonsContainer.setSpacing(true);

    boolean hasPrimaryAction = false;
    Map<Action, Button> buttonMap = new HashMap<>();
    for (Action action : actions) {
        Button button = WebComponentsHelper.createButton();
        button.setCaption(action.getCaption());
        button.addClickListener(event -> {
            try {
                action.actionPerform(null);
            } finally {
                ui.removeWindow(window);
            }
        });

        if (StringUtils.isNotEmpty(action.getIcon())) {
            button.setIcon(WebComponentsHelper.getIcon(action.getIcon()));
            button.addStyleName(WebButton.ICON_STYLE);
        }

        if (action instanceof AbstractAction && ((AbstractAction) action).isPrimary()) {
            button.addStyleName("c-primary-action");
            button.focus();

            hasPrimaryAction = true;
        }

        if (ui.isTestMode()) {
            button.setCubaId("optionDialog_" + action.getId());
            button.setId(ui.getTestIdManager().getTestId("optionDialog_" + action.getId()));
        }

        buttonsContainer.addComponent(button);
        buttonMap.put(action, button);
    }

    assignDialogShortcuts(buttonMap);

    if (!hasPrimaryAction && actions.length > 0) {
        ((Button) buttonsContainer.getComponent(0)).focus();
    }

    layout.addComponent(messageLab);
    layout.addComponent(buttonsContainer);

    layout.setExpandRatio(messageLab, 1);
    layout.setComponentAlignment(buttonsContainer, Alignment.BOTTOM_RIGHT);

    ui.addWindow(window);
    window.center();
}

From source file:com.jain.addon.action.confirm.ConfirmWindow.java

License:Apache License

@JNIComponentInit
public void init() {
    setModal(true);//  w w w  .j  a  va 2 s  .  c  o  m
    setWidth("25%");

    VerticalLayout layout = new VerticalLayout();
    setContent(layout);

    layout.setWidth("100%");
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setStyleName(JNStyleConstants.J_ALTERNATE_VIEW);

    JNConfirm confirm = action.getConfirm();
    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setSpacing(true);
    hLayout.setWidth("100%");
    findNAddIcon(confirm, hLayout);

    Label label = new Label(confirm.message());
    label.setContentMode(confirm.mode());
    hLayout.addComponent(label);
    hLayout.setExpandRatio(label, 2);
    layout.addComponent(hLayout);
    layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER);

    ActionMenuBar<ConfirmWindow> menuBar = new ActionMenuBar<ConfirmWindow>(null, this);
    layout.addComponent(menuBar);
    layout.setExpandRatio(menuBar, 2);
    layout.setComponentAlignment(menuBar, Alignment.MIDDLE_CENTER);
}

From source file:com.jain.addon.component.crud.JCrudWindow.java

License:Apache License

@JNIComponentInit
public void init() {
    setModal(true);//from  w  ww  .j  ava2s .  co  m
    setSizeUndefined();
    setWidth("70%");

    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setMargin(new MarginInfo(false, false, true, false));
    layout.setStyleName(JNStyleConstants.J_ALTERNATE_VIEW);

    setContent(layout);
    createFieldGroup(layout);

    createActions(layout);
}

From source file:com.jain.addon.component.crud.JCrudWindow.java

License:Apache License

private void createActions(VerticalLayout layout) {
    if (!isViewOnly()) {
        ActionBar<JCrudWindow<T>> hLayout = new ActionBar<JCrudWindow<T>>(null, this);

        VerticalLayout vLayout = new VerticalLayout();
        vLayout.setSizeUndefined();/*from   w  w  w  .  ja  va 2s  . c  o m*/
        vLayout.setStyleName(JNStyleConstants.J_VIEW);
        vLayout.addComponent(hLayout);

        layout.addComponent(vLayout);
        layout.setComponentAlignment(vLayout, Alignment.MIDDLE_CENTER);
        layout.setExpandRatio(vLayout, 1);
    }
}

From source file:com.jain.addon.web.layout.JainGroupLayout.java

License:Apache License

private JainLayout createOrUpdateCurrentLayout(JNIGroup group, String groupName) {
    if (group != null && group.getParent() != null) {
        JainLayout parentLayout = groupLayoutMap.get(group.getParent().getName());
        if (parentLayout == null) {
            parentLayout = createOrUpdateCurrentLayout(group.getParent(), group.getParent().getName());
        }/*  w  w  w.  j  a v  a2s. co  m*/

        if (parentLayout != null) {
            JainLayout layout = new JainLayout(spacing, margin,
                    group.getParent() == null ? group.getColumns() : group.getParent().getColumns());

            if (StringHelper.isNotEmptyWithTrim(alternateStyleName))
                layout.setStyleName(alternateStyleName);

            VerticalLayout groupLayout = new VerticalLayout();

            if (StringHelper.isNotEmptyWithTrim(styleName))
                groupLayout.setStyleName(styleName);

            if (StringHelper.isNotEmptyWithTrim(group.getDisplayName())) {
                groupLayout.setCaption(group.getDisplayName());
            }

            groupLayout.setSpacing(true);
            groupLayout.setMargin(true);
            groupLayout.setWidth("100%");
            groupLayout.addComponent(layout);
            parentLayout.addComponent(groupLayout, group.getColSpan());

            groupLayoutMap.put(groupName, layout);
            return layout;
        }
    }

    String groupDisplayName = group == null ? "" : group.getDisplayName();
    JainLayout layout = new JainLayout(spacing, margin, group == null ? columns : group.getColumns());

    if (StringHelper.isNotEmptyWithTrim(alternateStyleName))
        layout.setStyleName(alternateStyleName);

    VerticalLayout groupLayout = new VerticalLayout();

    if (StringHelper.isNotEmptyWithTrim(styleName))
        groupLayout.setStyleName(styleName);

    if (StringHelper.isNotEmptyWithTrim(groupDisplayName)) {
        groupLayout.setCaption(group.getDisplayName());
    }

    groupLayout.setSpacing(true);
    groupLayout.setMargin(true);
    groupLayout.setWidth("100%");
    groupLayout.addComponent(layout);
    super.addComponent(groupLayout);

    groupLayoutMap.put(groupName, layout);
    return layout;
}

From source file:com.jain.common.approot.ApplicationUI.java

License:Apache License

public void initialize(Locale locale) {
    user.setLocale(locale);/*from w  w w .j a  v  a  2s .co  m*/

    addApplicationTitle();

    VerticalLayout view = new VerticalLayout();
    setContent(view);

    view.setStyleName(ApplicationTheme.VIEW);
    view.setWidth("100%");
    view.setHeight("100%");
    view.setSpacing(false);
    view.setMargin(false);

    createWelcomebar(view);

    Header header = CDIComponent.getInstance(Header.class);
    view.addComponent(header);
    header.addDefaultTab();
}

From source file:com.jain.common.authenticate.LoginAction.java

License:Apache License

@JNIComponentInit
public void init() {
    setModal(true);/* w w  w  .  j  a  v a  2s .c  o  m*/
    setWidth("30%");

    VerticalLayout layout = new VerticalLayout();
    setContent(layout);

    layout.setWidth("100%");
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setStyleName(ApplicationTheme.ALTERNATE_VIEW);

    createFieldGroup(layout);

    createActions(layout);
}

From source file:com.jain.common.authenticate.LoginAction.java

License:Apache License

private void createActions(VerticalLayout layout) {
    ButtonSegment hLayout = new ButtonSegment(ApplicationTheme.FIRST, ApplicationTheme.LAST);
    hLayout.setStyleName(ApplicationTheme.HEADER_SEGMENT_SMALL);
    hLayout.createSegment(this, JAction.LOGIN, JAction.CANCEL);

    VerticalLayout vLayout = new VerticalLayout();
    vLayout.setSizeUndefined();//www . j  ava 2s  . com
    vLayout.setStyleName(ApplicationTheme.VIEW);
    vLayout.addComponent(hLayout);

    layout.addComponent(vLayout);
    layout.setComponentAlignment(vLayout, Alignment.MIDDLE_CENTER);
    layout.setExpandRatio(vLayout, 1);
}

From source file:com.jain.common.authenticate.LoginAction.java

License:Apache License

private void createFieldGroup(VerticalLayout layout) {
    I18NProvider provider = DefaultI18NResourceProvider.instance();

    userName = new TextField("user.name");
    userName.setCursorPosition(0);/*from www .j a v a  2 s . co  m*/
    userName.setRequired(true);
    userName.setRequiredError(provider.getMessage(getLocale(), "common.something.required", "user.name.title",
            JAction.LOGIN.getDisplayName()));
    userName.setDescription("user.name");
    userName.setSizeFull();
    userName.setStyleName(JNStyleConstants.J_FIELD);

    password = new PasswordField("password");
    password.setRequired(true);
    password.setRequiredError(provider.getMessage(getLocale(), "common.something.required", "password.title",
            JAction.LOGIN.getDisplayName()));
    password.setDescription("password");
    password.setSizeFull();
    password.setStyleName(JNStyleConstants.J_FIELD);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setStyleName(ApplicationTheme.VIEW);
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);
    verticalLayout.setWidth("100%");

    FormLayout formLayout = new FormLayout();
    formLayout.setStyleName(ApplicationTheme.ALTERNATE_VIEW);
    formLayout.setSpacing(true);
    formLayout.setMargin(true);
    formLayout.setWidth("100%");
    formLayout.addComponent(userName);
    formLayout.addComponent(password);

    verticalLayout.addComponent(formLayout);

    layout.addComponent(verticalLayout);
}

From source file:com.jain.i18N.definition.PersonDefinitionForm.java

License:Apache License

@JNIComponentInit
public void init() {
    setModal(true);/*from   w w  w.  j a v  a  2 s  .  com*/
    setWidth("70%");

    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setMargin(new MarginInfo(false, false, true, false));
    layout.setStyleName(ApplicationTheme.ALTERNATE_VIEW);

    setContent(layout);
    createFieldGroup(layout);

    createActions(layout);
}