Example usage for com.vaadin.ui HorizontalLayout setSizeUndefined

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

Introduction

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

Prototype

@Override
    public void setSizeUndefined() 

Source Link

Usage

From source file:org.balisunrise.vaadin.components.header.Header.java

private void init() {
    setStyleName("b-header");
    setHeight("41px");
    setWidth("100%");

    // parte da esquerda
    HorizontalLayout leftPart = new HorizontalLayout();
    leftPart.setSizeUndefined();
    leftPart.setHeight("100%");
    addComponent(leftPart);/*w  w  w.j  a  v  a2s.  c  om*/

    programName = new Label("Spilumba Cervejaria");
    programName.setStyleName("b-program-name");
    leftPart.addComponent(programName);

    fastMenuBar = new FastMenuBar();
    leftPart.addComponent(fastMenuBar);

    searchInput = new SearchInput();
    leftPart.addComponent(searchInput);

    moduleButton = new ModuleButton();
    leftPart.addComponent(moduleButton);

    // parte central do menu
    moduleMenu = new ModuleMenu();
    addComponent(moduleMenu);
    setComponentAlignment(moduleMenu, Alignment.MIDDLE_CENTER);

    // parte direita
    userBar = new UserBar();
    addComponent(userBar);
    setComponentAlignment(userBar, Alignment.TOP_RIGHT);
}

From source file:org.bubblecloud.ilves.module.audit.AuditLogFlowlet.java

License:Apache License

@Override
public void initialize() {
    // Get entity manager from site context and prepare container.
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<AuditLogEntry>(entityManager, true, false, false, AuditLogEntry.class,
            1000, new String[] { "created" }, new boolean[] { false }, "auditLogEntryId");

    // Get descriptors and set container properties.
    final List<FilterDescriptor> filterDescriptors = new ArrayList<FilterDescriptor>();
    filterDescriptors.add(new FilterDescriptor("startTime", "created", getSite().localize("filter-start-time"),
            new TimestampField(), 200, ">=", Date.class, new DateTime().withTimeAtStartOfDay().toDate()));
    filterDescriptors.add(new FilterDescriptor("endTime", "created", getSite().localize("filter-end-time"),
            new TimestampField(), 200, "<=", Date.class,
            new DateTime().withTimeAtStartOfDay().plusDays(1).toDate()));
    final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister
            .getFieldSetDescriptor(AuditLogEntry.class).getFieldDescriptors();
    ContainerUtil.addContainerProperties(entityContainer, fieldDescriptors);

    // Initialize layout
    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/*from  www. j a  va  2s  .  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();
    table.setPageLength(13);

    // Initialize grid
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDescriptors);
    entityGrid.setFilters(filterDescriptors);
    gridLayout.addComponent(entityGrid, 0, 1);

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

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final AuditLogEntry entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final AuditLogEntryFlowlet contentView = getFlow().forward(AuditLogEntryFlowlet.class);
            contentView.edit(entity, false);
        }
    });

}

From source file:org.bubblecloud.ilves.module.content.AssetsFlowlet.java

License:Apache License

@Override
public void initialize() {
    // Get entity manager from site context and prepare container.
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Asset>(entityManager, true, false, false, Asset.class, 1000,
            new String[] { "name" }, new boolean[] { true }, "assetId");

    // Get descriptors and set container properties.
    final List<FilterDescriptor> filterDescriptors = new ArrayList<FilterDescriptor>();
    final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister.getFieldSetDescriptor(Asset.class)
            .getFieldDescriptors();// w  w w  .j  a v a 2 s  .  com
    ContainerUtil.addContainerProperties(entityContainer, fieldDescriptors);

    // Initialize layout
    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    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);

    // Initialize grid
    entityGrid = new Grid(new Table(), entityContainer);
    entityGrid.setFields(fieldDescriptors);
    entityGrid.setFilters(filterDescriptors);
    gridLayout.addComponent(entityGrid, 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 Asset asset = new Asset();
            asset.setAssetId(UUID.randomUUID().toString());
            asset.setCreated(new Date());
            asset.setModified(asset.getCreated());
            asset.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final AssetFlowlet assetView = getFlow().forward(AssetFlowlet.class);
            assetView.edit(asset, true);
        }
    });

    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) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final Asset entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final AssetFlowlet assetView = getFlow().forward(AssetFlowlet.class);
            assetView.edit(entity, false);
        }
    });

    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) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            entityContainer.removeItem(entityGrid.getSelectedItemId());
            entityContainer.commit();
        }
    });
}

From source file:org.bubblecloud.ilves.module.content.ContentsFlowlet.java

License:Apache License

@Override
public void initialize() {
    // Get entity manager from site context and prepare container.
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Content>(entityManager, true, false, false, Content.class, 1000,
            new String[] { "page" }, new boolean[] { true }, "contentId");

    // Get descriptors and set container properties.
    final List<FilterDescriptor> filterDescriptors = new ArrayList<FilterDescriptor>();
    final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister
            .getFieldSetDescriptor(Content.class).getFieldDescriptors();
    ContainerUtil.addContainerProperties(entityContainer, fieldDescriptors);

    // Initialize layout
    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();//w  ww.  j  a va2s  .  com
    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);

    // Initialize grid
    entityGrid = new Grid(new Table(), entityContainer);
    entityGrid.setFields(fieldDescriptors);
    entityGrid.setFilters(filterDescriptors);
    gridLayout.addComponent(entityGrid, 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 Content content = new Content();
            content.setCreated(new Date());
            content.setModified(content.getCreated());
            content.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final ContentFlowlet contentView = getFlow().forward(ContentFlowlet.class);
            contentView.edit(content, true);
        }
    });

    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) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final Content entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final ContentFlowlet contentView = getFlow().forward(ContentFlowlet.class);
            contentView.edit(entity, false);
        }
    });

    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) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            entityContainer.removeItem(entityGrid.getSelectedItemId());
            entityContainer.commit();
        }
    });
}

From source file:org.bubblecloud.ilves.ui.administrator.company.CompaniesFlowlet.java

License:Apache License

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

    gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();//from   w w w .  j  a va  2  s. c  o  m
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    final List<FieldDescriptor> fieldDefinitions = SiteFields.getFieldDescriptors(Company.class);

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

    entityContainer = new EntityContainer<Company>(entityManager, true, false, false, Company.class, 1000,
            new String[] { "companyName" }, new boolean[] { false }, "companyId");
    for (final FieldDescriptor fieldDefinition : fieldDefinitions) {
        entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(),
                fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable());
    }

    final Table table = new FormattingTable();
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDefinitions);
    entityGrid.setFilters(filterDefinitions);

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("company", true);
    table.setColumnCollapsed("selfRegistration", true);
    table.setColumnCollapsed("emailPasswordReset", true);
    table.setColumnCollapsed("openIdLogin", true);
    table.setColumnCollapsed("certificateLogin", true);
    table.setColumnCollapsed("maxFailedLoginCount", true);
    table.setColumnCollapsed("passwordValidityPeriodDays", true);
    table.setColumnCollapsed("salesEmailAddress", true);
    table.setColumnCollapsed("supportEmailAddress", true);
    table.setColumnCollapsed("invoicingEmailAddress", true);
    table.setColumnCollapsed("gaTrackingId", true);
    gridLayout.addComponent(entityGrid, 0, 1);

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

    final Button addButton = new Button("Add");
    addButton.setIcon(getSite().getIcon("button-icon-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 Company company = new Company();
            company.setCreated(new Date());
            company.setModified(company.getCreated());
            company.setInvoicingAddress(new PostalAddress());
            company.setDeliveryAddress(new PostalAddress());
            final CompanyFlowlet companyView = getFlow().forward(CompanyFlowlet.class);
            companyView.edit(company, true);
        }
    });

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

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final Company entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final CompanyFlowlet companyView = getFlow().forward(CompanyFlowlet.class);
            companyView.edit(entity, false);
        }
    });

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

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final Company entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            SecurityService.removeCompany(getSite().getSiteContext(), entity);
            entityContainer.refresh();
        }
    });

}

From source file:org.bubblecloud.ilves.ui.administrator.customer.CustomersFlowlet.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", "firstName" }, new boolean[] { true, true, true },
            "customerId");

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

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    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();
    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, 1);

    final Button addButton = new Button("Add");
    addButton.setIcon(getSite().getIcon("button-icon-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 Customer customer = new Customer();
            customer.setCreated(new Date());
            customer.setModified(customer.getCreated());
            customer.setInvoicingAddress(new PostalAddress());
            customer.setDeliveryAddress(new PostalAddress());
            customer.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class);
            customerView.edit(customer, true);
        }
    });

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

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

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

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            SecurityService.removeCustomer(getSite().getSiteContext(), entity);
            entityContainer.refresh();
        }
    });

}

From source file:org.bubblecloud.ilves.ui.administrator.directory.UserDirectoriesFlowlet.java

License:Apache License

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

    for (final FieldDescriptor fieldDescriptor : fieldDefinitions) {
        if (fieldDescriptor.getId().equals("loginPassword")) {
            fieldDefinitions.remove(fieldDescriptor);
            break;
        }/*from  w  ww.  j  a va 2 s .c  o m*/
    }

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

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<UserDirectory>(entityManager, true, false, false, UserDirectory.class,
            1000, new String[] { "address", "port" }, new boolean[] { true, true }, "userDirectoryId");

    for (final FieldDescriptor fieldDefinition : fieldDefinitions) {
        entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(),
                fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable());
    }

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    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 Table();
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDefinitions);
    entityGrid.setFilters(filterDefinitions);
    //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId");

    table.setColumnCollapsed("loginDn", true);
    table.setColumnCollapsed("userEmailAttribute", true);
    table.setColumnCollapsed("userSearchBaseDn", true);
    table.setColumnCollapsed("groupSearchBaseDn", true);
    table.setColumnCollapsed("remoteLocalGroupMapping", true);
    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("company", true);
    gridLayout.addComponent(entityGrid, 0, 1);

    final Button addButton = new Button("Add");
    addButton.setIcon(getSite().getIcon("button-icon-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 UserDirectory userDirectory = new UserDirectory();
            userDirectory.setCreated(new Date());
            userDirectory.setModified(userDirectory.getCreated());
            userDirectory.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final UserDirectoryFlowlet userDirectoryView = getFlow().forward(UserDirectoryFlowlet.class);
            userDirectoryView.edit(userDirectory, true);
        }
    });

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

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final UserDirectory entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final UserDirectoryFlowlet userDirectoryView = getFlow().forward(UserDirectoryFlowlet.class);
            userDirectoryView.edit(entity, false);
        }
    });

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

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final UserDirectory entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            SecurityService.removeUserDirectory(getSite().getSiteContext(), entity);
            entityContainer.refresh();
        }
    });

}

From source file:org.bubblecloud.ilves.ui.administrator.group.GroupsFlowlet.java

License:Apache License

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

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

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

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/*  w  w w .  j  a  v a2s  .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);
    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 Group group = new Group();
            group.setCreated(new Date());
            group.setModified(group.getCreated());
            group.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final GroupFlowlet groupView = getFlow().forward(GroupFlowlet.class);
            groupView.edit(group, true);
        }
    });

    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) {
            if (grid.getSelectedItemId() == null) {
                return;
            }
            final Group entity = container.getEntity(grid.getSelectedItemId());
            final GroupFlowlet groupView = getFlow().forward(GroupFlowlet.class);
            groupView.edit(entity, false);
        }
    });

    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) {
            if (grid.getSelectedItemId() == null) {
                return;
            }
            final Group entity = container.getEntity(grid.getSelectedItemId());
            final List<User> users = UserDao.getGroupMembers(entityManager,
                    (Company) getSite().getSiteContext().getObject(Company.class), entity);

            for (final User user : users) {
                SecurityService.removeGroupMember(getSite().getSiteContext(), entity, user);
            }

            final List<Privilege> privileges = UserDao.getGroupPrivileges(entityManager, entity);
            for (final Privilege privilege : privileges) {
                SecurityService.removeGroupPrivilege(getSite().getSiteContext(), entity, privilege.getKey(),
                        null, privilege.getDataId(), null);
            }

            SecurityService.removeGroup(getSite().getSiteContext(), entity);
            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.bubblecloud.ilves.ui.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();// w  w  w .j  a v  a 2s.c o 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);
    table.setColumnCollapsed("certificate", true);
    table.setColumnCollapsed("failedLoginCount", 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) {
            if (grid.getSelectedItemId() == null) {
                return;
            }
            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) {
            if (grid.getSelectedItemId() == null) {
                return;
            }
            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) {
                SecurityService.removeGroupMember(getSite().getSiteContext(), group, entity);
            }

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

            SecurityService.removeUser(getSite().getSiteContext(), entity);
            container.refresh();
        }
    });

    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) {
            if (grid.getSelectedItemId() == null) {
                return;
            }
            final User user = container.getEntity(grid.getSelectedItemId());
            user.setLockedOut(true);
            SecurityService.updateUser(getSite().getSiteContext(), 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) {
            if (grid.getSelectedItemId() == null) {
                return;
            }
            final User user = container.getEntity(grid.getSelectedItemId());
            user.setLockedOut(false);
            user.setFailedLoginCount(0);
            SecurityService.updateUser(getSite().getSiteContext(), 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.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java

License:Open Source License

private HorizontalLayout getFooterLayout() {
    final HorizontalLayout footer = new HorizontalLayout();
    footer.setSizeUndefined();
    footer.addStyleName("confirmation-window-footer");
    footer.setSpacing(true);//from w  w  w .ja v a2s .  c o  m
    footer.setMargin(false);
    footer.addComponents(uploadBtn, cancelBtn);
    footer.setComponentAlignment(uploadBtn, Alignment.TOP_LEFT);
    footer.setComponentAlignment(cancelBtn, Alignment.TOP_RIGHT);
    return footer;
}