com.holonplatform.vaadin7.internal.data.container.AbstractItemDataSourceContainerBuilder Maven / Gradle / Ivy
/*
* Copyright 2016-2017 Axioma srl.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.holonplatform.vaadin7.internal.data.container;
import com.holonplatform.core.query.QueryConfigurationProvider;
import com.holonplatform.core.query.QueryFilter;
import com.holonplatform.core.query.QuerySort;
import com.holonplatform.vaadin7.data.ItemDataProvider;
import com.holonplatform.vaadin7.data.ItemIdentifierProvider;
import com.holonplatform.vaadin7.data.ItemDataSource.CommitHandler;
import com.holonplatform.vaadin7.data.ItemDataSource.PropertySortGenerator;
import com.holonplatform.vaadin7.data.container.ItemAdapter;
import com.holonplatform.vaadin7.data.container.ItemDataSourceContainer;
import com.holonplatform.vaadin7.data.container.ItemDataSourceContainerBuilder;
import com.vaadin.data.Container.ItemSetChangeListener;
/**
* Base {@link ItemDataSourceContainerBuilder} implementation.
*
* @param - Item type
* @param
Item property type
* @param Concrete builder type
*
* @since 5.0.0
*/
public abstract class AbstractItemDataSourceContainerBuilder- >
implements ItemDataSourceContainerBuilder
- {
/**
* Container instance to build and setup
*/
protected final DefaultItemDataSourceContainer
- container = new DefaultItemDataSourceContainer<>();
/**
* Container batch size
*/
protected int batchSize = ItemDataSourceContainer.DEFAULT_BATCH_SIZE;
/**
* Actual builder
* @return Builder
*/
protected abstract B builder();
/**
* Constructor
*/
public AbstractItemDataSourceContainerBuilder() {
super();
}
protected DefaultItemDataSourceContainer
- getContainer() {
return container;
}
/*
* (non-Javadoc)
* @see
* com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#dataSource(com.holonplatform.vaadin.data
* .ItemDataProvider)
*/
@Override
public B dataSource(ItemDataProvider
- dataProvider) {
container.setDataProvider(dataProvider);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#itemAdapter(com.holonplatform.vaadin.
* data.container.ItemAdapter)
*/
@Override
public B itemAdapter(ItemAdapter
- itemAdapter) {
container.setItemAdapter(itemAdapter);
return builder();
}
/*
* (non-Javadoc)
* @see
* com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#itemIdentifier(com.holonplatform.vaadin.
* data.ItemIdentifierProvider)
*/
@Override
public
B itemIdentifier(ItemIdentifierProvider- itemIdentifierProvider) {
container.setItemIdentifierProvider(itemIdentifierProvider);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.QueryContainerBuilder#autoRefresh(boolean)
*/
@Override
public B autoRefresh(boolean autoRefresh) {
container.setAutoRefresh(autoRefresh);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.QueryContainerBuilder#batchSize(int)
*/
@Override
public B batchSize(int batchSize) {
this.batchSize = batchSize;
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.QueryContainerBuilder#maxCacheSize(int)
*/
@Override
public B maxCacheSize(int maxCacheSize) {
container.setMaxCacheSize(maxCacheSize);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.QueryContainerBuilder#defaultValue(java.lang.Object, java.lang.Object)
*/
@Override
public B defaultValue(PROPERTY propertyId, Object defaultValue) {
container.setPropertyDefaultValue(propertyId, defaultValue);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.QueryContainerBuilder#setBuffered(boolean)
*/
@Override
public B buffered(boolean buffered) {
container.setBuffered(buffered);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.QueryContainerBuilder#withItemSetChangeListener(com.vaadin.data.Container.
* ItemSetChangeListener)
*/
@Override
public B withItemSetChangeListener(ItemSetChangeListener listener) {
container.addItemSetChangeListener(listener);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#withProperty(java.lang.Object,
* java.lang.Class)
*/
@Override
public B withProperty(PROPERTY propertyId, Class> type) {
container.addContainerProperty(propertyId, type, null);
return builder();
}
/*
* (non-Javadoc)
* @see
* com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#withSortableProperty(java.lang.Object,
* java.lang.Class)
*/
@Override
public B withSortableProperty(PROPERTY propertyId, Class> type) {
container.addContainerProperty(propertyId, type, false, true);
return builder();
}
/*
* (non-Javadoc)
* @see
* com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#withReadOnlyProperty(java.lang.Object,
* java.lang.Class)
*/
@Override
public B withReadOnlyProperty(PROPERTY propertyId, Class> type) {
container.addContainerProperty(propertyId, type, true, false);
return builder();
}
/*
* (non-Javadoc)
* @see
* com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#withReadOnlySortableProperty(java.lang.
* Object, java.lang.Class)
*/
@Override
public B withReadOnlySortableProperty(PROPERTY propertyId, Class> type) {
container.addContainerProperty(propertyId, type, true, true);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#sortable(java.lang.Object, boolean)
*/
@Override
public B sortable(PROPERTY propertyId, boolean sortable) {
container.setPropertySortable(propertyId, sortable);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#readOnly(java.lang.Object, boolean)
*/
@Override
public B readOnly(PROPERTY propertyId, boolean readOnly) {
container.setPropertyReadOnly(propertyId, readOnly);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#withPropertySortGenerator(java.lang.
* Object, com.holonplatform.vaadin.data.ItemDataSource.PropertySortGenerator)
*/
@Override
public B withPropertySortGenerator(PROPERTY property, PropertySortGenerator
propertySortGenerator) {
container.setPropertySortGenerator(property, propertySortGenerator);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#withQueryConfigurationProvider(com.
* holonframework.core.query.QueryConfigurationProvider)
*/
@Override
public B withQueryConfigurationProvider(QueryConfigurationProvider queryConfigurationProvider) {
container.addQueryConfigurationProvider(queryConfigurationProvider);
return builder();
}
/*
* (non-Javadoc)
* @see
* com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#fixedFilter(com.holonplatform.core.query
* .QueryFilter)
*/
@Override
public B fixedFilter(QueryFilter filter) {
container.setFixedFilter(filter);
return builder();
}
/*
* (non-Javadoc)
* @see
* com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#fixedSort(com.holonplatform.core.query.
* QuerySort)
*/
@Override
public B fixedSort(QuerySort sort) {
container.setFixedSort(sort);
return builder();
}
/*
* (non-Javadoc)
* @see
* com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#defaultSort(com.holonplatform.core.query
* .QuerySort)
*/
@Override
public B defaultSort(QuerySort sort) {
container.setDefaultSort(sort);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#queryParameter(java.lang.String,
* java.lang.Object)
*/
@Override
public B queryParameter(String name, Object value) {
container.addQueryParameter(name, value);
return builder();
}
/*
* (non-Javadoc)
* @see
* com.holonplatform.vaadin.data.container.ItemDataSourceContainerBuilder#commitHandler(com.holonplatform.vaadin.
* data.ItemDataSource.CommitHandler)
*/
@Override
public B commitHandler(CommitHandler- commitHandler) {
container.setCommitHandler(commitHandler);
return builder();
}
/*
* (non-Javadoc)
* @see com.holonplatform.vaadin.data.QueryContainerBuilder#build()
*/
@Override
public ItemDataSourceContainer
- build() {
// init container
container.init(batchSize);
return container;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy