| 1 |
# (C) Copyright 2007-2025 Enthought, Inc., Austin, TX |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# This software is provided without warranty under the terms of the BSD |
| 5 |
# license included in LICENSE.txt and may be redistributed only under |
| 6 |
# the conditions described in the aforementioned license. The license |
| 7 |
# is also available online at http://www.enthought.com/licenses/BSD.txt |
| 8 |
# |
| 9 |
# Thanks for using Enthought open source! |
| 10 |
""" The interface for extension registries. """ |
| 11 |
|
| 12 |
|
| 13 |
# Enthought library imports. |
| 14 |
from traits.api import Interface |
| 15 |
|
| 16 |
|
| 17 |
class IExtensionRegistry(Interface): |
| 18 |
"""The interface for extension registries.""" |
| 19 |
|
| 20 |
def add_extension_point_listener(self, listener, extension_point_id=None): |
| 21 |
"""Add a listener for extensions being added or removed. |
| 22 |
|
| 23 |
A listener is any Python callable with the following signature:: |
| 24 |
|
| 25 |
def listener(extension_registry, extension_point_changed_event): |
| 26 |
|
| 27 |
... |
| 28 |
|
| 29 |
If an extension point is specified then the listener will only be |
| 30 |
called when extensions are added to or removed from that extension |
| 31 |
point (the extension point may or may not have been added to the |
| 32 |
registry at the time of this call). |
| 33 |
|
| 34 |
If *no* extension point is specified then the listener will be called |
| 35 |
when extensions are added to or removed from *any* extension point. |
| 36 |
|
| 37 |
When extensions are added or removed all specific listeners are called |
| 38 |
first (in arbitrary order), followed by all non-specific listeners |
| 39 |
(again, in arbitrary order). |
| 40 |
|
| 41 |
""" |
| 42 |
|
| 43 |
def add_extension_point(self, extension_point): |
| 44 |
"""Add an extension point. |
| 45 |
|
| 46 |
If an extension point already exists with this Id then it is simply |
| 47 |
replaced. |
| 48 |
|
| 49 |
""" |
| 50 |
|
| 51 |
def get_extensions(self, extension_point_id): |
| 52 |
"""Return the extensions contributed to an extension point. |
| 53 |
|
| 54 |
Return an empty list if the extension point does not exist. |
| 55 |
|
| 56 |
""" |
| 57 |
|
| 58 |
def get_extension_point(self, extension_point_id): |
| 59 |
"""Return the extension point with the specified Id. |
| 60 |
|
| 61 |
Return None if no such extension point exists. |
| 62 |
|
| 63 |
""" |
| 64 |
|
| 65 |
def get_extension_points(self): |
| 66 |
"""Return all extension points that have been added to the registry.""" |
| 67 |
|
| 68 |
def remove_extension_point_listener( |
| 69 |
self, listener, extension_point_id=None |
| 70 |
): |
| 71 |
"""Remove a listener for extensions being added or removed. |
| 72 |
|
| 73 |
Raise a 'ValueError' if the listener does not exist. |
| 74 |
|
| 75 |
""" |
| 76 |
|
| 77 |
def remove_extension_point(self, extension_point_id): |
| 78 |
"""Remove an extension point. |
| 79 |
|
| 80 |
Raise an 'UnknownExtensionPoint' exception if no extension point exists |
| 81 |
with the specified Id. |
| 82 |
|
| 83 |
""" |
| 84 |
|
| 85 |
def set_extensions(self, extension_point_id, extensions): |
| 86 |
"""Set the extensions contributed to an extension point.""" |