Package muntjac :: Package data :: Package util :: Module container_ordered_wrapper :: Class ContainerOrderedWrapper
[hide private]
[frames] | no frames]

Class ContainerOrderedWrapper

source code

                      object --+        
                               |        
            container.IContainer --+    
                                   |    
                  container.IOrdered --+
                                       |
                          object --+   |
                                   |   |
    container.IItemSetChangeNotifier --+
                                       |
                          object --+   |
                                   |   |
container.IPropertySetChangeNotifier --+
                                       |
                                      ContainerOrderedWrapper
Known Subclasses:

A wrapper class for adding external ordering to containers not implementing the IOrdered interface.

If the wrapped container is changed directly (that is, not through the wrapper), and does not implement Container.ItemSetChangeNotifier and/or PropertySetChangeNotifier the hierarchy information must be updated with the updateOrderWrapper method.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self, toBeWrapped)
Constructs a new ordered wrapper for an existing Container.
source code
 
removeFromOrderWrapper(self, idd)
Removes the specified Item from the wrapper's internal hierarchy structure.
source code
 
addToOrderWrapper(self, idd, previousItemId=None)
Registers the specified Item to the last position in the wrapper's internal ordering.
source code
 
updateOrderWrapper(self)
Updates the wrapper's internal ordering information to include all Items in the underlying container.
source code
 
firstItemId(self)
Gets the ID of the first Item in the IContainer.
source code
 
isFirstId(self, itemId)
Tests if the Item corresponding to the given Item ID is the first Item in the IContainer.
source code
 
isLastId(self, itemId)
Tests if the Item corresponding to the given Item ID is the last Item in the IContainer.
source code
 
lastItemId(self)
Gets the ID of the last Item in the IContainer..
source code
 
nextItemId(self, itemId)
Gets the ID of the Item following the Item that corresponds to itemId.
source code
 
prevItemId(self, itemId)
Gets the ID of the Item preceding the Item that corresponds to itemId.
source code
 
addContainerProperty(self, propertyId, typ, defaultValue)
Registers a new Property to all Items in the Container.
source code
 
addItem(self, itemId=None)
Creates a new Item into the Container, assigns it an automatic ID, and adds it to the ordering.
source code
 
removeAllItems(self)
Removes all items from the underlying container and from the ordering.
source code
 
removeItem(self, itemId)
Removes an Item specified by the itemId from the underlying container and from the ordering.
source code
 
removeContainerProperty(self, propertyId)
Removes the specified Property from the underlying container and from the ordering.
source code
 
containsId(self, itemId)
Tests if the IContainer contains the specified Item.
source code
 
getItem(self, itemId)
Gets the Item with the given Item ID from the IContainer.
source code
 
getItemIds(self)
Gets the ID's of all visible (after filtering and sorting) Items stored in the IContainer.
source code
 
getContainerProperty(self, itemId, propertyId)
Gets the Property identified by the given itemId and propertyId from the IContainer.
source code
 
getContainerPropertyIds(self)
Gets the ID's of all Properties stored in the IContainer.
source code
 
getType(self, propertyId)
Gets the data type of all Properties identified by the given Property ID.
source code
 
size(self)
Gets the number of visible Items in the IContainer.
source code
 
__len__(self) source code
 
addListener(self, listener, iface=None)
Adds an Item set change listener for the object.
source code
 
addCallback(self, callback, eventType=None, *args) source code
 
removeListener(self, listener, iface=None)
Removes the Item set change listener from the object.
source code
 
removeCallback(self, callback, eventType=None) source code
 
addItemAfter(self, previousItemId, newItemId=None)
Adds a new item after the given item.
source code

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

Instance Variables [hide private]
  _container
The wrapped container
  _next
Ordering information, ie.
  _prev
Reverse ordering information for convenience and performance
  _first
ID of the first Item in the container.
  _last
ID of the last Item in the container.
  _ordered
Is the wrapped container ordered by itself, ie.
  _lastKnownSize
The last known size of the wrapped container.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, toBeWrapped)
(Constructor)

source code 
Constructs a new ordered wrapper for an existing Container. Works even if
the to-be-wrapped container already implements the Container.Ordered
interface.

@param toBeWrapped
           the container whose contents need to be ordered.

Overrides: object.__init__

removeFromOrderWrapper(self, idd)

source code 

Removes the specified Item from the wrapper's internal hierarchy structure.

Note : The Item is not removed from the underlying Container.

Parameters:
  • idd - the ID of the Item to be removed from the ordering.

addToOrderWrapper(self, idd, previousItemId=None)

source code 
Registers the specified Item to the last position in the wrapper's
internal ordering. The underlying container is not modified.

@param idd
           the ID of the Item to be added to the ordering.
---
Registers the specified Item after the specified itemId in the wrapper's
internal ordering. The underlying container is not modified. Given item
idd must be in the container, or must be null.

@param idd
           the ID of the Item to be added to the ordering.
@param previousItemId
           the Id of the previous item.

updateOrderWrapper(self)

source code 

Updates the wrapper's internal ordering information to include all Items in the underlying container.

Note: If the contents of the wrapped container change without the wrapper's knowledge, this method needs to be called to update the ordering information of the Items.

firstItemId(self)

source code 

Gets the ID of the first Item in the IContainer.

Returns:
ID of the first visible Item in the IContainer
Overrides: container.IOrdered.firstItemId
(inherited documentation)

isFirstId(self, itemId)

source code 

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

Parameters:
  • itemId - ID of an Item in the IContainer
Returns:
True if the Item is first visible item in the IContainer, False if not
Overrides: container.IOrdered.isFirstId
(inherited documentation)

isLastId(self, itemId)

source code 

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

Returns:
True if the Item is last visible item in the IContainer, False if not
Overrides: container.IOrdered.isLastId
(inherited documentation)

lastItemId(self)

source code 

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

Returns:
ID of the last visible Item in the IContainer
Overrides: container.IOrdered.lastItemId
(inherited documentation)

nextItemId(self, itemId)

source code 

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 IContainer, None is returned.

Parameters:
  • itemId - ID of a visible Item in the IContainer
Returns:
ID of the next visible Item or None
Overrides: container.IOrdered.nextItemId
(inherited documentation)

prevItemId(self, itemId)

source code 

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 IContainer, None is returned.

Parameters:
  • itemId - ID of a visible Item in the IContainer
Returns:
ID of the previous visible Item or None
Overrides: container.IOrdered.prevItemId
(inherited documentation)

addContainerProperty(self, propertyId, typ, defaultValue)

source code 

Registers a new Property to all Items in the Container.

Parameters:
  • propertyId - the ID of the new Property.
  • typ - the 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

addItem(self, itemId=None)

source code 

Creates a new Item into the Container, assigns it an automatic ID, and adds it to the ordering. Alternatively, registers a new Item by its ID to the underlying container and to the ordering.

Parameters:
  • itemId - the ID of the Item to be created.
Returns:
None if the operation failed
Raises:
  • NotImplementedError - if the addItem is not supported.
Overrides: container.IContainer.addItem

removeAllItems(self)

source code 

Removes all items from the underlying container and from the ordering.

Returns:
True if the operation succeeded, otherwise False
Raises:
  • NotImplementedError - if the removeAllItems is not supported.
Overrides: container.IContainer.removeAllItems

removeItem(self, itemId)

source code 

Removes an Item specified by the itemId from the underlying container and from the ordering.

Parameters:
  • itemId - the ID of the Item to be removed.
Returns:
True if the operation succeeded, False if not
Raises:
  • NotImplementedError - if the removeItem is not supported.
Overrides: container.IContainer.removeItem

removeContainerProperty(self, propertyId)

source code 

Removes the specified Property from the underlying container and from the ordering.

Note: The Property will be removed from all the Items in the Container.

Parameters:
  • propertyId - the ID of the Property to remove.
Returns:
True if the operation succeeded, False if not
Raises:
  • NotImplementedError - if the removeContainerProperty is not supported.
Overrides: container.IContainer.removeContainerProperty

containsId(self, itemId)

source code 

Tests if the IContainer 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.

Parameters:
  • itemId - ID the of Item to be tested
Returns:
boolean indicating if the IContainer holds the specified Item
Overrides: container.IContainer.containsId
(inherited documentation)

getItem(self, itemId)

source code 

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

Containers should not return Items that are filtered out.

Parameters:
  • itemId - ID of the Item to retrieve
Returns:
the Item with the given ID or None if the Item is not found in the IContainer
Overrides: container.IContainer.getItem
(inherited documentation)

getItemIds(self)

source code 

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

If the container is IOrdered, the collection returned by this method should follow that order. If the container is ISortable, 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.

Returns:
unmodifiable collection of Item IDs
Overrides: container.IContainer.getItemIds
(inherited documentation)

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)

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 data type of all Properties identified by the given Property ID.

Parameters:
  • propertyId - ID identifying the Properties
Returns:
data type of the Properties
Overrides: container.IContainer.getType
(inherited documentation)

size(self)

source code 

Gets the number of visible Items in the IContainer.

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

Returns:
number of Items in the IContainer
Overrides: container.IContainer.size
(inherited documentation)

addListener(self, listener, iface=None)

source code 

Adds an Item set change listener for the object.

Parameters:
  • listener - listener to be added
Overrides: container.IPropertySetChangeNotifier.addListener
(inherited documentation)

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

source code 
Overrides: container.IPropertySetChangeNotifier.addCallback

removeListener(self, listener, iface=None)

source code 

Removes the Item set change listener from the object.

Parameters:
  • listener - listener to be removed
Overrides: container.IPropertySetChangeNotifier.removeListener
(inherited documentation)

removeCallback(self, callback, eventType=None)

source code 
Overrides: container.IPropertySetChangeNotifier.removeCallback

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)

Instance Variable Details [hide private]

_next

Ordering information, ie. the mapping from Item ID to the next

_ordered

Is the wrapped container ordered by itself, ie. does it implement

_lastKnownSize

The last known size of the wrapped container. Used to check whether