Example usage for com.vaadin.ui HorizontalLayout setSpacing

List of usage examples for com.vaadin.ui HorizontalLayout setSpacing

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:com.hack23.cia.web.impl.ui.application.views.admin.system.pagemode.AbstractAdminSystemPageModContentFactoryImpl.java

License:Apache License

/**
 * Creates the paging controls.//  w w  w  .j  a  va2 s . co m
 *
 * @param name
 *            the name
 * @param pageId
 *            the page id
 * @param size
 *            the size
 * @param pageNr
 *            the page nr
 * @param resultPerPage
 *            the result per page
 * @return the horizontal layout
 */
protected final void createPagingControls(final AbstractOrderedLayout content, final String name,
        final String pageId, final Long size, final int pageNr, final int resultPerPage) {
    final HorizontalLayout pagingControls = new HorizontalLayout();
    pagingControls.setSpacing(true);
    pagingControls.setMargin(true);

    final int maxPages = (int) ((size + (resultPerPage - 1)) / resultPerPage);

    final StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(PAGE_HEADER).append(pageNr).append(PAGE_SEPARATOR).append(maxPages)
            .append(PAGES_TOTAL_RESULTS).append(size).append(RESULTS_PER_PAGE).append(resultPerPage)
            .append(SHOW);
    final Label pageInfo = new Label(stringBuilder.toString());
    pagingControls.addComponent(pageInfo);
    pagingControls.setExpandRatio(pageInfo, ContentRatio.SMALL);

    if (pageNr > PAGE_ONE) {
        addPagingLink(PREVIOUS_PAGE, name, pageId, pageNr - 1, pagingControls);
    }

    if (maxPages > PAGE_ONE && pageNr < maxPages) {
        addPagingLink(NEXT_PAGE, name, pageId, pageNr + 1, pagingControls);
    }

    if (maxPages > LIMIT_FOR_DISPLAYING_START_END_LINKS && pageNr > PAGE_ONE) {
        addPagingLink(FIRST_PAGE, name, pageId, 1, pagingControls);
    }

    if (maxPages > LIMIT_FOR_DISPLAYING_START_END_LINKS && pageNr < maxPages) {
        addPagingLink(LAST_PAGE, name, pageId, maxPages, pagingControls);
    }

    content.addComponent(pagingControls);
    content.setExpandRatio(pagingControls, ContentRatio.SMALL2);

}

From source file:com.haulmont.cuba.web.app.folders.FolderEditWindow.java

License:Apache License

public FolderEditWindow(boolean adding, Folder folder, Presentations presentations, Runnable commitHandler) {
    this.folder = folder;
    this.commitHandler = commitHandler;

    messages = AppBeans.get(Messages.NAME);
    messagesPack = AppConfig.getMessagesPack();
    userSessionSource = AppBeans.get(UserSessionSource.NAME);
    Configuration configuration = AppBeans.get(Configuration.NAME);
    clientConfig = configuration.getConfig(ClientConfig.class);

    setCaption(adding ? getMessage("folders.folderEditWindow.adding") : getMessage("folders.folderEditWindow"));

    ThemeConstants theme = App.getInstance().getThemeConstants();
    setWidthUndefined();//from   w  w w  .j ava2 s .c o  m
    setResizable(false);

    int[] modifiers = { ShortcutAction.ModifierKey.CTRL };
    addAction(new ShortcutListener("commit", com.vaadin.event.ShortcutAction.KeyCode.ENTER, modifiers) {
        @Override
        public void handleAction(Object sender, Object target) {
            commit();
        }
    });

    layout = new VerticalLayout();
    layout.setWidthUndefined();
    layout.setSpacing(true);

    setContent(layout);
    setModal(true);
    center();

    String fieldWidth = theme.get("cuba.web.FolderEditWindow.field.width");

    nameField = new TextField();
    nameField.setRequired(true);
    nameField.setCaption(getMessage("folders.folderEditWindow.nameField"));
    nameField.setWidth(fieldWidth);
    nameField.setValue(folder.getName());
    nameField.focus();
    layout.addComponent(nameField);

    tabNameField = new TextField();
    tabNameField.setCaption(getMessage("folders.folderEditWindow.tabNameField"));
    tabNameField.setWidth(fieldWidth);
    tabNameField.setValue(StringUtils.trimToEmpty(folder.getTabName()));
    layout.addComponent(tabNameField);

    parentSelect = new ComboBox();
    parentSelect.setCaption(getMessage("folders.folderEditWindow.parentSelect"));
    parentSelect.setWidth(fieldWidth);
    parentSelect.setNullSelectionAllowed(true);
    fillParentSelect();
    parentSelect.setValue(folder.getParent());
    layout.addComponent(parentSelect);

    if (folder instanceof SearchFolder) {
        if (presentations != null) {
            presentation = new ComboBox();
            presentation.setCaption(getMessage("folders.folderEditWindow.presentation"));
            presentation.setWidth(fieldWidth);
            presentation.setNullSelectionAllowed(true);
            fillPresentations(presentations);
            presentation.setValue(((SearchFolder) folder).getPresentation());
            layout.addComponent(presentation);
        } else if (((SearchFolder) folder).getPresentation() != null) {
            selectedPresentationField = new TextField();
            selectedPresentationField.setWidth(fieldWidth);
            selectedPresentationField.setCaption(getMessage("folders.folderEditWindow.presentation"));
            selectedPresentationField.setValue(((SearchFolder) folder).getPresentation().getName());
            selectedPresentationField.setEnabled(false);
            layout.addComponent(selectedPresentationField);
        }
    }

    sortOrderField = new TextField();
    sortOrderField.setCaption(getMessage("folders.folderEditWindow.sortOrder"));
    sortOrderField.setWidth(fieldWidth);
    sortOrderField.setValue(folder.getSortOrder() == null ? "" : folder.getSortOrder().toString());
    layout.addComponent(sortOrderField);

    if (userSessionSource.getUserSession().isSpecificPermitted("cuba.gui.searchFolder.global")
            && folder instanceof SearchFolder && BooleanUtils.isNotTrue(((SearchFolder) folder).getIsSet())) {
        globalCb = new CubaCheckBox(getMessage("folders.folderEditWindow.global"));
        globalCb.setValue(((SearchFolder) folder).getUser() == null);
        layout.addComponent(globalCb);
    }

    applyDefaultCb = new CubaCheckBox(getMessage("folders.folderEditWindow.applyDefault"));
    applyDefaultCb.setValue(BooleanUtils.isTrue(((AbstractSearchFolder) folder).getApplyDefault()));
    applyDefaultCb.setVisible(clientConfig.getGenericFilterManualApplyRequired()
            && folder instanceof SearchFolder && BooleanUtils.isNotTrue(((SearchFolder) folder).getIsSet()));
    layout.addComponent(applyDefaultCb);

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setMargin(new MarginInfo(true, false, false, false));
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    okBtn = new CubaButton(getMessage("actions.Ok"));
    okBtn.setIcon(WebComponentsHelper.getIcon("icons/ok.png"));
    okBtn.addStyleName(WebButton.ICON_STYLE);

    initButtonOkListener();
    buttonsLayout.addComponent(okBtn);

    cancelBtn = new CubaButton(getMessage("actions.Cancel"));
    cancelBtn.setIcon(WebComponentsHelper.getIcon("icons/cancel.png"));
    cancelBtn.addStyleName(WebButton.ICON_STYLE);
    cancelBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    buttonsLayout.addComponent(cancelBtn);

    if (AppUI.getCurrent().isTestMode()) {
        setCubaId("folderEditWindow");

        nameField.setCubaId("nameField");
        tabNameField.setCubaId("tabNameField");
        parentSelect.setCubaId("parentSelect");
        if (presentation != null) {
            presentation.setCubaId("presentationSelect");
        }
        sortOrderField.setCubaId("sortOrderField");
        if (selectedPresentationField != null) {
            selectedPresentationField.setCubaId("selectedPresentationField");
        }
        if (globalCb != null) {
            globalCb.setCubaId("globalCb");
        }
        applyDefaultCb.setCubaId("applyDefaultCb");
        okBtn.setCubaId("okBtn");
        cancelBtn.setCubaId("cancelBtn");
    }
}

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

License:Apache License

public ExceptionDialog(Throwable throwable, @Nullable String caption, @Nullable String message) {
    final AppUI ui = AppUI.getCurrent();

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

    com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction(
            "closeShortcutAction", closeCombination.getKey().getCode(),
            KeyCombination.Modifier.codes(closeCombination.getModifiers()));

    addActionHandler(new com.vaadin.event.Action.Handler() {
        @Override/*w ww.  j  av a 2  s  .c  om*/
        public com.vaadin.event.Action[] getActions(Object target, Object sender) {
            return new com.vaadin.event.Action[] { closeShortcutAction };
        }

        @Override
        public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
            if (Objects.equals(action, closeShortcutAction)) {
                close();
            }
        }
    });

    setCaption(caption != null ? caption : messages.getMainMessage("exceptionDialog.caption"));

    ThemeConstants theme = ui.getApp().getThemeConstants();
    setWidth(theme.get("cuba.web.ExceptionDialog.width"));
    center();

    final String text = message != null ? message : getText(throwable);
    Throwable exception = removeRemoteException(throwable);
    final String stackTrace = getStackTrace(exception);

    mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);

    TextArea textArea = new TextArea();
    textArea.setHeight(theme.get("cuba.web.ExceptionDialog.textArea.height"));
    textArea.setWidth(100, Unit.PERCENTAGE);

    boolean showExceptionDetails = userSessionSource.getUserSession() != null
            && security.isSpecificPermitted("cuba.gui.showExceptionDetails");

    if (showExceptionDetails) {
        textArea.setValue(text);
    } else {
        textArea.setValue(messages.getMainMessage("exceptionDialog.contactAdmin"));
    }
    textArea.setReadOnly(true);

    mainLayout.addComponent(textArea);

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setSpacing(true);
    buttonsLayout.setWidth("100%");
    mainLayout.addComponent(buttonsLayout);

    Button closeButton = new CubaButton(messages.getMainMessage("exceptionDialog.closeBtn"));
    closeButton.addClickListener((Button.ClickListener) event -> this.close());
    buttonsLayout.addComponent(closeButton);

    showStackTraceButton = new CubaButton(messages.getMainMessage("exceptionDialog.showStackTrace"));
    showStackTraceButton
            .addClickListener((Button.ClickListener) event -> setStackTraceVisible(!isStackTraceVisible));
    buttonsLayout.addComponent(showStackTraceButton);
    showStackTraceButton.setVisible(showExceptionDetails);

    Label spacer = new Label();
    buttonsLayout.addComponent(spacer);
    buttonsLayout.setExpandRatio(spacer, 1);

    String cubaLogContentClass = "c-exception-dialog-log-content";
    String cubaCopyLogContentClass = cubaLogContentClass + "-" + UUID.randomUUID();

    if (browserSupportCopy()) {
        copyButton = new CubaButton(messages.getMainMessage("exceptionDialog.copyStackTrace"));
        copyButton.setVisible(false);
        CubaCopyButtonExtension copyExtension = CubaCopyButtonExtension.copyWith(copyButton,
                cubaCopyLogContentClass);
        copyExtension
                .addCopyListener(
                        event -> Notification.show(
                                messages.getMainMessage(event.isSuccess() ? "exceptionDialog.copingSuccessful"
                                        : "exceptionDialog.copingFailed"),
                                Notification.Type.TRAY_NOTIFICATION));
        buttonsLayout.addComponent(copyButton);
    }

    if (userSessionSource.getUserSession() != null) {
        if (!StringUtils.isBlank(clientConfig.getSupportEmail())) {
            Button reportButton = new CubaButton(messages.getMainMessage("exceptionDialog.reportBtn"));
            reportButton.addClickListener((Button.ClickListener) event -> {
                sendSupportEmail(text, stackTrace);
                reportButton.setEnabled(false);
            });
            buttonsLayout.addComponent(reportButton);

            if (ui.isTestMode()) {
                reportButton.setCubaId("errorReportButton");
            }
        }
    }

    Button logoutButton = new CubaButton(messages.getMainMessage("exceptionDialog.logout"));
    logoutButton.addClickListener((Button.ClickListener) event -> logoutPrompt());
    buttonsLayout.addComponent(logoutButton);

    stackTraceTextArea = new TextArea();
    stackTraceTextArea.setSizeFull();
    stackTraceTextArea.setWordwrap(false);
    stackTraceTextArea.setValue(stackTrace);
    stackTraceTextArea.setStyleName(cubaLogContentClass);
    stackTraceTextArea.addStyleName(cubaCopyLogContentClass);
    stackTraceTextArea.setReadOnly(true);

    setContent(mainLayout);
    setResizable(false);

    if (ui.isTestMode()) {
        setId(ui.getTestIdManager().getTestId("exceptionDialog"));
        setCubaId("exceptionDialog");

        closeButton.setCubaId("closeButton");
        if (copyButton != null) {
            copyButton.setCubaId("copyStackTraceButton");
        }
        showStackTraceButton.setCubaId("showStackTraceButton");
        stackTraceTextArea.setCubaId("stackTraceTextArea");
        logoutButton.setCubaId("logoutButton");
    }
}

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

License:Apache License

protected void initLayout() {
    ThemeConstants theme = App.getInstance().getThemeConstants();

    VerticalLayout root = new VerticalLayout();
    root.setWidthUndefined();/*w  w w .j  av a 2 s  . co m*/
    root.setSpacing(true);
    setContent(root);

    messages = AppBeans.get(Messages.class);

    nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
    nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
    nameField.setValue(getPresentationCaption());
    root.addComponent(nameField);

    autoSaveField = new CheckBox();
    autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
    autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
    root.addComponent(autoSaveField);

    defaultField = new CheckBox();
    defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
    defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
    root.addComponent(defaultField);

    if (allowGlobalPresentations) {
        globalField = new CheckBox();
        globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
        globalField.setValue(!isNew && presentation.getUser() == null);
        root.addComponent(globalField);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidthUndefined();
    root.addComponent(buttons);
    root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);

    Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
    commitButton.addClickListener(event -> {
        if (validate()) {
            commit();
            close();
        }
    });
    buttons.addComponent(commitButton);

    Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
    closeButton.addClickListener(event -> {
        close();
    });
    buttons.addComponent(closeButton);

    nameField.focus();
}

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

License:Apache License

protected HorizontalLayout createTitleLayout() {
    HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setStyleName("cuba-login-title");
    titleLayout.setSpacing(true);

    Image logoImage = getLogoImage();
    if (logoImage != null) {
        logoImage.setStyleName("cuba-login-icon");
        titleLayout.addComponent(logoImage);
        titleLayout.setComponentAlignment(logoImage, Alignment.MIDDLE_LEFT);
    }//from  w w w.j  a  v a  2 s . c  om

    String welcomeMsg = messages.getMainMessage("loginWindow.welcomeLabel", resolvedLocale);
    Label label = new Label(welcomeMsg.replace("\n", "<br/>"));
    label.setContentMode(ContentMode.HTML);
    label.setWidthUndefined();
    label.setStyleName("cuba-login-caption");

    if (!StringUtils.isBlank(label.getValue())) {
        titleLayout.addComponent(label);
        titleLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    }
    return titleLayout;
}

From source file:com.haulmont.cuba.web.toolkit.ui.CubaRowsCount.java

License:Apache License

public CubaRowsCount() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setStyleName("c-paging");
    layout.setSpacing(false);
    layout.setMargin(new MarginInfo(false, false, false, true));

    setCompositionRoot(layout);/*from  w ww .  j  a  va2s .  c om*/

    CubaPlaceHolder expander = new CubaPlaceHolder();
    expander.setWidth("100%");
    layout.addComponent(expander);
    layout.setExpandRatio(expander, 1);

    AbstractOrderedLayout contentLayout = createContentLayout();
    layout.addComponent(contentLayout);

    layout.setWidth("100%");
    setWidth("100%");
}

From source file:com.haulmont.cuba.web.toolkit.ui.CubaRowsCount.java

License:Apache License

protected AbstractOrderedLayout createContentLayout() {
    HorizontalLayout contentLayout = new HorizontalLayout();
    contentLayout.setStyleName("c-paging-wrap");
    contentLayout.setSpacing(true);

    firstButton = new CubaButton();
    firstButton.setIcon(WebComponentsHelper.getIcon("icons/rows-count-first.png"));
    firstButton.setStyleName("c-paging-change-page");
    firstButton.addStyleName("c-paging-first");
    contentLayout.addComponent(firstButton);

    contentLayout.setComponentAlignment(firstButton, Alignment.MIDDLE_CENTER);

    prevButton = new CubaButton();
    prevButton.setIcon(WebComponentsHelper.getIcon("icons/rows-count-prev.png"));
    prevButton.setStyleName("c-paging-change-page");
    prevButton.addStyleName("c-paging-prev");
    contentLayout.addComponent(prevButton);
    contentLayout.setComponentAlignment(prevButton, Alignment.MIDDLE_CENTER);

    label = new Label();
    label.setWidthUndefined();//w  w  w.j  a  v a 2  s .c om
    label.setStyleName("c-paging-status");
    contentLayout.addComponent(label);
    contentLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);

    countButton = new CubaButton("[?]");
    countButton.setWidthUndefined();
    countButton.setStyleName(BaseTheme.BUTTON_LINK);
    countButton.addStyleName("c-paging-count");
    countButton.setTabIndex(-1);
    contentLayout.addComponent(countButton);
    contentLayout.setComponentAlignment(countButton, Alignment.MIDDLE_CENTER);

    nextButton = new CubaButton();
    nextButton.setIcon(WebComponentsHelper.getIcon("icons/rows-count-next.png"));
    nextButton.setStyleName("c-paging-change-page");
    nextButton.addStyleName("c-paging-next");
    contentLayout.addComponent(nextButton);
    contentLayout.setComponentAlignment(nextButton, Alignment.MIDDLE_CENTER);

    lastButton = new CubaButton();
    lastButton.setIcon(WebComponentsHelper.getIcon("icons/rows-count-last.png"));
    lastButton.setStyleName("c-paging-change-page");
    lastButton.addStyleName("c-paging-last");
    contentLayout.addComponent(lastButton);
    contentLayout.setComponentAlignment(lastButton, Alignment.MIDDLE_CENTER);

    return contentLayout;
}

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  a v  a  2s.  c o m*/

    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.haulmont.cuba.web.widgets.CubaRowsCount.java

License:Apache License

public CubaRowsCount() {
    HorizontalLayout layout = new HorizontalLayout(); // vaadin8 use CssLayout instead
    layout.setStyleName("c-paging");
    layout.setSpacing(false);
    layout.setMargin(new MarginInfo(false, false, false, true));

    setCompositionRoot(layout);/* w w  w . j  av a 2  s  .c  om*/

    CubaPlaceHolder expander = new CubaPlaceHolder();
    expander.setWidth("100%");
    layout.addComponent(expander);
    layout.setExpandRatio(expander, 1);

    AbstractOrderedLayout contentLayout = createContentLayout();
    layout.addComponent(contentLayout);

    layout.setWidth("100%");
    setWidth("100%");
}

From source file:com.haulmont.cuba.web.widgets.CubaRowsCount.java

License:Apache License

protected AbstractOrderedLayout createContentLayout() {
    HorizontalLayout contentLayout = new HorizontalLayout(); // vaadin8 use CssLayout instead
    contentLayout.setStyleName("c-paging-wrap");
    contentLayout.setSpacing(true);
    contentLayout.setMargin(false);//from   w  w w  . j a  v a2s  . co  m

    firstButton = new CubaButton();
    firstButton.setStyleName("c-paging-change-page");
    firstButton.addStyleName("c-paging-first");
    contentLayout.addComponent(firstButton);

    contentLayout.setComponentAlignment(firstButton, Alignment.MIDDLE_CENTER);

    prevButton = new CubaButton();
    prevButton.setStyleName("c-paging-change-page");
    prevButton.addStyleName("c-paging-prev");
    contentLayout.addComponent(prevButton);
    contentLayout.setComponentAlignment(prevButton, Alignment.MIDDLE_CENTER);

    label = new Label();
    label.setWidthUndefined();
    label.setStyleName("c-paging-status");
    contentLayout.addComponent(label);
    contentLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);

    countButton = new CubaButton("[?]");
    countButton.setWidthUndefined();
    countButton.setStyleName(ValoTheme.BUTTON_LINK);
    countButton.addStyleName("c-paging-count");
    countButton.setTabIndex(-1);
    contentLayout.addComponent(countButton);
    contentLayout.setComponentAlignment(countButton, Alignment.MIDDLE_CENTER);

    nextButton = new CubaButton();
    nextButton.setStyleName("c-paging-change-page");
    nextButton.addStyleName("c-paging-next");
    contentLayout.addComponent(nextButton);
    contentLayout.setComponentAlignment(nextButton, Alignment.MIDDLE_CENTER);

    lastButton = new CubaButton();
    lastButton.setStyleName("c-paging-change-page");
    lastButton.addStyleName("c-paging-last");
    contentLayout.addComponent(lastButton);
    contentLayout.setComponentAlignment(lastButton, Alignment.MIDDLE_CENTER);

    return contentLayout;
}