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: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);//  ww w.j  a v a2  s .c  om
    layout.setMargin(new MarginInfo(false, false, false, true));

    setCompositionRoot(layout);

    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.jain.addon.action.confirm.ConfirmWindow.java

License:Apache License

@JNIComponentInit
public void init() {
    setModal(true);//www .  j a  va2s . c om
    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.web.layout.JainLayout.java

License:Apache License

/**
 * Add a column with column span for current component 
 * @param @link Component}/*from w  w  w .j a  v  a 2  s .  co m*/
 * @param colSpan
 */
public void addComponent(Component component, int colSpan) {
    HorizontalLayout hLayout = getHLayout(colSpan);
    hLayout.addComponent(component);
    hLayout.setExpandRatio(component, 1.0f);
}

From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.DynQueueMemberManagement.java

/** 
 * ?(?????)/*  w  ww  .ja  v  a2  s.c o  m*/
 * @return HorizontalLayout
 */
private HorizontalLayout createCenterHLayout() {
    HorizontalLayout centerHLayout = new HorizontalLayout();
    centerHLayout.setSpacing(true);
    centerHLayout.setWidth("100%");

    // ?(??)
    VerticalLayout leftComponents = createLeftComponents();
    centerHLayout.addComponent(leftComponents);
    centerHLayout.setExpandRatio(leftComponents, 0.4f);

    // ??("?")
    VerticalLayout middleComponents = createMiddleComponents();
    centerHLayout.addComponent(middleComponents);
    centerHLayout.setComponentAlignment(middleComponents, Alignment.MIDDLE_CENTER);
    centerHLayout.setExpandRatio(middleComponents, 0.2f);

    // ??(????)
    VerticalLayout rightComponents = createRightComponents();
    centerHLayout.addComponent(rightComponents);
    centerHLayout.setExpandRatio(rightComponents, 0.4f);

    return centerHLayout;
}

From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.MgrPhone2PhoneSettingView.java

/**
 *  ????/* w  w w.ja  va  2s .co m*/
 * @param panelContent
 */
private void createCsrSelectTables(VerticalLayout panelContent) {
    csrSelectHLayout = new HorizontalLayout();
    csrSelectHLayout.setSpacing(true);
    csrSelectHLayout.setVisible(false);
    csrSelectHLayout.setWidth("100%");
    panelContent.addComponent(csrSelectHLayout);

    Label caption = new Label("");
    caption.setWidth("-1px");
    caption.setDescription("<B>??</B>");
    csrSelectHLayout.addComponent(caption);

    // ???
    HorizontalLayout panelLayout = new HorizontalLayout();
    panelLayout.setSpacing(true);
    panelLayout.setMargin(false, true, false, true);
    panelLayout.setWidth("100%");

    Panel tablePanel = new Panel();
    tablePanel.setContent(panelLayout);
    csrSelectHLayout.addComponent(tablePanel);
    csrSelectHLayout.setExpandRatio(tablePanel, 1.0f);

    // (??)
    VerticalLayout leftComponents = createLeftComponents();
    panelLayout.addComponent(leftComponents);
    panelLayout.setExpandRatio(leftComponents, 0.4f);

    // ??("?")
    VerticalLayout middleComponents = createMiddleComponents();
    panelLayout.addComponent(middleComponents);
    panelLayout.setComponentAlignment(middleComponents, Alignment.MIDDLE_CENTER);
    panelLayout.setExpandRatio(middleComponents, 0.2f);

    // ?(????)
    VerticalLayout rightComponents = createRightComponents();
    panelLayout.addComponent(rightComponents);
    panelLayout.setExpandRatio(rightComponents, 0.4f);
}

From source file:com.klwork.explorer.ui.business.flow.act.MyTaskRelatedContentComponent.java

License:Apache License

protected void initActions() {
    // WW_TODO ?//from  w w  w .ja  v a  2s .c  om
    HorizontalLayout actionsContainer = new HorizontalLayout();
    actionsContainer.setSizeFull();

    Label processTitle = new Label(relatedContentTitle);
    processTitle.addStyleName(ExplorerLayout.STYLE_H3);
    processTitle.setSizeFull();
    actionsContainer.addComponent(processTitle);
    actionsContainer.setComponentAlignment(processTitle, Alignment.MIDDLE_LEFT);
    actionsContainer.setExpandRatio(processTitle, 1.0f);
    actionsContainer.setComponentAlignment(processTitle, Alignment.MIDDLE_RIGHT);
    //?
    if (!readOnly) {
        Button addRelatedContentButton = getAddButton();
        actionsContainer.addComponent(addRelatedContentButton);
    }

    addComponent(actionsContainer);
}

From source file:com.klwork.explorer.ui.form.FormPropertiesForm.java

License:Apache License

protected void initButtons() {
    submitFormButton = new Button();
    cancelFormButton = new Button();

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);/*w w w  .  j  av  a  2 s  . co m*/
    buttons.setWidth(100, Unit.PERCENTAGE);
    buttons.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    buttons.addComponent(submitFormButton);
    buttons.setComponentAlignment(submitFormButton, Alignment.BOTTOM_RIGHT);

    buttons.addComponent(cancelFormButton);
    buttons.setComponentAlignment(cancelFormButton, Alignment.BOTTOM_RIGHT);

    Label buttonSpacer = new Label();
    buttons.addComponent(buttonSpacer);
    buttons.setExpandRatio(buttonSpacer, 1.0f);
    addComponent(buttons);
}

From source file:com.klwork.explorer.ui.task.ProcessInstanceEventsPanel.java

License:Apache License

public void initAddEventInput(HorizontalLayout hLayout) {
    Panel textFieldPanel = new Panel(); // Hack: actionHandlers can only be
    // attached to panels or windows
    textFieldPanel.addStyleName(Reindeer.PANEL_LIGHT);
    VerticalLayout textFieldPanelLayout = new VerticalLayout();
    textFieldPanel.setContent(textFieldPanelLayout);

    textFieldPanel.setWidth(100, Unit.PERCENTAGE);
    hLayout.addComponent(textFieldPanel);
    hLayout.setExpandRatio(textFieldPanel, 1.0f);

    commentInputField = new TextField();
    commentInputField.setWidth(100, Unit.PERCENTAGE);
    textFieldPanelLayout.addComponent(commentInputField);

    // Hack to catch keyboard 'enter'
    textFieldPanel.addActionHandler(new Handler() {
        public void handleAction(Action action, Object sender, Object target) {
            addNewComment(commentInputField.getValue().toString());
        }//  www  . ja  v  a  2  s  . c  om

        public Action[] getActions(Object target, Object sender) {
            return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null) };
        }
    });
}

From source file:com.klwork.explorer.ui.task.SubTaskComponent.java

License:Apache License

protected void initTitle(HorizontalLayout headerLayout) {
    title = new Label(i18nManager.getMessage(Messages.TASK_SUBTASKS));
    title.addStyleName(ExplorerLayout.STYLE_H3);
    title.setWidth(100, UNITS_PERCENTAGE);
    headerLayout.addComponent(title);// ww  w .ja va 2 s  . c o m
    headerLayout.setExpandRatio(title, 1.0f);
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initDescription(HorizontalLayout layout) {
    final CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(descriptionLayout);
    layout.setExpandRatio(descriptionLayout, 1.0f);
    layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT);

    String descriptionText = null;
    if (task.getDescription() != null && !"".equals(task.getDescription())) {
        descriptionText = task.getDescription();
    } else {//??
        descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION);
    }//from w w  w . j  a v  a2s.  c  o m
    final Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    descriptionLayout.addComponent(descriptionLabel);

    descriptionLayout.addLayoutClickListener(new LayoutClickListener() {
        public void layoutClick(LayoutClickEvent event) {
            if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) {
                // layout for textarea + ok button
                final VerticalLayout editLayout = new VerticalLayout();
                editLayout.setSpacing(true);

                // textarea
                final TextArea descriptionTextArea = new TextArea();
                //
                descriptionTextArea.setNullRepresentation("");
                descriptionTextArea.setWidth(100, Unit.PERCENTAGE);
                descriptionTextArea.setValue(task.getDescription());
                editLayout.addComponent(descriptionTextArea);

                // ok button
                Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                editLayout.addComponent(okButton);
                editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);

                // replace
                descriptionLayout.replaceComponent(descriptionLabel, editLayout);

                // When OK is clicked -> update task data + ui
                okButton.addClickListener(new ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        // Update data
                        task.setDescription(descriptionTextArea.getValue().toString());
                        taskService.saveTask(task);

                        // Update UI
                        descriptionLabel.setValue(task.getDescription());
                        descriptionLayout.replaceComponent(editLayout, descriptionLabel);
                    }
                });
            }
        }
    });
}