a
    ©ˆc‚	  ã                   @   sD   d Z ddlmZmZmZ ddlmZ ddlmZ G dd„ deƒZ	dS )	zA An extension registry that uses plugins as extension providers. é    )ÚInstanceÚobserveÚon_trait_changeé   )ÚIPluginManager)ÚProviderExtensionRegistryc                   @   sH   e Zd ZdZeeƒZedƒdd„ ƒZe	dƒdd„ ƒZ
e	dƒd	d
„ ƒZdS )ÚPluginExtensionRegistryzÞ An extension registry that uses plugins as extension providers.

    The application's plugins are used as the registries providers so adding
    or removing a plugin affects the extension points and extensions etc.

    Úplugin_managerc                 C   sJ   |j |j }}|dur*|D ]}|  |¡ q|durF|D ]}|  |¡ q6dS )z Static trait change handler. N)ÚoldÚnewÚremove_providerÚadd_provider)ÚselfÚeventr
   r   Úplugin© r   úe/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/envisage/plugin_extension_registry.pyÚ_update_providers(   s    z)PluginExtensionRegistry._update_providerszplugin_manager:plugin_addedc                 C   s   |   |j¡ dS ©z Dynamic trait change handler. N)r   r   ©r   ÚobjZ
trait_namer
   r   r   r   r   Ú_on_plugin_added8   s    z(PluginExtensionRegistry._on_plugin_addedzplugin_manager:plugin_removedc                 C   s   |   |j¡ dS r   )r   r   r   r   r   r   Ú_on_plugin_removed>   s    z*PluginExtensionRegistry._on_plugin_removedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r	   r   r   r   r   r   r   r   r   r   r      s   


r   N)
r   Z
traits.apir   r   r   Zi_plugin_managerr   Zprovider_extension_registryr   r   r   r   r   r   Ú<module>
   s   