Package muntjac :: Package ui :: Module tree :: Class Tree
[hide private]
[frames] | no frames]

Class Tree

source code

                            object --+                        
                                     |                        
                   util.IEventListener --+                    
                                         |                    
             terminal.paintable.IPaintable --+                
                                             |                
                                object --+   |                
                                         |   |                
    terminal.variable_owner.IVariableOwner --+                
                                             |                
                                object --+   |                
                                         |   |                
               terminal.sizeable.ISizeable --+                
                                             |                
                          component.IComponent --+            
                                                 |            
                                    object --+   |            
                                             |   |            
  event.method_event_source.IMethodEventSource --+            
                                                 |            
              abstract_component.AbstractComponent --+        
                                                     |        
                                object --+           |        
                                         |           |        
                   data.buffered.IBuffered --+       |        
                                             |       |        
                                object --+   |       |        
                                         |   |       |        
             data.validatable.IValidatable --+       |        
                                             |       |        
            data.buffered.IBufferedValidatable --+   |        
                                                 |   |        
                                    object --+   |   |        
                                             |   |   |        
            data.property.IValueChangeNotifier --+   |        
                                                 |   |        
                                    object --+   |   |        
                                             |   |   |        
            data.property.IValueChangeListener --+   |        
                                                 |   |        
                                object --+       |   |        
                                         |       |   |        
                     data.property.IViewer --+   |   |        
                                             |   |   |        
                         data.property.IEditor --+   |        
                                                 |   |        
                        object --+               |   |        
                                 |               |   |        
               util.IEventListener --+           |   |        
                                     |           |   |        
         terminal.paintable.IPaintable --+       |   |        
                                         |       |   |        
                            object --+   |       |   |        
                                     |   |       |   |        
terminal.variable_owner.IVariableOwner --+       |   |        
                                         |       |   |        
                            object --+   |       |   |        
                                     |   |       |   |        
           terminal.sizeable.ISizeable --+       |   |        
                                         |       |   |        
                      component.IComponent --+   |   |        
                                             |   |   |        
                          component.IFocusable --+   |        
                                                 |   |        
                                      field.IField --+        
                                                     |        
                                        object --+   |        
                                                 |   |        
                    event.action.IShortcutNotifier --+        
                                                     |        
                                        object --+   |        
                                                 |   |        
       data.property.IReadOnlyStatusChangeNotifier --+        
                                                     |        
                                        object --+   |        
                                                 |   |        
       data.property.IReadOnlyStatusChangeListener --+        
                                                     |        
                          abstract_field.AbstractField --+    
                                                         |    
                                            object --+   |    
                                                     |   |    
                             data.container.IContainer --+    
                                                         |    
                                            object --+   |    
                                                     |   |    
                                data.container.IViewer --+    
                                                         |    
                                            object --+   |    
                                                     |   |    
             data.container.IPropertySetChangeListener --+    
                                                         |    
                                            object --+   |    
                                                     |   |    
             data.container.IPropertySetChangeNotifier --+    
                                                         |    
                                            object --+   |    
                                                     |   |    
                 data.container.IItemSetChangeNotifier --+    
                                                         |    
                                            object --+   |    
                                                     |   |    
                 data.container.IItemSetChangeListener --+    
                                                         |    
                            abstract_select.AbstractSelect --+
                                                             |
                                            object --+       |
                                                     |       |
                             data.container.IContainer --+   |
                                                         |   |
                              data.container.IHierarchical --+
                                                             |
                                                object --+   |
                                                         |   |
                                   event.action.IContainer --+
                                                             |
                                            object --+       |
                                                     |       |
             event.item_click_event.IItemClickNotifier --+   |
                                                         |   |
                   event.item_click_event.IItemClickSource --+
                                                             |
                                                object --+   |
                                                         |   |
                 event.item_click_event.IItemClickNotifier --+
                                                             |
                                    object --+               |
                                             |               |
                           util.IEventListener --+           |
                                                 |           |
                     terminal.paintable.IPaintable --+       |
                                                     |       |
                                        object --+   |       |
                                                 |   |       |
            terminal.variable_owner.IVariableOwner --+       |
                                                     |       |
                                        object --+   |       |
                                                 |   |       |
                       terminal.sizeable.ISizeable --+       |
                                                     |       |
                                  component.IComponent --+   |
                                                         |   |
                          event.dd.drag_source.IDragSource --+
                                                             |
                                    object --+               |
                                             |               |
                           util.IEventListener --+           |
                                                 |           |
                     terminal.paintable.IPaintable --+       |
                                                     |       |
                                        object --+   |       |
                                                 |   |       |
            terminal.variable_owner.IVariableOwner --+       |
                                                     |       |
                                        object --+   |       |
                                                 |   |       |
                       terminal.sizeable.ISizeable --+       |
                                                     |       |
                                  component.IComponent --+   |
                                                         |   |
                          event.dd.drop_target.IDropTarget --+
                                                             |
                                                            Tree

Tree component. A Tree can be used to select an item (or multiple items) from a hierarchical set of items.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self, caption=None, dataSource=None)
Creates a new tree with caption and connect it to a IContainer.
source code
 
isExpanded(self, itemId)
Check is an item is expanded
source code
 
expandItem(self, itemId, sendChildTree=None)
Expands an item.
source code
 
requestRepaint(self)
Requests that the paintable should be repainted as soon as possible.
source code
 
requestPartialRepaint(self) source code
 
expandItemsRecursively(self, startItemId)
Expands the items recursively
source code
 
collapseItem(self, itemId)
Collapses an item.
source code
 
collapseItemsRecursively(self, startItemId)
Collapses the items recursively.
source code
 
isSelectable(self)
Returns the current selectable state.
source code
 
setSelectable(self, selectable)
Sets the selectable state.
source code
 
setMultiselectMode(self, mode)
Sets the behavior of the multiselect mode
source code
 
getMultiselectMode(self)
Returns the mode the multiselect is in.
source code
 
changeVariables(self, source, variables)
Invoked when the value of a variable has changed.
source code
 
handleSelectedItems(self, variables)
Handles the selection
source code
 
paintContent(self, target)
Paints any needed component-specific things to the given UIDL stream.
source code
 
areChildrenAllowed(self, itemId)
Tests if the Item with given ID can have any children.
source code
 
getChildren(self, itemId)
Gets the IDs of all Items that are children of the specified Item.
source code
 
getParent(self, itemId=None)
Gets the ID of the parent Item of the specified Item.
source code
 
hasChildren(self, itemId)
Tests if the Item specified with itemId has child Items.
source code
 
isRoot(self, itemId)
Tests if the Item specified with itemId is a root Item.
source code
 
rootItemIds(self)
Gets the IDs of all Items in the container that don't have a parent.
source code
 
setChildrenAllowed(self, itemId, areChildrenAllowed)
Sets the given Item's capability to have children.
source code
 
setParent(self, itemId, newParentId=None)
Sets the parent component of the component.
source code
 
setContainerDataSource(self, newDataSource)
Sets the IContainer that serves as the data source of the viewer.
source code
 
addListener(self, listener, iface)
Adds the expand/collapse listener.
source code
 
addCallback(self, callback, eventType=None, *args) source code
 
removeListener(self, listener, iface=None)
Removes the expand/collapse listener.
source code
 
removeCallback(self, callback, eventType=None) source code
 
fireExpandEvent(self, itemId)
Emits the expand event.
source code
 
fireCollapseEvent(self, itemId)
Emits collapse event.
source code
 
addActionHandler(self, actionHandler)
Adds an action handler.
source code
 
removeActionHandler(self, actionHandler)
Removes an action handler.
source code
 
removeAllActionHandlers(self)
Removes all action handlers
source code
 
getVisibleItemIds(self)
Gets the visible item ids.
source code
 
setNullSelectionItemId(self, nullSelectionItemId)
Tree does not support setNullSelectionItemId.
source code
 
setNewItemsAllowed(self, allowNewOptions)
Adding new items is not supported.
source code
 
setLazyLoading(self, useLazyLoading)
Tree does not support lazy options loading mode.
source code
 
setItemStyleGenerator(self, itemStyleGenerator)
Sets the IItemStyleGenerator to be used with this tree.
source code
 
getItemStyleGenerator(self)
Returns: the current IItemStyleGenerator for this tree.
source code
 
removeItem(self, itemId)
Removes the Item identified by ItemId from the IContainer.
source code
 
getDropHandler(self)
Returns: the drop handler that will receive the dragged data or null if drops are not currently accepted
source code
 
setDropHandler(self, dropHandler) source code
 
translateDropTargetDetails(self, clientVariables)
Called before the DragAndDropEvent is passed to DropHandler.
source code
 
key(self, itemId)
Helper API for TreeDropCriterion
source code
 
setDragMode(self, dragMode)
Sets the drag mode that controls how Tree behaves as a IDragSource.
source code
 
getDragMode(self)
Returns: the drag mode that controls how Tree behaves as a IDragSource.
source code
 
getTransferable(self, payload)
IDragSource may convert data added by client side component to meaningful values for server side developer or add other data based on it.
source code
 
setItemDescriptionGenerator(self, generator)
Set the item description generator which generates tooltips for the tree items
source code
 
getItemDescriptionGenerator(self)
Get the item description generator which generates tooltips for tree items.
source code

Inherited from abstract_select.AbstractSelect: __len__, addContainerProperty, addItem, attach, containerItemSetChange, containerPropertySetChange, containsId, detach, fireItemSetChange, firePropertySetChange, getCaptionChangeListener, getContainerDataSource, getContainerProperty, getContainerPropertyIds, getItem, getItemCaption, getItemCaptionMode, getItemCaptionPropertyId, getItemIcon, getItemIconPropertyId, getItemIds, getListeners, getNewItemHandler, getNullSelectionItemId, getType, getValue, isEmpty, isMultiSelect, isNewItemsAllowed, isNullSelectionAllowed, isSelected, paintItem, removeAllItems, removeContainerProperty, select, setItemCaption, setItemCaptionMode, setItemCaptionPropertyId, setItemIcon, setItemIconPropertyId, setMultiSelect, setNewItemHandler, setNullSelectionAllowed, setValue, size, unselect

Inherited from abstract_field.AbstractField: __str__, addShortcutListener, addValidator, commit, discard, fireReadOnlyStatusChange, fireValueChange, focus, getActionManager, getErrorMessage, getPropertyDataSource, getRequiredError, getTabIndex, getValidators, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isValidationVisible, isWriteThrough, readOnlyStatusChange, readValueFromProperty, removeShortcutListener, removeValidator, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setRequiredError, setTabIndex, setValidationVisible, setWriteThrough, shouldHideErrors, validate, valueChange

Inherited from abstract_component.AbstractComponent: __getstate__, __setstate__, addStyleName, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, fireRequestRepaintEvent, getApplication, getCSSHeight, getCSSWidth, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getLocale, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, hasListeners, isEnabled, isImmediate, isVisible, paint, parseStringSize, registerCallback, registerListener, removeStyleName, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidthUnits, withdrawCallback, withdrawListener

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

Class Methods [hide private]

Inherited from abstract_field.AbstractField: constructField

Class Variables [hide private]
  CLIENT_WIDGET = None
hash(x)

Inherited from abstract_select.AbstractSelect: ITEM_CAPTION_MODE_EXPLICIT, ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID, ITEM_CAPTION_MODE_ICON_ONLY, ITEM_CAPTION_MODE_ID, ITEM_CAPTION_MODE_INDEX, ITEM_CAPTION_MODE_ITEM, ITEM_CAPTION_MODE_PROPERTY

Inherited from abstract_component.AbstractComponent: SIZE_PATTERN

Inherited from terminal.sizeable.ISizeable: SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS, UNIT_SYMBOLS

Instance Variables [hide private]
  _expanded
Set of expanded nodes.
  _actionHandlers
List of action handlers.
  _actionMapper
Action mapper.
  _selectable
Is the tree selectable on the client side.
  _partialUpdate
Flag to indicate sub-tree loading
  _expandedItemId
Holds a itemId which was recently expanded
  _initialPaint
a flag which indicates initial paint.
  _itemDescriptionGenerator
Item tooltip generator

Inherited from abstract_select.AbstractSelect: itemIdMapper, items

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, caption=None, dataSource=None)
(Constructor)

source code 

Creates a new tree with caption and connect it to a IContainer.

Parameters:
  • args - tuple of the form
    • ()
    • (caption)
      1. the caption of the component.
    • (caption, dataSource)
      1. the caption of the component.
      2. the IContainer datasource to be selected from by this select.
    • (caption, options)
      1. the caption of the component.
      2. the Collection containing the options.
Overrides: object.__init__

isExpanded(self, itemId)

source code 

Check is an item is expanded

Parameters:
  • itemId - the item id.
Returns:
true iff the item is expanded.

expandItem(self, itemId, sendChildTree=None)

source code 

Expands an item.

Parameters:
  • itemId - the item id.
  • sendChildTree - flag to indicate if client needs subtree or not (may be cached)
Returns:
True iff the expand operation succeeded

requestRepaint(self)

source code 

Requests that the paintable should be repainted as soon as possible.

Overrides: terminal.paintable.IPaintable.requestRepaint
(inherited documentation)

expandItemsRecursively(self, startItemId)

source code 

Expands the items recursively

Expands all the children recursively starting from an item. Operation succeeds only if all expandable items are expanded.

Returns:
True iff the expand operation succeeded

collapseItem(self, itemId)

source code 

Collapses an item.

Parameters:
  • itemId - the item id.
Returns:
True iff the collapse operation succeeded

collapseItemsRecursively(self, startItemId)

source code 

Collapses the items recursively.

Collapse all the children recursively starting from an item. Operation succeeds only if all expandable items are collapsed.

Returns:
True iff the collapse operation succeeded

isSelectable(self)

source code 

Returns the current selectable state. Selectable determines if the a node can be selected on the client side. Selectable does not affect setValue or select.

The tree is selectable by default.

Returns:
the current selectable state.

setSelectable(self, selectable)

source code 

Sets the selectable state. Selectable determines if the a node can be selected on the client side. Selectable does not affect setValue or select.

The tree is selectable by default.

Parameters:
  • selectable - The new selectable state.

setMultiselectMode(self, mode)

source code 

Sets the behavior of the multiselect mode

Parameters:
  • mode - The mode to set

getMultiselectMode(self)

source code 

Returns the mode the multiselect is in. The mode controls how multiselection can be done.

Returns:
The mode

changeVariables(self, source, variables)

source code 

Invoked when the value of a variable has changed.

Parameters:
  • source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
  • variables - the Mapping from variable names to new variable values.
Overrides: terminal.variable_owner.IVariableOwner.changeVariables
(inherited documentation)

handleSelectedItems(self, variables)

source code 

Handles the selection

Parameters:
  • variables - The variables sent to the server from the client

paintContent(self, target)

source code 

Paints any needed component-specific things to the given UIDL stream.

Parameters:
  • target - the Paint Event.
Raises:
Overrides: abstract_component.AbstractComponent.paintContent

areChildrenAllowed(self, itemId)

source code 

Tests if the Item with given ID can have any children.

Parameters:
  • itemId - ID of the Item in the container whose child capability is to be tested
Returns:
True if the specified Item exists in the IContainer and it can have children, False if it's not found from the container or it can't have children.
Overrides: data.container.IHierarchical.areChildrenAllowed

getChildren(self, itemId)

source code 

Gets the IDs of all Items that are children of the specified Item.

Parameters:
  • itemId - ID of the Item whose children the caller is interested in
Returns:
An iterable containing the IDs of all other Items that are children in the container hierarchy
Overrides: data.container.IHierarchical.getChildren

getParent(self, itemId=None)

source code 

Gets the ID of the parent Item of the specified Item.

Parameters:
  • itemId - ID of the Item whose parent the caller wishes to find out.
Returns:
the parent component
Overrides: component.IComponent.getParent

See Also: IHierarchical.getParent

hasChildren(self, itemId)

source code 

Tests if the Item specified with itemId has child Items.

Parameters:
  • itemId - ID of the Item to be tested
Returns:
True if the specified Item has children, False if not (is a leaf)
Overrides: data.container.IHierarchical.hasChildren

isRoot(self, itemId)

source code 

Tests if the Item specified with itemId is a root Item.

Parameters:
  • itemId - ID of the Item whose root status is to be tested
Returns:
True if the specified Item is a root, False if not
Overrides: data.container.IHierarchical.isRoot

rootItemIds(self)

source code 

Gets the IDs of all Items in the container that don't have a parent.

Returns:
An iterable containing IDs of all root elements of the container
Overrides: data.container.IHierarchical.rootItemIds

setChildrenAllowed(self, itemId, areChildrenAllowed)

source code 

Sets the given Item's capability to have children.

Parameters:
  • itemId - ID of the Item in the container whose child capability is to be set
  • areChildrenAllowed - boolean value specifying if the Item can have children or not
Returns:
True if the operation succeeded, False if not
Overrides: data.container.IHierarchical.setChildrenAllowed

setParent(self, itemId, newParentId=None)

source code 

Sets the parent component of the component.

This method automatically calls attach if the parent becomes attached to the application, regardless of whether it was attached previously. Conversely, if the parent is None and the component is attached to the application, detach is called for the component.

This method is rarely called directly. The ComponentContainer.addComponent method is normally used for adding components to a container and it will call this method implicitly.

It is not possible to change the parent without first setting the parent to None.

Parameters:
  • parent - the parent component
Returns:
True if the operation succeeded, False if not
Raises:
  • ValueError - if a parent is given even though the component already has a parent
Overrides: component.IComponent.setParent
(inherited documentation)

setContainerDataSource(self, newDataSource)

source code 

Sets the IContainer that serves as the data source of the viewer.

Parameters:
  • newDataSource - the new data source.
Overrides: data.container.IViewer.setContainerDataSource

See Also: container.Viewer.setContainerDataSource

addListener(self, listener, iface)

source code 

Adds the expand/collapse listener.

Parameters:
  • listener - the listener to be added.
Raises:
  • ValueError - unless method has a match in object
Overrides: data.container.IItemSetChangeNotifier.addListener

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

source code 
Overrides: data.container.IItemSetChangeNotifier.addCallback

removeListener(self, listener, iface=None)

source code 

Removes the expand/collapse listener.

Parameters:
  • listener - the listener to be removed.
Overrides: data.container.IItemSetChangeNotifier.removeListener

removeCallback(self, callback, eventType=None)

source code 
Overrides: data.container.IItemSetChangeNotifier.removeCallback

fireExpandEvent(self, itemId)

source code 

Emits the expand event.

Parameters:
  • itemId - the item id.

fireCollapseEvent(self, itemId)

source code 

Emits collapse event.

Parameters:
  • itemId - the item id.

addActionHandler(self, actionHandler)

source code 

Adds an action handler.

Parameters:
  • actionHandler - the new handler to be added.
Overrides: event.action.IContainer.addActionHandler

removeActionHandler(self, actionHandler)

source code 

Removes an action handler.

Parameters:
  • actionHandler - the handler to be removed.
Overrides: event.action.IContainer.removeActionHandler

getVisibleItemIds(self)

source code 

Gets the visible item ids.

Overrides: abstract_select.AbstractSelect.getVisibleItemIds

See Also: Select.getVisibleItemIds

setNullSelectionItemId(self, nullSelectionItemId)

source code 

Tree does not support setNullSelectionItemId.

Parameters:
  • nullSelectionItemId - the nullSelectionItemId to set.
Overrides: abstract_select.AbstractSelect.setNullSelectionItemId

setNewItemsAllowed(self, allowNewOptions)

source code 

Adding new items is not supported.

Parameters:
  • allowNewOptions - the New value of property allowNewOptions.
Raises:
  • NotImplementedError - if set to true.
Overrides: abstract_select.AbstractSelect.setNewItemsAllowed

See Also: Select.setNewItemsAllowed

setLazyLoading(self, useLazyLoading)

source code 

Tree does not support lazy options loading mode. Setting this true will throw NotImplementedError.

See Also: Select.setLazyLoading

setItemStyleGenerator(self, itemStyleGenerator)

source code 

Sets the IItemStyleGenerator to be used with this tree.

Parameters:
  • itemStyleGenerator - item style generator or null to remove generator

getItemStyleGenerator(self)

source code 
Returns:
the current IItemStyleGenerator for this tree. None if IItemStyleGenerator is not set.

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: data.container.IContainer.removeItem
(inherited documentation)

getDropHandler(self)

source code 
Returns:
the drop handler that will receive the dragged data or null if drops are not currently accepted
Overrides: event.dd.drop_target.IDropTarget.getDropHandler
(inherited documentation)

translateDropTargetDetails(self, clientVariables)

source code 

Called before the DragAndDropEvent is passed to DropHandler. Implementation may for example translate the drop target details provided by the client side (drop target) to meaningful server side values. If null is returned the terminal implementation will automatically create a TargetDetails with raw client side data.

Parameters:
  • clientVariables - data passed from the DropTargets client side counterpart.
Returns:
A DropTargetDetails object with the translated data or null to use a default implementation.
Overrides: event.dd.drop_target.IDropTarget.translateDropTargetDetails
(inherited documentation)

getDragMode(self)

source code 
Returns:
the drag mode that controls how Tree behaves as a IDragSource.

See Also: TreeDragMode

getTransferable(self, payload)

source code 

IDragSource may convert data added by client side component to meaningful values for server side developer or add other data based on it.

For example Tree converts item identifiers to generated string keys for the client side. Muntjac developer don't and can't know anything about these generated keys, only about item identifiers. When tree node is dragged client puts that key to Transferables client side counterpart. In Tree.getTransferable the key is converted back to item identifier that the server side developer can use.

Parameters:
  • rawVariables - the data that client side initially included in Transferables client side counterpart.
Returns:
the Transferable instance that will be passed to DropHandler (and/or AcceptCriterion)
Overrides: event.dd.drag_source.IDragSource.getTransferable
(inherited documentation)

setItemDescriptionGenerator(self, generator)

source code 

Set the item description generator which generates tooltips for the tree items

Parameters:
  • generator - The generator to use or null to disable

Instance Variable Details [hide private]

_initialPaint

a flag which indicates initial paint. After this flag set