com.vaadin.data.util.

Class GeneratedPropertyContainer

    • Constructor Detail

      • GeneratedPropertyContainer

        public GeneratedPropertyContainer(Container.Indexed container)

        Constructor for GeneratedPropertyContainer.

        Parameters:

        container - underlying indexed container

    • Method Detail

      • addGeneratedProperty

        public void addGeneratedProperty(Object propertyId,
                                         PropertyValueGenerator<?> generator)

        Add a new PropertyValueGenerator with given property id. This will override any existing properties with the same property id. Fires a PropertySetChangeEvent.

        Parameters:

        propertyId - property id

        generator - a property value generator

      • removeGeneratedProperty

        public void removeGeneratedProperty(Object propertyId)

        Removes any possible PropertyValueGenerator with given property id. Fires a PropertySetChangeEvent.

        Parameters:

        propertyId - property id

      • sort

        public void sort(Object[] propertyId,
                         boolean[] ascending)

        Description copied from interface: Container.Sortable

        Sorts the container items.

        Sorting a container can irreversibly change the order of its items or only change the order temporarily, depending on the container.

        Specified by:

        sort in interface Container.Sortable

        Parameters:

        propertyId - Array of container property IDs, whose values are used to sort the items in container as primary, secondary, ... sorting criterion. All of the item IDs must be in the collection returned by Container.Sortable.getSortableContainerPropertyIds()

        ascending - Array of sorting order flags corresponding to each property ID used in sorting. If this array is shorter than propertyId array, ascending order is assumed for items where the order is not specified. Use true to sort in ascending order, false to use descending order.

      • addItem

        public Item addItem(Object itemId)
                     throws UnsupportedOperationException

        Description copied from interface: Container

        Creates a new Item with the given ID in the Container.

        The new Item is returned, and it is ready to have its Properties modified. Returns null if the operation fails or the Container already contains a Item with the given ID.

        This functionality is optional.

        Specified by:

        addItem in interface Container

        Parameters:

        itemId - ID of the Item to be created

        Returns:

        Created new Item, or null in case of a failure

        Throws:

        UnsupportedOperationException - if adding an item with an explicit item ID is not supported by the container

      • addItemAt

        public Item addItemAt(int index,
                              Object newItemId)
                       throws UnsupportedOperationException

        Description copied from interface: Container.Indexed

        Adds a new item at given index (in the filtered view).

        The indexes of the item currently in the given position and all the following items are incremented.

        This method should apply filters to the added item after inserting it, possibly hiding it immediately. If the container is being sorted, the item may be added at the correct sorted position instead of the given position. See Container.Indexed, Container.Filterable and Container.Sortable for more information.

        Specified by:

        addItemAt in interface Container.Indexed

        Parameters:

        index - Index (in the filtered and sorted view) at which to add the new item.

        newItemId - Id of the new item to be added.

        Returns:

        new Item or null if the operation fails.

        Throws:

        UnsupportedOperationException - if the operation is not supported by the container

      • getItem

        public Item getItem(Object itemId)

        Description copied from interface: Container

        Gets the Item with the given Item ID from the Container. If the Container does not contain the requested Item, null is returned.

        Containers should not return Items that are filtered out.

        Specified by:

        getItem in interface Container

        Parameters:

        itemId - ID of the Item to retrieve

        Returns:

        the Item with the given ID or null if the Item is not found in the Container

      • getContainerProperty

        public Property<?> getContainerProperty(Object itemId,
                                                Object propertyId)

        Description copied from interface: Container

        Gets the Property identified by the given itemId and propertyId from the Container. If the Container does not contain the item or it is filtered out, or the Container does not have the Property, null is returned.

        Specified by:

        getContainerProperty in interface Container

        Parameters:

        itemId - ID of the visible Item which contains the Property

        propertyId - ID of the Property to retrieve

        Returns:

        Property with the given ID or null

      • getContainerPropertyIds

        public Collection<?> getContainerPropertyIds()

        Returns a list of propety ids available in this container. This collection will contain properties for generated properties. Removed properties will not show unless there is a generated property overriding those.

        Specified by:

        getContainerPropertyIds in interface Container

        Returns:

        unmodifiable collection of Property IDs

      • addContainerProperty

        public boolean addContainerProperty(Object propertyId,
                                            Class<?> type,
                                            Object defaultValue)
                                     throws UnsupportedOperationException

        Adds a previously removed property back to GeneratedPropertyContainer. Adding a property that is not previously removed causes an UnsupportedOperationException.

        Specified by:

        addContainerProperty in interface Container

        Parameters:

        propertyId - ID of the Property

        type - Data type of the new Property

        defaultValue - The value all created Properties are initialized to

        Returns:

        true if the operation succeeded, false if not

        Throws:

        UnsupportedOperationException - if the container does not support explicitly adding container properties

      • getType

        public Class<?> getType(Object propertyId)

        Description copied from interface: Container

        Gets the data type of all Properties identified by the given Property ID.

        Specified by:

        getType in interface Container

        Parameters:

        propertyId - ID identifying the Properties

        Returns:

        data type of the Properties

      • nextItemId

        public Object nextItemId(Object itemId)

        Description copied from interface: Container.Ordered

        Gets the ID of the Item following the Item that corresponds to itemId. If the given Item is the last or not found in the Container, null is returned.

        Specified by:

        nextItemId in interface Container.Ordered

        Parameters:

        itemId - ID of a visible Item in the Container

        Returns:

        ID of the next visible Item or null

      • prevItemId

        public Object prevItemId(Object itemId)

        Description copied from interface: Container.Ordered

        Gets the ID of the Item preceding the Item that corresponds to itemId. If the given Item is the first or not found in the Container, null is returned.

        Specified by:

        prevItemId in interface Container.Ordered

        Parameters:

        itemId - ID of a visible Item in the Container

        Returns:

        ID of the previous visible Item or null

      • firstItemId

        public Object firstItemId()

        Description copied from interface: Container.Ordered

        Gets the ID of the first Item in the Container.

        Specified by:

        firstItemId in interface Container.Ordered

        Returns:

        ID of the first visible Item in the Container

      • lastItemId

        public Object lastItemId()

        Description copied from interface: Container.Ordered

        Gets the ID of the last Item in the Container..

        Specified by:

        lastItemId in interface Container.Ordered

        Returns:

        ID of the last visible Item in the Container

      • isFirstId

        public boolean isFirstId(Object itemId)

        Description copied from interface: Container.Ordered

        Tests if the Item corresponding to the given Item ID is the first Item in the Container.

        Specified by:

        isFirstId in interface Container.Ordered

        Parameters:

        itemId - ID of an Item in the Container

        Returns:

        true if the Item is first visible item in the Container, false if not

      • isLastId

        public boolean isLastId(Object itemId)

        Description copied from interface: Container.Ordered

        Tests if the Item corresponding to the given Item ID is the last Item in the Container.

        Specified by:

        isLastId in interface Container.Ordered

        Returns:

        true if the Item is last visible item in the Container, false if not

      • getItemIds

        public Collection<?> getItemIds()

        Description copied from interface: Container

        Gets the ID's of all visible (after filtering and sorting) Items stored in the Container. The ID's cannot be modified through the returned collection.

        If the container is Container.Ordered, the collection returned by this method should follow that order. If the container is Container.Sortable, the items should be in the sorted order.

        Calling this method for large lazy containers can be an expensive operation and should be avoided when practical.

        Specified by:

        getItemIds in interface Container

        Returns:

        unmodifiable collection of Item IDs

      • size

        public int size()

        Description copied from interface: Container

        Gets the number of visible Items in the Container.

        Filtering can hide items so that they will not be visible through the container API.

        Specified by:

        size in interface Container

        Returns:

        number of Items in the Container

      • containsId

        public boolean containsId(Object itemId)

        Description copied from interface: Container

        Tests if the Container contains the specified Item.

        Filtering can hide items so that they will not be visible through the container API, and this method should respect visibility of items (i.e. only indicate visible items as being in the container) if feasible for the container.

        Specified by:

        containsId in interface Container

        Parameters:

        itemId - ID the of Item to be tested

        Returns:

        boolean indicating if the Container holds the specified Item

      • addItem

        public Object addItem()
                       throws UnsupportedOperationException

        Description copied from interface: Container

        Creates a new Item into the Container, and assign it an automatic ID.

        The new ID is returned, or null if the operation fails. After a successful call you can use the getItemmethod to fetch the Item.

        This functionality is optional.

        Specified by:

        addItem in interface Container

        Returns:

        ID of the newly created Item, or null in case of a failure

        Throws:

        UnsupportedOperationException - if adding an item without an explicit item ID is not supported by the container

      • removeItem

        public boolean removeItem(Object itemId)
                           throws UnsupportedOperationException

        Description copied from interface: Container

        Removes the Item identified by ItemId from the Container.

        Containers that support filtering should also allow removing an item that is currently filtered out.

        This functionality is optional.

        Specified by:

        removeItem in interface Container

        Parameters:

        itemId - ID of the Item to remove

        Returns:

        true if the operation succeeded, false if not

        Throws:

        UnsupportedOperationException - if the container does not support removing individual items

      • removeAllItems

        public boolean removeAllItems()
                               throws UnsupportedOperationException

        Description copied from interface: Container

        Removes all Items from the Container.

        Note that Property ID and type information is preserved. This functionality is optional.

        Specified by:

        removeAllItems in interface Container

        Returns:

        true if the operation succeeded, false if not

        Throws:

        UnsupportedOperationException - if the container does not support removing all items

      • indexOfId

        public int indexOfId(Object itemId)

        Description copied from interface: Container.Indexed

        Gets the index of the Item corresponding to the itemId. The following is true for the returned index: 0 <= index < size(), or index = -1 if there is no visible item with that id in the container.

        Specified by:

        indexOfId in interface Container.Indexed

        Parameters:

        itemId - ID of an Item in the Container

        Returns:

        index of the Item, or -1 if (the filtered and sorted view of) the Container does not include the Item

      • getIdByIndex

        public Object getIdByIndex(int index)

        Description copied from interface: Container.Indexed

        Get the item id for the item at the position given by index.

        Specified by:

        getIdByIndex in interface Container.Indexed

        Parameters:

        index - the index of the requested item id

        Returns:

        the item id of the item at the given index

      • getItemIds

        public List<?> getItemIds(int startIndex,
                                  int numberOfItems)

        Description copied from interface: Container.Indexed

        Get numberOfItems consecutive item ids from the container, starting with the item id at startIndex.

        Implementations should return at most numberOfItems item ids, but can contain less if the container has less items than required to fulfill the request. The returned list must hence contain all of the item ids from the range:

        startIndex to max(startIndex + (numberOfItems-1), container.size()-1).

        For quick migration to new API see: ContainerHelpers#getItemIdsUsingGetIdByIndex(int, int, Indexed)

        Specified by:

        getItemIds in interface Container.Indexed

        Parameters:

        startIndex - the index for the first item which id to include

        numberOfItems - the number of consecutive item ids to get from the given start index, must be >= 0

        Returns:

        List containing the requested item ids or empty list if numberOfItems == 0; not null

      • addItemAt

        public Object addItemAt(int index)
                         throws UnsupportedOperationException

        Description copied from interface: Container.Indexed

        Adds a new item at given index (in the filtered view).

        The indices of the item currently in the given position and all the following items are incremented.

        This method should apply filters to the added item after inserting it, possibly hiding it immediately. If the container is being sorted, the item may be added at the correct sorted position instead of the given position. See Container.Indexed, Container.Ordered, Container.Filterable and Container.Sortable for more information.

        Specified by:

        addItemAt in interface Container.Indexed

        Parameters:

        index - Index (in the filtered and sorted view) to add the new item.

        Returns:

        item id of the created item or null if the operation fails.

        Throws:

        UnsupportedOperationException - if the operation is not supported by the container

      • getWrappedContainer

        public Container.Indexed getWrappedContainer()

        Returns the original underlying container.

        Returns:

        the original underlying container