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.esofthead.mycollab.vaadin.web.ui.OptionPopupContent.java

License:Open Source License

public OptionPopupContent() {
    VerticalLayout root = new VerticalLayout();
    root.setStyleName(UIConstants.OPTION_POPUP_CONTENT);
    this.setCompositionRoot(root);
}

From source file:com.foo01.ui.ReservationDetailView.java

@Override
protected final void onBecomingVisible() {
    getNavigationBar().setCaption("Detail Rezervace");

    //buttony pod navbarem
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setStyleName("buttonToolBarLayout");
    buttonsLayout.setWidth("100%");

    Button deleteButton = new Button();
    deleteButton.setCaption("SMAZAT");
    deleteButton.setWidth(null);//from ww  w . j av a  2 s .c  o m
    buttonsLayout.addComponent(deleteButton);

    Label plug = new Label();
    buttonsLayout.addComponent(plug);

    Button saveButton = new Button();
    saveButton.setCaption("ULOIT");
    saveButton.setWidth(null);
    buttonsLayout.addComponent(saveButton);
    buttonsLayout.setExpandRatio(plug, 1.0f);
    List<Source> sourcesList = MockSource.mockSources();

    //combobox na zdroje a jmeno uzivatele
    HorizontalLayout sourceAndNameLayout = new HorizontalLayout();
    sourceAndNameLayout.setWidth("100%");
    sourceAndNameLayout.setStyleName("sourceAndNameLayout");

    NativeSelect select = new NativeSelect();
    select.setNullSelectionAllowed(false);
    System.out.println(Page.getCurrent().getBrowserWindowWidth());
    String width = Page.getCurrent().getBrowserWindowWidth() / 2.5 + "px";
    select.setWidth(width);
    select.addItems(sourcesList);
    for (Source s : sourcesList) {
        if (reservation.getSource().equals(s)) {
            select.select(s);
            break;
        }
    }
    sourceAndNameLayout.addComponent(select);

    Label plug2 = new Label();
    sourceAndNameLayout.addComponent(plug2);

    Label name = new Label(reservation.getUser());
    name.setWidth(null);
    sourceAndNameLayout.addComponent(name);
    sourceAndNameLayout.setExpandRatio(plug2, 1.0f);

    //datepickery
    DatePicker dateFrom = new DatePicker();
    dateFrom.setStyleName("datePickerDetailView");
    dateFrom.setValue(reservation.getBeginning());
    dateFrom.setUseNative(true);
    dateFrom.setResolution(Resolution.TIME);
    dateFrom.setWidth("100%");

    DatePicker dateTo = new DatePicker();
    dateTo.setStyleName("datePickerDetailView");
    dateTo.setValue(reservation.getEnding());
    dateTo.setUseNative(true);
    dateTo.setResolution(Resolution.TIME);
    dateTo.setWidth("100%");

    //layout pro slider a popisky
    HorizontalLayout sliderLayout = new HorizontalLayout();
    sliderLayout.setStyleName("sliderLayout");
    sliderLayout.setWidth("100%");
    sliderLayout.setSpacing(true);

    Label sliderCaption = new Label("Po?et: ");
    sliderCaption.addStyleName("sliderCaption");
    sliderCaption.setWidth(null);
    sliderLayout.addComponent(sliderCaption);

    final Label horvalue = new Label();
    horvalue.setWidth("45px");
    horvalue.setStyleName("value");
    sliderLayout.addComponent(horvalue);

    final Slider horslider = new Slider(1, 10);
    horslider.setOrientation(SliderOrientation.HORIZONTAL);
    horslider.setValue(Double.valueOf(1));
    horslider.getState();
    horslider.getValue();
    horslider.setImmediate(true);
    horslider.setWidth("100%");
    sliderLayout.addComponent(horslider);
    sliderLayout.setExpandRatio(horslider, 1.0f);

    horvalue.setValue(String.valueOf(horslider.getValue().intValue()));

    horslider.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            int value = horslider.getValue().intValue();

            horvalue.setValue(String.valueOf(value));
        }
    });

    //switch schvaleno
    HorizontalLayout switchLayout = new HorizontalLayout();
    switchLayout.setStyleName("switchLayout");
    switchLayout.addComponent(new Label("Schvleno:"));
    switchLayout.setSpacing(true);
    Switch checkbox = new Switch(null, true);
    switchLayout.addComponent(checkbox);

    //popis rezervace
    TextArea description = new TextArea();
    description.setStyleName("descriptionDetailView");

    description.setWidth("100%");
    description.setImmediate(false);
    description.setCaption("Popis:");
    description.setValue(reservation.getDescription());
    //description.setRequired(true);
    description.setRequiredError("Popis mus bt zadn!");
    description.setNullRepresentation("");
    description.setReadOnly(true);
    //description.setRows(0);

    final VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    content.setStyleName(width);
    content.addComponent(buttonsLayout);
    content.addComponent(sourceAndNameLayout);
    content.addComponent(dateFrom);
    content.addComponent(dateTo);

    content.addComponent(sliderLayout);
    content.addComponent(switchLayout);
    content.addComponent(description);

    setContent(content);
}

From source file:com.freebox.engeneering.application.web.common.ApplicationLayout.java

License:Apache License

/**
  * Initializes view layout when system enters 'initView' action state.
  *//from   ww w . j  a  v  a 2 s  . c om
  * @param event -  state event.
  */
public void initView(@SuppressWarnings("rawtypes") StateEvent event) {
    final HorizontalLayout content = new HorizontalLayout();
    content.setSizeFull();
    content.setStyleName("main-view");

    final HorizontalSplitPanel leftSplitPanel = new HorizontalSplitPanel();
    leftSplitPanel.setSplitPosition(20, Sizeable.Unit.PERCENTAGE);

    final ComponentContainer leftSideBar = createPlaceholder(StateLayout.LEFT_SIDE_BAR);
    leftSideBar.setSizeFull();
    content.addComponent(leftSideBar, 0);

    final VerticalLayout verticalLayoutContent = new VerticalLayout();
    verticalLayoutContent.setStyleName("freebox-view");
    verticalLayoutContent.addComponent(createPlaceholder(StateLayout.HEADER));
    verticalLayoutContent.setSpacing(true);
    final ComponentContainer layoutContent = createPlaceholder(StateLayout.CONTENT);
    layoutContent.setSizeFull();
    verticalLayoutContent.addComponent(layoutContent);
    verticalLayoutContent.setSizeFull();
    //verticalLayoutContent.addComponent(createPlaceholder(StateLayout.FOOTER));

    verticalLayoutContent.setExpandRatio(layoutContent, 8f);

    content.addComponent(verticalLayoutContent, 1);
    content.setExpandRatio(leftSideBar, 1.0f);
    content.setExpandRatio(verticalLayoutContent, 9f);

    setView(content);
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.pagemode.AbstractPageModContentFactoryImpl.java

License:Apache License

/**
 * Creates the panel content./*from  ww w  .j av  a  2 s . co  m*/
 *
 * @return the vertical layout
 */
protected final VerticalLayout createPanelContent() {
    final VerticalLayout panelContent = new VerticalLayout();
    panelContent.setMargin(true);
    panelContent.setWidth(100, Unit.PERCENTAGE);
    panelContent.setHeight(100, Unit.PERCENTAGE);
    panelContent.setStyleName("Header");
    return panelContent;
}

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

License:Apache License

protected void showCriticalExceptionMessage(Exception exception) {
    String initErrorCaption = messages.getMainMessage("app.initErrorCaption");
    String initErrorMessage = messages.getMainMessage("app.initErrorMessage");

    VerticalLayout content = new VerticalLayout();
    content.setStyleName("c-init-error-view");
    content.setSizeFull();//from   ww  w. j  av a 2  s  .  c o m

    VerticalLayout errorPanel = new VerticalLayout();
    errorPanel.setStyleName("c-init-error-panel");
    errorPanel.setWidthUndefined();
    errorPanel.setSpacing(true);

    Label captionLabel = new Label(initErrorCaption);
    captionLabel.setWidthUndefined();
    captionLabel.setStyleName("c-init-error-caption");
    captionLabel.addStyleName("h2");
    captionLabel.setValue(initErrorCaption);

    errorPanel.addComponent(captionLabel);

    Label messageLabel = new Label(initErrorCaption);
    messageLabel.setWidthUndefined();
    messageLabel.setStyleName("c-init-error-message");
    messageLabel.setValue(initErrorMessage);

    errorPanel.addComponent(messageLabel);

    Button retryButton = new Button(messages.getMainMessage("app.initRetry"));
    retryButton.setStyleName("c-init-error-retry");
    retryButton.addClickListener(event -> {
        // always restart UI
        String url = ControllerUtils.getLocationWithoutParams() + "?restartApp";
        getPage().open(url, "_self");
    });

    errorPanel.addComponent(retryButton);
    errorPanel.setComponentAlignment(retryButton, Alignment.MIDDLE_CENTER);

    content.addComponent(errorPanel);
    content.setComponentAlignment(errorPanel, Alignment.MIDDLE_CENTER);

    setContent(content);
}

From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java

License:Apache License

protected void showNoUserSessionDialog(App app) {
    Messages messages = AppBeans.get(Messages.NAME);

    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);//from ww w .j av  a 2 s. c  o m
    dialog.setResizable(false);
    dialog.setModal(true);

    AppUI ui = app.getAppUI();

    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }

    Label messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.setStyleName("c-nousersession-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);

    Button reloginBtn = new Button();
    if (ui.isTestMode()) {
        reloginBtn.setCubaId("reloginBtn");
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
    reloginBtn.addStyleName(WebButton.ICON_STYLE);
    reloginBtn.addStyleName("c-primary-action");
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));

    String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
    reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName));

    ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());

    reloginBtn.focus();

    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);

    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);

    ui.addWindow(dialog);

    dialog.center();
}

From source file:com.haulmont.cuba.web.gui.components.table.AbbreviatedCellClickListener.java

License:Apache License

@SuppressWarnings("unchecked")
@Override// w w  w.  j a  va  2 s  . c  o  m
public void onClick(Entity item, String columnId) {
    Table.Column column = table.getColumn(columnId);
    MetaProperty metaProperty;
    String value;
    if (DynamicAttributesUtils.isDynamicAttribute(columnId)) {
        metaProperty = dynamicAttributesTools.getMetaPropertyPath(item.getMetaClass(), columnId)
                .getMetaProperty();
        value = dynamicAttributesTools.getDynamicAttributeValueAsString(metaProperty,
                item.getValueEx(columnId));
    } else {
        value = item.getValueEx(columnId);
    }
    if (column.getMaxTextLength() != null) {
        boolean isMultiLineCell = StringUtils.contains(value, "\n");
        if (value == null
                || (value.length() <= column.getMaxTextLength() + MAX_TEXT_LENGTH_GAP && !isMultiLineCell)) {
            // todo artamonov if we click with CTRL and Table is multiselect then we lose previous selected items
            //noinspection SuspiciousMethodCalls
            if (!table.getSelected().contains(item)) {
                table.setSelected(item);
            }
            // do not show popup view
            return;
        }
    }

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);
    layout.setSpacing(false);
    layout.setWidthUndefined();
    layout.setStyleName("c-table-view-textcut");

    CubaTextArea textArea = new CubaTextArea();
    textArea.setValue(Strings.nullToEmpty(value));
    textArea.setReadOnly(true);

    CubaResizableTextAreaWrapper content = new CubaResizableTextAreaWrapper(textArea);
    content.setResizableDirection(ResizeDirection.BOTH);

    // todo implement injection for ThemeConstains in components
    ThemeConstants theme = App.getInstance().getThemeConstants();
    if (theme != null) {
        content.setWidth(theme.get("cuba.web.Table.abbreviatedPopupWidth"));
        content.setHeight(theme.get("cuba.web.Table.abbreviatedPopupHeight"));
    } else {
        content.setWidth("320px");
        content.setHeight("200px");
    }

    layout.addComponent(content);

    CubaEnhancedTable enhancedTable = table.unwrap(CubaEnhancedTable.class);
    enhancedTable.showCustomPopup(layout);
    enhancedTable.setCustomPopupAutoClose(false);
}

From source file:com.haulmont.cuba.web.gui.components.WebAbstractTable.java

License:Apache License

@Override
public void showCustomPopupActions(List<Action> actions) {
    VerticalLayout customContextMenu = new VerticalLayout();
    customContextMenu.setWidthUndefined();
    customContextMenu.setStyleName("c-cm-container");

    for (Action action : actions) {
        ContextMenuButton contextMenuButton = createContextMenuButton();
        contextMenuButton.setStyleName("c-cm-button");
        contextMenuButton.setAction(action);

        Component vButton = WebComponentsHelper.unwrap(contextMenuButton);
        customContextMenu.addComponent(vButton);
    }//from w w  w .jav  a  2  s  .co m

    if (customContextMenu.getComponentCount() > 0) {
        component.showCustomPopup(customContextMenu);
        component.setCustomPopupAutoClose(true);
    }
}

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

License:Apache License

protected VerticalLayout createCenterLayout(int formWidth, int formHeight, int fieldWidth,
        boolean localesSelectVisible) {
    VerticalLayout centerLayout = new VerticalLayout();
    centerLayout.setStyleName("cuba-login-bottom");
    centerLayout.setWidth(formWidth + "px");
    centerLayout.setHeight(formHeight + "px");

    HorizontalLayout titleLayout = createTitleLayout();
    centerLayout.addComponent(titleLayout);
    centerLayout.setComponentAlignment(titleLayout, Alignment.MIDDLE_CENTER);

    FormLayout loginFormLayout = createLoginFormLayout(fieldWidth, localesSelectVisible);
    centerLayout.addComponent(loginFormLayout);
    centerLayout.setComponentAlignment(loginFormLayout, Alignment.MIDDLE_CENTER);
    return centerLayout;
}

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

License:Apache License

@Override
public void showMessageDialog(String title, String message, MessageType messageType) {
    backgroundWorker.checkUIAccess();/*from   ww  w .  jav a 2s.  co  m*/

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

    if (ui.isTestMode()) {
        vWindow.setCubaId("messageDialog");
        vWindow.setId(ui.getTestIdManager().getTestId("messageDialog"));
    }

    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);

    vWindow.addAction(new ShortcutListener("Esc", closeCombination.getKey().getCode(),
            KeyCombination.Modifier.codes(closeCombination.getModifiers())) {
        @Override
        public void handleAction(Object sender, Object target) {
            vWindow.close();
        }
    });

    vWindow.addAction(new ShortcutListener("Enter", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            vWindow.close();
        }
    });

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

    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();
    }
    layout.addComponent(messageLab);

    DialogAction action = new DialogAction(Type.OK);
    Button button = WebComponentsHelper.createButton();

    button.setCaption(action.getCaption());
    button.setIcon(WebComponentsHelper.getIcon(action.getIcon()));
    button.addStyleName(WebButton.ICON_STYLE);
    button.addClickListener(event -> vWindow.close());

    button.focus();

    layout.addComponent(button);

    layout.setComponentAlignment(button, Alignment.BOTTOM_RIGHT);

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

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

    boolean modal = true;
    if (!hasModalWindow()) {
        if (messageType.getModal() != null) {
            modal = messageType.getModal();
        } else if (dialogParams.getModal() != null) {
            modal = dialogParams.getModal();
        }
    }
    vWindow.setModal(modal);

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

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

    dialogParams.reset();

    ui.addWindow(vWindow);
    vWindow.center();
    vWindow.focus();
}