com.vaadin.data.util.BeanItemContainer Java Examples

The following examples show how to use com.vaadin.data.util.BeanItemContainer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddressbookUI.java    From spring-cloud-microservice-example with GNU General Public License v3.0 6 votes vote down vote up
private void configureComponents() {
     /* Synchronous event handling.
     *
     * Receive user interaction events on the server-side. This allows you
     * to synchronously handle those events. Vaadin automatically sends
     * only the needed changes to the web page without loading a new page.
     */
    newContact.addClickListener(e -> contactForm.edit(new User()));

    filter.setInputPrompt("Filter contacts...");
    filter.addTextChangeListener(e -> refreshContacts(e.getText()));

    contactList.setContainerDataSource(new BeanItemContainer<>(User.class));
    contactList.setColumnOrder("id", "firstName", "lastName", "email");
    contactList.removeColumn("birthDate");
    contactList.setSelectionMode(Grid.SelectionMode.SINGLE);
    contactList.addSelectionListener(e
            -> contactForm.edit((User) contactList.getSelectedRow()));
    refreshContacts();
}
 
Example #2
Source File: PIPSQLResolverEditorWindow.java    From XACML with MIT License 6 votes vote down vote up
protected void populateData(String prefix, String list, BeanItemContainer<ResolverAttribute> container) {
	for (String field : Splitter.on(',').trimResults().omitEmptyStrings().split(list)) {
		//
		// Create a bean for this field
		//
		ResolverAttribute bean = new ResolverAttribute(prefix, field);
		//
		// Now try to find the attribute information
		//
		for (PIPResolverParam param : this.entity.getEntity().getPipresolverParams()) {
			if (param.getParamName().equals(prefix + field + ".id")) {
				bean.setId(param);
			} else if (param.getParamName().equals(prefix + field + ".category")) {
				bean.setCategory(param);
			} else if (param.getParamName().equals(prefix + field + ".datatype")) {
				bean.setDatatype(param);
			} else if (param.getParamName().equals(prefix + field + ".issuer")) {
				bean.setIssuer(param);
			} else if (param.getParamName().equals(prefix + field + ".column")) {
				bean.setColumn(param);
			}
		}
		container.addBean(bean);
	}
}
 
Example #3
Source File: EnumerationEditorComponent.java    From XACML with MIT License 6 votes vote down vote up
public EnumerationEditorComponent(Attribute attribute, Identifier datatype) {
	buildMainLayout();
	setCompositionRoot(mainLayout);
	//
	// Save our attribute
	//
	this.attribute = attribute;
	this.datatype = datatype;
	//
	// Construct a bean container that the 
	// table uses to manage the values.
	//
	this.beanContainer = new BeanItemContainer<ConstraintValue>(ConstraintValue.class);
	//
	// Initialize our components
	//
	this.initializeTable();
	this.initializeButtons();
}
 
Example #4
Source File: MyWindow.java    From java-course-ee with MIT License 5 votes vote down vote up
@Override
protected void init(VaadinRequest vaadinRequest) {
    mainWindow = new Window("Test Vaadin application");

    mainWindow.setWidth(800, Unit.PIXELS);
    mainWindow.setHeight(600, Unit.PIXELS);
    mainWindow.center();

    grid.setWidth("100%");
    grid.setHeight(300, Unit.PIXELS);
    grid.setSelectionMode(Grid.SelectionMode.SINGLE);

    grid.setContainerDataSource(new BeanItemContainer<Person>(Person.class, DaoImpl.getAllPersons()));
    grid.setColumns("name", "birth");
    Grid.Column bornColumn = grid.getColumn("birth");
    bornColumn.setRenderer(new DateRenderer("%1$td-%1$tm-%1$tY"));
    grid.addSelectionListener(event -> {
        Set<Object> selected = event.getSelected();
        Person o = (Person) selected.toArray()[0];
        BeanFieldGroup.bindFieldsUnbuffered(o, formLayout);
        formLayout.id.setEnabled(true);
        formLayout.name.setEnabled(true);
        formLayout.birth.setEnabled(true);
    });

    formLayout.id.setEnabled(false);
    formLayout.name.setEnabled(false);
    formLayout.birth.setEnabled(false);

    verticalLayout.setMargin(true);

    verticalLayout.addComponent(grid);
    verticalLayout.addComponent(formLayout);

    mainWindow.setContent(verticalLayout);

    addWindow(mainWindow);
}
 
Example #5
Source File: SchemaSelectorComponent.java    From RDFUnit with Apache License 2.0 5 votes vote down vote up
private static Container generateTestContainer() {
    BeanItemContainer<SchemaSource> container = new BeanItemContainer<>(
            SchemaSource.class);

    java.util.Collection<SchemaSource> sources;
    try {
        sources = SchemaService.getSourceListAll(false, null);
    } catch (UndefinedSchemaException e) {
        LOGGER.error("Undefined schema", e);
        sources = new ArrayList<>();
    }

    sources.forEach(container::addBean);
    return container;
}
 
Example #6
Source File: TableComponent.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Create the BeanContainer to use.
 * @param beanClass bean type in container
 * @param data intial data.
 * @return a new BeanContainer
 */
protected Container createBeanContainer(Class<T> beanClass, List<T> data) {
	Constructor<?extends Container> ctor = 
			ClassUtils.getConstructorIfAvailable(this.containerClass, Class.class, Collection.class);
	
	if (ctor != null)
		return BeanUtils.instantiateClass(ctor, beanClass, data);
	
	return new BeanItemContainer<T>(beanClass, data);
}
 
Example #7
Source File: RepositoryForm.java    From doecode with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Update/paint the agent Grid.
 */
private void updateAgentList() {
    List<Agent> agents = repository.getAgents();
    agentGrid.setContainerDataSource(new BeanItemContainer<>(Agent.class, agents));
    agentGrid.markAsDirty();
}
 
Example #8
Source File: RepositoryForm.java    From doecode with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Reset the identifier list/grid.
 */
private void updateIdentifierList() {
    List<Identifier> identifiers = repository.getIdentifiers();
    idGrid.setContainerDataSource(new BeanItemContainer<>(Identifier.class, identifiers));
    idGrid.markAsDirty();
}
 
Example #9
Source File: AddressbookUI.java    From spring-cloud-microservice-example with GNU General Public License v3.0 4 votes vote down vote up
private void refreshContacts(String stringFilter) {
    contactList.setContainerDataSource(new BeanItemContainer<>(
            User.class, userClient.findAll().getContent()));
    contactForm.setVisible(false);
}