Package muntjac :: Package data :: Package util :: Module indexed_container :: Class IndexedContainer
[hide private]
[frames] | no frames]

Class IndexedContainer

source code

                                    object --+            
                                             |            
                          container.IContainer --+        
                                                 |        
              abstract_container.AbstractContainer --+    
                                                     |    
                                        object --+   |    
                                                 |   |    
                  container.IItemSetChangeNotifier --+    
                                                     |    
                                object --+           |    
                                         |           |    
                      container.IContainer --+       |    
                                             |       |    
                            container.IOrdered --+   |    
                                                 |   |    
                                container.IIndexed --+    
                                                     |    
abstract_in_memory_container.AbstractInMemoryContainer --+
                                                         |
                                            object --+   |
                                                     |   |
                  container.IPropertySetChangeNotifier --+
                                                         |
                                            object --+   |
                                                     |   |
                         property.IValueChangeNotifier --+
                                                         |
                                    object --+           |
                                             |           |
                          container.IContainer --+       |
                                                 |       |
                                container.IOrdered --+   |
                                                     |   |
                                   container.ISortable --+
                                                         |
                                        object --+       |
                                                 |       |
                              container.IContainer --+   |
                                                     |   |
                                 container.IFilterable --+
                                                         |
                                        object --+       |
                                                 |       |
                              container.IContainer --+   |
                                                     |   |
                           container.ISimpleFilterable --+
                                                         |
                                                        IndexedContainer

An implementation of the IContainer.Indexed interface with all important features.

Features:


See Also: IContainer

Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self, itemIds=None)
Constructor for an abstract in-memory container.
source code
 
getUnfilteredItem(self, itemId)
Get an item even if filtered out.
source code
 
getContainerPropertyIds(self)
Gets the ID's of all Properties stored in the IContainer.
source code
 
getType(self, propertyId)
Gets the type of a IProperty stored in the list.
source code
 
getContainerProperty(self, itemId, propertyId)
Gets the Property identified by the given itemId and propertyId from the IContainer.
source code
 
addContainerProperty(self, propertyId, typ, defaultValue)
Adds a new Property to all Items in the IContainer.
source code
 
removeAllItems(self)
Removes all Items from the IContainer.
source code
 
addItem(self, itemId=None)
Creates a new Item with the given ID in the IContainer.
source code
 
addDefaultValues(self, t)
Helper method to add default values for items if available
source code
 
removeItem(self, itemId)
Removes the Item identified by ItemId from the IContainer.
source code
 
removeContainerProperty(self, propertyId)
Removes a Property specified by the given Property ID from the IContainer.
source code
 
addItemAfter(self, previousItemId, newItemId=None)
Adds a new item after the given item.
source code
 
addItemAt(self, index, newItemId=None)
Adds a new item at given index (in the filtered view).
source code
 
generateId(self)
Generates an unique identifier for use as an item id.
source code
 
registerNewItem(self, index, newItemId, item)
Registers a new item as having been added to the container.
source code
 
addListener(self, listener, iface=None)
Implementation of the corresponding method in IPropertySetChangeNotifier and ItemSetChangeNotifier, override and implement the interface to use this.
source code
 
addCallback(self, callback, eventType=None, *args) source code
 
removeListener(self, listener, iface=None)
Implementation of the corresponding method in IPropertySetChangeNotifier and ItemSetChangeNotifier, override and implement the interface to use this.
source code
 
removeCallback(self, callback, eventType=None) source code
 
firePropertyValueChange(self, source)
Sends a IProperty value change event to all interested listeners.
source code
 
getListeners(self, eventType) source code
 
getCallbacks(self, eventType) source code
 
fireItemAdded(self, position, itemId, item)
Notify item set change listeners that an item has been added to the container.
source code
 
fireItemSetChange(self, event=None)
Sends a simple Item set change event to all interested listeners, indicating that anything in the contents may have changed (items added, removed etc.).
source code
 
addSinglePropertyChangeListener(self, propertyId, itemId, listener)
Adds new single IProperty change listener.
source code
 
removeSinglePropertyChangeListener(self, propertyId, itemId, listener)
Removes a previously registered single IProperty change listener.
source code
 
sort(self, propertyId, ascending)
Sort method.
source code
 
getSortableContainerPropertyIds(self)
Gets the container property IDs which can be used to sort the items.
source code
 
getItemSorter(self)
Returns the ItemSorter used for comparing items in a sort.
source code
 
setItemSorter(self, itemSorter)
Sets the ItemSorter used for comparing items in a sort.
source code
 
clone(self)
Supports cloning of the IndexedContainer cleanly.
source code
 
addContainerFilter(self, *args)
Adds a filter for the container.
source code
 
removeAllContainerFilters(self)
Remove all active filters from the container.
source code
 
removeContainerFilters(self, propertyId)
Remove all filters from the given property.
source code
 
removeContainerFilter(self, fltr)
Removes a filter from the container.
source code

Inherited from abstract_in_memory_container.AbstractInMemoryContainer: __len__, addFilter, containsId, doFilterContainer, doSort, filterAll, fireItemRemoved, firstItemId, getAllItemIds, getFilteredItemIds, getFilters, getIdByIndex, getItem, getItemIds, getSortablePropertyIds, getVisibleItemIds, indexOfId, internalAddAt, internalAddItemAfter, internalAddItemAt, internalAddItemAtEnd, internalRemoveAllItems, internalRemoveItem, isFiltered, isFirstId, isLastId, isPropertyFiltered, lastItemId, nextItemId, passesFilters, prevItemId, removeAllFilters, removeFilter, removeFilters, setAllItemIds, setFilteredItemIds, setFilters, size, sortContainer

Inherited from abstract_container.AbstractContainer: fireContainerPropertySetChange, getItemSetChangeListeners, getPropertySetChangeListeners, setItemSetChangeListeners, setPropertySetChangeListeners

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, itemIds=None)
(Constructor)

source code 

Constructor for an abstract in-memory container.

Overrides: object.__init__
(inherited documentation)

getUnfilteredItem(self, itemId)

source code 

Get an item even if filtered out.

For internal use only.

Overrides: abstract_in_memory_container.AbstractInMemoryContainer.getUnfilteredItem
(inherited documentation)

getContainerPropertyIds(self)

source code 

Gets the ID's of all Properties stored in the IContainer. The ID's cannot be modified through the returned collection.

Returns:
unmodifiable collection of Property IDs
Overrides: container.IContainer.getContainerPropertyIds
(inherited documentation)

getType(self, propertyId)

source code 

Gets the type of a IProperty stored in the list.

Parameters:
  • propertyId - the ID of the IProperty.
Returns:
Type of the requested IProperty
Overrides: container.IContainer.getType

getContainerProperty(self, itemId, propertyId)

source code 

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

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 None
Overrides: container.IContainer.getContainerProperty
(inherited documentation)

addContainerProperty(self, propertyId, typ, defaultValue)

source code 

Adds a new Property to all Items in the IContainer. The Property ID, data type and default value of the new Property are given as parameters.

This functionality is optional.

Parameters:
  • propertyId - ID of the Property
  • typ - Data type of the new Property
  • defaultValue - The value all created Properties are initialized to
Returns:
True if the operation succeeded, False if not
Raises:
  • NotImplementedError - if the container does not support explicitly adding container properties
Overrides: container.IContainer.addContainerProperty
(inherited documentation)

removeAllItems(self)

source code 

Removes all Items from the IContainer.

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

Returns:
True if the operation succeeded, False if not
Raises:
  • NotImplementedError - if the container does not support removing all items
Overrides: container.IContainer.removeAllItems
(inherited documentation)

addItem(self, itemId=None)

source code 

Creates a new Item with the given ID in the IContainer. Creates a new Item into the IContainer, and assign it an automatic ID if itemId is None.

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

Parameters:
  • itemId - ID of the Item to be created
Returns:
Created new Item, or None in case of a failure
Raises:
  • NotImplementedError - if adding an item with an explicit item ID is not supported by the container
Overrides: container.IContainer.addItem
(inherited documentation)

addDefaultValues(self, t)

source code 

Helper method to add default values for items if available

Parameters:
  • t - data table of added item

removeItem(self, itemId)

source code 

Removes the Item identified by ItemId from the IContainer.

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

This functionality is optional.

Parameters:
  • itemId - ID of the Item to remove
Returns:
True if the operation succeeded, False if not
Raises:
  • NotImplementedError - if the container does not support removing individual items
Overrides: container.IContainer.removeItem
(inherited documentation)

removeContainerProperty(self, propertyId)

source code 

Removes a Property specified by the given Property ID from the IContainer. Note that the Property will be removed from all Items in the IContainer.

This functionality is optional.

Parameters:
  • propertyId - ID of the Property to remove
Returns:
True if the operation succeeded, False if not
Raises:
  • NotImplementedError - if the container does not support removing container properties
Overrides: container.IContainer.removeContainerProperty
(inherited documentation)

addItemAfter(self, previousItemId, newItemId=None)

source code 

Adds a new item after the given item.

Adding an item after null item adds the item as first item of the ordered container.

Parameters:
  • previousItemId - Id of the visible item in ordered container after which to insert the new item.
  • newItemId - Id of the new item to be added.
Returns:
new item or null if the operation fails.
Raises:
  • NotImplementedError - if the operation is not supported by the container
Overrides: container.IOrdered.addItemAfter
(inherited documentation)

addItemAt(self, index, newItemId=None)

source code 

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 IIndexed, IOrdered, IFilterable and ISortable for more information.

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.
Raises:
  • NotImplementedError - if the operation is not supported by the container
Overrides: container.IIndexed.addItemAt
(inherited documentation)

generateId(self)

source code 

Generates an unique identifier for use as an item id. Guarantees that the generated id is not currently used as an id.

registerNewItem(self, index, newItemId, item)

source code 

Registers a new item as having been added to the container. This can involve storing the item or any relevant information about it in internal container-specific collections if necessary, as well as registering listeners etc.

The full identifier list in AbstractInMemoryContainer has already been updated to reflect the new item when this method is called.

Overrides: abstract_in_memory_container.AbstractInMemoryContainer.registerNewItem
(inherited documentation)

addListener(self, listener, iface=None)

source code 

Implementation of the corresponding method in IPropertySetChangeNotifier and ItemSetChangeNotifier, override and implement the interface to use this.

Parameters:
  • listener - listener to be added
Overrides: property.IValueChangeNotifier.addListener
(inherited documentation)

addCallback(self, callback, eventType=None, *args)

source code 
Overrides: property.IValueChangeNotifier.addCallback

removeListener(self, listener, iface=None)

source code 

Implementation of the corresponding method in IPropertySetChangeNotifier and ItemSetChangeNotifier, override and implement the interface to use this.

Parameters:
  • listener - listener to be removed
Overrides: property.IValueChangeNotifier.removeListener
(inherited documentation)

removeCallback(self, callback, eventType=None)

source code 
Overrides: property.IValueChangeNotifier.removeCallback

firePropertyValueChange(self, source)

source code 

Sends a IProperty value change event to all interested listeners.

Parameters:
  • source - the IndexedContainerProperty object.

getListeners(self, eventType)

source code 
Overrides: abstract_container.AbstractContainer.getListeners

getCallbacks(self, eventType)

source code 
Overrides: abstract_container.AbstractContainer.getCallbacks

fireItemAdded(self, position, itemId, item)

source code 

Notify item set change listeners that an item has been added to the container.

Unless subclasses specify otherwise, the default notification indicates a full refresh.

Parameters:
  • position - position of the added item in the view (if visible)
  • itemId - id of the added item
  • item - the added item
Overrides: abstract_in_memory_container.AbstractInMemoryContainer.fireItemAdded
(inherited documentation)

fireItemSetChange(self, event=None)

source code 

Sends a simple Item set change event to all interested listeners, indicating that anything in the contents may have changed (items added, removed etc.).

Parameters:
  • event - the item set change event to send, optionally with additional information
Overrides: abstract_container.AbstractContainer.fireItemSetChange
(inherited documentation)

addSinglePropertyChangeListener(self, propertyId, itemId, listener)

source code 

Adds new single IProperty change listener.

Parameters:
  • propertyId - the ID of the IProperty to add.
  • itemId - the ID of the IItem .
  • listener - the listener to be added.

removeSinglePropertyChangeListener(self, propertyId, itemId, listener)

source code 

Removes a previously registered single IProperty change listener.

Parameters:
  • propertyId - the ID of the IProperty to remove.
  • itemId - the ID of the IItem.
  • listener - the listener to be removed.

sort(self, propertyId, ascending)

source code 

Sort method.

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.

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 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.
Overrides: container.ISortable.sort
(inherited documentation)

getSortableContainerPropertyIds(self)

source code 

Gets the container property IDs which can be used to sort the items.

Returns:
the IDs of the properties that can be used for sorting the container
Overrides: container.ISortable.getSortableContainerPropertyIds
(inherited documentation)

getItemSorter(self)

source code 

Returns the ItemSorter used for comparing items in a sort. See setItemSorter for more information.

Returns:
The ItemSorter used for comparing two items in a sort.
Overrides: abstract_in_memory_container.AbstractInMemoryContainer.getItemSorter
(inherited documentation)

setItemSorter(self, itemSorter)

source code 

Sets the ItemSorter used for comparing items in a sort. The ItemSorter.compare method is called with item ids to perform the sorting. A default ItemSorter is used if this is not explicitly set.

Parameters:
  • itemSorter - The ItemSorter used for comparing two items in a sort (not null).
Overrides: abstract_in_memory_container.AbstractInMemoryContainer.setItemSorter
(inherited documentation)

clone(self)

source code 

Supports cloning of the IndexedContainer cleanly.

Raises:
  • CloneNotSupportedException - if an object cannot be cloned. .

Deprecated: cloning support might be removed from IndexedContainer in the future

addContainerFilter(self, *args)

source code 

Adds a filter for the container.

If a container has multiple filters, only items accepted by all filters are visible.

Parameters:
  • propertyId - Property for which the filter is applied to.
  • filterString - String that must match the value of the property
  • ignoreCase - Determine if the casing can be ignored when comparing strings.
  • onlyMatchPrefix - Only match prefixes; no other matches are included.
Raises:
Overrides: container.ISimpleFilterable.addContainerFilter
(inherited documentation)

removeAllContainerFilters(self)

source code 

Remove all active filters from the container.

Overrides: container.ISimpleFilterable.removeAllContainerFilters
(inherited documentation)

removeContainerFilters(self, propertyId)

source code 

Remove all filters from the given property.

Parameters:
  • propertyId - for which to remove filters
Overrides: container.ISimpleFilterable.removeContainerFilters
(inherited documentation)

removeContainerFilter(self, fltr)

source code 

Removes a filter from the container.

This requires that the __eq__ method considers the filters as equivalent (same instance or properly implemented __eq__ method).

Overrides: container.IFilterable.removeContainerFilter
(inherited documentation)