Example usage for com.vaadin.ui GridLayout setRowExpandRatio

List of usage examples for com.vaadin.ui GridLayout setRowExpandRatio

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setRowExpandRatio.

Prototype

public void setRowExpandRatio(int rowIndex, float ratio) 

Source Link

Document

Sets the expand ratio of given row.

Usage

From source file:org.vaadin.addons.sitekit.viewlet.administrator.user.UserFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout layout = new GridLayout(2, 3);
    layout.setSizeFull();// w w w  .  j  a v  a2  s.c o  m
    layout.setMargin(false);
    layout.setSpacing(true);
    layout.setRowExpandRatio(1, 1f);
    layout.setColumnExpandRatio(1, 1f);
    setViewContent(layout);

    editor = new ValidatingEditor(SiteFields.getFieldDescriptors(User.class));
    editor.setCaption("User");
    editor.addListener((ValidatingEditorStateListener) this);
    editor.setWidth("380px");
    layout.addComponent(editor, 0, 1);

    final List<FieldDescriptor> childFieldDescriptors = SiteFields.getFieldDescriptors(GroupMember.class);
    final List<FilterDescriptor> childFilterDescriptors = new ArrayList<FilterDescriptor>();
    childContainer = new EntityContainer<GroupMember>(entityManager, GroupMember.class, "groupMemberId", 1000,
            true, false, false);
    childContainer.getQueryView().getQueryDefinition().setDefaultSortState(
            new String[] { "user.firstName", "user.lastName" }, new boolean[] { true, true });

    ContainerUtil.addContainerProperties(childContainer, childFieldDescriptors);

    final Table childTable = new FormattingTable();
    childGrid = new Grid(childTable, childContainer);
    childGrid.setFields(childFieldDescriptors);
    childGrid.setFilters(childFilterDescriptors);

    childTable.setColumnCollapsed("created", true);

    layout.addComponent(childGrid, 1, 1);

    final HorizontalLayout editorButtonLayout = new HorizontalLayout();
    editorButtonLayout.setSpacing(true);
    layout.addComponent(editorButtonLayout, 0, 2);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    editorButtonLayout.addComponent(saveButton);
    saveButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            editor.commit();
            entityManager.getTransaction().begin();
            try {

                if (user.getPasswordHash() != null) {
                    final int hashSize = 64;
                    if (user.getPasswordHash().length() != hashSize) {
                        final byte[] passwordAndSaltBytes = (user.getEmailAddress() + ":"
                                + user.getPasswordHash()).getBytes(Charset.forName("UTF-8"));
                        try {
                            final MessageDigest md = MessageDigest.getInstance("SHA-256");
                            final byte[] passwordAndSaltDigest = md.digest(passwordAndSaltBytes);
                            user.setPasswordHash(StringUtil.toHexString(passwordAndSaltDigest));
                        } catch (NoSuchAlgorithmException e) {
                            e.printStackTrace();
                        }
                    }
                }
                // UserLogic.updateUser(user,
                // UserDao.getGroupMembers(entityManager, user));
                user = entityManager.merge(user);
                entityManager.persist(user);
                entityManager.getTransaction().commit();
                editor.setItem(new BeanItem<User>(user), false);
                //entityManager.detach(user);
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + user, t);
            }
        }
    });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    editorButtonLayout.addComponent(discardButton);
    discardButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            editor.discard();
        }
    });

    childListButtonLayout = new HorizontalLayout();
    childListButtonLayout.setSpacing(true);
    childListButtonLayout.setSizeUndefined();
    layout.addComponent(childListButtonLayout, 1, 0);

    final Button addButton = getSite().getButton("add");
    childListButtonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final GroupMember userElement = new GroupMember();
            userElement.setUser(user);
            userElement.setCreated(new Date());
            final UserGroupMemberFlowlet userGroupMemberFlowlet = getFlow()
                    .forward(UserGroupMemberFlowlet.class);
            userGroupMemberFlowlet.edit(userElement, true);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    childListButtonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            childContainer.removeItem(childGrid.getSelectedItemId());
            childContainer.commit();
        }
    });

}

From source file:org.vaadin.addons.sitekit.viewlet.administrator.user.UserGroupMemberFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();//from   www .j av  a 2 s .co m
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    final List<FieldDescriptor> fieldDescriptors = new ArrayList<FieldDescriptor>(
            SiteFields.getFieldDescriptors(GroupMember.class));

    for (final FieldDescriptor fieldDescriptor : fieldDescriptors) {
        if ("user".equals(fieldDescriptor.getId())) {
            fieldDescriptors.remove(fieldDescriptor);
            break;
        }
    }

    groupMemberEditor = new ValidatingEditor(fieldDescriptors);
    groupMemberEditor.setCaption("GroupMember");
    groupMemberEditor.addListener(this);
    gridLayout.addComponent(groupMemberEditor, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 1);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    buttonLayout.addComponent(saveButton);
    saveButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            groupMemberEditor.commit();

            entityManager.getTransaction().begin();
            try {
                entity = entityManager.merge(entity);
                entityManager.persist(entity);
                entityManager.getTransaction().commit();
                //entityManager.detach(entity);
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + entity, t);
            }
        }
    });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    buttonLayout.addComponent(discardButton);
    discardButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            groupMemberEditor.discard();
        }
    });

}

From source file:org.vaadin.addons.sitekit.viewlet.administrator.user.UsersFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = SiteFields.getFieldDescriptors(User.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new EntityContainer<User>(entityManager, true, false, false, User.class, 1000,
            new String[] { "lastName", "firstName" }, new boolean[] { true, true }, "userId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/*from ww  w.  ja  va  2 s .  co  m*/
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("passwordHash", true);
    table.setColumnCollapsed("openIdIdentifier", true);
    gridLayout.addComponent(grid, 0, 1);

    final Button addButton = getSite().getButton("add");
    buttonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User user = new User();
            user.setCreated(new Date());
            user.setModified(user.getCreated());
            user.setOwner((Company) getSite().getSiteContext().getObject(Company.class));

            final UserFlowlet userView = getFlow().getFlowlet(UserFlowlet.class);
            userView.edit(user, true);
            getFlow().forward(UserFlowlet.class);
        }
    });

    final Button editButton = getSite().getButton("edit");
    buttonLayout.addComponent(editButton);
    editButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User entity = container.getEntity(grid.getSelectedItemId());
            final UserFlowlet userView = getFlow().getFlowlet(UserFlowlet.class);
            userView.edit(entity, false);
            getFlow().forward(UserFlowlet.class);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    buttonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User entity = container.getEntity(grid.getSelectedItemId());

            final List<Group> groups = UserDao.getUserGroups(entityManager,
                    (Company) getSite().getSiteContext().getObject(Company.class), entity);

            for (final Group group : groups) {
                UserDao.removeGroupMember(entityManager, group, entity);
            }

            final List<Privilege> privileges = UserDao.getUserPrivileges(entityManager, entity);
            for (final Privilege privilege : privileges) {
                UserDao.removeUserPrivilege(entityManager, entity, privilege.getKey(), privilege.getDataId());
            }

            container.removeItem(grid.getSelectedItemId());
            container.commit();
        }
    });

    final Button lockButton = getSite().getButton("lock");
    lockButton.setImmediate(true);
    buttonLayout.addComponent(lockButton);
    lockButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User user = container.getEntity(grid.getSelectedItemId());
            user.setLockedOut(true);
            UserDao.updateUser(entityManager, entityManager.merge(user));
            container.refresh();
        }
    });

    final Button unlockButton = getSite().getButton("unlock");
    unlockButton.setImmediate(true);
    buttonLayout.addComponent(unlockButton);
    unlockButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User user = container.getEntity(grid.getSelectedItemId());
            user.setLockedOut(false);
            user.setFailedLoginCount(0);
            UserDao.updateUser(entityManager, entityManager.merge(user));
            container.refresh();
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
    grid.refresh();
}

From source file:org.vaadin.addons.sitekit.viewlet.user.AccountFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDefinitions = SiteFields.getFieldDescriptors(Customer.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();
    filterDefinitions.add(new FilterDescriptor("companyName", "companyName", "Company Name", new TextField(),
            101, "=", String.class, ""));
    filterDefinitions.add(new FilterDescriptor("lastName", "lastName", "Last Name", new TextField(), 101, "=",
            String.class, ""));

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Customer>(entityManager, true, false, false, Customer.class, 1000,
            new String[] { "companyName", "lastName" }, new boolean[] { false, false }, "customerId");

    for (final FieldDescriptor fieldDefinition : fieldDefinitions) {
        entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(),
                fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable());
    }//from  w w w  . j  a v  a2s  .  c o m

    final GridLayout gridLayout = new GridLayout(1, 6);
    gridLayout.setRowExpandRatio(0, 0.0f);
    gridLayout.setRowExpandRatio(1, 0.0f);
    gridLayout.setRowExpandRatio(2, 0.0f);
    gridLayout.setRowExpandRatio(3, 0.0f);
    gridLayout.setRowExpandRatio(4, 0.0f);
    gridLayout.setRowExpandRatio(5, 1.0f);

    gridLayout.setSizeFull();
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(4, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout userAccountTitle = new HorizontalLayout();
    userAccountTitle.setMargin(new MarginInfo(false, false, false, false));
    userAccountTitle.setSpacing(true);
    final Embedded userAccountTitleIcon = new Embedded(null, getSite().getIcon("view-icon-user"));
    userAccountTitleIcon.setWidth(32, UNITS_PIXELS);
    userAccountTitleIcon.setHeight(32, UNITS_PIXELS);
    userAccountTitle.addComponent(userAccountTitleIcon);
    final Label userAccountTitleLabel = new Label("<h2>User Account</h2>", Label.CONTENT_XHTML);
    userAccountTitle.addComponent(userAccountTitleLabel);
    gridLayout.addComponent(userAccountTitle, 0, 0);

    final HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setMargin(new MarginInfo(true, false, false, false));
    titleLayout.setSpacing(true);
    final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-customer"));
    titleIcon.setWidth(32, UNITS_PIXELS);
    titleIcon.setHeight(32, UNITS_PIXELS);
    titleLayout.addComponent(titleIcon);
    final Label titleLabel = new Label("<h2>Customer Accounts</h2>", Label.CONTENT_XHTML);
    titleLayout.addComponent(titleLabel);
    gridLayout.addComponent(titleLayout, 0, 3);

    final Table table = new Table();
    table.setPageLength(10);
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDefinitions);
    entityGrid.setFilters(filterDefinitions);
    //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId");

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("company", true);
    gridLayout.addComponent(entityGrid, 0, 5);

    final Button editUserButton = new Button("Edit User Account");
    editUserButton.setIcon(getSite().getIcon("button-icon-edit"));
    gridLayout.addComponent(editUserButton, 0, 2);
    editUserButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User entity = ((SecurityProviderSessionImpl) getSite().getSecurityProvider())
                    .getUserFromSession();
            final UserAccountFlowlet customerView = getFlow().getFlowlet(UserAccountFlowlet.class);
            customerView.edit(entity, false);
            getFlow().forward(UserAccountFlowlet.class);
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    if (company.isOpenIdLogin()) {
        final Panel openIdPanel = new Panel();
        openIdPanel.setStyleName(Reindeer.PANEL_LIGHT);
        openIdPanel.setCaption("Choose OpenID Provider:");
        gridLayout.addComponent(openIdPanel, 0, 1);
        final HorizontalLayout openIdLayout = new HorizontalLayout();
        openIdPanel.setContent(openIdLayout);
        openIdLayout.setMargin(new MarginInfo(false, false, true, false));
        openIdLayout.setSpacing(true);
        final String returnViewName = "openidlink";
        final Map<String, String> urlIconMap = OpenIdUtil.getOpenIdProviderUrlIconMap();
        for (final String url : urlIconMap.keySet()) {
            openIdLayout.addComponent(OpenIdUtil.getLoginButton(url, urlIconMap.get(url), returnViewName));
        }
    }

    final HorizontalLayout customerButtonsLayout = new HorizontalLayout();
    gridLayout.addComponent(customerButtonsLayout, 0, 4);
    customerButtonsLayout.setMargin(false);
    customerButtonsLayout.setSpacing(true);

    final Button editCustomerDetailsButton = new Button("Edit Customer Details");
    customerButtonsLayout.addComponent(editCustomerDetailsButton);
    editCustomerDetailsButton.setEnabled(false);
    editCustomerDetailsButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerDetailsButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class);
            customerView.edit(entity, false);
        }
    });

    final Button editCustomerMembersButton = new Button("Edit Customer Members");
    customerButtonsLayout.addComponent(editCustomerMembersButton);
    editCustomerMembersButton.setEnabled(false);
    editCustomerMembersButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerMembersButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
            view.edit(entity.getMemberGroup(), false);
        }
    });

    final Button editCustomerAdminsButton = new Button("Edit Customer Admins");
    customerButtonsLayout.addComponent(editCustomerAdminsButton);
    editCustomerAdminsButton.setEnabled(false);
    editCustomerAdminsButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerAdminsButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
            view.edit(entity.getAdminGroup(), false);
        }
    });

    table.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(final Property.ValueChangeEvent event) {
            editCustomerDetailsButton.setEnabled(table.getValue() != null);
            editCustomerMembersButton.setEnabled(table.getValue() != null);
            editCustomerAdminsButton.setEnabled(table.getValue() != null);
        }
    });

}

From source file:org.vaadin.addons.sitekit.viewlet.user.UserAccountFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout layout = new GridLayout(1, 3);
    layout.setSizeFull();/*from  w  w w. j av  a2  s .  c o m*/
    layout.setMargin(false);
    layout.setSpacing(true);
    layout.setRowExpandRatio(1, 1f);
    layout.setColumnExpandRatio(1, 1f);
    setViewContent(layout);

    editor = new ValidatingEditor(SiteFields.getFieldDescriptors(User.class));
    editor.setCaption("User");
    editor.addListener((ValidatingEditorStateListener) this);
    editor.setWidth("380px");
    layout.addComponent(editor, 0, 1);

    final HorizontalLayout editorButtonLayout = new HorizontalLayout();
    editorButtonLayout.setSpacing(true);
    layout.addComponent(editorButtonLayout, 0, 2);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    editorButtonLayout.addComponent(saveButton);
    saveButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            editor.commit();
            entityManager.getTransaction().begin();
            try {

                if (user.getPasswordHash() != null) {
                    final int hashSize = 64;
                    if (user.getPasswordHash().length() != hashSize) {
                        final byte[] passwordAndSaltBytes = (user.getEmailAddress() + ":"
                                + user.getPasswordHash()).getBytes(Charset.forName("UTF-8"));
                        try {
                            final MessageDigest md = MessageDigest.getInstance("SHA-256");
                            final byte[] passwordAndSaltDigest = md.digest(passwordAndSaltBytes);
                            user.setPasswordHash(StringUtil.toHexString(passwordAndSaltDigest));
                        } catch (NoSuchAlgorithmException e) {
                            e.printStackTrace();
                        }
                    }
                }
                // UserLogic.updateUser(user,
                // UserDao.getGroupMembers(entityManager, user));
                user = entityManager.merge(user);
                entityManager.persist(user);
                entityManager.getTransaction().commit();
                editor.setItem(new BeanItem<User>(user), false);
                entityManager.detach(user);
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + user, t);
            }
        }
    });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    editorButtonLayout.addComponent(discardButton);
    discardButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            editor.discard();
        }
    });

}

From source file:uk.q3c.krail.testapp.view.GridViewBase.java

License:Apache License

@Override
protected void doBuild() {
    Label label = new Label("This is the " + this.getClass().getSimpleName());
    label.setHeight("100px");
    GridLayout grid = new GridLayout(3, 3);

    grid.addComponent(label, 1, 1);//from  w  ww . j a v a 2s . c om
    grid.setSizeFull();
    grid.setColumnExpandRatio(0, 0.33f);
    grid.setColumnExpandRatio(1, 0.33f);
    grid.setColumnExpandRatio(2, 0.33f);

    grid.setRowExpandRatio(0, 0.4f);
    grid.setRowExpandRatio(1, 0.2f);
    grid.setRowExpandRatio(2, 0.4f);

    label.setSizeFull();
    setRootComponent(grid);

}

From source file:uk.q3c.krail.testapp.view.ViewBaseGrid.java

License:Apache License

@Override
public void doBuild() {
    GridLayout grid = new GridLayout(3, 4);
    Panel topMarginPanel = new Panel();
    topMarginPanel.setHeight(topMargin + "px");
    topMarginPanel.setWidth("100%");

    grid.setSizeFull();// www .  j  av  a  2s.  co m
    grid.setColumnExpandRatio(0, 0.400f);
    grid.setColumnExpandRatio(1, 0.20f);
    grid.setColumnExpandRatio(2, 0.40f);

    grid.setRowExpandRatio(1, 0.40f);
    grid.setRowExpandRatio(2, 0.20f);
    grid.setRowExpandRatio(3, 0.40f);
    setRootComponent(grid);
}

From source file:uk.q3c.krail.testapp.view.WidgetsetView.java

License:Apache License

@Override
public void doBuild() {
    buttonPanel = new Panel();
    VerticalLayout verticalLayout = new VerticalLayout();
    buttonPanel.setContent(verticalLayout);

    setRootComponent(new GridLayout(3, 4));

    GridLayout grid = getGrid();

    grid.addComponent(buttonPanel, 1, 2);
    grid.setSizeFull();/*from  w  w w .  j av a  2s .co m*/
    grid.setColumnExpandRatio(0, 0.400f);
    grid.setColumnExpandRatio(1, 0.20f);
    grid.setColumnExpandRatio(2, 0.40f);

    grid.setRowExpandRatio(0, 0.05f);
    grid.setRowExpandRatio(1, 0.15f);
    grid.setRowExpandRatio(2, 0.4f);
    grid.setRowExpandRatio(3, 0.15f);

    spinner = new Spinner(SpinnerType.FOLDING_CUBE).large();
    verticalLayout.addComponent(spinner);

    changeSpinnerType = new Button("Change Spinner Type");
    changeSpinnerType.addClickListener(e -> spinner.setType(SpinnerType.WAVE));
    verticalLayout.addComponent(changeSpinnerType);

    stepper = new IntStepper("Stepper");
    stepper.setValue(5);
    verticalLayout.addComponent(stepper);

    infoArea = new Label();
    infoArea.setContentMode(ContentMode.HTML);
    infoArea.setSizeFull();
    infoArea.setValue("These components are used purely to ensure that the Widgetset has compiled and included "
            + "add-ons");
    grid.addComponent(infoArea, 0, 1, 1, 1);

    param1 = new Label();
    param2 = new Label();
    VerticalLayout parameters = new VerticalLayout(param1, param2);
    grid.addComponent(parameters, 0, 2, 0, 2);
}