All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.holonplatform.vaadin7.data.container.ItemDataSourceContainerBuilder Maven / Gradle / Ivy

There is a newer version: 5.2.4
Show newest version
/*
 * 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.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.ItemDataSource;
import com.holonplatform.vaadin7.data.ItemIdentifierProvider;
import com.holonplatform.vaadin7.data.ItemDataSource.CommitHandler;
import com.holonplatform.vaadin7.data.ItemDataSource.PropertySortGenerator;
import com.vaadin.data.Buffered;
import com.vaadin.data.Container;
import com.vaadin.data.Container.ItemSetChangeListener;
import com.vaadin.data.Item;

/**
 * Builder to create {@link ItemDataSourceContainer} instances.
 * 
 * @param  Item property type
 * @param  Item type
 * 
 * @since 5.0.0
 */
public interface ItemDataSourceContainerBuilder> {

	/**
	 * Set the items data provider.
	 * @param dataProvider The items data provider to set
	 * @return this
	 */
	B dataSource(ItemDataProvider dataProvider);

	/**
	 * Set the item adapter to convert data source item data type to a container {@link Item} and back.
	 * @param itemAdapter The item adapter to set
	 * @return this
	 */
	B itemAdapter(ItemAdapter itemAdapter);

	/**
	 * Set the item identifier provider to use to obtain item ids.
	 * @param  Item id type
	 * @param itemIdentifierProvider the item identifier provider to set
	 * @return this
	 */
	 B itemIdentifier(ItemIdentifierProvider itemIdentifierProvider);

	/**
	 * Add an Item property to this container
	 * @param propertyId Property id
	 * @param type Property value type
	 * @return this
	 */
	B withProperty(PROPERTY propertyId, Class type);

	/**
	 * Add an Item property to this container and declares it as sortable
	 * @param propertyId Property id
	 * @param type Property value type
	 * @return this
	 */
	B withSortableProperty(PROPERTY propertyId, Class type);

	/**
	 * Add an Item property to this container and declares it as read-only
	 * @param propertyId Property id
	 * @param type Property value type
	 * @return this
	 */
	B withReadOnlyProperty(PROPERTY propertyId, Class type);

	/**
	 * Add an Item property to this container and declares it as read-only and sortable
	 * @param propertyId Property id
	 * @param type Property value type
	 * @return this
	 */
	B withReadOnlySortableProperty(PROPERTY propertyId, Class type);

	/**
	 * Set if auto-refresh is enabled for this container, i.e. items are loaded when one of the Container method which
	 * involve operations on item set is called.
	 * 

* If auto-refresh is not enabled, {@link ItemDataSource#refresh()} method must be called to load items before using * this Container. *

* @param autoRefresh true to enable auto-refresh * @return this */ B autoRefresh(boolean autoRefresh); /** * Set batch (page) size for items loading using {@link ItemDataProvider}. *

* A value <=0 means no paging, and {@link ItemDataProvider} should behave in a consistent manner. *

* @param batchSize Batch (page) size for items loading * @return this */ B batchSize(int batchSize); /** * Set max items cache size * @param maxCacheSize Max cache size to set * @return this */ B maxCacheSize(int maxCacheSize); /** * Set whether given property id is sortable. * @param propertyId Property id * @param sortable Whether given property id is sortable * @return this */ B sortable(PROPERTY propertyId, boolean sortable); /** * Set whether given property id is read-only. * @param propertyId Property id * @param readOnly Whether given property id is read-only * @return this */ B readOnly(PROPERTY propertyId, boolean readOnly); /** * Set a default value to initialize the given propertyId * @param propertyId Property id * @param defaultValue Default value * @return this */ B defaultValue(PROPERTY propertyId, Object defaultValue); /** * Sets the buffered mode to the specified status. *

* When in buffered mode, an internal buffer will be used to store changes using {@link CommitHandler} until * {@link ItemDataSource#commit()} is called. Calling {@link ItemDataSource#discard()} will revert the internal * buffer to the value of the data source. *

*

* When in non-buffered mode, write operations will be done directly on the data source using {@link CommitHandler}. * In this mode the {@link ItemDataSource#commit()} and {@link ItemDataSource#discard()} methods serve no purpose. *

* @param buffered true if buffered mode should be turned on, false otherwise * @return this */ B buffered(boolean buffered); /** * Set a {@link PropertySortGenerator} to generate {@link QuerySort}s for given property * @param property Property (not null) * @param propertySortGenerator PropertySortGenerator (not null) * @return this */ B withPropertySortGenerator(PROPERTY property, PropertySortGenerator propertySortGenerator); /** * Add an external {@link QueryConfigurationProvider} for additional query configuration * @param queryConfigurationProvider QueryConfigurationProvider to add * @return this */ B withQueryConfigurationProvider(QueryConfigurationProvider queryConfigurationProvider); /** * Set query fixed filter (always added to query predicates) * @param filter Query fixed filter, or null for none * @return this */ B fixedFilter(QueryFilter filter); /** * Set query fixed sort (always added to query sorts) * @param sort Query fixed sort, or null for none * @return this */ B fixedSort(QuerySort sort); /** * Set query default sort. If not null and no other sort is available, this one will be used * @param sort Default query sort * @return this */ B defaultSort(QuerySort sort); /** * Add a query parameter * @param name Parameter name * @param value Parameter value * @return this */ B queryParameter(String name, Object value); /** * Set the handler to manage item set modifications. *

* This is required to activate item set modification support, using methods such as {@link Container#addItem()}, * {@link Container#removeItem(Object)} and {@link Buffered#commit()}. *

* @param commitHandler Item commit handler * @return this */ B commitHandler(CommitHandler commitHandler); /** * Add an {@link ItemSetChangeListener} * @param listener Listener to add * @return this */ B withItemSetChangeListener(ItemSetChangeListener listener); /** * Build {@link ItemDataSourceContainer} instance * @return ItemDataSourceContainer instance */ ItemDataSourceContainer build(); /** * Default {@link ItemDataSourceContainerBuilder}. * @param Item type * @param Item property type */ public interface BaseItemDataSourceContainerBuilder extends ItemDataSourceContainerBuilder> { } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy