Example usage for com.vaadin.ui HorizontalLayout setExpandRatio

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

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:org.eclipse.hawkbit.ui.distributions.disttype.DistributionSetTypeSoftwareModuleSelectLayout.java

License:Open Source License

private HorizontalLayout createTwinColumnLayout() {
    final HorizontalLayout twinColumnLayout = new HorizontalLayout();
    twinColumnLayout.setSizeFull();//w  w w.j a v  a 2  s .c  o  m
    twinColumnLayout.setWidth("400px");

    buildSourceTable();
    buildSelectedTable();

    final VerticalLayout selectButtonLayout = new VerticalLayout();
    final Button selectButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SELECT_DIST_TYPE, "", "",
            "arrow-button", true, FontAwesome.FORWARD, SPUIButtonStyleNoBorder.class);
    selectButton.addClickListener(event -> addSMType());
    final Button unSelectButton = SPUIComponentProvider.getButton("unselect-dist-type", "", "", "arrow-button",
            true, FontAwesome.BACKWARD, SPUIButtonStyleNoBorder.class);
    unSelectButton.addClickListener(event -> removeSMType());
    selectButtonLayout.addComponent(selectButton);
    selectButtonLayout.addComponent(unSelectButton);
    selectButtonLayout.setComponentAlignment(selectButton, Alignment.MIDDLE_CENTER);
    selectButtonLayout.setComponentAlignment(unSelectButton, Alignment.MIDDLE_CENTER);

    twinColumnLayout.addComponent(sourceTable);
    twinColumnLayout.addComponent(selectButtonLayout);
    twinColumnLayout.addComponent(selectedTable);
    twinColumnLayout.setComponentAlignment(sourceTable, Alignment.MIDDLE_LEFT);
    twinColumnLayout.setComponentAlignment(selectButtonLayout, Alignment.MIDDLE_CENTER);
    twinColumnLayout.setComponentAlignment(selectedTable, Alignment.MIDDLE_RIGHT);
    twinColumnLayout.setExpandRatio(sourceTable, 0.45F);
    twinColumnLayout.setExpandRatio(selectButtonLayout, 0.07F);
    twinColumnLayout.setExpandRatio(selectedTable, 0.48F);
    sourceTable.setVisibleColumns(DIST_TYPE_NAME);
    return twinColumnLayout;
}

From source file:org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetDetails.java

License:Open Source License

private static VerticalLayout createSoftwareModuleLayout(final String softwareModuleName) {
    final VerticalLayout verticalLayout = new VerticalLayout();
    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();/*from ww w.  j  a va 2s. c  o  m*/
    final Label softwareModule = HawkbitCommonUtil.getFormatedLabel("");
    softwareModule.setValue(softwareModuleName);
    softwareModule.setDescription(softwareModuleName);
    softwareModule.setId(softwareModuleName + "-label");
    horizontalLayout.addComponent(softwareModule);
    horizontalLayout.setExpandRatio(softwareModule, 1F);
    verticalLayout.addComponent(horizontalLayout);
    return verticalLayout;
}

From source file:org.eclipse.hawkbit.ui.filtermanagement.CreateOrUpdateFilterHeader.java

License:Open Source License

private void buildLayout() {
    captionLayout = new HorizontalLayout();
    captionLayout.setDescription(i18n.getMessage("tooltip.click.to.edit"));
    captionLayout.setId(UIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LAYOUT_ID);

    titleFilterIconsLayout = new HorizontalLayout();
    titleFilterIconsLayout.addComponents(headerCaption, captionLayout);
    titleFilterIconsLayout.setSpacing(true);

    final HorizontalLayout breadcrumbLayout = new HorizontalLayout();
    breadcrumbLayout.addComponent(breadcrumbButton);
    breadcrumbLayout.addComponent(new Label(">"));
    breadcrumbName = new LabelBuilder().buildCaptionLabel();
    breadcrumbLayout.addComponent(breadcrumbName);
    breadcrumbName.addStyleName("breadcrumbPaddingLeft");

    final HorizontalLayout titleFilterLayout = new HorizontalLayout();
    titleFilterLayout.setSizeFull();/*from w  ww.  j ava2 s  .  c  o  m*/
    titleFilterLayout.addComponents(titleFilterIconsLayout, closeIcon);
    titleFilterLayout.setExpandRatio(titleFilterIconsLayout, 1.0F);
    titleFilterLayout.setComponentAlignment(titleFilterIconsLayout, Alignment.TOP_LEFT);
    titleFilterLayout.setComponentAlignment(closeIcon, Alignment.TOP_RIGHT);

    final HorizontalLayout iconLayout = new HorizontalLayout();
    iconLayout.setSizeUndefined();
    iconLayout.setSpacing(false);
    iconLayout.addComponents(helpLink, searchIcon, saveButton);

    final HorizontalLayout queryLayout = new HorizontalLayout();
    queryLayout.setSizeUndefined();
    queryLayout.setSpacing(true);
    queryLayout.addComponents(queryTextField, iconLayout);

    addComponent(breadcrumbLayout);
    addComponent(titleFilterLayout);
    addComponent(queryLayout);
    setSpacing(true);
    addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
    addStyleName("bordered-layout");
}

From source file:org.eclipse.hawkbit.ui.filtermanagement.TargetFilterHeader.java

License:Open Source License

private void buildLayout() {
    final HorizontalLayout titleFilterIconsLayout = createHeaderFilterIconLayout();
    titleFilterIconsLayout.addComponents(headerCaption, searchField, searchResetIcon);
    if (permissionChecker.hasCreateTargetPermission()) {
        titleFilterIconsLayout.addComponent(createfilterButton);
        titleFilterIconsLayout.setComponentAlignment(createfilterButton, Alignment.TOP_LEFT);
    }/*from w w  w .  j  a  v  a 2 s  .co m*/
    titleFilterIconsLayout.setExpandRatio(headerCaption, 0.3F);
    titleFilterIconsLayout.setExpandRatio(searchField, 0.7F);
    titleFilterIconsLayout.setHeight("40px");
    addComponent(titleFilterIconsLayout);
    addStyleName("bordered-layout");
    addStyleName("no-border-bottom");

}

From source file:org.eclipse.hawkbit.ui.HawkbitUI.java

License:Open Source License

@Override
protected void init(final VaadinRequest vaadinRequest) {
    LOG.info("ManagementUI init starts uiid - {}", getUI().getUIId());
    if (pushStrategy != null) {
        pushStrategy.init(getUI());//from  w w  w.  j a  v a  2s  . c o m
    }
    addDetachListener(this);
    SpringContextHelper.setContext(context);

    Responsive.makeResponsive(this);
    addStyleName(ValoTheme.UI_WITH_MENU);
    setResponsive(Boolean.TRUE);

    final HorizontalLayout rootLayout = new HorizontalLayout();
    rootLayout.setSizeFull();

    dashboardMenu.init();
    dashboardMenu.setResponsive(true);

    final VerticalLayout contentVerticalLayout = new VerticalLayout();
    contentVerticalLayout.setSizeFull();
    contentVerticalLayout.setStyleName("main-content");
    contentVerticalLayout.addComponent(buildHeader());
    contentVerticalLayout.addComponent(buildViewTitle());

    final Panel content = buildContent();
    contentVerticalLayout.addComponent(content);
    contentVerticalLayout.setExpandRatio(content, 1);

    rootLayout.addComponent(dashboardMenu);
    rootLayout.addComponent(contentVerticalLayout);
    rootLayout.setExpandRatio(contentVerticalLayout, 1);
    setContent(rootLayout);

    final Navigator navigator = new Navigator(this, content);
    navigator.addViewChangeListener(new ViewChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean beforeViewChange(final ViewChangeEvent event) {
            return true;
        }

        @Override
        public void afterViewChange(final ViewChangeEvent event) {
            final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName());
            dashboardMenu.postViewChange(new PostViewChangeEvent(view));
            if (view == null) {
                viewTitle.setCaption(null);
                return;
            }
            viewTitle.setCaption(view.getDashboardCaptionLong());
            notificationUnreadButton.setCurrentView(event.getNewView());
        }
    });

    navigator.setErrorView(errorview);
    navigator.addProvider(new ManagementViewProvider());
    setNavigator(navigator);
    navigator.addView(EMPTY_VIEW, new Navigator.EmptyView());
    // set locale is required for I18N class also, to get the locale from
    // cookie
    final String locale = getLocaleId(SPUIDefinitions.getAvailableLocales());
    setLocale(new Locale(locale));

    if (UI.getCurrent().getErrorHandler() == null) {
        UI.getCurrent().setErrorHandler(new HawkbitUIErrorHandler());
    }

    LOG.info("Current locale of the application is : {}", HawkbitCommonUtil.getLocale());
}

From source file:org.eclipse.hawkbit.ui.management.actionhistory.ActionHistoryHeader.java

License:Open Source License

private void buildLayout() {
    final HorizontalLayout titleMaxIconsLayout = new HorizontalLayout();
    titleMaxIconsLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
    titleMaxIconsLayout.setSpacing(false);
    titleMaxIconsLayout.setMargin(false);
    titleMaxIconsLayout.setSizeFull();// w ww. j  a v  a2s .c o  m
    titleMaxIconsLayout.addComponents(titleOfActionHistory, maxMinButton);
    titleMaxIconsLayout.setComponentAlignment(titleOfActionHistory, Alignment.TOP_LEFT);
    titleMaxIconsLayout.setComponentAlignment(maxMinButton, Alignment.TOP_RIGHT);
    titleMaxIconsLayout.setExpandRatio(titleOfActionHistory, 0.8f);
    titleMaxIconsLayout.setExpandRatio(maxMinButton, 0.2f);

    // Note: here the only purpose of adding drop hints to the layout is to
    // maintain consistent
    // height for all widgets headers.
    addComponent(titleMaxIconsLayout);
    setComponentAlignment(titleMaxIconsLayout, Alignment.TOP_LEFT);
    setWidth(100, Unit.PERCENTAGE);
    setImmediate(true);
    addStyleName("action-history-header");
    addStyleName("bordered-layout");
    addStyleName("no-border-bottom");
}

From source file:org.eclipse.hawkbit.ui.management.targettable.TargetBulkUpdateWindowLayout.java

License:Open Source License

private void buildLayout() {
    mainLayout = new VerticalLayout();
    mainLayout.setSpacing(Boolean.TRUE);
    mainLayout.setSizeUndefined();/*from www.j a  va  2s.c o  m*/
    mainLayout.setWidth("200px");

    final HorizontalLayout captionLayout = new HorizontalLayout();
    captionLayout.setSizeFull();
    captionLayout.addComponents(windowCaption, minimizeButton, closeButton);
    captionLayout.setExpandRatio(windowCaption, 1.0F);
    captionLayout.addStyleName("v-window-header");

    final HorizontalLayout uploaderLayout = new HorizontalLayout();
    uploaderLayout.addComponent(bulkUploader);
    uploaderLayout.addComponent(linkToSystemConfigHelp);
    uploaderLayout.setComponentAlignment(linkToSystemConfigHelp, Alignment.BOTTOM_RIGHT);
    uploaderLayout.setExpandRatio(bulkUploader, 1.0F);
    uploaderLayout.setSizeFull();
    mainLayout.addComponents(captionLayout, dsNamecomboBox, descTextArea, tokenVerticalLayout, descTextArea,
            progressBar, targetsCountLabel, uploaderLayout);
}

From source file:org.eclipse.hawkbit.ui.rollout.rollout.AddUpdateRolloutWindowLayout.java

License:Open Source License

private HorizontalLayout createApprovalLayout() {
    approveButtonsGroup = new OptionGroup();
    approveButtonsGroup.setId(UIComponentIdProvider.ROLLOUT_APPROVAL_OPTIONGROUP_ID);
    approveButtonsGroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
    approveButtonsGroup.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
    approveButtonsGroup.addStyleName("custom-option-group");
    approveButtonsGroup.addItems(Rollout.ApprovalDecision.APPROVED, Rollout.ApprovalDecision.DENIED);

    approveButtonsGroup.setItemCaption(Rollout.ApprovalDecision.APPROVED,
            i18n.getMessage(APPROVAL_BUTTON_LABEL));
    approveButtonsGroup.setItemIcon(Rollout.ApprovalDecision.APPROVED, FontAwesome.CHECK);
    approveButtonsGroup.setItemCaption(Rollout.ApprovalDecision.DENIED, i18n.getMessage(DENY_BUTTON_LABEL));
    approveButtonsGroup.setItemIcon(Rollout.ApprovalDecision.DENIED, FontAwesome.TIMES);

    approvalRemarkField = createTextField("label.approval.remark",
            UIComponentIdProvider.ROLLOUT_APPROVAL_REMARK_FIELD_ID, Rollout.APPROVAL_REMARK_MAX_SIZE);
    approvalRemarkField.setWidth(100.0F, Unit.PERCENTAGE);

    final HorizontalLayout layout = new HorizontalLayout(approveButtonsGroup, approvalRemarkField);
    layout.setWidth(100.0F, Unit.PERCENTAGE);
    layout.setExpandRatio(approvalRemarkField, 1.0F);
    return layout;
}

From source file:org.eclipse.hawkbit.ui.tenantconfiguration.authentication.CertificateAuthenticationConfigurationItem.java

License:Open Source License

public CertificateAuthenticationConfigurationItem(
        final TenantConfigurationManagement tenantConfigurationManagement, final VaadinMessageSource i18n) {
    super(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED, tenantConfigurationManagement, i18n);

    super.init("label.configuration.auth.header");
    configurationEnabled = isConfigEnabled();

    detailLayout = new VerticalLayout();
    detailLayout.setImmediate(true);/* www .ja v  a  2  s  .co m*/

    final HorizontalLayout caRootAuthorityLayout = new HorizontalLayout();
    caRootAuthorityLayout.setSpacing(true);

    final Label caRootAuthorityLabel = new LabelBuilder().name("SSL Issuer Hash:").buildLabel();
    caRootAuthorityLabel.setDescription(
            "The SSL Issuer iRules.X509 hash, to validate against the controller request certifcate.");
    caRootAuthorityLabel.setWidthUndefined();

    caRootAuthorityTextField = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent();
    caRootAuthorityTextField.setWidth("100%");
    caRootAuthorityTextField.addTextChangeListener(event -> caRootAuthorityChanged());

    caRootAuthorityLayout.addComponent(caRootAuthorityLabel);
    caRootAuthorityLayout.setExpandRatio(caRootAuthorityLabel, 0);
    caRootAuthorityLayout.addComponent(caRootAuthorityTextField);
    caRootAuthorityLayout.setExpandRatio(caRootAuthorityTextField, 1);
    caRootAuthorityLayout.setWidth("100%");

    detailLayout.addComponent(caRootAuthorityLayout);

    if (isConfigEnabled()) {
        caRootAuthorityTextField.setValue(getCaRootAuthorityValue());
        setDetailVisible(true);
    }
}

From source file:org.eclipse.skalli.view.component.PeopleSearchWindow.java

License:Open Source License

private void createContents() {
    setModal(true);/*  ww w  . java2  s  .c  om*/
    setCaption("Search people...");

    setWidth("310px"); //$NON-NLS-1$
    setHeight("400px"); //$NON-NLS-1$

    root = new VerticalLayout();
    root.setMargin(true);
    root.setSpacing(true);

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

    searchField = new TextField("Search for:");
    searchField.setWidth("20em"); //$NON-NLS-1$
    searchField.setImmediate(true);
    searchField.addListener(new ValueChangeListener() {
        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            search((String) searchField.getValue());
            list.focus();
        }
    });
    search.addComponent(searchField);
    search.setComponentAlignment(searchField, Alignment.BOTTOM_LEFT);
    search.setExpandRatio(searchField, 1.0f);

    Button searchButton = new NativeButton("", new Button.ClickListener() { //$NON-NLS-1$
        @Override
        public void buttonClick(ClickEvent event) {
            search((String) searchField.getValue());
        }
    });
    searchButton.setDescription("Search");
    searchButton.setStyleName(STYLE_USER_DOSEARCH);
    search.addComponent(searchButton);
    search.setComponentAlignment(searchButton, Alignment.BOTTOM_LEFT);
    search.setExpandRatio(searchButton, 0);

    root.addComponent(search);

    list = new ListSelect("Search results:", dataSource);
    list.setSizeFull();
    list.setMultiSelect(true);
    list.setImmediate(true);

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

    Button addButton = new Button("Add");
    addButton.setIcon(ICON_BUTTON_ADD_SELECTED);
    addButton.setDescription("Adds the selected person to the list.");
    addButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Set<User> values = (Set<User>) list.getValue();
            if (selectHandler != null && values != null) {
                selectHandler.onPeopleSelected(values);
                list.removeAllItems();
                searchField.setValue(""); //$NON-NLS-1$
                searchField.focus();
            }
        }
    });
    buttons.addComponent(addButton);

    Button addAndCloseButton = new Button("Add & Close");
    addAndCloseButton.setIcon(ICON_BUTTON_ADD_SELECTED);
    addAndCloseButton.setDescription("Adds the selected person to the list and closes the dialog.");
    addAndCloseButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Set<User> values = (Set<User>) list.getValue();
            if (selectHandler != null && values != null) {
                selectHandler.onPeopleSelected(values);
                close();
            }
        }
    });
    buttons.addComponent(addAndCloseButton);

    root.addComponent(list);
    root.addComponent(buttons);
    root.setSizeFull();
    root.setExpandRatio(list, 1);
    //    root.setStyleName(STYLE_LAYOUT);
    setContent(root);
    searchField.focus();
}