3
8Ad]X^ ã               @   sô   d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZ ddlmZmZmZmZ ddlmZ G dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZ G dd„ deƒZ!dS )z_ Defines the tree node descriptor used by the tree editor and tree editor
    factory classes.
é    )Úabsolute_importN)Ú	AdaptedToÚAdapterÚAnyÚBoolÚCallableÚDictÚEitherÚHasPrivateTraitsÚInstanceÚ	InterfaceÚisinterfaceÚListÚPropertyÚStrÚcached_property)ÚSequenceTypesÚget_resource_pathÚxgetattrÚxsetattré   )ÚAViewc                   sl  e Zd ZdZeZeZeZeZeZ	e
dƒZe
dƒZe
dƒZe
dƒZe
dƒZe
dƒZe
dƒZe
dƒZeeƒZeeƒZeeƒZedd�Zedd�ZeZeedeƒƒZeZeZ eZ!eZ"eZ#e$Z%eZ&edƒZ'edƒZ(ed	ƒZ)eZ*eZ+eZ,eZ-e.Z/‡ fd
d„Z0e1dd„ ƒZ2e1dd„ ƒZ3dd„ Z4dd„ Z5dd„ Z6dd„ Z7dd„ Z8dd„ Z9dd„ Z:dd„ Z;d d!„ Z<d"d#„ Z=d$d%„ Z>d&d'„ Z?d(d)„ Z@d*d+„ ZAd,d-„ ZBd.d/„ ZCd0d1„ ZDd2d3„ ZEd4d5„ ZFd6d7„ ZGd8d9„ ZHd:d;„ ZId<d=„ ZJdgd?d@„ZKdAdB„ ZLdCdD„ ZMdEdF„ ZNdGdH„ ZOdIdJ„ ZPdKdL„ ZQdMdN„ ZRdOdP„ ZSdQdR„ ZTdSdT„ ZUdUdV„ ZVdWdX„ ZWdYdZ„ ZXd[d\„ ZYd]d^„ ZZd_d`„ Z[dadb„ Z\dcdd„ Z]dedf„ Z^‡  Z_S )hÚTreeNodez^ Represents a tree node. Used by the tree editor and tree editor factory
        classes.
    TFÚnode_for)Z
depends_onNz<item>z<group>z<open>c                s(   t t| ƒjf |Ž | jdkr$tƒ | _d S )NÚ )Úsuperr   Ú__init__Ú	icon_pathr   )ÚselfÚtraits)Ú	__class__© ún/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/traitsui-6.1.2-py3.6.egg/traitsui/tree_node.pyr   ±   s    
zTreeNode.__init__c             C   s   t dd„ | jD ƒƒS )Nc             S   s   g | ]}t |ƒs|‘qS r!   )r   )Ú.0Úklassr!   r!   r"   ú
<listcomp>º   s    z0TreeNode._get_node_for_class.<locals>.<listcomp>)Útupler   )r   r!   r!   r"   Ú_get_node_for_class¸   s    zTreeNode._get_node_for_classc             C   s   dd„ | j D ƒS )Nc             S   s   g | ]}t |ƒr|‘qS r!   )r   )r#   r$   r!   r!   r"   r%   ¿   s    z4TreeNode._get_node_for_interface.<locals>.<listcomp>)r   )r   r!   r!   r"   Ú_get_node_for_interface½   s    z TreeNode._get_node_for_interfacec             C   s
   | j dkS )z8 Returns whether this object can have children.
        r   )Úchildren)r   Úobjectr!   r!   r"   Úallows_childrenÈ   s    zTreeNode.allows_childrenc             C   s   t | j|ƒƒdkS )z2 Returns whether the object has children.
        r   )ÚlenÚget_children)r   r*   r!   r!   r"   Úhas_childrenÑ   s    zTreeNode.has_childrenc             C   s   t || jdƒS )z% Gets the object's children.
        N)Úgetattrr)   )r   r*   r!   r!   r"   r-   Ú   s    zTreeNode.get_childrenc             C   s   | j S )z0 Gets the object's children identifier.
        )r)   )r   r*   r!   r!   r"   Úget_children_idã   s    zTreeNode.get_children_idc             C   s   | j |ƒ}|j|ƒ dS )z3 Appends a child to the object's children.
        N)r-   Úappend)r   r*   Úchildr)   r!   r!   r"   Úappend_childì   s    
zTreeNode.append_childc             C   s   | j |ƒ}|g|||…< dS )z5 Inserts a child into the object's children.
        N)r-   )r   r*   Úindexr2   r)   r!   r!   r"   Úinsert_childö   s    
zTreeNode.insert_childc             C   s   dS )a}   Checks whether a specified object can be deleted.

        The following return values are possible:

        - **True** if the object should be deleted with no further prompting.
        - **False** if the object should not be deleted.
        - Anything else: Caller should take its default action (which might
          include prompting the user to confirm deletion).
        Nr!   )r   r*   r!   r!   r"   Úconfirm_delete  s    
zTreeNode.confirm_deletec             C   s   | j |ƒ|= dS )zJ Deletes a child at a specified index from the object's children.
        N)r-   )r   r*   r4   r!   r!   r"   Údelete_child  s    zTreeNode.delete_childc             C   s   |j || j|dd� dS )zb Sets up or removes a listener for children being replaced on a
        specified object.
        Úfast_ui)ÚremoveÚdispatchN)Úon_trait_changer)   )r   r*   Úlistenerr9   r!   r!   r"   Úwhen_children_replaced  s    zTreeNode.when_children_replacedc             C   s   |j || jd |dd� dS )za Sets up or removes a listener for children being changed on a
        specified object.
        Ú_itemsr8   )r9   r:   N)r;   r)   )r   r*   r<   r9   r!   r!   r"   Úwhen_children_changed)  s    zTreeNode.when_children_changedc             C   sH   | j }|dd… dkr"|dd… S t||dƒ}| jdkr<|S | j||ƒS )z; Gets the label to display for a specified object.
        Nr   ú=r   )Úlabelr   Ú	formatter)r   r*   rA   r!   r!   r"   Ú	get_label4  s    
zTreeNode.get_labelc             C   s&   | j }|dd… dkr"t|||ƒ dS )z0 Sets the label for a specified object.
        Nr   r@   )rA   r   )r   r*   rA   Ú
label_namer!   r!   r"   Ú	set_labelF  s    zTreeNode.set_labelc                sp   | j }|dd… dkrld|ˆˆ f}|s@‡ ‡fdd„}|| j|< n| jj|dƒ}|dkrZdS ˆj|||dd� dS )	zb Sets up or removes a listener for the label being changed on a
        specified object.
        Nr   r@   rA   c                s   ˆ ˆ||ƒS )z2 Ensure listener gets called with correct object. r!   )ÚtargetÚnameÚnew)r<   r*   r!   r"   Úwrapped_listenerY  s    z5TreeNode.when_label_changed.<locals>.wrapped_listenerÚui)r9   r:   )rA   Ú_listener_cacheÚpopr;   )r   r*   r<   r9   rA   ÚmemorI   r!   )r<   r*   r"   Úwhen_label_changedQ  s    
zTreeNode.when_label_changedc             C   sZ   | j }t||g ƒ}g }x>tjj| j|ƒD ]*\}}|dkrD|j|ƒ q(|j||ƒƒ q(W |S )z@ Get the labels for any columns that have been defined.
        N)Úcolumn_labelsr   ÚsixÚmovesÚzip_longestÚcolumn_formattersr1   )r   r*   ÚtraitÚlabelsÚ	formattedrB   rA   r!   r!   r"   Úget_column_labelsf  s    zTreeNode.get_column_labelsc                s~   | j }|dkrzd|ˆˆ f}|s8‡ ‡fdd„}|| j|< n| jj|dƒ}|dkrRdS ˆj|||dd� ˆj||d |dd� dS )	ac   Sets up or removes a listener for the column labels being changed on
        a specified object.

        This will fire when either the list is reassigned or when it is
        modified. I.e., it listens both to the trait change event and the
        trait_items change event. Implement the listener appropriately to
        handle either case.
        r   Zcolumn_labelc                s   ˆ ˆ||ƒS )z2 Ensure listener gets called with correct object. r!   )rF   rG   rH   )r<   r*   r!   r"   rI   …  s    z<TreeNode.when_column_labels_change.<locals>.wrapped_listenerNrJ   )r9   r:   r>   )rO   rK   rL   r;   )r   r*   r<   r9   rT   rM   rI   r!   )r<   r*   r"   Úwhen_column_labels_changex  s    	
z"TreeNode.when_column_labels_changec             C   sT   | j }|dkr|S |dd… dkr.|dd… S t||dƒ}| jdkrH|S | j||ƒS )z= Gets the tooltip to display for a specified object.
        r   Nr   r@   )Útooltipr   Útooltip_formatter)r   r*   rY   r!   r!   r"   Úget_tooltip˜  s    
zTreeNode.get_tooltipc             C   s    | j |ƒs| jS |r| jS | jS )z2 Returns the icon for a specified object.
        )r+   Ú	icon_itemÚ	icon_openÚ
icon_group)r   r*   Úis_expandedr!   r!   r"   Úget_icon­  s
    
zTreeNode.get_iconc             C   s   | j S )z; Returns the path used to locate an object's icon.
        )r   )r   r*   r!   r!   r"   Úget_icon_path¼  s    zTreeNode.get_icon_pathc             C   s   | j S )zq Returns the name to use when adding a new object instance
            (displayed in the "New" submenu).
        )rG   )r   r*   r!   r!   r"   Úget_nameÆ  s    zTreeNode.get_namec             C   s   | j S )z6 Gets the view to use when editing an object.
        )Úview)r   r*   r!   r!   r"   Úget_viewÐ  s    zTreeNode.get_viewc             C   s   | j S )z= Returns the right-click context menu for an object.
        )Úmenu)r   r*   r!   r!   r"   Úget_menuÙ  s    zTreeNode.get_menuc             C   s$   | j }t|tjƒr t|||d�}|S )N)Údefault)Ú
backgroundÚ
isinstancerP   Ústring_typesr   )r   r*   rh   r!   r!   r"   Úget_backgroundÞ  s    zTreeNode.get_backgroundc             C   s$   | j }t|tjƒr t|||d�}|S )N)rg   )Ú
foregroundri   rP   rj   r   )r   r*   rl   r!   r!   r"   Úget_foregroundä  s    zTreeNode.get_foregroundr   c             C   s   | j S )z0 Return the renderer for the object and column. )Úrenderer)r   r*   Úcolumnr!   r!   r"   Úget_rendererê  s    zTreeNode.get_rendererc             C   s   | j S )z? Returns whether the object's children can be renamed.
        )Úrename)r   r*   r!   r!   r"   Ú
can_renameò  s    zTreeNode.can_renamec             C   s   | j S )z4 Returns whether the object can be renamed.
        )Ú	rename_me)r   r*   r!   r!   r"   Úcan_rename_meû  s    zTreeNode.can_rename_mec             C   s   | j S )z> Returns whether the object's children can be copied.
        )Úcopy)r   r*   r!   r!   r"   Úcan_copy  s    zTreeNode.can_copyc             C   s   | j S )z? Returns whether the object's children can be deleted.
        )Údelete)r   r*   r!   r!   r"   Ú
can_delete  s    zTreeNode.can_deletec             C   s   | j S )z4 Returns whether the object can be deleted.
        )Ú	delete_me)r   r*   r!   r!   r"   Úcan_delete_me  s    zTreeNode.can_delete_mec             C   s   | j S )zW Returns whether the object's children can be inserted (vs.
        appended).
        )Úinsert)r   r*   r!   r!   r"   Ú
can_insert   s    zTreeNode.can_insertc             C   s   | j S )zW Returns whether the object's children should be automatically
        opened.
        )Ú	auto_open)r   r*   r!   r!   r"   Úcan_auto_open*  s    zTreeNode.can_auto_openc             C   s   | j S )zW Returns whether the object's children should be automatically
        closed.
        )Ú
auto_close)r   r*   r!   r!   r"   Úcan_auto_close4  s    zTreeNode.can_auto_closec             C   s   t || jƒp|j| jŽ S )zK Returns whether this is the node that handles a specified object.
        )ri   Únode_for_classÚhas_traits_interfaceÚnode_for_interface)r   r*   r!   r!   r"   Úis_node_for?  s    zTreeNode.is_node_forc             C   sN   | j |ƒ}| j|ƒrdS x0| jD ]&}t|ƒtkr8|d }t||ƒr dS q W dS )zB Returns whether a given object is droppable on the node.
        Tr   F)Ú
_class_forÚ
is_addableÚmoveÚtyper   Ú
issubclass)r   r*   Ú
add_objectr$   Úitemr!   r!   r"   Úcan_addI  s    


zTreeNode.can_addc             C   s   | j S )zF Returns the list of classes that can be added to the object.
        )Úadd)r   r*   r!   r!   r"   Úget_add\  s    zTreeNode.get_addc             C   s   |S )z< Returns a draggable version of a specified object.
        r!   )r   r*   r!   r!   r"   Úget_drag_objecte  s    zTreeNode.get_drag_objectc             C   sd   | j |ƒ}| j|ƒr|S xF| jD ]<}t|ƒtkrNt||d ƒr\|d ||ƒS q t||ƒr |S q W |S )z< Returns a droppable version of a specified object.
        r   r   )r…   r†   r‡   rˆ   r   r‰   )r   r*   Údropped_objectr$   r‹   r!   r!   r"   Údrop_objectn  s    


zTreeNode.drop_objectc             C   s   | j dk	r| j |ƒ dS dS )z+ Handles an object being selected.
        NT)Ú	on_select)r   r*   r!   r!   r"   Úselect‚  s    

zTreeNode.selectc             C   s   | j dk	r| j |ƒ dS dS )z* Handles an object being clicked.
        NT)Úon_click)r   r*   r!   r!   r"   Úclick�  s    

zTreeNode.clickc             C   s   | j dk	r| j |ƒ dS dS )z1 Handles an object being double-clicked.
        NT)Ú	on_dclick)r   r*   r!   r!   r"   Údclickœ  s    

zTreeNode.dclickc             C   s   | j dk	r| j |ƒ dS dS )z, Handles an object being activated.
        NT)Úon_activated)r   r*   r!   r!   r"   Ú	activated©  s    

zTreeNode.activatedc             C   s6   x0| j D ]&}t|ƒtkr |d }t||ƒrdS qW dS )zL Returns whether a specified object class can be added to the node.
        r   TF)r�   rˆ   r   r‰   )r   r$   r‹   r!   r!   r"   r†   ¶  s    
zTreeNode.is_addablec             C   s   t |tƒr|S |jS )z) Returns the class of an object.
        )ri   rˆ   r    )r   r*   r!   r!   r"   r…   Æ  s    
zTreeNode._class_for)r   )`Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r)   rA   rO   rY   rG   r   rq   rs   ru   rw   ry   r{   r}   r   r   r   r�   r‡   r   r   r�   rƒ   r   rB   r	   rS   rZ   r’   r”   r–   r˜   r   rc   re   r\   r^   r]   r   rh   rl   rn   r   rK   r   r   r'   r(   r+   r.   r-   r0   r3   r5   r6   r7   r=   r?   rC   rE   rN   rW   rX   r[   r`   ra   rb   rd   rf   rk   rm   rp   rr   rt   rv   rx   rz   r|   r~   r€   r„   rŒ   rŽ   r�   r‘   r“   r•   r—   r™   r†   r…   Ú__classcell__r!   r!   )r    r"   r   /   s¤   

				

 

	
				



		r   c               @   s4  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%dGdH„ Z&dIdJ„ Z'dKS )LÚ	ITreeNodec             C   s   dS )z8 Returns whether this object can have children.
        Nr!   )r   r!   r!   r"   r+   Õ  s    zITreeNode.allows_childrenc             C   s   dS )z2 Returns whether the object has children.
        Nr!   )r   r!   r!   r"   r.   Ù  s    zITreeNode.has_childrenc             C   s   dS )z% Gets the object's children.
        Nr!   )r   r!   r!   r"   r-   Ý  s    zITreeNode.get_childrenc             C   s   dS )z0 Gets the object's children identifier.
        Nr!   )r   r!   r!   r"   r0   á  s    zITreeNode.get_children_idc             C   s   dS )z3 Appends a child to the object's children.
        Nr!   )r   r2   r!   r!   r"   r3   å  s    zITreeNode.append_childc             C   s   dS )z5 Inserts a child into the object's children.
        Nr!   )r   r4   r2   r!   r!   r"   r5   é  s    zITreeNode.insert_childc             C   s   dS )a}   Checks whether a specified object can be deleted.

        The following return values are possible:

        - **True** if the object should be deleted with no further prompting.
        - **False** if the object should not be deleted.
        - Anything else: Caller should take its default action (which might
          include prompting the user to confirm deletion).
        Nr!   )r   r!   r!   r"   r6   í  s    zITreeNode.confirm_deletec             C   s   dS )zJ Deletes a child at a specified index from the object's children.
        Nr!   )r   r4   r!   r!   r"   r7   ø  s    zITreeNode.delete_childc             C   s   dS )zf Sets up or removes a listener for children being replaced on a
            specified object.
        Nr!   )r   r<   r9   r!   r!   r"   r=   ü  s    z ITreeNode.when_children_replacedc             C   s   dS )ze Sets up or removes a listener for children being changed on a
            specified object.
        Nr!   )r   r<   r9   r!   r!   r"   r?     s    zITreeNode.when_children_changedc             C   s   dS )z; Gets the label to display for a specified object.
        Nr!   )r   r!   r!   r"   rC     s    zITreeNode.get_labelc             C   s   dS )z0 Sets the label for a specified object.
        Nr!   )r   rA   r!   r!   r"   rE   
  s    zITreeNode.set_labelc             C   s   dS )zf Sets up or removes a listener for the label being changed on a
            specified object.
        Nr!   )r   r<   r9   r!   r!   r"   rN     s    zITreeNode.when_label_changedc             C   s   dS )z@ Get the labels for any columns that have been defined.
        Nr!   )r   r*   r!   r!   r"   rW     s    zITreeNode.get_column_labelsc             C   s   dS )ac   Sets up or removes a listener for the column labels being changed on
        a specified object.

        This will fire when either the list is reassigned or when it is
        modified. I.e., it listens both to the trait change event and the
        trait_items change event. Implement the listener appropriately to handle
        either case.
        Nr!   )r   r*   r<   r9   r!   r!   r"   rX     s    z#ITreeNode.when_column_labels_changec             C   s   dS )z= Gets the tooltip to display for a specified object.
        Nr!   )r   r!   r!   r"   r[   !  s    zITreeNode.get_tooltipc             C   s   dS )z2 Returns the icon for a specified object.
        Nr!   )r   r_   r!   r!   r"   r`   %  s    zITreeNode.get_iconc             C   s   dS )z; Returns the path used to locate an object's icon.
        Nr!   )r   r!   r!   r"   ra   )  s    zITreeNode.get_icon_pathc             C   s   dS )zq Returns the name to use when adding a new object instance
            (displayed in the "New" submenu).
        Nr!   )r   r!   r!   r"   rb   -  s    zITreeNode.get_namec             C   s   dS )z6 Gets the view to use when editing an object.
        Nr!   )r   r!   r!   r"   rd   2  s    zITreeNode.get_viewc             C   s   dS )z= Returns the right-click context menu for an object.
        Nr!   )r   r!   r!   r"   rf   6  s    zITreeNode.get_menuc             C   s   dS )z? Returns whether the object's children can be renamed.
        Nr!   )r   r!   r!   r"   rr   :  s    zITreeNode.can_renamec             C   s   dS )z4 Returns whether the object can be renamed.
        Nr!   )r   r!   r!   r"   rt   >  s    zITreeNode.can_rename_mec             C   s   dS )z> Returns whether the object's children can be copied.
        Nr!   )r   r!   r!   r"   rv   B  s    zITreeNode.can_copyc             C   s   dS )z? Returns whether the object's children can be deleted.
        Nr!   )r   r!   r!   r"   rx   F  s    zITreeNode.can_deletec             C   s   dS )z4 Returns whether the object can be deleted.
        Nr!   )r   r!   r!   r"   rz   J  s    zITreeNode.can_delete_mec             C   s   dS )z[ Returns whether the object's children can be inserted (vs.
            appended).
        Nr!   )r   r!   r!   r"   r|   N  s    zITreeNode.can_insertc             C   s   dS )z[ Returns whether the object's children should be automatically
            opened.
        Nr!   )r   r!   r!   r"   r~   S  s    zITreeNode.can_auto_openc             C   s   dS )z[ Returns whether the object's children should be automatically
            closed.
        Nr!   )r   r!   r!   r"   r€   X  s    zITreeNode.can_auto_closec             C   s   dS )zB Returns whether a given object is droppable on the node.
        Nr!   )r   rŠ   r!   r!   r"   rŒ   ]  s    zITreeNode.can_addc             C   s   dS )zF Returns the list of classes that can be added to the object.
        Nr!   )r   r!   r!   r"   rŽ   a  s    zITreeNode.get_addc             C   s   dS )z< Returns a draggable version of a specified object.
        Nr!   )r   r!   r!   r"   r�   e  s    zITreeNode.get_drag_objectc             C   s   dS )z< Returns a droppable version of a specified object.
        Nr!   )r   r�   r!   r!   r"   r‘   i  s    zITreeNode.drop_objectc             C   s   dS )z+ Handles an object being selected.
        Nr!   )r   r!   r!   r"   r“   m  s    zITreeNode.selectc             C   s   dS )z* Handles an object being clicked.
        Nr!   )r   r!   r!   r"   r•   q  s    zITreeNode.clickc             C   s   dS )z1 Handles an object being double-clicked.
        Nr!   )r   r!   r!   r"   r—   u  s    zITreeNode.dclickc             C   s   dS )z, Handles an object being activated.
        Nr!   )r   r!   r!   r"   r™   y  s    zITreeNode.activatedN)(rš   r›   rœ   r+   r.   r-   r0   r3   r5   r6   r7   r=   r?   rC   rE   rN   rW   rX   r[   r`   ra   rb   rd   rf   rr   rt   rv   rx   rz   r|   r~   r€   rŒ   rŽ   r�   r‘   r“   r•   r—   r™   r!   r!   r!   r"   rŸ   Ó  sJ   
rŸ   c               @   sR  e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ ZdTd1d2„Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%dGdH„ Z&dIdJ„ Z'dKdL„ Z(dMdN„ Z)dOdP„ Z*dQdR„ Z+dSS )UÚITreeNodeAdapteraI   Abstract base class for an adapter that implements the ITreeNode
    interface.

    Usage:

    1. Create a subclass of ITreeNodeAdapter.
    2. Register the adapter to define what class (or classes) this is an
       ITreeNode adapter for (ie.
       ``register_factory(<from class>, ITreeNode, ITreeNodeAdapter)``).
    3. Override any of the following methods as necessary, using the
       ``self.adaptee`` trait to access the adapted object if needed.

    Note
    ----
    This base class implements all of the ITreeNode interface methods,
    but does not necessarily provide useful implementations for all of the
    methods. It allows you to get a new adapter class up and running quickly,
    but you should carefully review your final adapter implementation class
    to make sure it behaves correctly in your application.
    c             C   s   dS )z8 Returns whether this object can have children.
        Fr!   )r   r!   r!   r"   r+   ˜  s    z ITreeNodeAdapter.allows_childrenc             C   s   dS )z2 Returns whether the object has children.
        Fr!   )r   r!   r!   r"   r.   �  s    zITreeNodeAdapter.has_childrenc             C   s   g S )z% Gets the object's children.
        r!   )r   r!   r!   r"   r-   ¢  s    zITreeNodeAdapter.get_childrenc             C   s   dS )z0 Gets the object's children identifier.
        r   r!   )r   r!   r!   r"   r0   §  s    z ITreeNodeAdapter.get_children_idc             C   s   dS )z3 Appends a child to the object's children.
        Nr!   )r   r2   r!   r!   r"   r3   ¬  s    zITreeNodeAdapter.append_childc             C   s   dS )z5 Inserts a child into the object's children.
        Nr!   )r   r4   r2   r!   r!   r"   r5   ±  s    zITreeNodeAdapter.insert_childc             C   s   dS )a}   Checks whether a specified object can be deleted.

        The following return values are possible:

        - **True** if the object should be deleted with no further prompting.
        - **False** if the object should not be deleted.
        - Anything else: Caller should take its default action (which might
          include prompting the user to confirm deletion).
        Fr!   )r   r!   r!   r"   r6   ¶  s    
zITreeNodeAdapter.confirm_deletec             C   s   dS )zJ Deletes a child at a specified index from the object's children.
        Nr!   )r   r4   r!   r!   r"   r7   Â  s    zITreeNodeAdapter.delete_childc             C   s   dS )zf Sets up or removes a listener for children being replaced on a
            specified object.
        Nr!   )r   r<   r9   r!   r!   r"   r=   Ç  s    z'ITreeNodeAdapter.when_children_replacedc             C   s   dS )ze Sets up or removes a listener for children being changed on a
            specified object.
        Nr!   )r   r<   r9   r!   r!   r"   r?   Í  s    z&ITreeNodeAdapter.when_children_changedc             C   s   dS )z; Gets the label to display for a specified object.
        zNo label specifiedr!   )r   r!   r!   r"   rC   Ó  s    zITreeNodeAdapter.get_labelc             C   s   dS )z0 Sets the label for a specified object.
        Nr!   )r   rA   r!   r!   r"   rE   Ø  s    zITreeNodeAdapter.set_labelc             C   s   dS )zf Sets up or removes a listener for the label being changed on a
            specified object.
        Nr!   )r   r<   r9   r!   r!   r"   rN   Ý  s    z#ITreeNodeAdapter.when_label_changedc             C   s   g S )z@ Get the labels for any columns that have been defined.
        r!   )r   r!   r!   r"   rW   ã  s    z"ITreeNodeAdapter.get_column_labelsc             C   s   dS )ac   Sets up or removes a listener for the column labels being changed on
        a specified object.

        This will fire when either the list is reassigned or when it is
        modified. I.e., it listens both to the trait change event and the
        trait_items change event. Implement the listener appropriately to handle
        either case.
        Nr!   )r   r<   r9   r!   r!   r"   rX   è  s    	z*ITreeNodeAdapter.when_column_labels_changec             C   s   dS )z= Gets the tooltip to display for a specified object.
        r   r!   )r   r!   r!   r"   r[   ó  s    zITreeNodeAdapter.get_tooltipc             C   s   dS )z2 Returns the icon for a specified object.
        z<item>r!   )r   r_   r!   r!   r"   r`   ø  s    zITreeNodeAdapter.get_iconc             C   s   dS )z; Returns the path used to locate an object's icon.
        r   r!   )r   r!   r!   r"   ra   ý  s    zITreeNodeAdapter.get_icon_pathc             C   s   dS )zq Returns the name to use when adding a new object instance
            (displayed in the "New" submenu).
        r   r!   )r   r!   r!   r"   rb     s    zITreeNodeAdapter.get_namec             C   s   dS )z6 Gets the view to use when editing an object.
        Nr!   )r   r!   r!   r"   rd     s    zITreeNodeAdapter.get_viewc             C   s   dS )z= Returns the right-click context menu for an object.
        Nr!   )r   r!   r!   r"   rf     s    zITreeNodeAdapter.get_menuc             C   s   dS )z+ Returns the background for object
        Nr!   )r   r!   r!   r"   rk     s    zITreeNodeAdapter.get_backgroundc             C   s   dS )z+ Returns the foreground for object
        Nr!   )r   r!   r!   r"   rm     s    zITreeNodeAdapter.get_foregroundr   c             C   s   dS )z) Returns the renderer for object
        Nr!   )r   ro   r!   r!   r"   rp     s    zITreeNodeAdapter.get_rendererc             C   s   dS )z? Returns whether the object's children can be renamed.
        Fr!   )r   r!   r!   r"   rr   !  s    zITreeNodeAdapter.can_renamec             C   s   dS )z4 Returns whether the object can be renamed.
        Fr!   )r   r!   r!   r"   rt   &  s    zITreeNodeAdapter.can_rename_mec             C   s   dS )z> Returns whether the object's children can be copied.
        Fr!   )r   r!   r!   r"   rv   +  s    zITreeNodeAdapter.can_copyc             C   s   dS )z? Returns whether the object's children can be deleted.
        Fr!   )r   r!   r!   r"   rx   0  s    zITreeNodeAdapter.can_deletec             C   s   dS )z4 Returns whether the object can be deleted.
        Fr!   )r   r!   r!   r"   rz   5  s    zITreeNodeAdapter.can_delete_mec             C   s   dS )z[ Returns whether the object's children can be inserted (vs.
            appended).
        Fr!   )r   r!   r!   r"   r|   :  s    zITreeNodeAdapter.can_insertc             C   s   dS )z[ Returns whether the object's children should be automatically
            opened.
        Fr!   )r   r!   r!   r"   r~   @  s    zITreeNodeAdapter.can_auto_openc             C   s   dS )z[ Returns whether the object's children should be automatically
            closed.
        Fr!   )r   r!   r!   r"   r€   F  s    zITreeNodeAdapter.can_auto_closec             C   s   dS )zB Returns whether a given object is droppable on the node.
        Fr!   )r   rŠ   r!   r!   r"   rŒ   L  s    zITreeNodeAdapter.can_addc             C   s   g S )zF Returns the list of classes that can be added to the object.
        r!   )r   r!   r!   r"   rŽ   Q  s    zITreeNodeAdapter.get_addc             C   s   | j S )z< Returns a draggable version of a specified object.
        )Zadaptee)r   r!   r!   r"   r�   V  s    z ITreeNodeAdapter.get_drag_objectc             C   s   |S )z< Returns a droppable version of a specified object.
        r!   )r   r�   r!   r!   r"   r‘   [  s    zITreeNodeAdapter.drop_objectc             C   s   dS )z+ Handles an object being selected.
        Nr!   )r   r!   r!   r"   r“   `  s    zITreeNodeAdapter.selectc             C   s   dS )z* Handles an object being clicked.
        Nr!   )r   r!   r!   r"   r•   e  s    zITreeNodeAdapter.clickc             C   s   dS )z1 Handles an object being double-clicked.
        Nr!   )r   r!   r!   r"   r—   j  s    zITreeNodeAdapter.dclickc             C   s   dS )z, Handles an object being activated.
        Nr!   )r   r!   r!   r"   r™   o  s    zITreeNodeAdapter.activatedN)r   ),rš   r›   rœ   r�   r+   r.   r-   r0   r3   r5   r6   r7   r=   r?   rC   rE   rN   rW   rX   r[   r`   ra   rb   rd   rf   rk   rm   rp   rr   rt   rv   rx   rz   r|   r~   r€   rŒ   rŽ   r�   r‘   r“   r•   r—   r™   r!   r!   r!   r"   r    ‚  sR   
r    c               @   sZ  e Zd ZdZeeƒZdd„ Zdd„ Zdd„ Z	dd	„ Z
d
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ ZdTd1d2„Zd3d4„ Zd5d6„ Z d7d8„ Z!d9d:„ Z"d;d<„ Z#d=d>„ Z$d?d@„ Z%dAdB„ Z&dCdD„ Z'dEdF„ Z(dGdH„ Z)dIdJ„ Z*dKdL„ Z+dMdN„ Z,dOdP„ Z-dQdR„ Z.dSS )UÚITreeNodeAdapterBridgezÒ Private class for use by a toolkit-specific implementation of the
        TreeEditor to allow bridging the TreeNode interface used by the editor
        to the ITreeNode interface used by object adapters.
    c             C   s
   | j jƒ S )z8 Returns whether this object can have children.
        )Úadapterr+   )r   r*   r!   r!   r"   r+   „  s    z&ITreeNodeAdapterBridge.allows_childrenc             C   s
   | j jƒ S )z2 Returns whether the object has children.
        )r¢   r.   )r   r*   r!   r!   r"   r.   ‰  s    z#ITreeNodeAdapterBridge.has_childrenc             C   s
   | j jƒ S )z% Gets the object's children.
        )r¢   r-   )r   r*   r!   r!   r"   r-   Ž  s    z#ITreeNodeAdapterBridge.get_childrenc             C   s
   | j jƒ S )z0 Gets the object's children identifier.
        )r¢   r0   )r   r*   r!   r!   r"   r0   “  s    z&ITreeNodeAdapterBridge.get_children_idc             C   s   | j j|ƒS )z3 Appends a child to the object's children.
        )r¢   r3   )r   r*   r2   r!   r!   r"   r3   ˜  s    z#ITreeNodeAdapterBridge.append_childc             C   s   | j j||ƒS )z5 Inserts a child into the object's children.
        )r¢   r5   )r   r*   r4   r2   r!   r!   r"   r5   �  s    z#ITreeNodeAdapterBridge.insert_childc             C   s
   | j jƒ S )a}   Checks whether a specified object can be deleted.

        The following return values are possible:

        - **True** if the object should be deleted with no further prompting.
        - **False** if the object should not be deleted.
        - Anything else: Caller should take its default action (which might
          include prompting the user to confirm deletion).
        )r¢   r6   )r   r*   r!   r!   r"   r6   ¢  s    
z%ITreeNodeAdapterBridge.confirm_deletec             C   s   | j j|ƒS )zJ Deletes a child at a specified index from the object's children.
        )r¢   r7   )r   r*   r4   r!   r!   r"   r7   ®  s    z#ITreeNodeAdapterBridge.delete_childc             C   s   | j j||ƒS )zf Sets up or removes a listener for children being replaced on a
            specified object.
        )r¢   r=   )r   r*   r<   r9   r!   r!   r"   r=   ³  s    z-ITreeNodeAdapterBridge.when_children_replacedc             C   s   | j j||ƒS )ze Sets up or removes a listener for children being changed on a
            specified object.
        )r¢   r?   )r   r*   r<   r9   r!   r!   r"   r?   ¹  s    z,ITreeNodeAdapterBridge.when_children_changedc             C   s
   | j jƒ S )z; Gets the label to display for a specified object.
        )r¢   rC   )r   r*   r!   r!   r"   rC   ¿  s    z ITreeNodeAdapterBridge.get_labelc             C   s   | j j|ƒS )z0 Sets the label for a specified object.
        )r¢   rE   )r   r*   rA   r!   r!   r"   rE   Ä  s    z ITreeNodeAdapterBridge.set_labelc             C   s   | j j||ƒS )zf Sets up or removes a listener for the label being changed on a
            specified object.
        )r¢   rN   )r   r*   r<   r9   r!   r!   r"   rN   É  s    z)ITreeNodeAdapterBridge.when_label_changedc             C   s
   | j jƒ S )z@ Get the labels for any columns that have been defined.
        )r¢   rW   )r   r*   r!   r!   r"   rW   Ï  s    z(ITreeNodeAdapterBridge.get_column_labelsc             C   s   | j j||ƒS )ac   Sets up or removes a listener for the column labels being changed on
        a specified object.

        This will fire when either the list is reassigned or when it is
        modified. I.e., it listens both to the trait change event and the
        trait_items change event. Implement the listener appropriately to handle
        either case.
        )r¢   rX   )r   r*   r<   r9   r!   r!   r"   rX   Ô  s    	z0ITreeNodeAdapterBridge.when_column_labels_changec             C   s
   | j jƒ S )z= Gets the tooltip to display for a specified object.
        )r¢   r[   )r   r*   r!   r!   r"   r[   ß  s    z"ITreeNodeAdapterBridge.get_tooltipc             C   s   | j j|ƒS )z2 Returns the icon for a specified object.
        )r¢   r`   )r   r*   r_   r!   r!   r"   r`   ä  s    zITreeNodeAdapterBridge.get_iconc             C   s
   | j jƒ S )z; Returns the path used to locate an object's icon.
        )r¢   ra   )r   r*   r!   r!   r"   ra   é  s    z$ITreeNodeAdapterBridge.get_icon_pathc             C   s
   | j jƒ S )zq Returns the name to use when adding a new object instance
            (displayed in the "New" submenu).
        )r¢   rb   )r   r*   r!   r!   r"   rb   î  s    zITreeNodeAdapterBridge.get_namec             C   s
   | j jƒ S )z6 Gets the view to use when editing an object.
        )r¢   rd   )r   r*   r!   r!   r"   rd   ô  s    zITreeNodeAdapterBridge.get_viewc             C   s
   | j jƒ S )z= Returns the right-click context menu for an object.
        )r¢   rf   )r   r*   r!   r!   r"   rf   ù  s    zITreeNodeAdapterBridge.get_menuc             C   s
   | j jƒ S )z+ Returns the background for object
        )r¢   rk   )r   r*   r!   r!   r"   rk   þ  s    z%ITreeNodeAdapterBridge.get_backgroundc             C   s
   | j jƒ S )z+ Returns the foreground for object
        )r¢   rm   )r   r*   r!   r!   r"   rm     s    z%ITreeNodeAdapterBridge.get_foregroundr   c             C   s   | j j|ƒS )z) Returns the renderer for object
        )r¢   rp   )r   r*   ro   r!   r!   r"   rp     s    z#ITreeNodeAdapterBridge.get_rendererc             C   s
   | j jƒ S )z? Returns whether the object's children can be renamed.
        )r¢   rr   )r   r*   r!   r!   r"   rr     s    z!ITreeNodeAdapterBridge.can_renamec             C   s
   | j jƒ S )z4 Returns whether the object can be renamed.
        )r¢   rt   )r   r*   r!   r!   r"   rt     s    z$ITreeNodeAdapterBridge.can_rename_mec             C   s
   | j jƒ S )z> Returns whether the object's children can be copied.
        )r¢   rv   )r   r*   r!   r!   r"   rv     s    zITreeNodeAdapterBridge.can_copyc             C   s
   | j jƒ S )z? Returns whether the object's children can be deleted.
        )r¢   rx   )r   r*   r!   r!   r"   rx     s    z!ITreeNodeAdapterBridge.can_deletec             C   s
   | j jƒ S )z4 Returns whether the object can be deleted.
        )r¢   rz   )r   r*   r!   r!   r"   rz   !  s    z$ITreeNodeAdapterBridge.can_delete_mec             C   s
   | j jƒ S )z[ Returns whether the object's children can be inserted (vs.
            appended).
        )r¢   r|   )r   r*   r!   r!   r"   r|   &  s    z!ITreeNodeAdapterBridge.can_insertc             C   s
   | j jƒ S )z[ Returns whether the object's children should be automatically
            opened.
        )r¢   r~   )r   r*   r!   r!   r"   r~   ,  s    z$ITreeNodeAdapterBridge.can_auto_openc             C   s
   | j jƒ S )z[ Returns whether the object's children should be automatically
            closed.
        )r¢   r€   )r   r*   r!   r!   r"   r€   2  s    z%ITreeNodeAdapterBridge.can_auto_closec             C   s   | j j|ƒS )zB Returns whether a given object is droppable on the node.
        )r¢   rŒ   )r   r*   rŠ   r!   r!   r"   rŒ   8  s    zITreeNodeAdapterBridge.can_addc             C   s
   | j jƒ S )zF Returns the list of classes that can be added to the object.
        )r¢   rŽ   )r   r*   r!   r!   r"   rŽ   =  s    zITreeNodeAdapterBridge.get_addc             C   s
   | j jƒ S )z< Returns a draggable version of a specified object.
        )r¢   r�   )r   r*   r!   r!   r"   r�   B  s    z&ITreeNodeAdapterBridge.get_drag_objectc             C   s   | j j|ƒS )z< Returns a droppable version of a specified object.
        )r¢   r‘   )r   r*   r�   r!   r!   r"   r‘   G  s    z"ITreeNodeAdapterBridge.drop_objectc             C   s
   | j jƒ S )z+ Handles an object being selected.
        )r¢   r“   )r   r*   r!   r!   r"   r“   L  s    zITreeNodeAdapterBridge.selectc             C   s
   | j jƒ S )z* Handles an object being clicked.
        )r¢   r•   )r   r*   r!   r!   r"   r•   Q  s    zITreeNodeAdapterBridge.clickc             C   s
   | j jƒ S )z1 Handles an object being double-clicked.
        )r¢   r—   )r   r*   r!   r!   r"   r—   V  s    zITreeNodeAdapterBridge.dclickc             C   s
   | j jƒ S )z, Handles an object being activated.
        )r¢   r™   )r   r*   r!   r!   r"   r™   [  s    z ITreeNodeAdapterBridge.activatedN)r   )/rš   r›   rœ   r�   r   rŸ   r¢   r+   r.   r-   r0   r3   r5   r6   r7   r=   r?   rC   rE   rN   rW   rX   r[   r`   ra   rb   rd   rf   rk   rm   rp   rr   rt   rv   rx   rz   r|   r~   r€   rŒ   rŽ   r�   r‘   r“   r•   r—   r™   r!   r!   r!   r"   r¡   y  sT   
r¡   c               @   s,  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%dGdH„ Z&dIS )JÚObjectTreeNodec             C   s
   |j | ƒS )z8 Returns whether this object can have children.
        )Útno_allows_children)r   r*   r!   r!   r"   r+   n  s    zObjectTreeNode.allows_childrenc             C   s
   |j | ƒS )z2 Returns whether the object has children.
        )Útno_has_children)r   r*   r!   r!   r"   r.   w  s    zObjectTreeNode.has_childrenc             C   s
   |j | ƒS )z% Gets the object's children.
        )Útno_get_children)r   r*   r!   r!   r"   r-   €  s    zObjectTreeNode.get_childrenc             C   s
   |j | ƒS )z0 Gets the object's children identifier.
        )Útno_get_children_id)r   r*   r!   r!   r"   r0   ‰  s    zObjectTreeNode.get_children_idc             C   s   |j | |ƒS )z3 Appends a child to the object's children.
        )Útno_append_child)r   r*   r2   r!   r!   r"   r3   ’  s    zObjectTreeNode.append_childc             C   s   |j | ||ƒS )z5 Inserts a child into the object's children.
        )Útno_insert_child)r   r*   r4   r2   r!   r!   r"   r5   ›  s    zObjectTreeNode.insert_childc             C   s
   |j | ƒS )a}   Checks whether a specified object can be deleted.

        The following return values are possible:

        - **True** if the object should be deleted with no further prompting.
        - **False** if the object should not be deleted.
        - Anything else: Caller should take its default action (which might
          include prompting the user to confirm deletion).
        )Útno_confirm_delete)r   r*   r!   r!   r"   r6   §  s    
zObjectTreeNode.confirm_deletec             C   s   |j | |ƒS )zJ Deletes a child at a specified index from the object's children.
        )Útno_delete_child)r   r*   r4   r!   r!   r"   r7   ·  s    zObjectTreeNode.delete_childc             C   s   |j | ||ƒS )zf Sets up or removes a listener for children being replaced on a
            specified object.
        )Útno_when_children_replaced)r   r*   r<   r9   r!   r!   r"   r=   Á  s    z%ObjectTreeNode.when_children_replacedc             C   s   |j | ||ƒS )ze Sets up or removes a listener for children being changed on a
            specified object.
        )Útno_when_children_changed)r   r*   r<   r9   r!   r!   r"   r?   Ì  s    z$ObjectTreeNode.when_children_changedc             C   s
   |j | ƒS )z; Gets the label to display for a specified object.
        )Útno_get_label)r   r*   r!   r!   r"   rC   Ö  s    zObjectTreeNode.get_labelc             C   s   |j | |ƒS )z0 Sets the label for a specified object.
        )Útno_set_label)r   r*   rA   r!   r!   r"   rE   ß  s    zObjectTreeNode.set_labelc             C   s   |j | ||ƒS )zf Sets up or removes a listener for the label being changed on a
            specified object.
        )Útno_when_label_changed)r   r*   r<   r9   r!   r!   r"   rN   è  s    z!ObjectTreeNode.when_label_changedc             C   s
   |j | ƒS )z= Gets the tooltip to display for a specified object.
        )Útno_get_tooltip)r   r*   r!   r!   r"   r[   ò  s    zObjectTreeNode.get_tooltipc             C   s   |j | |ƒS )z2 Returns the icon for a specified object.
        )Útno_get_icon)r   r*   r_   r!   r!   r"   r`   û  s    zObjectTreeNode.get_iconc             C   s
   |j | ƒS )z; Returns the path used to locate an object's icon.
        )Útno_get_icon_path)r   r*   r!   r!   r"   ra     s    zObjectTreeNode.get_icon_pathc             C   s
   |j | ƒS )zq Returns the name to use when adding a new object instance
            (displayed in the "New" submenu).
        )Útno_get_name)r   r*   r!   r!   r"   rb     s    zObjectTreeNode.get_namec             C   s
   |j | ƒS )z6 Gets the view to use when editing an object.
        )Útno_get_view)r   r*   r!   r!   r"   rd     s    zObjectTreeNode.get_viewc             C   s
   |j | ƒS )z= Returns the right-click context menu for an object.
        )Útno_get_menu)r   r*   r!   r!   r"   rf   !  s    zObjectTreeNode.get_menuc             C   s
   |j | ƒS )z? Returns whether the object's children can be renamed.
        )Útno_can_rename)r   r*   r!   r!   r"   rr   *  s    zObjectTreeNode.can_renamec             C   s
   |j | ƒS )z4 Returns whether the object can be renamed.
        )Útno_can_rename_me)r   r*   r!   r!   r"   rt   3  s    zObjectTreeNode.can_rename_mec             C   s
   |j | ƒS )z> Returns whether the object's children can be copied.
        )Útno_can_copy)r   r*   r!   r!   r"   rv   <  s    zObjectTreeNode.can_copyc             C   s
   |j | ƒS )z? Returns whether the object's children can be deleted.
        )Útno_can_delete)r   r*   r!   r!   r"   rx   E  s    zObjectTreeNode.can_deletec             C   s
   |j | ƒS )z4 Returns whether the object can be deleted.
        )Útno_can_delete_me)r   r*   r!   r!   r"   rz   N  s    zObjectTreeNode.can_delete_mec             C   s
   |j | ƒS )zW Returns whether the object's children can be inserted (vs.
        appended).
        )Útno_can_insert)r   r*   r!   r!   r"   r|   X  s    zObjectTreeNode.can_insertc             C   s
   |j | ƒS )z[ Returns whether the object's children should be automatically
            opened.
        )Útno_can_auto_open)r   r*   r!   r!   r"   r~   b  s    zObjectTreeNode.can_auto_openc             C   s
   |j | ƒS )z[ Returns whether the object's children should be automatically
            closed.
        )Útno_can_auto_close)r   r*   r!   r!   r"   r€   l  s    zObjectTreeNode.can_auto_closec             C   s   t |tƒr|j| ƒS dS )z] Returns whether this is the node that should handle a
            specified object.
        F)ri   ÚTreeNodeObjectÚtno_is_node_for)r   r*   r!   r!   r"   r„   w  s    

zObjectTreeNode.is_node_forc             C   s   |j | |ƒS )zB Returns whether a given object is droppable on the node.
        )Útno_can_add)r   r*   rŠ   r!   r!   r"   rŒ   „  s    zObjectTreeNode.can_addc             C   s
   |j | ƒS )zF Returns the list of classes that can be added to the object.
        )Útno_get_add)r   r*   r!   r!   r"   rŽ   �  s    zObjectTreeNode.get_addc             C   s
   |j | ƒS )z< Returns a draggable version of a specified object.
        )Útno_get_drag_object)r   r*   r!   r!   r"   r�   –  s    zObjectTreeNode.get_drag_objectc             C   s   |j | |ƒS )z< Returns a droppable version of a specified object.
        )Útno_drop_object)r   r*   r�   r!   r!   r"   r‘   Ÿ  s    zObjectTreeNode.drop_objectc             C   s
   |j | ƒS )z+ Handles an object being selected.
        )Ú
tno_select)r   r*   r!   r!   r"   r“   ¨  s    zObjectTreeNode.selectc             C   s
   |j | ƒS )z* Handles an object being clicked.
        )Ú	tno_click)r   r*   r!   r!   r"   r•   ±  s    zObjectTreeNode.clickc             C   s
   |j | ƒS )z1 Handles an object being double-clicked.
        )Ú
tno_dclick)r   r*   r!   r!   r"   r—   º  s    zObjectTreeNode.dclickc             C   s
   |j | ƒS )z, Handles an object being activated.
        )Útno_activated)r   r*   r!   r!   r"   r™   Ã  s    zObjectTreeNode.activatedN)'rš   r›   rœ   r+   r.   r-   r0   r3   r5   r6   r7   r=   r?   rC   rE   rN   r[   r`   ra   rb   rd   rf   rr   rt   rv   rx   rz   r|   r~   r€   r„   rŒ   rŽ   r�   r‘   r“   r•   r—   r™   r!   r!   r!   r"   r£   h  sH   					

		
		

						


							r£   c               @   s4  e Zd ZdZeZdd„ Zdd„ Zdd„ Zdd	„ Z	d
d„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Z d8d9„ Z!d:d;„ Z"d<d=„ Z#d>d?„ Z$d@dA„ Z%dBdC„ Z&dDdE„ Z'dFdG„ Z(dHdI„ Z)dJS )Kr¿   z< Represents the object that corresponds to a tree node.
    c             C   s
   |j dkS )z6 Returns whether this object allows children.
        r   )r)   )r   Únoder!   r!   r"   r¤   Ø  s    z"TreeNodeObject.tno_allows_childrenc             C   s   t | j|ƒƒdkS )z3 Returns whether this object has children.
        r   )r,   r¦   )r   rÉ   r!   r!   r"   r¥   á  s    zTreeNodeObject.tno_has_childrenc             C   s   t | |jdƒS )z% Gets the object's children.
        N)r/   r)   )r   rÉ   r!   r!   r"   r¦   ê  s    zTreeNodeObject.tno_get_childrenc             C   s   |j S )z0 Gets the object's children identifier.
        )r)   )r   rÉ   r!   r!   r"   r§   ó  s    z"TreeNodeObject.tno_get_children_idc             C   s   | j |ƒj|ƒ dS )z3 Appends a child to the object's children.
        N)r¦   r1   )r   rÉ   r2   r!   r!   r"   r¨   ü  s    zTreeNodeObject.tno_append_childc             C   s   | j |ƒ}|g|||…< dS )z5 Inserts a child into the object's children.
        N)r¦   )r   rÉ   r4   r2   r)   r!   r!   r"   r©     s    
zTreeNodeObject.tno_insert_childc             C   s   dS )a}   Checks whether a specified object can be deleted.

        The following return values are possible:

        - **True** if the object should be deleted with no further prompting.
        - **False** if the object should not be deleted.
        - Anything else: Caller should take its default action (which might
          include prompting the user to confirm deletion).
        Nr!   )r   rÉ   r!   r!   r"   rª     s    
z!TreeNodeObject.tno_confirm_deletec             C   s   | j |ƒ|= dS )zJ Deletes a child at a specified index from the object's children.
        N)r¦   )r   rÉ   r4   r!   r!   r"   r«   "  s    zTreeNodeObject.tno_delete_childc             C   s   | j ||j|dd� dS )zb Sets up or removes a listener for children being replaced on a
        specified object.
        r8   )r9   r:   N)r;   r)   )r   rÉ   r<   r9   r!   r!   r"   r¬   -  s    z)TreeNodeObject.tno_when_children_replacedc             C   s   | j ||jd |dd� dS )za Sets up or removes a listener for children being changed on a
        specified object.
        r>   r8   )r9   r:   N)r;   r)   )r   rÉ   r<   r9   r!   r!   r"   r­   9  s    z(TreeNodeObject.tno_when_children_changedc             C   sF   |j }|dd… dkr"|dd… S t| |ƒ}|jdkr:|S |j| |ƒS )z; Gets the label to display for a specified object.
        Nr   r@   )rA   r   rB   )r   rÉ   rA   r!   r!   r"   r®   D  s    

zTreeNodeObject.tno_get_labelc             C   s&   |j }|dd… dkr"t| ||ƒ dS )z0 Sets the label for a specified object.
        Nr   r@   )rA   r   )r   rÉ   rA   rD   r!   r!   r"   r¯   V  s    zTreeNodeObject.tno_set_labelc                sp   |j }|dd… dkrld||ˆ f}|s@‡ ‡fdd„}|ˆj|< nˆjj|dƒ}|dkrZdS ˆj|||dd� dS )	zc Sets up or removes a listener for  the label being changed on a
        specified object.
        Nr   r@   rA   c                s   ˆ ˆ||ƒS )z2 Ensure listener gets called with correct object. r!   )rF   rG   rH   )r<   r   r!   r"   rI   i  s    z?TreeNodeObject.tno_when_label_changed.<locals>.wrapped_listenerrJ   )r9   r:   )rA   rK   rL   r;   )r   rÉ   r<   r9   rA   rM   rI   r!   )r<   r   r"   r°   a  s    
z%TreeNodeObject.tno_when_label_changedc             C   sR   |j }|dkr|S |dd… dkr.|dd… S t| |ƒ}|jdkrF|S |j| |ƒS )z= Gets the tooltip to display for a specified object.
        r   Nr   r@   )rY   r   rZ   )r   rÉ   rY   r!   r!   r"   r±   z  s    

zTreeNodeObject.tno_get_tooltipc             C   s    | j |ƒs|jS |r|jS |jS )z2 Returns the icon for a specified object.
        )r¤   r\   r]   r^   )r   rÉ   r_   r!   r!   r"   r²   �  s
    
zTreeNodeObject.tno_get_iconc             C   s   |j S )z; Returns the path used to locate an object's icon.
        )r   )r   rÉ   r!   r!   r"   r³   ž  s    z TreeNodeObject.tno_get_icon_pathc             C   s   |j S )zq Returns the name to use when adding a new object instance
            (displayed in the "New" submenu).
        )rG   )r   rÉ   r!   r!   r"   r´   ¨  s    zTreeNodeObject.tno_get_namec             C   s   |j S )z6 Gets the view to use when editing an object.
        )rc   )r   rÉ   r!   r!   r"   rµ   ²  s    zTreeNodeObject.tno_get_viewc             C   s   |j S )z= Returns the right-click context menu for an object.
        )re   )r   rÉ   r!   r!   r"   r¶   »  s    zTreeNodeObject.tno_get_menuc             C   s   |j S )z? Returns whether the object's children can be renamed.
        )rq   )r   rÉ   r!   r!   r"   r·   Ä  s    zTreeNodeObject.tno_can_renamec             C   s   |j S )z4 Returns whether the object can be renamed.
        )rs   )r   rÉ   r!   r!   r"   r¸   Í  s    z TreeNodeObject.tno_can_rename_mec             C   s   |j S )z> Returns whether the object's children can be copied.
        )ru   )r   rÉ   r!   r!   r"   r¹   Ö  s    zTreeNodeObject.tno_can_copyc             C   s   |j S )z? Returns whether the object's children can be deleted.
        )rw   )r   rÉ   r!   r!   r"   rº   ß  s    zTreeNodeObject.tno_can_deletec             C   s   |j S )z4 Returns whether the object can be deleted.
        )ry   )r   rÉ   r!   r!   r"   r»   è  s    z TreeNodeObject.tno_can_delete_mec             C   s   |j S )zW Returns whether the object's children can be inserted (vs.
        appended).
        )r{   )r   rÉ   r!   r!   r"   r¼   ò  s    zTreeNodeObject.tno_can_insertc             C   s   |j S )zW Returns whether the object's children should be automatically
        opened.
        )r}   )r   rÉ   r!   r!   r"   r½   ü  s    z TreeNodeObject.tno_can_auto_openc             C   s   |j S )zW Returns whether the object's children should be automatically
        closed.
        )r   )r   rÉ   r!   r!   r"   r¾     s    z!TreeNodeObject.tno_can_auto_closec             C   s   t | |jƒp| j|jŽ S )z] Returns whether this is the node that should handle a
            specified object.
        )ri   r�   r‚   rƒ   )r   rÉ   r!   r!   r"   rÀ     s    zTreeNodeObject.tno_is_node_forc             C   sN   |j |ƒ}|j|ƒrdS x0|jD ]&}t|ƒtkr8|d }t||ƒr dS q W dS )zB Returns whether a given object is droppable on the node.
        Tr   F)r…   r†   r‡   rˆ   r   r‰   )r   rÉ   rŠ   r$   r‹   r!   r!   r"   rÁ     s    


zTreeNodeObject.tno_can_addc             C   s   |j S )zF Returns the list of classes that can be added to the object.
        )r�   )r   rÉ   r!   r!   r"   rÂ   /  s    zTreeNodeObject.tno_get_addc             C   s   | S )z< Returns a draggable version of a specified object.
        r!   )r   rÉ   r!   r!   r"   rÃ   8  s    z"TreeNodeObject.tno_get_drag_objectc             C   sZ   |j |ƒr|S xF|jD ]<}t|ƒtkrDt||d ƒrR|d | |ƒS qt||ƒr|S qW dS )z< Returns a droppable version of a specified object.
        r   r   N)r†   r‡   rˆ   r   ri   )r   rÉ   r�   r‹   r!   r!   r"   rÄ   A  s    

zTreeNodeObject.tno_drop_objectc             C   s   |j dk	r|j | ƒ dS dS )z+ Handles an object being selected.
        NT)r’   )r   rÉ   r!   r!   r"   rÅ   S  s    

zTreeNodeObject.tno_selectc             C   s   |j dk	r|j | ƒ dS dS )z* Handles an object being clicked.
        NT)r”   )r   rÉ   r!   r!   r"   rÆ   `  s    

zTreeNodeObject.tno_clickc             C   s   |j dk	r|j | ƒ dS dS )z1 Handles an object being double-clicked.
        NT)r–   )r   rÉ   r!   r!   r"   rÇ   m  s    

zTreeNodeObject.tno_dclickc             C   s   |j dk	r|j | ƒ dS dS )z, Handles an object being activated.
        NT)r˜   )r   rÉ   r!   r!   r"   rÈ   z  s    

zTreeNodeObject.tno_activatedN)*rš   r›   rœ   r�   r   rK   r¤   r¥   r¦   r§   r¨   r©   rª   r«   r¬   r­   r®   r¯   r°   r±   r²   r³   r´   rµ   r¶   r·   r¸   r¹   rº   r»   r¼   r½   r¾   rÀ   rÁ   rÂ   rÃ   rÄ   rÅ   rÆ   rÇ   rÈ   r!   r!   r!   r"   r¿   Í  sL   					

						


		r¿   c               @   s  e Zd ZeeƒZeeƒZdd„ Zdd„ Z	dd„ Z
dd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Z d3d4„ Z!d5d6„ Z"d7d8„ Z#d9d:„ Z$d;d<„ Z%d=S )>ÚMultiTreeNodec             C   s   dS )zV Returns whether this object can have children (True for this
        class).
        Tr!   )r   r*   r!   r!   r"   r+   ˜  s    zMultiTreeNode.allows_childrenc             C   s   dS )zI Returns whether this object has children (True for this class).
        Tr!   )r   r*   r!   r!   r"   r.   ¢  s    zMultiTreeNode.has_childrenc                s   ‡ fdd„| j D ƒS )z% Gets the object's children.
        c                s   g | ]}ˆ |f‘qS r!   r!   )r#   rÉ   )r*   r!   r"   r%   ®  s    z.MultiTreeNode.get_children.<locals>.<listcomp>)Únodes)r   r*   r!   )r*   r"   r-   «  s    zMultiTreeNode.get_childrenc             C   s   dS )z0 Gets the object's children identifier.
        r   r!   )r   r*   r!   r!   r"   r0   ´  s    zMultiTreeNode.get_children_idc             C   s   dS )zb Sets up or removes a listener for children being replaced on a
        specified object.
        Nr!   )r   r*   r<   r9   r!   r!   r"   r=   ¾  s    z$MultiTreeNode.when_children_replacedc             C   s   dS )za Sets up or removes a listener for children being changed on a
        specified object.
        Nr!   )r   r*   r<   r9   r!   r!   r"   r?   É  s    z#MultiTreeNode.when_children_changedc             C   s   | j j|ƒS )z; Gets the label to display for a specified object.
        )Ú	root_noderC   )r   r*   r!   r!   r"   rC   Ó  s    zMultiTreeNode.get_labelc             C   s   | j j||ƒS )z0 Sets the label for a specified object.
        )rÌ   rE   )r   r*   rA   r!   r!   r"   rE   Ü  s    zMultiTreeNode.set_labelc             C   s   | j j|||ƒS )zb Sets up or removes a listener for the label being changed on a
        specified object.
        )rÌ   rN   )r   r*   r<   r9   r!   r!   r"   rN   å  s    z MultiTreeNode.when_label_changedc             C   s   | j j||ƒS )z2 Returns the icon for a specified object.
        )rÌ   r`   )r   r*   r_   r!   r!   r"   r`   ï  s    zMultiTreeNode.get_iconc             C   s   | j j|ƒS )z; Returns the path used to locate an object's icon.
        )rÌ   ra   )r   r*   r!   r!   r"   ra   ø  s    zMultiTreeNode.get_icon_pathc             C   s   | j j|ƒS )zq Returns the name to use when adding a new object instance
            (displayed in the "New" submenu).
        )rÌ   rb   )r   r*   r!   r!   r"   rb   	  s    zMultiTreeNode.get_namec             C   s   | j j|ƒS )z6 Gets the view to use when editing an object.
        )rÌ   rd   )r   r*   r!   r!   r"   rd   	  s    zMultiTreeNode.get_viewc             C   s   | j j|ƒS )z= Returns the right-click context menu for an object.
        )rÌ   rf   )r   r*   r!   r!   r"   rf   	  s    zMultiTreeNode.get_menuc             C   s   dS )z^ Returns whether the object's children can be renamed (False for
        this class).
        Fr!   )r   r*   r!   r!   r"   rr   	  s    zMultiTreeNode.can_renamec             C   s   dS )zK Returns whether the object can be renamed (False for this class).
        Fr!   )r   r*   r!   r!   r"   rt   (	  s    zMultiTreeNode.can_rename_mec             C   s   | j j|ƒS )z> Returns whether the object's children can be copied.
        )rÌ   rv   )r   r*   r!   r!   r"   rv   1	  s    zMultiTreeNode.can_copyc             C   s   dS )z^ Returns whether the object's children can be deleted (False for
        this class).
        Fr!   )r   r*   r!   r!   r"   rx   :	  s    zMultiTreeNode.can_deletec             C   s   dS )zJ Returns whether the object can be deleted (True for this class).
        Tr!   )r   r*   r!   r!   r"   rz   D	  s    zMultiTreeNode.can_delete_mec             C   s   dS )z„ Returns whether the object's children can be inserted (False,
        meaning that children are appended, for this class).
        Fr!   )r   r*   r!   r!   r"   r|   N	  s    zMultiTreeNode.can_insertc             C   s   | j j|ƒS )zW Returns whether the object's children should be automatically
        opened.
        )rÌ   r~   )r   r*   r!   r!   r"   r~   X	  s    zMultiTreeNode.can_auto_openc             C   s   | j j|ƒS )zW Returns whether the object's children should be automatically
        closed.
        )rÌ   r€   )r   r*   r!   r!   r"   r€   b	  s    zMultiTreeNode.can_auto_closec             C   s   dS )za Returns whether a given object is droppable on the node (False for
        this class).
        Fr!   )r   r*   rŠ   r!   r!   r"   rŒ   l	  s    zMultiTreeNode.can_addc             C   s   g S )zF Returns the list of classes that can be added to the object.
        r!   )r   r*   r!   r!   r"   rŽ   v	  s    zMultiTreeNode.get_addc             C   s   | j j|ƒS )z< Returns a draggable version of a specified object.
        )rÌ   r�   )r   r*   r!   r!   r"   r�   	  s    zMultiTreeNode.get_drag_objectc             C   s   | j j||ƒS )z< Returns a droppable version of a specified object.
        )rÌ   r‘   )r   r*   r�   r!   r!   r"   r‘   ˆ	  s    zMultiTreeNode.drop_objectc             C   s   | j j|ƒS )z+ Handles an object being selected.
        )rÌ   r“   )r   r*   r!   r!   r"   r“   ‘	  s    zMultiTreeNode.selectc             C   s   | j j|ƒS )z* Handles an object being clicked.
        )rÌ   r•   )r   r*   r!   r!   r"   r•   š	  s    zMultiTreeNode.clickc             C   s   | j j|ƒS )z1 Handles an object being double-clicked.
        )rÌ   r—   )r   r*   r!   r!   r"   r—   £	  s    zMultiTreeNode.dclickc             C   s   | j j|ƒS )z, Handles an object being activated.
        )rÌ   r™   )r   r*   r!   r!   r"   r™   ¬	  s    zMultiTreeNode.activatedN)&rš   r›   rœ   r   r   rÌ   r   rË   r+   r.   r-   r0   r=   r?   rC   rE   rN   r`   ra   rb   rd   rf   rr   rt   rv   rx   rz   r|   r~   r€   rŒ   rŽ   r�   r‘   r“   r•   r—   r™   r!   r!   r!   r"   rÊ   ˆ  s@   
		

		
	

		
		





						rÊ   )"r�   Ú
__future__r   rP   Z
traits.apir   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   Ztraits.trait_baser   r   r   r   Z	ui_traitsr   r   rŸ   r    r¡   r£   r¿   rÊ   r!   r!   r!   r"   Ú<module>   s2   D     ) 0 x p  g   >