a
    §ˆcø  ã                   @   sJ   d Z ddlZddlmZmZmZ ddlmZ e e	¡Z
G dd„ deƒZdS )ú: The node manager looks after a collection of node types. é    N)ÚHasPrivateTraitsÚListÚobserveé   )ÚNodeTypec                       sV   e Zd ZdZeeƒZeƒ Z‡ fdd„Zdd„ Z	dd„ Z
dd	„ Zed
ƒdd„ ƒZ‡  ZS )ÚNodeManagerr   c                    s   t ƒ jf i |¤Ž i | _dS )z Creates a new tree model. N)ÚsuperÚ__init__Ú_node_to_type_map)ÚselfZtraits©Ú	__class__© ú[/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/tree/node_manager.pyr
   +   s    zNodeManager.__init__c                 C   s   | |_ | j |¡ dS )z& Adds a new node type to the manager. N)Únode_managerÚ
node_typesÚappend)r   Ú	node_typer   r   r   Úadd_node_type@   s    zNodeManager.add_node_typec                 C   sf   |   |¡}| j |d¡}|du rH| jD ]}| |¡r&|| j|<  qHq&d}|du rbt dt|ƒ ¡ |S )zq Returns the node's type.

        Returns None if none of the manager's node types recognize the node.

        Nzno node type for %s)Úget_keyr   Úgetr   Zis_type_forÚloggerÚwarningÚstr)r   ÚnodeÚkeyr   r   r   r   Úget_node_typeF   s    



zNodeManager.get_node_typec                 C   s&   zt |ƒ}W n   t|ƒ}Y n0 |S )zt Generates a unique key for a node.

        In this case,  'unique' means unqiue within the node manager.

        )ÚhashÚid)r   r   r   r   r   r   r   g   s
    
zNodeManager.get_keyr   c                 C   s   |j }|D ]
}| |_q
dS )z= Called when the entire list of node types has been changed. N)Únewr   )r   Úeventr    r   r   r   r   Ú&_update_node_manager_on_new_node_types}   s    z2NodeManager._update_node_manager_on_new_node_types)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Zsystem_actionsr
   r   r   r   r   r"   Ú__classcell__r   r   r   r   r      s   !r   )r&   ÚloggingZ
traits.apir   r   r   r   r   Ú	getLoggerr#   r   r   r   r   r   r   Ú<module>   s
   
