Java源码示例:com.vaadin.data.util.BeanItemContainer

示例1
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();
}
 
示例2
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);
	}
}
 
示例3
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();
}
 
示例4
@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);
}
 
示例5
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;
}
 
示例6
/**
 * 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);
}
 
示例7
/**
 * Update/paint the agent Grid.
 */
private void updateAgentList() {
    List<Agent> agents = repository.getAgents();
    agentGrid.setContainerDataSource(new BeanItemContainer<>(Agent.class, agents));
    agentGrid.markAsDirty();
}
 
示例8
/**
 * Reset the identifier list/grid.
 */
private void updateIdentifierList() {
    List<Identifier> identifiers = repository.getIdentifiers();
    idGrid.setContainerDataSource(new BeanItemContainer<>(Identifier.class, identifiers));
    idGrid.markAsDirty();
}
 
示例9
private void refreshContacts(String stringFilter) {
    contactList.setContainerDataSource(new BeanItemContainer<>(
            User.class, userClient.findAll().getContent()));
    contactForm.setVisible(false);
}