a
    §ˆc&  ã                   @   sx   d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ G d
d„ deƒZdS )ú, A tree control with extensible node types. é    )Úgetfullargspec©ÚActionEvent)ÚInstanceÚListÚobserveÚPropertyé   )ÚNodeManager)ÚNodeType)ÚNodeTreeModel)ÚTreec                   @   sª   e Zd ZdZeedƒZeeeƒƒZ	ee
eƒƒZdd„ Zdd„ Zdd„ Zd	d
„ Zedƒdd„ ƒZedƒ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S ) ÚNodeTreer   © c                 C   s   | j jS )z$ Returns the root node of the tree. ©ÚmodelÚnode_manager©Úselfr   r   úX/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/tree/node_tree.pyÚ_get_node_manager3   s    zNodeTree._get_node_managerc                 C   s   || j _dS )z! Sets the root node of the tree. Nr   )r   r   r   r   r   Ú_set_node_manager8   s    zNodeTree._set_node_managerc                 C   s
   | j jjS )z% Returns the node types in the tree. ©r   r   Ú
node_typesr   r   r   r   Ú_get_node_types@   s    zNodeTree._get_node_typesc                 C   s   || j j_dS )z" Sets the node types in the tree. Nr   )r   r   r   r   r   Ú_set_node_typesE   s    
zNodeTree._set_node_typesZnode_activatedc                 C   s*   |j }| j |¡}|dur&|  ||¡ dS )z? Called when a node has been activated (i.e., double-clicked). N)Únewr   Zget_default_actionÚ_perform_default_action)r   ÚeventÚobjZdefault_actionr   r   r   Ú)_perform_default_action_on_activated_nodeR   s    z2NodeTree._perform_default_action_on_activated_nodeZnode_right_clickedc                 C   sD   |j }|\}}|  |¡ || _| j |¡}|dur@|  |||¡ dS )z< Called when the right mouse button is clicked on the tree. N)r   ÚselectÚ_contextr   Zget_context_menuÚ_popup_menu)r   r   Z	obj_pointr    ÚpointÚmenu_managerr   r   r   Ú"_show_menu_on_right_clicked_objectZ   s    
z+NodeTree._show_menu_on_right_clicked_objectc                 C   s   dS )z! Adds a menu item to a menu bar. Nr   )r   Z	menu_itemr   r   r   Úadd_to_menuq   s    zNodeTree.add_to_menuc                 C   s   dS )z% Adds a tool bar item to a tool bar. Nr   )r   Ztoolvar_itemr   r   r   Úadd_to_toolbarv   s    zNodeTree.add_to_toolbarc                 C   s   dS )z6 Returns True iff an action can be added to the menu. Tr   )r   Úactionr   r   r   Úcan_add_to_menu{   s    zNodeTree.can_add_to_menuc                 C   sD   | |_ | j|_t|jƒ\}}}}t|ƒdkr6| ¡  n
| |¡ dS )z Perform an action. r
   N)Úwidgetr#   Úcontextr   ÚperformÚlen)r   r*   r   ÚargsÚvarargsÚvarkwÚdefaultsr   r   r   r.   €   s    

zNodeTree.performc                 C   s   t | |d�S )z5 Return a new action event for the specified object. )r,   r-   r   )r   r    r   r   r   Ú_create_action_event˜   s    zNodeTree._create_action_eventc                 C   s   |  |  |¡¡ dS )z5 Perform the default action on the specified object. N)r.   r4   )r   r*   r    r   r   r   r   �   s    z NodeTree._perform_default_actionc                 C   s,   |  | j| ¡}| ¡ s(|j|Ž  | ¡  dS )z/ Popup the menu described by the menu manager. N)Zcreate_menuÚcontrolZis_emptyÚshowÚdestroy)r   r&   r    r%   Úmenur   r   r   r$   ¢   s
    
zNodeTree._popup_menuN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r	   r   r   r   r   r   r   r   r   r   r   r!   r'   r(   r)   r+   r.   r4   r   r$   r   r   r   r   r      s&   
	

r   N)r<   Úinspectr   Zpyface.action.apir   Z
traits.apir   r   r   r	   r   r   Z	node_typer   Znode_tree_modelr   Útreer   r   r   r   r   r   Ú<module>   s   