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.skalli.view.component.Tray.java

License:Open Source License

private ComponentContainer createContent(String caption, String description, ThemeResource icon,
        boolean isRequired) {
    CssLayout layout = new CssLayout();
    layout.setStyleName(STYLE_TRAY);/*from  w  w w. j  a  va2s  .c o m*/
    layout.setMargin(true);

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);
    header.setStyleName(STYLE_TRAY_HEADER);
    header.setWidth("100%");

    this.icon = icon;
    trayIcon = new Embedded(null, icon);
    trayIcon.setStyleName(STYLE_TRAY_HEADER_ICON);
    header.addComponent(trayIcon);
    header.setComponentAlignment(trayIcon, Alignment.MIDDLE_LEFT);
    header.setExpandRatio(trayIcon, 0);

    Label captionLabel = new Label(StringEscapeUtils.escapeHtml(caption), Label.CONTENT_XHTML);
    captionLabel.setStyleName(STYLE_TRAY_HEADER_LABEL);
    header.addComponent(captionLabel);
    header.setExpandRatio(captionLabel, 1);
    header.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT);

    this.isRequired = isRequired;
    if (!isRequired) {
        activator = new NativeButton("", new ToggleEnabledListener());
        header.addComponent(activator);
        header.setExpandRatio(activator, 0);
        header.setComponentAlignment(activator, Alignment.MIDDLE_RIGHT);
    }

    opener = new NativeButton("", new ToggleVisibleListener());
    header.addComponent(opener);
    header.setExpandRatio(opener, 0);
    header.setComponentAlignment(opener, Alignment.MIDDLE_RIGHT);

    layout.addComponent(header);

    CssLayout content = new CssLayout();
    Label descriptionLabel = new Label(HtmlUtils.clean(description), Label.CONTENT_XHTML);
    descriptionLabel.setStyleName(STYLE_TRAY_DESCRIPTION);
    content.addComponent(descriptionLabel);

    layout.addComponent(content);
    setCompositionRoot(layout);
    return content;
}

From source file:org.eclipse.skalli.view.internal.window.ProjectEditPanelEntry.java

License:Open Source License

@SuppressWarnings("serial")
private ComponentContainer createTray() {
    CssLayout layout = new CssLayout();
    layout.setStyleName(STYLE_TRAY);//from  www.  jav a 2 s.c om
    layout.setMargin(true);

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);
    header.setStyleName(STYLE_TRAY_HEADER);
    header.setWidth("100%"); //$NON-NLS-1$

    trayIcon = new Embedded();
    trayIcon.setStyleName(STYLE_TRAY_HEADER_ICON);

    final String icon = formService.getIconPath();
    if (StringUtils.isNotBlank(icon)) {
        trayIcon.setSource(new StreamResource(new ExtensionStreamSource(formService.getClass(), icon),
                FilenameUtils.getName(icon), application));
    }
    header.addComponent(trayIcon);
    header.setComponentAlignment(trayIcon, Alignment.MIDDLE_LEFT);
    header.setExpandRatio(trayIcon, 0);

    Label captionLabel = new Label(getCaptionWithAnchor(), Label.CONTENT_XHTML);
    captionLabel.setStyleName(STYLE_TRAY_HEADER_LABEL);
    header.addComponent(captionLabel);
    header.setExpandRatio(captionLabel, 1);
    header.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT);

    editButton = new Button();
    layoutLinkButton(editButton, header, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            switch (state) {
            case DISABLED:
                setState(TrayState.EDITABLE_VISIBLE);
                break;
            case INHERITED_VISIBLE:
                setState(TrayState.EDITABLE_VISIBLE);
                break;
            case INHERITED_INVISIBLE:
                setState(TrayState.EDITABLE_VISIBLE);
                break;
            }
        }
    });

    inheritButton = new Button();
    layoutLinkButton(inheritButton, header, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            form.commit();
            switch (state) {
            case DISABLED:
                setState(TrayState.INHERITED_VISIBLE);
                break;
            case EDITABLE_VISIBLE:
                setState(TrayState.INHERITED_VISIBLE);
                break;
            case EDITABLE_INVISIBLE:
                setState(TrayState.INHERITED_VISIBLE);
                break;
            }
        }
    });

    disableButton = new Button();
    layoutLinkButton(disableButton, header, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            form.commit();
            switch (state) {
            case EDITABLE_INVISIBLE:
                setState(TrayState.DISABLED);
                break;
            case EDITABLE_VISIBLE:
                setState(TrayState.DISABLED);
                break;
            case INHERITED_INVISIBLE:
                setState(TrayState.DISABLED);
                break;
            case INHERITED_VISIBLE:
                setState(TrayState.DISABLED);
                break;
            }
        }
    });

    visibleButton = new NativeButton();
    layoutIconButton(visibleButton, header, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            switch (state) {
            case EDITABLE_INVISIBLE:
                setState(TrayState.EDITABLE_VISIBLE);
                break;
            case EDITABLE_VISIBLE:
                setState(TrayState.EDITABLE_INVISIBLE);
                break;
            case INHERITED_INVISIBLE:
                setState(TrayState.INHERITED_VISIBLE);
                break;
            case INHERITED_VISIBLE:
                setState(TrayState.INHERITED_INVISIBLE);
                break;
            }
        }
    });

    layout.addComponent(header);

    CssLayout content = new CssLayout();
    Label descriptionLabel = new Label(extensionService.getDescription(), Label.CONTENT_XHTML);
    descriptionLabel.setStyleName(STYLE_TRAY_DESCRIPTION);
    content.addComponent(descriptionLabel);

    layout.addComponent(content);
    return layout;
}

From source file:org.eclipse.skalli.view.internal.window.ProjectEditPanelEntry.java

License:Open Source License

@SuppressWarnings("deprecation")
private void layoutLinkButton(Button button, HorizontalLayout layout, ClickListener listener) {
    button.setStyle(Button.STYLE_LINK);
    button.addListener(listener);/*from   www  .j  av a  2 s.  co  m*/
    layout.addComponent(button);
    layout.setExpandRatio(button, 0);
    layout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);
}

From source file:org.eclipse.skalli.view.internal.window.ProjectEditPanelEntry.java

License:Open Source License

private void layoutIconButton(Button button, HorizontalLayout layout, ClickListener listener) {
    button.addListener(listener);/*w  w w  .jav a2s. c  o  m*/
    layout.addComponent(button);
    layout.setExpandRatio(button, 0);
    layout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);
}

From source file:org.escidoc.browser.controller.ContentModelView.java

License:Open Source License

private HorizontalLayout buildHlMetaViews() {
    // common part: create layout
    HorizontalLayout hlMetaViews = new HorizontalLayout();
    hlMetaViews.setImmediate(false);//ww w .j  a  v  a 2s .  c  o m
    hlMetaViews.setWidth("100.0%");
    hlMetaViews.setHeight("100.0%");
    hlMetaViews.setMargin(false);

    // leftPanel
    Panel leftPanel = buildLeftPanel();
    hlMetaViews.addComponent(leftPanel);
    hlMetaViews.setExpandRatio(leftPanel, 4.5f);

    // rightPanel
    Panel rightPanel = buildRightPanel();
    hlMetaViews.addComponent(rightPanel);
    hlMetaViews.setExpandRatio(rightPanel, 5.5f);

    return hlMetaViews;
}

From source file:org.escidoc.browser.controller.ContentModelView.java

License:Open Source License

private HorizontalLayout bindProperties() {
    HorizontalLayout hlProperties = new HorizontalLayout();
    hlProperties.setWidth("100%");
    VerticalLayout vlLeft = new VerticalLayout();
    VerticalLayout vlRight = new VerticalLayout();
    final Label descMetadata1 = new Label("ID: " + resourceProxy.getId());

    vlLeft.addComponent(descMetadata1);/*from   ww w . ja  v  a2 s  .  co m*/

    // RIGHT SIDE
    final Label descMetadata2 = new Label(ViewConstants.CREATED_BY + " " + resourceProxy.getCreator() + " on "
            + resourceProxy.getCreatedOn() + "<br/>", Label.CONTENT_XHTML);

    descMetadata2.setStyleName("floatright columnheight50");
    descMetadata2.setWidth("65%");
    vlRight.addComponent(descMetadata2);

    hlProperties.addComponent(vlLeft);
    hlProperties.setExpandRatio(vlLeft, 0.4f);
    hlProperties.addComponent(vlRight);
    hlProperties.setExpandRatio(vlRight, 0.6f);
    return hlProperties;
}

From source file:org.escidoc.browser.ui.maincontent.ContainerView.java

License:Open Source License

private HorizontalLayout buildHlMetaViews() throws EscidocClientException {
    // common part: create layout
    HorizontalLayout hlMetaViews = new HorizontalLayout();
    hlMetaViews.setImmediate(false);/*ww w.ja v  a 2s . co m*/
    hlMetaViews.setWidth("100.0%");
    hlMetaViews.setHeight("100.0%");
    hlMetaViews.setMargin(false);

    // leftPanel
    Panel leftPanel = buildLeftPanel();
    hlMetaViews.addComponent(leftPanel);
    hlMetaViews.setExpandRatio(leftPanel, 4.5f);

    // rightPanel
    Panel rightPanel = buildRightPanel();
    hlMetaViews.addComponent(rightPanel);
    hlMetaViews.setExpandRatio(rightPanel, 5.5f);

    return hlMetaViews;
}

From source file:org.escidoc.browser.ui.maincontent.ContextView.java

License:Open Source License

/**
 * Binding Context Properties 2 sets of labels in 2 rows
 * //from ww  w . ja  v a 2s  . co m
 * @return
 */
private HorizontalLayout bindProperties() {
    HorizontalLayout hlProperties = new HorizontalLayout();
    hlProperties.setWidth("100%");
    vlLeft = new VerticalLayout();
    VerticalLayout vlRight = new VerticalLayout();
    final Label descMetadata1 = new Label("ID: " + resourceProxy.getId());
    lblType = new Label(ViewConstants.CONTEXT_TYPE + resourceProxy.getPropertiesType(), Label.CONTENT_RAW);
    lblType.setDescription(ViewConstants.CONTEXT_TYPE);
    lblStatus = new Label(resourceProxy.getType().getLabel() + " is " + resourceProxy.getStatus(),
            Label.CONTENT_RAW);
    lblStatus.setDescription(ViewConstants.DESC_STATUS);

    vlLeft.addComponent(descMetadata1);
    vlLeft.addComponent(lblType);
    vlLeft.addComponent(lblStatus);

    // RIGHT SIDE
    vlRight.addComponent(ViewHelper.buildCreateAndModifyLabel(resourceProxy));

    hlProperties.addComponent(vlLeft);
    hlProperties.setExpandRatio(vlLeft, 0.4f);
    hlProperties.addComponent(vlRight);
    hlProperties.setExpandRatio(vlRight, 0.6f);
    return hlProperties;
}

From source file:org.escidoc.browser.ui.maincontent.FolderView.java

License:Open Source License

/**
 * Binding Context Properties 2 sets of labels in 2 rows
 * /*from   w  ww. j a  va2s . co  m*/
 * @return
 */
private HorizontalLayout bindProperties() {
    HorizontalLayout hlProperties = new HorizontalLayout();
    hlProperties.setWidth("100%");
    vlLeft = new VerticalLayout();
    VerticalLayout vlRight = new VerticalLayout();
    final Label descMetadata1 = new Label("ID: " + resourceProxy.getId());
    status = resourceProxy.getType().getLabel() + " is ";
    lblStatus = new Label(status + resourceProxy.getStatus(), Label.CONTENT_RAW);
    lblStatus.setDescription(ViewConstants.DESC_STATUS);
    vlLeft.addComponent(descMetadata1);
    if (folderController.hasAccess()) {
        status = "Latest status is ";
        lblCurrentVersionStatus = new Label(status + resourceProxy.getVersionStatus());
        lblCurrentVersionStatus.setDescription(ViewConstants.DESC_STATUS);
        lblCurrentVersionStatus.setStyleName("inset");
        vlLeft.addComponent(lblCurrentVersionStatus);

    } else {
        vlLeft.addComponent(lblStatus);
    }

    // RIGHT SIDE
    vlRight.addComponent(ViewHelper.buildCreateAndModifyLabel(resourceProxy));

    hlProperties.addComponent(vlLeft);
    hlProperties.setExpandRatio(vlLeft, 0.4f);
    hlProperties.addComponent(vlRight);
    hlProperties.setExpandRatio(vlRight, 0.6f);
    return hlProperties;
}

From source file:org.escidoc.browser.ui.maincontent.ItemView.java

License:Open Source License

private HorizontalLayout buildHlMetaViews() {
    // common part: create layout
    HorizontalLayout hlMetaViews = new HorizontalLayout();
    hlMetaViews.setImmediate(false);/* w  w  w  . ja  va2s  .  co m*/
    hlMetaViews.setWidth("100.0%");
    hlMetaViews.setHeight("100.0%");
    hlMetaViews.setMargin(false);

    // leftPanel
    Panel leftPanel = buildLeftPanel();
    hlMetaViews.addComponent(leftPanel);
    hlMetaViews.setExpandRatio(leftPanel, 0.7f);

    // rightPanel
    Panel rightPanel = buildRightPanel();
    hlMetaViews.addComponent(rightPanel);
    hlMetaViews.setExpandRatio(rightPanel, 0.3f);

    return hlMetaViews;
}