envisage-4.1.0/0000755000175100001440000000000011674464662014316 5ustar ischnellusers00000000000000envisage-4.1.0/LICENSE.txt0000644000175100001440000000312011674464014016124 0ustar ischnellusers00000000000000This software is OSI Certified Open Source Software. OSI Certified is a certification mark of the Open Source Initiative. Copyright (c) 2006, Enthought, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Enthought, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. envisage-4.1.0/envisage/0000755000175100001440000000000011674464014016106 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugin_event.py0000644000175100001440000000050411674464014021156 0ustar ischnellusers00000000000000""" A plugin event. """ # Enthought library imports. from traits.api import Instance, Vetoable class PluginEvent(Vetoable): """ A plugin event. """ # The plugin that the event is for. plugin = Instance('envisage.api.IPlugin') #### EOF ###################################################################### envisage-4.1.0/envisage/i_service_user.py0000644000175100001440000000077611674464014021500 0ustar ischnellusers00000000000000""" The interface for objects using the 'Service' trait type. """ # Enthought library imports. from traits.api import Instance, Interface # Local imports. from i_service_registry import IServiceRegistry class IServiceUser(Interface): """ The interface for objects using the 'Service' trait type. """ # The service registry that the object's services are stored in. service_registry = Instance(IServiceRegistry) #### EOF ###################################################################### envisage-4.1.0/envisage/application.py0000644000175100001440000004001611674464014020764 0ustar ischnellusers00000000000000""" An extensible, pluggable, application. """ # Standard library imports. import logging, os # Enthought library imports. from traits.etsconfig.api import ETSConfig from apptools.preferences.api import IPreferences, ScopedPreferences from apptools.preferences.api import set_default_preferences from traits.api import Delegate, Event, HasTraits, Instance, Str from traits.api import VetoableEvent, implements # Local imports. from i_application import IApplication from i_extension_registry import IExtensionRegistry from i_import_manager import IImportManager from i_plugin_manager import IPluginManager from i_service_registry import IServiceRegistry from application_event import ApplicationEvent from import_manager import ImportManager # Logging. logger = logging.getLogger(__name__) class Application(HasTraits): """ An extensible, pluggable, application. This class handles the common case for non-GUI applications, and it is intended to be subclassed to change start/stop behaviour etc. """ implements(IApplication) #### 'IApplication' interface ############################################# # The application's globally unique identifier. id = Str # The name of a directory (created for you) to which the application can # read and write non-user accessible data, i.e. configuration information, # preferences, etc. home = Str # The name of a directory (created for you upon access) to which the # application can read and write user-accessible data, e.g. projects created # by the user. user_data = Str # The root preferences node. preferences = Instance(IPreferences) #### Events #### # Fired when the application is starting. starting = VetoableEvent(ApplicationEvent) # Fired when all plugins have been started. started = Event(ApplicationEvent) # Fired when the application is stopping. stopping = VetoableEvent(ApplicationEvent) # Fired when all plugins have been stopped. stopped = Event(ApplicationEvent) #### 'IPluginManager' interface ########################################### #### Events #### # Fired when a plugin has been added. plugin_added = Delegate('plugin_manager', modify=True) # Fired when a plugin has been removed. plugin_removed = Delegate('plugin_manager', modify=True) #### 'Application' interface ############################################## # These traits allow application developers to build completely different # styles of extensible application. It allows Envisage to be used as a # framework for frameworks ;^) # # The extension registry. extension_registry = Instance(IExtensionRegistry) # The plugin manager (starts and stops plugins etc). plugin_manager = Instance(IPluginManager) # The service registry. service_registry = Instance(IServiceRegistry) #### Private interface #################################################### # The import manager. _import_manager = Instance(IImportManager, factory=ImportManager) ########################################################################### # 'object' interface. ########################################################################### def __init__(self, plugins=None, **traits): """ Constructor. We allow the caller to specify an initial list of plugins, but the list itself is not part of the public API. To add and remove plugins after after construction, use the 'add_plugin' and 'remove_plugin' methods respectively. The application is also iterable, so to iterate over the plugins use 'for plugin in application: ...'. """ super(Application, self).__init__(**traits) # fixme: We have to initialize the application home here (i.e. we can't # wait until the 'home' trait is accessed) because the scoped # preferences uses 'ETSConfig.application' home as the name of the # default preferences file. self._initialize_application_home() # Set the default preferences node used by the preferences package. # This allows 'PreferencesHelper' and 'PreferenceBinding' instances to # be used as more convenient ways to access preferences. # # fixme: This is another sneaky global! set_default_preferences(self.preferences) # We allow the caller to specify an initial list of plugins, but the # list itself is not part of the public API. To add and remove plugins # after construction, use the 'add_plugin' and 'remove_plugin' methods # respectively. The application is also iterable, so to iterate over # the plugins use 'for plugin in application: ...'. if plugins is not None: map(self.add_plugin, plugins) return ########################################################################### # 'IApplication' interface. ########################################################################### #### Trait initializers ################################################### def _home_default(self): """ Trait initializer. """ return ETSConfig.application_home def _user_data_default(self): """ Trait initializer. """ user_data = os.path.join( ETSConfig.user_data, self.id ) # Make sure it exists! if not os.path.exists(user_data): os.makedirs(user_data) return user_data def _preferences_default(self): """ Trait initializer. """ return ScopedPreferences() #### Methods ############################################################## def run(self): """ Run the application. """ if self.start(): self.stop() return ########################################################################### # 'IExtensionRegistry' interface. ########################################################################### def add_extension_point_listener(self, listener, extension_point_id=None): """ Add a listener for extensions being added/removed. """ self.extension_registry.add_extension_point_listener( listener, extension_point_id ) return def add_extension_point(self, extension_point): """ Add an extension point. """ self.extension_registry.add_extension_point(extension_point) return def get_extensions(self, extension_point_id): """ Return a list containing all contributions to an extension point. """ return self.extension_registry.get_extensions(extension_point_id) def get_extension_point(self, extension_point_id): """ Return the extension point with the specified Id. """ return self.extension_registry.get_extension_point(extension_point_id) def get_extension_points(self): """ Return all extension points that have been added to the registry. """ return self.extension_registry.get_extension_points() def remove_extension_point_listener(self,listener,extension_point_id=None): """ Remove a listener for extensions being added/removed. """ self.extension_registry.remove_extension_point_listener( listener, extension_point_id ) return def remove_extension_point(self, extension_point_id): """ Remove an extension point. """ self.extension_registry.remove_extension_point(extension_point_id) return def set_extensions(self, extension_point_id, extensions): """ Set the extensions contributed to an extension point. """ self.extension_registry.set_extensions(extension_point_id, extensions) return ########################################################################### # 'IImportManager' interface. ########################################################################### def import_symbol(self, symbol_path): """ Import the symbol defined by the specified symbol path. """ return self._import_manager.import_symbol(symbol_path) ########################################################################### # 'IPluginManager' interface. ########################################################################### def __iter__(self): """ Return an iterator over the manager's plugins. """ return iter(self.plugin_manager) def add_plugin(self, plugin): """ Add a plugin to the manager. """ self.plugin_manager.add_plugin(plugin) return def get_plugin(self, plugin_id): """ Return the plugin with the specified Id. """ return self.plugin_manager.get_plugin(plugin_id) def remove_plugin(self, plugin): """ Remove a plugin from the manager. """ self.plugin_manager.remove_plugin(plugin) return def start(self): """ Start the plugin manager. Returns True unless the start was vetoed. """ # fixme: This method is notionally on the 'IPluginManager' interface # but that interface knows nothing about the vetoable events etc and # hence doesn't have a return value. logger.debug('---------- application starting ----------') # Lifecycle event. self.starting = event = self._create_application_event() if not event.veto: # Start the plugin manager (this starts all of the manager's # plugins). self.plugin_manager.start() # Lifecycle event. self.started = self._create_application_event() logger.debug('---------- application started ----------') else: logger.debug('---------- application start vetoed ----------') return not event.veto def start_plugin(self, plugin=None, plugin_id=None): """ Start the specified plugin. """ return self.plugin_manager.start_plugin(plugin, plugin_id) def stop(self): """ Stop the plugin manager. Returns True unless the stop was vetoed. """ # fixme: This method is notionally on the 'IPluginManager' interface # but that interface knows nothing about the vetoable events etc and # hence doesn't have a return value. logger.debug('---------- application stopping ----------') # Lifecycle event. self.stopping = event = self._create_application_event() if not event.veto: # Stop the plugin manager (this stops all of the manager's # plugins). self.plugin_manager.stop() # Save all preferences. self.preferences.save() # Lifecycle event. self.stopped = self._create_application_event() logger.debug('---------- application stopped ----------') else: logger.debug('---------- application stop vetoed ----------') return not event.veto def stop_plugin(self, plugin=None, plugin_id=None): """ Stop the specified plugin. """ return self.plugin_manager.stop_plugin(plugin, plugin_id) ########################################################################### # 'IServiceRegistry' interface. ########################################################################### def get_service(self, protocol, query='', minimize='', maximize=''): """ Return at most one service that matches the specified query. """ service = self.service_registry.get_service( protocol, query, minimize, maximize ) return service def get_service_from_id(self, service_id): """ Return the service with the specified id. """ return self.service_registry.get_service_from_id(service_id) def get_service_properties(self, service_id): """ Return the dictionary of properties associated with a service. """ return self.service_registry.get_service_properties(service_id) def get_services(self, protocol, query='', minimize='', maximize=''): """ Return all services that match the specified query. """ services = self.service_registry.get_services( protocol, query, minimize, maximize ) return services def register_service(self, protocol, obj, properties=None): """ Register a service. """ service_id = self.service_registry.register_service( protocol, obj, properties ) return service_id def set_service_properties(self, service_id, properties): """ Set the dictionary of properties associated with a service. """ self.service_registry.set_service_properties(service_id, properties) return def unregister_service(self, service_id): """ Unregister a service. """ self.service_registry.unregister_service(service_id) return ########################################################################### # 'Application' interface. ########################################################################### #### Trait initializers ################################################### def _extension_registry_default(self): """ Trait initializer. """ # Do the import here to emphasize the fact that this is just the # default implementation and that the application developer is free # to override it! from plugin_extension_registry import PluginExtensionRegistry return PluginExtensionRegistry(plugin_manager=self) def _plugin_manager_default(self): """ Trait initializer. """ # Do the import here to emphasize the fact that this is just the # default implementation and that the application developer is free # to override it! from plugin_manager import PluginManager return PluginManager(application=self) def _service_registry_default(self): """ Trait initializer. """ # Do the import here to emphasize the fact that this is just the # default implementation and that the application developer is free # to override it! from service_registry import ServiceRegistry return ServiceRegistry() ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ # fixme: We have this to make it easier to assign a new plugin manager # at construction time due to the fact that the plugin manager needs a # reference to the application and vice-versa, e.g. we can do # # application = Application(plugin_manager=EggPluginManager()) # # If we didn't have this then we would have to do this:- # # application = Application() # application.plugin_manager = EggPluginManager(application=application) # # Of course, it would be better if the plugin manager didn't require a # reference to the application at all (it currently uses it to set the # 'application' trait of plugin instances - but that is only done for the # same reason as this (i.e. it is nice to be able to pass plugins into the # application constructor). def _plugin_manager_changed(self, trait_name, old, new): """ Static trait change handler. """ if old is not None: old.application = None if new is not None: new.application = self return #### Methods ############################################################## def _create_application_event(self): """ Create an application event. """ return ApplicationEvent(application=self) def _initialize_application_home(self): """ Initialize the application home directory. """ ETSConfig.application_home = os.path.join( ETSConfig.application_data, self.id ) # Make sure it exists! if not os.path.exists(ETSConfig.application_home): os.makedirs(ETSConfig.application_home) return #### EOF ###################################################################### envisage-4.1.0/envisage/resource/0000755000175100001440000000000011674464014017735 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/resource/tests/0000755000175100001440000000000011674464014021077 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/resource/tests/resource_manager_test_case.py0000644000175100001440000001071511674464014027030 0ustar ischnellusers00000000000000""" Tests for the resource manager. """ # Standard library imports. import unittest import urllib2 import StringIO # Major package imports. from pkg_resources import resource_filename # Enthought library imports. from envisage.resource.api import ResourceManager from envisage.resource.api import NoSuchResourceError from traits.api import HasTraits, Int, Str # This module's package. PKG = 'envisage.resource.tests' # mimics urllib2.urlopen for some tests. # In setUp it replaces urllib2.urlopen for some tests, # and in tearDown, the regular urlopen is put back into place. def stubout_urlopen(url): if 'bogus' in url: raise urllib2.HTTPError(url, '404', 'No such resource', '', None) elif 'localhost' in url: return StringIO.StringIO('This is a test file.\n') else: raise ValueError('Unexpected URL %r in stubout_urlopen' % url) class ResourceManagerTestCase(unittest.TestCase): """ Tests for the resource manager. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ self.stored_urlopen = urllib2.urlopen urllib2.urlopen = stubout_urlopen return def tearDown(self): """ Called immediately after each test method has been called. """ urllib2.urlopen = self.stored_urlopen return ########################################################################### # Tests. ########################################################################### def test_file_resource(self): """ file resource """ rm = ResourceManager() # Get the filename of the 'api.py' file. filename = resource_filename('envisage.resource', 'api.py') # Open a file resource. f = rm.file('file://' + filename) self.assertNotEqual(f, None) contents = f.read() f.close() # Open the api file via the file system. g = file(filename, 'rb') self.assertEqual(g.read(), contents) g.close() return def test_no_such_file_resource(self): """ no such file resource """ rm = ResourceManager() # Open a file resource. self.failUnlessRaises( NoSuchResourceError, rm.file, 'file://../bogus.py' ) return def test_package_resource(self): """ package resource """ rm = ResourceManager() # Open a package resource. f = rm.file('pkgfile://envisage.resource/api.py') self.assertNotEqual(f, None) contents = f.read() f.close() # Get the filename of the 'api.py' file. filename = resource_filename('envisage.resource', 'api.py') # Open the api file via the file system. g = file(filename, 'rb') self.assertEqual(g.read(), contents) g.close() return def test_no_such_package_resource(self): """ no such package resource """ rm = ResourceManager() # Open a package resource. self.failUnlessRaises( NoSuchResourceError, rm.file, 'pkgfile://envisage.resource/bogus.py' ) self.failUnlessRaises( NoSuchResourceError, rm.file, 'pkgfile://completely.bogus/bogus.py' ) return def test_http_resource(self): """ http resource """ # Open an HTTP document resource. rm = ResourceManager() f = rm.file('http://localhost:1234/file.dat') self.assertNotEqual(f, None) contents = f.read() f.close() self.assertEquals(contents, 'This is a test file.\n') return def test_no_such_http_resource(self): """ no such http resource """ # Open an HTTP document resource. rm = ResourceManager() self.failUnlessRaises( NoSuchResourceError, rm.file, 'http://localhost:1234/bogus.dat' ) return def test_unknown_protocol(self): """ unknown protocol """ # Open an HTTP document resource. rm = ResourceManager() self.failUnlessRaises(ValueError, rm.file, 'bogus://foo/bar/baz') return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/resource/tests/__init__.py0000644000175100001440000000000011674464014023176 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/resource/i_resource_manager.py0000644000175100001440000000133311674464014024140 0ustar ischnellusers00000000000000""" The resource manager interface. """ # Enthought library imports. from traits.api import Instance, Interface # Local imports. from i_resource_protocol import IResourceProtocol class IResourceManager(Interface): """ The resource manager interface. """ # The protocols used by the manager to resolve resource URLs. resource_protocols = Instance(IResourceProtocol) def file(self, url): """ Return a readable file-like object for the specified url. Raise a 'NoSuchResourceError' if the resource does not exist. e.g.:: manager.file('pkgfile://acme.ui.workbench/preferences.ini') """ #### EOF ###################################################################### envisage-4.1.0/envisage/resource/api.py0000644000175100001440000000056511674464014021066 0ustar ischnellusers00000000000000from i_resource_protocol import IResourceProtocol from i_resource_manager import IResourceManager from file_resource_protocol import FileResourceProtocol from http_resource_protocol import HTTPResourceProtocol from no_such_resource_error import NoSuchResourceError from package_resource_protocol import PackageResourceProtocol from resource_manager import ResourceManager envisage-4.1.0/envisage/resource/resource_manager.py0000644000175100001440000000366411674464014023641 0ustar ischnellusers00000000000000""" The default resource manager. """ # Enthought library imports. from traits.api import Dict, HasTraits, Str, implements # Local imports. from i_resource_manager import IResourceManager from i_resource_protocol import IResourceProtocol class ResourceManager(HasTraits): """ The default resource manager. """ implements(IResourceManager) #### 'IResourceManager' interface ######################################### # The protocols used by the manager to resolve resource URLs. resource_protocols = Dict(Str, IResourceProtocol) ########################################################################### # 'IResourceManager' interface. ########################################################################### #### Trait initializers ################################################### def _resource_protocols_default(self): """ Trait initializer. """ # We do the import(s) here in case somebody wants a resource manager # that doesn't use the default protocol(s). from file_resource_protocol import FileResourceProtocol from http_resource_protocol import HTTPResourceProtocol from package_resource_protocol import PackageResourceProtocol resource_protocols = { 'file' : FileResourceProtocol(), 'http' : HTTPResourceProtocol(), 'pkgfile' : PackageResourceProtocol() } return resource_protocols #### Methods ############################################################## def file(self, url): """ Return a readable file-like object for the specified url. """ protocol_name, address = url.split('://') protocol = self.resource_protocols.get(protocol_name) if protocol is None: raise ValueError('unknown protocol in URL %s' % url) return protocol.file(address) #### EOF ###################################################################### envisage-4.1.0/envisage/resource/i_resource_protocol.py0000644000175100001440000000110311674464014024362 0ustar ischnellusers00000000000000""" The interface for protocols that handle resource URLs. """ # Enthought library imports. from traits.api import Interface class IResourceProtocol(Interface): """ The interface for protocols that handle resource URLs. """ def file(self, address): """ Return a readable file-like object for the specified address. Raise a 'NoSuchResourceError' if the resource does not exist. e.g.:: protocol.file('acme.ui.workbench/preferences.ini') """ #### EOF ###################################################################### envisage-4.1.0/envisage/resource/file_resource_protocol.py0000644000175100001440000000224711674464014025063 0ustar ischnellusers00000000000000""" A resource protocol for a local file system. """ # Standard library imports. import errno # Enthought library imports. from traits.api import HasTraits, implements # Local imports. from i_resource_protocol import IResourceProtocol from no_such_resource_error import NoSuchResourceError class FileResourceProtocol(HasTraits): """ A resource protocol for a local file system. """ implements(IResourceProtocol) ########################################################################### # 'IResourceProtocol' interface. ########################################################################### def file(self, address): """ Return a readable file-like object for the specified address. """ # Opened in binary mode to be consistent with package resources. This # means, for example, that line-endings will not be converted. try: f = file(address, 'rb') except IOError, e: if e.errno == errno.ENOENT: raise NoSuchResourceError(address) else: raise return f #### EOF ###################################################################### envisage-4.1.0/envisage/resource/no_such_resource_error.py0000644000175100001440000000061611674464014025070 0ustar ischnellusers00000000000000""" The exception raised when trying to open a non-existent resource. """ class NoSuchResourceError(Exception): """ The exception raised when trying to open a non-existent resource. """ def __init__(self, message=''): """ Constructor. """ Exception.__init__(self, message) return #### EOF ###################################################################### envisage-4.1.0/envisage/resource/http_resource_protocol.py0000644000175100001440000000204411674464014025116 0ustar ischnellusers00000000000000""" A resource protocol for HTTP documents. """ # Enthought library imports. from traits.api import HasTraits, implements # Local imports. from i_resource_protocol import IResourceProtocol from no_such_resource_error import NoSuchResourceError class HTTPResourceProtocol(HasTraits): """ A resource protocol for HTTP documents. """ implements(IResourceProtocol) ########################################################################### # 'IResourceProtocol' interface. ########################################################################### def file(self, address): """ Return a readable file-like object for the specified address. """ # Do the import here 'cos I'm not sure how much this will actually # be used. import urllib2 try: f = urllib2.urlopen('http://' + address) except urllib2.HTTPError: raise NoSuchResourceError('http:://' + address) return f #### EOF ###################################################################### envisage-4.1.0/envisage/resource/package_resource_protocol.py0000644000175100001440000000301311674464014025527 0ustar ischnellusers00000000000000""" A resource protocol for package resources. """ # Standard library imports. import errno, pkg_resources # Enthought library imports. from traits.api import HasTraits, implements # Local imports. from i_resource_protocol import IResourceProtocol from no_such_resource_error import NoSuchResourceError class PackageResourceProtocol(HasTraits): """ A resource protocol for package resources. This protocol uses 'pkg_resources' to find and access resources. An address for this protocol is a string in the form:: 'package/resource' e.g:: 'acme.ui.workbench/preferences.ini' """ implements(IResourceProtocol) ########################################################################### # 'IResourceProtocol' interface. ########################################################################### def file(self, address): """ Return a readable file-like object for the specified address. """ first_forward_slash = address.index('/') package = address[:first_forward_slash] resource_name = address[first_forward_slash+1:] try: f = pkg_resources.resource_stream(package, resource_name) except IOError, e: if e.errno == errno.ENOENT: raise NoSuchResourceError(address) else: raise except ImportError: raise NoSuchResourceError(address) return f #### EOF ###################################################################### envisage-4.1.0/envisage/resource/__init__.py0000644000175100001440000000000011674464014022034 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/i_plugin.py0000644000175100001440000000301711674464014020267 0ustar ischnellusers00000000000000""" The plugin interface. """ # Enthought library imports. from traits.api import Instance, Interface, Str # Local imports. from i_plugin_activator import IPluginActivator class IPlugin(Interface): """ The plugin interface. """ # The activator used to start and stop the plugin. activator = Instance(IPluginActivator) # The application that the plugin is part of. application = Instance('envisage.api.IApplication') # The name of a directory (created for you) that the plugin can read and # write to at will. home = Str # The plugin's unique identifier. # # Where 'unique' technically means 'unique within the plugin manager', but # since the chances are that you will want to include plugins from external # sources, this really means 'globally unique'! Using the Python package # path might be useful here. e.g. 'envisage'. id = Str # The plugin's name (suitable for displaying to the user). name = Str def start(self): """ Start the plugin. This method is called by the framework when the application is starting up. If you want to start a plugin manually use:: application.start_plugin(plugin) """ def stop(self): """ Stop the plugin. This method is called by the framework when the application is stopping. If you want to stop a plugin manually use:: application.stop_plugin(plugin) """ #### EOF ###################################################################### envisage-4.1.0/envisage/tests/0000755000175100001440000000000011674464014017250 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/foo.py0000644000175100001440000000045511674464014020411 0ustar ischnellusers00000000000000""" A test class used in the service registry tests! """ # Enthought library imports. from traits.api import HasTraits, implements # Local imports. from i_foo import IFoo class Foo(HasTraits): implements(IFoo) #### EOF ###################################################################### envisage-4.1.0/envisage/tests/eggs/0000755000175100001440000000000011674464014020175 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.foo/0000755000175100001440000000000011674464014021664 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.foo/acme/0000755000175100001440000000000011674464014022571 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.foo/acme/foo/0000755000175100001440000000000011674464014023354 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.foo/acme/foo/foo_plugin.py0000644000175100001440000000171511674464014026073 0ustar ischnellusers00000000000000""" The 'Foo' plugin """ # Enthought library imports. from envisage.api import Plugin from traits.api import Bool class FooPlugin(Plugin): """ The 'Foo' plugin """ #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.foo' #### 'FooPlugin' interface ################################################ started = Bool(False) stopped = Bool(False) ########################################################################### # 'IPlugin' interface. ########################################################################### def start(self): """ Start the plugin. """ self.started = True self.stopped = False return def stop(self): """ Stop the plugin. """ self.started = False self.stopped = True return #### EOF ###################################################################### envisage-4.1.0/envisage/tests/eggs/acme.foo/acme/foo/__init__.py0000644000175100001440000000034311674464014025465 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/envisage/tests/eggs/acme.foo/acme/__init__.py0000644000175100001440000000034311674464014024702 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/envisage/tests/eggs/acme.foo/setup.py0000644000175100001440000000113311674464014023374 0ustar ischnellusers00000000000000# Major package imports. from setuptools import setup, find_packages setup( name = 'acme.foo', version = '0.1a1', author = 'Enthought, Inc', author_email = 'info@enthought.com', license = 'BSD', zip_safe = True, packages = find_packages(), include_package_data = True, namespace_packages = [ 'acme', 'acme.foo' ], install_requires = [ ], entry_points = """ [envisage.plugins] acme.foo = acme.foo.foo_plugin:FooPlugin """ ) envisage-4.1.0/envisage/tests/eggs/acme.bar-0.1a1.egg0000644000175100001440000000670411674464014023056 0ustar ischnellusers00000000000000PK5\[8~a?acme/__init__.py 0D "z+CbIRMn,13PiU@c?$K\ç!,9=ӻz;($GZ%^oZA8 *Ǽv$;reBoghU{D}oVdPKSb9acme/__init__.pycE= @g!*'PRVN"!,&  ^8+cfx;N¯F-CL Y!Ӏ.fRtddiC]Mp3ɪH&k`\z]uM2 YSFsrǬFm#CPK5\[8\)2-?acme/bar/bar_plugin.pyKj0aPr6:@@]\@Ƕ@T= }%r^nm:뇲ޘ_(ѡiySg1GD#Z2#P^Ȏ-< e7dtqiqSJT֝";<'nM^TeoI)/1n^KW҆ɳNǛdvu2tiA͘7ȔL_p]I_]R/qE`iePKSb9/Macme/bar/bar_plugin.pycϊ@ƫ;f2O 9UYa0z{3fgE|_ЪΌ:QUW5󛯯װ{"ٶj)Tk(I"9 jd(18yL/3DeGK֍۴CqnnegY_qMgl8/17 19ďAk̜w?YEGG-INFO/entry_points.txtRԼԼT̼XT"[8!,b0PKSb9?EGG-INFO/namespace_packages.txtKLMJzIE\PKSb9 jEGG-INFO/PKG-INFOMA 0D!0fRAQP7$[ bdOE jP!r* ~x g@(hqvcB.oۙK$p7aD@]E&׾80=&DZPKSb9Z EGG-INFO/requires.txtKLMKPKSb9t-KEGG-INFO/SOURCES.txtu0 !c"F⹙PQV.OC{GY, X`йPjEFb[Y1!kX@Fb%lbz0f Yv%i>0qoPKSb9߳EGG-INFO/top_level.txtKLMPKSb92EGG-INFO/zip-safePK5\[8~a?acme/__init__.pyPKSb9acme/__init__.pycPK5\[8\)2-?acme/bar/bar_plugin.pyPKSb9/Macme/bar/bar_plugin.pycPK5\[8~a?acme/bar/__init__.pyPKSb9OMacme/bar/__init__.pycPKSb92EGG-INFO/dependency_links.txtPKSb9t>w?Y EGG-INFO/entry_points.txtPKSb9?EGG-INFO/namespace_packages.txtPKSb9 jEGG-INFO/PKG-INFOPKSb9Z EGG-INFO/requires.txtPKSb9t-KEGG-INFO/SOURCES.txtPKSb9߳ EGG-INFO/top_level.txtPKSb92 EGG-INFO/zip-safePK envisage-4.1.0/envisage/tests/eggs/acme.foo-0.1a1.egg0000644000175100001440000000647611674464014023103 0ustar ischnellusers00000000000000PK5\[8~a?acme/__init__.py 0D "z+CbIRMn,13PiU@c?$K\ç!,9=ӻz;($GZ%^oZA8 *Ǽv$;reBoghU{D}oVdPKa9acme/__init__.pycE= @g!*'PRVN"!,&  ^8+cfx;N¯F-CL Y!Ӏ.fRtddiC]Mp3ɪH&k`\z]uM2 YSFsrǬFm#CPK5\[8g0?acme/foo/foo_plugin.pyKN0rH 5" dXrb@.2B4"T(>!,·lGт/wZ`.8qL*xV3%>H)V0c:we>UސMT>[=k1&~(Jơi\e!_5Me{X;!=+)K˴0.8W7LTj;cźQd6\4,ɋڠ+/9d.SY%gËdv5%:= %2I g`ߩ{p867FY|PKa9Haacme/foo/foo_plugin.pycj@gW !)9$zEZBi!BYRaw-/»J)Īf(WnJjO}bzNsSnw}y Z: Kv8f?&V@B} bC$]ʳ}lBʲ֪,;k#ܑwYMZ OJH5Bv8)"(hɪu++F۪VyiA]ӽTY?p?հ3jPK5\[8~a?acme/foo/__init__.py 0D "z+CbIRMn,13PiU@c?$K\ç!,9=ӻz;($GZ%^oZA8 *Ǽv$;reBoghU{D}oVdPKa9%acme/foo/__init__.pycE= A ,JmlIӃoZzx3< > {a= Ka(pabms]@!E=A{[)L q4.T3$Q>4eW0XR8=#mPKa9w,EGG-INFO/SOURCES.txtu 0 K8<%Kœ!9|w3,V'lI~,`}j.9u>u(r@$s%C0]ZI cſHLv@ ~PKa9߳EGG-INFO/top_level.txtKLMPK{s82EGG-INFO/zip-safePK5\[8~a?acme/__init__.pyPKa9acme/__init__.pycPK5\[8g0?acme/foo/foo_plugin.pyPKa9Ha acme/foo/foo_plugin.pycPK5\[8~a?acme/foo/__init__.pyPKa9%acme/foo/__init__.pycPKa92EGG-INFO/dependency_links.txtPKa9{Ձ?Y EGG-INFO/entry_points.txtPKa9̯uEGG-INFO/namespace_packages.txtPKa9GtEGG-INFO/PKG-INFOPKa9w,EGG-INFO/SOURCES.txtPKa9߳M EGG-INFO/top_level.txtPK{s82 EGG-INFO/zip-safePK n envisage-4.1.0/envisage/tests/eggs/acme.baz-0.1a1.egg0000644000175100001440000000670411674464014023066 0ustar ischnellusers00000000000000PK4\[8~a?acme/__init__.py 0D "z+CbIRMn,13PiU@c?$K\ç!,9=ӻz;($GZ%^oZA8 *Ǽv$;reBoghU{D}oVdPKhb9jacme/__init__.pycE= @g!*'PRVN"!,& =' ^8+cfx;N¯F-CL Y!Ӏ.fRtddiC]Mp3ɪH&k`\z]uM2 YSFsrǬFm#CPK4\[8FWa.?acme/baz/baz_plugin.pyKj0aPN6:@@]\@Ƕ@T= +YU΢m:k1ӯ!G-|%B"~+I+?fށZgiYF |uH_U<:xpH`BItlB1P= thZVYDq(* ^Wp%r44bPk+CYnj([)r*DŽuN-8OA,lM>-6oIޔw~::dWhGq̎f. 1輑dJS\WW`K\9wzPKhb9 8Aacme/baz/baz_plugin.pycn@gGAZāť> *T$8Th V$k::]V^'x!^f  TXO3|˷oYcI@@qfPs(801Asjfو:+i}e|'cxbw:!y.@n E#"@4Dpq[<< YЎ,k/vI`lg~HnJ YFj:srRyz-^;!zK+G-k]կX]_e/)ʢ7/.`溪=Gh:θ{!HX}ahl3n)O ҟU\t[ה|%o`MP @ޏT 5SQN4Nw%ƭھZ\77J3\Ã{Y_aMgl8gBRwt >:PKhb9߳EGG-INFO/top_level.txtKLMPKhb92EGG-INFO/zip-safePK4\[8~a?acme/__init__.pyPKhb9jacme/__init__.pycPK4\[8FWa.?acme/baz/baz_plugin.pyPKhb9 8A acme/baz/baz_plugin.pycPK4\[8~a?acme/baz/__init__.pyPKhb9$I!ӿacme/baz/__init__.pycPKhb92EGG-INFO/dependency_links.txtPKhb9M(*?Y EGG-INFO/entry_points.txtPKhb9EGG-INFO/namespace_packages.txtPKhb93]EGG-INFO/PKG-INFOPKhb98@ EGG-INFO/requires.txtPKhb90^[KEGG-INFO/SOURCES.txtPKhb9߳ EGG-INFO/top_level.txtPKhb92 EGG-INFO/zip-safePK envisage-4.1.0/envisage/tests/eggs/acme.bar/0000755000175100001440000000000011674464014021645 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.bar/acme/0000755000175100001440000000000011674464014022552 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.bar/acme/bar/0000755000175100001440000000000011674464014023316 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.bar/acme/bar/bar_plugin.py0000644000175100001440000000171511674464014026016 0ustar ischnellusers00000000000000""" The 'Bar' plugin """ # Enthought library imports. from envisage.api import Plugin from traits.api import Bool class BarPlugin(Plugin): """ The 'Bar' plugin """ #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.bar' #### 'BarPlugin' interface ################################################ started = Bool(False) stopped = Bool(False) ########################################################################### # 'IPlugin' interface. ########################################################################### def start(self): """ Start the plugin. """ self.started = True self.stopped = False return def stop(self): """ Stop the plugin. """ self.started = False self.stopped = True return #### EOF ###################################################################### envisage-4.1.0/envisage/tests/eggs/acme.bar/acme/bar/__init__.py0000644000175100001440000000034311674464014025427 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/envisage/tests/eggs/acme.bar/acme/__init__.py0000644000175100001440000000034311674464014024663 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/envisage/tests/eggs/acme.bar/setup.py0000644000175100001440000000115611674464014023362 0ustar ischnellusers00000000000000# Major package imports. from setuptools import setup, find_packages setup( name = 'acme.bar', version = '0.1a1', author = 'Enthought, Inc', author_email = 'info@enthought.com', license = 'BSD', zip_safe = True, packages = find_packages(), include_package_data = True, namespace_packages = [ 'acme', 'acme.bar' ], install_requires = [ 'acme.foo' ], entry_points = """ [envisage.plugins] acme.bar = acme.bar.bar_plugin:BarPlugin """ ) envisage-4.1.0/envisage/tests/eggs/acme.baz/0000755000175100001440000000000011674464014021655 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.baz/acme/0000755000175100001440000000000011674464014022562 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.baz/acme/baz/0000755000175100001440000000000011674464014023336 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/eggs/acme.baz/acme/baz/baz_plugin.py0000644000175100001440000000171511674464014026046 0ustar ischnellusers00000000000000""" The 'Baz' plugin """ # Enthought library imports. from envisage.api import Plugin from traits.api import Bool class BazPlugin(Plugin): """ The 'Baz' plugin """ #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.baz' #### 'BazPlugin' interface ################################################ started = Bool(False) stopped = Bool(False) ########################################################################### # 'IPlugin' interface. ########################################################################### def start(self): """ Start the plugin. """ self.started = True self.stopped = False return def stop(self): """ Stop the plugin. """ self.started = False self.stopped = True return #### EOF ###################################################################### envisage-4.1.0/envisage/tests/eggs/acme.baz/acme/baz/__init__.py0000644000175100001440000000034311674464014025447 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/envisage/tests/eggs/acme.baz/acme/__init__.py0000644000175100001440000000034311674464014024673 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/envisage/tests/eggs/acme.baz/setup.py0000644000175100001440000000115611674464014023372 0ustar ischnellusers00000000000000# Major package imports. from setuptools import setup, find_packages setup( name = 'acme.baz', version = '0.1a1', author = 'Enthought, Inc', author_email = 'info@enthought.com', license = 'BSD', zip_safe = True, packages = find_packages(), include_package_data = True, namespace_packages = [ 'acme', 'acme.baz' ], install_requires = [ 'acme.bar' ], entry_points = """ [envisage.plugins] acme.baz = acme.baz.baz_plugin:BazPlugin """ ) envisage-4.1.0/envisage/tests/class_load_hook_test_case.py0000644000175100001440000000660711674464014025011 0ustar ischnellusers00000000000000""" Tests for class load hooks. """ # Standard library imports. import sys, unittest # Enthought library imports. from envisage.api import ClassLoadHook from traits.api import HasTraits # This module's package. PKG = 'envisage.tests' class ClassLoadHookTestCase(unittest.TestCase): """ Tests for class load hooks. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_connect(self): """ connect """ def on_class_loaded(cls): """ Called when a class is loaded. """ on_class_loaded.cls = cls return # To register with 'MetaHasTraits' we use 'module_name.class_name'. hook = ClassLoadHook( class_name = ClassLoadHookTestCase.__module__ + '.Foo', on_load = on_class_loaded ) hook.connect() class Foo(HasTraits): pass self.assertEqual(Foo, on_class_loaded.cls) return def test_class_already_loaded(self): """ class already loaded """ def on_class_loaded(cls): """ Called when a class is loaded. """ on_class_loaded.cls = cls return # To register with 'MetaHasTraits' we use 'module_name.class_name'. hook = ClassLoadHook( class_name = self._get_full_class_name(ClassLoadHookTestCase), on_load = on_class_loaded ) hook.connect() # Make sure the 'on_load' got called immediately because the class is # already loaded. self.assertEqual(ClassLoadHookTestCase, on_class_loaded.cls) return def test_disconnect(self): """ disconnect """ def on_class_loaded(cls): """ Called when a class is loaded. """ on_class_loaded.cls = cls return # To register with 'MetaHasTraits' we use 'module_name.class_name'. hook = ClassLoadHook( class_name = ClassLoadHookTestCase.__module__ + '.Foo', on_load = on_class_loaded ) hook.connect() class Foo(HasTraits): pass self.assertEqual(Foo, on_class_loaded.cls) # 'Reset' the listener, on_class_loaded.cls = None # Now disconnect. hook.disconnect() class Foo(HasTraits): pass self.assertEqual(None, on_class_loaded.cls) return ########################################################################### # Private interface. ########################################################################### def _get_full_class_name(self, cls): """ Return the full (possibly) dotted name of a class. """ return cls.__module__ + '.' + cls.__name__ # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/safeweakref_test_case.py0000644000175100001440000001004011674464014024132 0ustar ischnellusers00000000000000""" Tests for safe weakrefs. """ # Standard library imports. import unittest, weakref # Enthought library imports. from envisage.safeweakref import ref from traits.api import HasTraits class SafeWeakrefTestCase(unittest.TestCase): """ Tests for safe weakrefs. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_can_create_weakref_to_bound_method(self): class Foo(HasTraits): def method(self): self.method_called = True f = Foo() # Get a weak reference to a bound method. r = ref(f.method) self.assertNotEqual(None, r()) # Make sure we can call it. r()() self.assert_(f.method_called) # Delete the object to delete the method! del f # The reference should now return None. self.assertEqual(None, r()) return def test_two_weakrefs_to_bound_method_are_identical(self): class Foo(HasTraits): def method(self): pass f = Foo() self.assert_(ref(f.method) is ref(f.method)) return def test_internal_cache_is_weak_too(self): # smell: Fragile test because we are reaching into the internals of the # object under test. # # I can't see a (clean!) way around this without adding something to # the public API that would only exist for testing, but in terms of # 'bang for the buck' I think this is good enough despite the # fragility. cache = ref._cache class Foo(HasTraits): def method(self): pass f = Foo() # Get the length of the cache before we do anything. len_cache = len(cache) # Create a weak reference to the bound method and make sure that # exactly one item has been added to the cache. r = ref(f.method) self.assertEqual(len_cache + 1, len(cache)) # Delete the instance! del f # Our `ref` should now reference nothing... self.assertEqual(None, r()) # ... and the cache should be back to its original size! self.assertEqual(len_cache, len(cache)) return def test_two_weakrefs_to_bound_method_are_equal(self): class Foo(HasTraits): def method(self): pass f = Foo() # Make sure that two references to the same method compare as equal. r1 = ref(f.method) r2 = ref(f.method) self.assertEqual(r1, r2) # Make sure that a reference compares as unequal to non-references! self.assert_(not r1 == 99) return def test_two_weakrefs_to_bound_method_hash_equally(self): class Foo(HasTraits): def method(self): pass f = Foo() # Make sure we can hash the references. r1 = ref(f.method) r2 = ref(f.method) self.assertEqual(hash(r1), hash(r2)) # Make sure we can hash non-bound methods. r1 = ref(Foo) r2 = ref(Foo) self.assertEqual(hash(r1), hash(r2)) return def test_get_builtin_weakref_for_non_bound_method(self): class Foo(HasTraits): pass f = Foo() # Get a weak reference to something that is not a bound method. r = ref(f) self.assertEqual(weakref.ref, type(r)) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/service_test_case.py0000644000175100001440000000457211674464014023324 0ustar ischnellusers00000000000000""" Tests for the 'Service' trait type. """ # Standard library imports. import unittest # Enthought library imports. from envisage.api import Application, Plugin, Service from traits.api import HasTraits, Instance class TestApplication(Application): """ The type of application used in the tests. """ id = 'test' class ServiceTestCase(unittest.TestCase): """ Tests for the 'Service' trait type. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_service_trait_type(self): """ service trait type""" class Foo(HasTraits): pass class PluginA(Plugin): id = 'A' foo = Instance(Foo, (), service=True) class PluginB(Plugin): id = 'B' foo = Service(Foo) a = PluginA() b = PluginB() application = TestApplication(plugins=[a, b]) application.start() # Make sure the services were registered. self.assertEqual(a.foo, b.foo) # Stop the application. application.stop() # Make sure the service was unregistered. self.assertEqual(None, b.foo) # You can't set service traits! self.failUnlessRaises(SystemError, setattr, b, 'foo', 'bogus') return def test_service_trait_type_with_no_service_registry(self): """ service trait type with no service registry """ class Foo(HasTraits): pass class Bar(HasTraits): foo = Service(Foo) # We should get an exception because the object does not have an # 'service_registry' trait. b = Bar() self.failUnlessRaises(ValueError, getattr, b, 'foo') return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/bar_category.py0000644000175100001440000000036011674464014022262 0ustar ischnellusers00000000000000""" A test class used to test categories. """ # Enthought library imports. from traits.api import HasTraits, Int class BarCategory(HasTraits): y = Int #### EOF ###################################################################### envisage-4.1.0/envisage/tests/extension_registry_test_case.py0000644000175100001440000001276311674464014025631 0ustar ischnellusers00000000000000""" Tests for the base extension registry. """ # Standard library imports. import unittest # Enthought library imports. from envisage.api import Application, ExtensionPoint from envisage.api import ExtensionRegistry, UnknownExtensionPoint from envisage.api import UnknownExtension from traits.api import List class ExtensionRegistryTestCase(unittest.TestCase): """ Tests for the base extension registry. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ # We do all of the testing via the application to make sure it offers # the same interface! self.registry = Application(extension_registry=ExtensionRegistry()) return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_empty_registry(self): """ empty registry """ registry = self.registry # Make sure there are no extensions. extensions = registry.get_extensions('my.ep') self.assertEqual(0, len(extensions)) # Make sure there are no extension points. extension_points = registry.get_extension_points() self.assertEqual(0, len(extension_points)) return def test_add_extension_point(self): """ add extension point """ registry = self.registry # Add an extension *point*. registry.add_extension_point(self._create_extension_point('my.ep')) # Make sure there's NO extensions. extensions = registry.get_extensions('my.ep') self.assertEqual(0, len(extensions)) # Make sure there's one and only one extension point. extension_points = registry.get_extension_points() self.assertEqual(1, len(extension_points)) self.assertEqual('my.ep', extension_points[0].id) return def test_get_extension_point(self): """ get extension point """ registry = self.registry # Add an extension *point*. registry.add_extension_point(self._create_extension_point('my.ep')) # Make sure we can get it. extension_point = registry.get_extension_point('my.ep') self.assertNotEqual(None, extension_point) self.assertEqual('my.ep', extension_point.id) return def test_remove_empty_extension_point(self): """ remove empty_extension point """ registry = self.registry # Add an extension point... registry.add_extension_point(self._create_extension_point('my.ep')) # ...and remove it! registry.remove_extension_point('my.ep') # Make sure there are no extension points. extension_points = registry.get_extension_points() self.assertEqual(0, len(extension_points)) return def test_remove_non_empty_extension_point(self): """ remove non-empty extension point """ registry = self.registry # Add an extension point... registry.add_extension_point(self._create_extension_point('my.ep')) # ... with some extensions... registry.set_extensions('my.ep', [42]) # ...and remove it! registry.remove_extension_point('my.ep') # Make sure there are no extension points. extension_points = registry.get_extension_points() self.assertEqual(0, len(extension_points)) # And that the extensions are gone too. self.assertEqual([], registry.get_extensions('my.ep')) return def test_remove_non_existent_extension_point(self): """ remove non existent extension point """ registry = self.registry self.failUnlessRaises( UnknownExtensionPoint, registry.remove_extension_point, 'my.ep' ) return def test_remove_non_existent_listener(self): """ remove non existent listener """ registry = self.registry def listener(registry, extension_point, added, removed, index): """ Called when an extension point has changed. """ self.listener_called = (registry, extension_point, added, removed) return self.failUnlessRaises( ValueError, registry.remove_extension_point_listener, listener ) return def test_set_extensions(self): """ set extensions """ registry = self.registry # Add an extension *point*. registry.add_extension_point(self._create_extension_point('my.ep')) # Set some extensions. registry.set_extensions('my.ep', [1, 2, 3]) # Make sure we can get them. self.assertEqual([1, 2, 3], registry.get_extensions('my.ep')) return ########################################################################### # Private interface. ########################################################################### def _create_extension_point(self, id, trait_type=List, desc=''): """ Create an extension point. """ return ExtensionPoint(id=id, trait_type=trait_type, desc=desc) # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/egg_plugin_manager_test_case.py0000644000175100001440000001427311674464014025475 0ustar ischnellusers00000000000000""" Tests for the Egg plugin manager. """ # Standard library imports. import unittest # Enthought library imports. from envisage.api import EggPluginManager # Local imports. from egg_based_test_case import EggBasedTestCase class EggPluginManagerTestCase(EggBasedTestCase): """ Tests for the Egg plugin manager. """ ########################################################################### # Tests. ########################################################################### # fixme: Depending how many eggs are on sys.path, this test may take too # long to be part of the TDD cycle. def test_no_include_or_exclude(self): """ no include or exclude """ # Add all of the eggs in the egg basket. self._add_eggs_on_path([self.egg_dir]) # Make sure that the plugin manager only includes those plugins. plugin_manager = EggPluginManager() # We don't know how many plugins we will actually get - it depends on # what eggs are on sys.path! What we *do* know however is the the 3 # 'acme' test eggs should be in there! ids = [plugin.id for plugin in plugin_manager] self.assert_('acme.foo' in ids) self.assert_('acme.bar' in ids) self.assert_('acme.baz' in ids) return def test_include_specific(self): """ include specific """ # Add all of the eggs in the egg basket. self._add_eggs_on_path([self.egg_dir]) # The Ids of the plugins that we expect the plugin manager to find. expected = ['acme.foo', 'acme.bar'] # We explicitly limit the plugins to be just the 'acme' test plugins # because otherwise the egg plugin manager will pick up *every* plugin # in *every* egg on sys.path! include = ['acme\.foo', 'acme\.bar'] # Make sure that the plugin manager only includes those plugins. plugin_manager = EggPluginManager(include=include) # Make sure the plugin manager found only the required plugins and that # it starts and stops them correctly.. self._test_start_and_stop(plugin_manager, expected) return def test_include_multiple(self): """ include multiple """ # Add all of the eggs in the egg basket. self._add_eggs_on_path([self.egg_dir]) # The Ids of the plugins that we expect the plugin manager to find. expected = ['acme.foo', 'acme.bar', 'acme.baz'] # We explicitly limit the plugins to be just the 'acme' test plugins # because otherwise the egg plugin manager will pick up *every* plugin # in *every* egg on sys.path! include = ['acme.*'] # Make sure that the plugin manager only includes those plugins. plugin_manager = EggPluginManager(include=include) # Make sure the plugin manager found only the required plugins and that # it starts and stops them correctly.. self._test_start_and_stop(plugin_manager, expected) return def test_exclude_specific(self): """ exclude specific """ # Add all of the eggs in the egg basket. self._add_eggs_on_path([self.egg_dir]) # The Ids of the plugins that we expect the plugin manager to find. expected = ['acme.bar'] # We explicitly limit the plugins to be just the 'acme' test plugins # because otherwise the egg plugin manager will pick up *every* plugin # in *every* egg on sys.path! include = ['acme.*'] # Now exclude all but 'acme.bar'... exclude = ['acme\.foo', 'acme\.baz'] # Make sure that the plugin manager excludes the specified plugins. plugin_manager = EggPluginManager(include=include, exclude=exclude) # Make sure the plugin manager found only the required plugins and that # it starts and stops them correctly.. self._test_start_and_stop(plugin_manager, expected) return def test_exclude_multiple(self): """ exclude multiple """ # Add all of the eggs in the egg basket. self._add_eggs_on_path([self.egg_dir]) # The Ids of the plugins that we expect the plugin manager to find. expected = ['acme.foo'] # We explicitly limit the plugins to be just the 'acme' test plugins # because otherwise the egg plugin manager will pick up *every* plugin # in *every* egg on sys.path! include = ['acme.*'] # Now exclude every plugin that starts with 'acme.b'. exclude = ['acme\.b.*'] # Make sure that the plugin manager excludes the specified plugins. plugin_manager = EggPluginManager(include=include, exclude=exclude) # Make sure the plugin manager found only the required plugins and that # it starts and stops them correctly.. self._test_start_and_stop(plugin_manager, expected) return ########################################################################### # Private interface. ########################################################################### def _test_start_and_stop(self, plugin_manager, expected): """ Make sure the plugin manager starts and stops the expected plugins. """ # Make sure the plugin manager found only the required plugins. self.assertEqual(expected, [plugin.id for plugin in plugin_manager]) # Start the plugin manager. This starts all of the plugin manager's # plugins. plugin_manager.start() # Make sure all of the the plugins were started. for id in expected: plugin = plugin_manager.get_plugin(id) self.assertNotEqual(None, plugin) self.assertEqual(True, plugin.started) # Stop the plugin manager. This stops all of the plugin manager's # plugins. plugin_manager.stop() # Make sure all of the the plugins were stopped. for id in expected: plugin = plugin_manager.get_plugin(id) self.assertNotEqual(None, plugin) self.assertEqual(True, plugin.stopped) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/preferences.ini0000644000175100001440000000003011674464014022243 0ustar ischnellusers00000000000000[enthought.test] x = 42 envisage-4.1.0/envisage/tests/import_manager_test_case.py0000644000175100001440000000356011674464014024664 0ustar ischnellusers00000000000000""" Tests for the import manager. """ # Standard library imports. import unittest # Enthought library imports. from envisage.api import Application, ImportManager class ImportManagerTestCase(unittest.TestCase): """ Tests for the import manager. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ # We do all of the testing via the application to make sure it offers # the same interface! self.import_manager = Application(import_manager=ImportManager()) return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_import_dotted_symbol(self): """ import dotted symbol """ symbol = self.import_manager.import_symbol('unittest.TestCase') self.assertEqual(symbol, unittest.TestCase) return def test_import_nested_symbol(self): """ import nested symbol """ symbol = self.import_manager.import_symbol('unittest:TestCase.setUp') self.assertEqual(symbol, unittest.TestCase.setUp) return def test_import_dotted_module(self): """ import dotted modulel """ symbol = self.import_manager.import_symbol( 'envisage.api:ImportManager' ) self.assertEqual(symbol, ImportManager) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/egg_based_test_case.py0000644000175100001440000000457611674464014023570 0ustar ischnellusers00000000000000""" Base class for Egg-based test cases. """ # Standard library imports. import unittest import pkg_resources from os.path import dirname, join class EggBasedTestCase(unittest.TestCase): """ Base class for Egg-based test cases. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ # The location of the 'eggs' directory. self.egg_dir = join(dirname(__file__), 'eggs') return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Private interface. ########################################################################### def _add_egg(self, filename, working_set=None): """ Create and add a distribution from the specified '.egg'. """ if working_set is None: working_set = pkg_resources.working_set # The eggs must be in our egg directory! filename = join(dirname(__file__), 'eggs', filename) # Create a distribution for the egg. distributions = pkg_resources.find_distributions(filename) # Add the distributions to the working set (this makes any Python # modules in the eggs available for importing). map(working_set.add, distributions) return def _add_eggs_on_path(self, path, working_set=None): """ Add all eggs found on the path to a working set. """ if working_set is None: working_set = pkg_resources.working_set environment = pkg_resources.Environment(path) # 'find_plugins' identifies those distributions that *could* be added # to the working set without version conflicts or missing requirements. distributions, errors = working_set.find_plugins(environment) if len(errors) > 0: raise SystemError('Cannot find eggs %s' % errors) # Add the distributions to the working set (this makes any Python # modules in the eggs available for importing). map(working_set.add, distributions) return #### EOF ###################################################################### envisage-4.1.0/envisage/tests/event_tracker.py0000644000175100001440000000476511674464014022472 0ustar ischnellusers00000000000000""" Used to track events in tests. """ # Enthought library imports. from traits.api import HasTraits, List, Str, Tuple class EventTracker(HasTraits): """ Used to track traits events. """ # The traits events that have fired. # # This is a list of tuples in the form:- # # (obj, trait_name, old, new) events = List(Tuple) # The names of the traits events that have fired. # # This is useful if you just care about the order of the events, not the # contents. event_names = List(Str) # The trait event subscriptions used by the tracker. # # This is a list of tuples in the form:- # # (obj, trait_name) # # Where 'obj' is the object to listen to, and 'trait_name' is the name of # the trait to listen to, or None to listen for all trait events. subscriptions = List(Tuple) ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ def _subscriptions_changed(self, old, new): """ Static trait change handler. """ map(self._remove_subscription, old) map(self._add_subscription, new) return def _subscriptions_items_changed(self, event): """ Static trait change handler. """ map(self._remove_subscription, event.removed) map(self._add_subscription, event.added) return def _listener(self, obj, trait_name, old, new): """ Dynamic trait change listener. """ self.events.append((obj, trait_name, old, new)) self.event_names.append(trait_name) return #### Methods ############################################################## def _add_subscription(self, subscription): """ Add a subscription. """ obj, trait_name = subscription if trait_name is not None: obj.on_trait_change(self._listener, trait_name) else: obj.on_trait_change(self._listener) return def _remove_subscription(self, subscription): """ Remove a subscription. """ obj, trait_name = subscription if trait_name is not None: obj.on_trait_change(self._listener, trait_name, remove=True) else: obj.on_trait_change(self._listener, remove=True) return #### EOF ###################################################################### envisage-4.1.0/envisage/tests/mutable_extension_registry.py0000644000175100001440000000415111674464014025300 0ustar ischnellusers00000000000000""" A mutable, manually populated extension registry used for testing. """ # Enthought library imports. from envisage.api import ExtensionRegistry, UnknownExtension from traits.api import implements class MutableExtensionRegistry(ExtensionRegistry): """ A mutable, manually populated extension registry used for testing. """ ########################################################################### # 'MutableExtensionRegistry' interface. ########################################################################### def add_extension(self, extension_point_id, extension): """ Contribute an extension to an extension point. """ self.add_extensions(extension_point_id, [extension]) return def add_extensions(self, extension_point_id, extensions): """ Contribute a list of extensions to an extension point. """ self._check_extension_point(extension_point_id) old = self._get_extensions(extension_point_id) index = len(old) old.extend(extensions) # Let any listeners know that the extensions have been added. refs = self._get_listener_refs(extension_point_id) self._call_listeners(refs, extension_point_id, extensions, [], index) return def remove_extension(self, extension_point_id, extension): """ Remove a contribution from an extension point. """ self.remove_extensions(extension_point_id, [extension]) return def remove_extensions(self, extension_point_id, extensions): """ Remove a list of contributions from an extension point. """ for extension in extensions: try: self._get_extensions(extension_point_id).remove(extension) except ValueError: raise UnknownExtension(extension_point_id, extension) # Let any listeners know that the extensions have been removed. refs = self._get_listener_refs(extension_point_id) self._call_listeners(refs, extension_point_id, [], extensions, None) return #### EOF ###################################################################### envisage-4.1.0/envisage/tests/service_registry_test_case.py0000644000175100001440000003743211674464014025255 0ustar ischnellusers00000000000000""" Tests for the service registry. """ # Standard library imports. import sys, unittest # Enthought library imports. from envisage.api import Application, ServiceRegistry from traits.api import HasTraits, Int, Interface, implements # This module's package. PKG = 'envisage.tests' def service_factory(**properties): """ A factory for foos. """ return HasTraits(**properties) class ServiceRegistryTestCase(unittest.TestCase): """ Tests for the service registry. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ # We do all of the testing via the application to make sure it offers # the same interface! self.service_registry = Application(service_registry=ServiceRegistry()) # module 'foo' need to be cleared out when this test is run by nose, # because other tests also import foo. if PKG + '.foo' in sys.modules: del sys.modules[PKG + '.foo'] return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_imported_service_factory(self): """ imported service factory """ class IFoo(Interface): price = Int # Register a service factory. self.service_registry.register_service( HasTraits, PKG + '.service_registry_test_case.service_factory', {'price' : 100} ) # Create a query that matches the registered object. service = self.service_registry.get_service(HasTraits, 'price <= 100') self.assertNotEqual(None, service) self.assertEqual(HasTraits, type(service)) # This shows that the properties were passed in to the factory. self.assertEqual(100, service.price) # Make sure that the object created by the factory is cached (i.e. we # get the same object back from now on!). service2 = self.service_registry.get_service(HasTraits, 'price <= 100') self.assert_(service is service2) return def test_function_service_factory(self): """ function service factory """ class IFoo(Interface): price = Int class Foo(HasTraits): implements(IFoo) price = Int def foo_factory(**properties): """ A factory for foos. """ return Foo(**properties) # Register a service factory. self.service_registry.register_service( IFoo, foo_factory, {'price' : 100} ) # Create a query that matches the registered object. service = self.service_registry.get_service(IFoo, 'price <= 100') self.assertNotEqual(None, service) self.assertEqual(Foo, type(service)) # Make sure that the object created by the factory is cached (i.e. we # get the same object back from now on!). service2 = self.service_registry.get_service(IFoo, 'price <= 100') self.assert_(service is service2) return def test_lazy_function_service_factory(self): """ lazy function service factory """ # Register a service factory by name. def foo_factory(**properties): """ A factory for foos. """ from envisage.tests.foo import Foo foo_factory.foo = Foo() return foo_factory.foo i_foo = PKG + '.i_foo.IFoo' foo = PKG + '.foo' self.service_registry.register_service(i_foo, foo_factory) # Get rid of the 'foo' module (used in other tests). if foo in sys.modules: del sys.modules[foo] # Make sure that we haven't imported the 'foo' module. self.assert_(foo not in sys.modules) # Look up a non-existent service. services = self.service_registry.get_services('bogus.IBogus') # Make sure that we *still* haven't imported the 'foo' module. self.assert_(foo not in sys.modules) # Look it up again. services = self.service_registry.get_services(i_foo) self.assertEqual([foo_factory.foo], services) self.assert_(foo in sys.modules) # Clean up! del sys.modules[foo] return def test_lazy_bound_method_service_factory(self): """ lazy bound method service factory """ i_foo = PKG + '.i_foo.IFoo' foo = PKG + '.foo' class ServiceProvider(HasTraits): """ A class that provides a service. This is used to make sure a bound method can be used as a service factory. """ # Register a service factory by name. def foo_factory(self, **properties): """ A factory for foos. """ from envisage.tests.foo import Foo self.foo = Foo() return self.foo sp = ServiceProvider() self.service_registry.register_service(i_foo, sp.foo_factory) # Get rid of the 'foo' module (used in other tests). if foo in sys.modules: del sys.modules[foo] # Make sure that we haven't imported the 'foo' module. self.assert_(foo not in sys.modules) # Look up a non-existent service. services = self.service_registry.get_services('bogus.IBogus') # Make sure that we *still* haven't imported the 'foo' module. self.assert_(foo not in sys.modules) # Look up the service. services = self.service_registry.get_services(i_foo) self.assertEqual([sp.foo], services) self.assert_(foo in sys.modules) # Clean up! del sys.modules[foo] return def test_get_services(self): """ get services """ class IFoo(Interface): pass class Foo(HasTraits): implements(IFoo) # Register two services. foo = Foo() self.service_registry.register_service(IFoo, foo) foo = Foo() self.service_registry.register_service(IFoo, foo) # Look it up again. services = self.service_registry.get_services(IFoo) self.assertEqual(2, len(services)) class IBar(Interface): pass # Lookup a non-existent service. services = self.service_registry.get_services(IBar) self.assertEqual([], services) return def test_get_services_with_strings(self): """ get services with strings """ from envisage.tests.foo import Foo # Register a couple of services using a string protocol name. protocol_name = 'envisage.tests.foo.IFoo' self.service_registry.register_service(protocol_name, Foo()) self.service_registry.register_service(protocol_name, Foo()) # Look them up using the same string! services = self.service_registry.get_services(protocol_name) self.assertEqual(2, len(services)) return def test_get_services_with_query(self): """ get services with query """ class IFoo(Interface): price = Int class Foo(HasTraits): implements(IFoo) price = Int # Register two services. # # This one shows how the object's attributes are used when evaluating # a query. foo = Foo(price=100) self.service_registry.register_service(IFoo, foo) # This one shows how properties can be specified that *take precedence* # over the object's attributes when evaluating a query. goo = Foo(price=10) self.service_registry.register_service(IFoo, goo, {'price' : 200}) # Create a query that doesn't match any registered object. services = self.service_registry.get_services(IFoo, 'color == "red"') self.assertEqual([], services) # Create a query that matches one of the registered objects. services = self.service_registry.get_services(IFoo, 'price <= 100') self.assertEqual([foo], services) # Create a query that matches both registered objects. services = self.service_registry.get_services(IFoo, 'price >= 100') self.assert_(foo in services) self.assert_(goo in services) self.assertEqual(2, len(services)) class IBar(Interface): pass # Lookup a non-existent service. services = self.service_registry.get_services(IBar, 'price <= 100') self.assertEqual([], services) return def test_get_service(self): """ get service """ class IFoo(Interface): pass class Foo(HasTraits): implements(IFoo) # Register a couple of services. foo = Foo() self.service_registry.register_service(IFoo, foo) goo = Foo() self.service_registry.register_service(IFoo, goo) # Look up one of them! service = self.service_registry.get_service(IFoo) self.assert_(foo is service or goo is service) class IBar(Interface): pass # Lookup a non-existent service. service = self.service_registry.get_service(IBar) self.assertEqual(None, service) return def test_get_service_with_query(self): """ get service with query """ class IFoo(Interface): price = Int class Foo(HasTraits): implements(IFoo) price = Int # Register two services. # # This one shows how the object's attributes are used when evaluating # a query. foo = Foo(price=100) self.service_registry.register_service(IFoo, foo) # This one shows how properties can be specified that *take precedence* # over the object's attributes when evaluating a query. goo = Foo(price=10) self.service_registry.register_service(IFoo, goo, {'price' : 200}) # Create a query that doesn't match any registered object. service = self.service_registry.get_service(IFoo, 'price < 100') self.assertEqual(None, service) # Create a query that matches one of the registered objects. service = self.service_registry.get_service(IFoo, 'price <= 100') self.assertEqual(foo, service) # Create a query that matches both registered objects. service = self.service_registry.get_service(IFoo, 'price >= 100') self.assert_(foo is service or goo is service) class IBar(Interface): pass # Lookup a non-existent service. service = self.service_registry.get_service(IBar, 'price <= 100') self.assertEqual(None, service) return def test_get_and_set_service_properties(self): """ get and set service properties """ class IFoo(Interface): price = Int class Foo(HasTraits): implements(IFoo) price = Int # Register two services. # # This one has no properties. foo = Foo(price=100) foo_id = self.service_registry.register_service(IFoo, foo) # This one has properties. goo = Foo(price=10) goo_id = self.service_registry.register_service( IFoo, goo, {'price' : 200} ) # Get the properties. foo_properties = self.service_registry.get_service_properties(foo_id) self.assertEqual({}, foo_properties) goo_properties = self.service_registry.get_service_properties(goo_id) self.assertEqual(200, goo_properties['price']) # Update the properties. foo_properties['price'] = 300 goo_properties['price'] = 500 # Set the properties. self.service_registry.set_service_properties(foo_id, foo_properties) self.service_registry.set_service_properties(goo_id, goo_properties) # Get the properties again. foo_properties = self.service_registry.get_service_properties(foo_id) self.assertEqual(300, foo_properties['price']) goo_properties = self.service_registry.get_service_properties(goo_id) self.assertEqual(500, goo_properties['price']) # Try to get the properties of a non-existent service. self.failUnlessRaises( ValueError, self.service_registry.get_service_properties, -1 ) # Try to set the properties of a non-existent service. self.failUnlessRaises( ValueError, self.service_registry.set_service_properties, -1, {} ) return def test_unregister_service(self): """ unregister service """ class IFoo(Interface): price = Int class Foo(HasTraits): implements(IFoo) price = Int # Register two services. # # This one shows how the object's attributes are used when evaluating # a query. foo = Foo(price=100) foo_id = self.service_registry.register_service(IFoo, foo) # This one shows how properties can be specified that *take precedence* # over the object's attributes when evaluating a query. goo = Foo(price=10) goo_id = self.service_registry.register_service( IFoo, goo, {'price' : 200} ) # Create a query that doesn't match any registered object. service = self.service_registry.get_service(IFoo, 'price < 100') self.assertEqual(None, service) # Create a query that matches one of the registered objects. service = self.service_registry.get_service(IFoo, 'price <= 100') self.assertEqual(foo, service) # Create a query that matches both registered objects. service = self.service_registry.get_service(IFoo, 'price >= 100') self.assert_(foo is service or goo is service) #### Now do some unregistering! #### # Unregister 'foo'. self.service_registry.unregister_service(foo_id) # This query should no longer match any of the registered objects. service = self.service_registry.get_service(IFoo, 'price <= 100') self.assertEqual(None, service) # Unregister 'goo'. self.service_registry.unregister_service(goo_id) # This query should no longer match any of the registered objects. service = self.service_registry.get_service(IFoo, 'price >= 100') self.assertEqual(None, service) # Try to unregister a non-existent service. self.failUnlessRaises( ValueError, self.service_registry.unregister_service, -1 ) return def test_minimize_and_maximize(self): """ minimize and maximize """ class IFoo(Interface): price = Int class Foo(HasTraits): implements(IFoo) price = Int # Register some objects with various prices. x = Foo(price=10) y = Foo(price=5) z = Foo(price=100) for foo in [x, y, z]: self.service_registry.register_service(IFoo, foo) # Find the service with the lowest price. service = self.service_registry.get_service(IFoo, minimize='price') self.assertNotEqual(None, service) self.assertEqual(Foo, type(service)) self.assertEqual(y, service) # Find the service with the highest price. service = self.service_registry.get_service(IFoo, maximize='price') self.assertNotEqual(None, service) self.assertEqual(Foo, type(service)) self.assertEqual(z, service) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/core_plugin_test_case.py0000644000175100001440000001371111674464014024165 0ustar ischnellusers00000000000000""" Tests for the core plugin. """ # Standard library imports. import os.path import unittest # Major package imports. from pkg_resources import resource_filename # Enthought library imports. from envisage.api import Application, Category, ClassLoadHook, Plugin from envisage.api import ServiceOffer from traits.api import HasTraits, Int, Interface, List # This module's package. PKG = 'envisage.tests' class TestApplication(Application): """ The type of application used in the tests. """ id = 'core.plugin.test' class CorePluginTestCase(unittest.TestCase): """ Tests for the core plugin. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_service_offers(self): """ service offers """ from envisage.core_plugin import CorePlugin class IMyService(Interface): pass class PluginA(Plugin): id = 'A' service_offers = List( contributes_to='envisage.service_offers' ) def _service_offers_default(self): """ Trait initializer. """ service_offers = [ ServiceOffer( protocol=IMyService, factory=self._my_service_factory ) ] return service_offers def _my_service_factory(self, **properties): """ Service factory. """ return 42 core = CorePlugin() a = PluginA() application = TestApplication(plugins=[core, a]) application.start() # Lookup the service. self.assertEqual(42, application.get_service(IMyService)) # Stop the core plugin. application.stop_plugin(core) # Make sure th service has gone. self.assertEqual(None, application.get_service(IMyService)) return def test_categories(self): """ categories """ from envisage.core_plugin import CorePlugin class PluginA(Plugin): id = 'A' categories = List(contributes_to='envisage.categories') def _categories_default(self): """ Trait initializer. """ bar_category = Category( class_name = PKG + '.bar_category.BarCategory', target_class_name = CorePluginTestCase.__module__ + '.Bar' ) return [bar_category] core = CorePlugin() a = PluginA() application = TestApplication(plugins=[core, a]) application.start() # Create the target class. class Bar(HasTraits): x = Int # Make sure the category was imported and added. # # fixme: The following assertion was commented out. Please don't do # that! If a test fails we need to work out why - otherwise you have # just completely removed the benefits of having tests in the first # place! This test works for me on Python 2.4! self.assert_('y' in Bar.class_traits()) return def test_class_load_hooks(self): """ class load hooks """ from envisage.core_plugin import CorePlugin def on_class_loaded(cls): """ Called when a class has been loaded. """ on_class_loaded.cls = cls return class PluginA(Plugin): id = 'A' class_load_hooks = List( [ ClassLoadHook( class_name = CorePluginTestCase.__module__ + '.Baz', on_load = on_class_loaded, ) ], contributes_to='envisage.class_load_hooks' ) core = CorePlugin() a = PluginA() application = TestApplication(plugins=[core, a]) application.start() # Make sure we ignore a class that we are not interested in! class Bif(HasTraits): pass # Make sure the class load hook was *ignored*. self.assert_(not hasattr(on_class_loaded, 'cls')) # Create the target class. class Baz(HasTraits): pass # Make sure the class load hook was called. # # fixme: The following assertion was commented out. Please don't do # that! If a test fails we need to work out why - otherwise you have # just completely removed the benefits of having tests in the first # place! This test works for me on Python 2.4! self.assertEqual(Baz, on_class_loaded.cls) return def test_preferences(self): """ preferences """ # The core plugin is the plugin that offers the preferences extension # point. from envisage.core_plugin import CorePlugin class PluginA(Plugin): id = 'A' preferences = List(contributes_to='envisage.preferences') def _preferences_default(self): """ Trait initializer. """ return ['file://' + resource_filename(PKG, 'preferences.ini')] application = TestApplication(plugins=[CorePlugin(), PluginA()]) application.run() # Make sure we can get one of the preferences. self.assertEqual('42', application.preferences.get('enthought.test.x')) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/slice_test_case.py0000644000175100001440000000756711674464014022772 0ustar ischnellusers00000000000000""" Tests to help find out how trait list events work. These tests exist because when we are using the 'ExtensionPoint' trait type we try to mimic trait list events when extensions are added or removed. """ # Standard library imports. import unittest # Enthought library imports. from traits.api import HasTraits, List # The starting list for all tests. TEST_LIST = [7, 9, 2, 3, 4, 1, 6, 5, 8, 0] def listener(obj, trait_name, old, event): """ Recreate a list operation from a trait list event. """ clone = TEST_LIST[:] # If nothing was added then this is a 'del' or 'remove' operation. if len(event.added) == 0: if isinstance(event.index, slice): del clone[event.index] else: del clone[event.index : event.index + len(event.removed)] # If nothing was removed then it is an 'append', 'insert' or 'extend' # operation. elif len(event.removed) == 0: if isinstance(event.index, slice): clone[event.index] = event.added[0] else: clone.insert(event.index, event.added[0]) # Otherwise, it is an assigment ('sort' and 'reverse' fall into this # category). else: if isinstance(event.index, slice): clone[event.index] = event.added[0] else: clone[event.index : event.index + len(event.added)] = event.added listener.clone = clone return class SliceTestCase(unittest.TestCase): """ Tests to help find out how trait list events work. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ class Foo(HasTraits): l = List self.f = Foo(l=TEST_LIST) self.f.on_trait_change(listener, 'l_items') return def tearDown(self): """ Called immediately after each test method has been called. """ # Make sure we successfully recreated the operation. self.assertEqual(self.f.l, listener.clone) return ########################################################################### # Tests. ########################################################################### def test_append(self): """ append """ self.f.l.append(99) return def test_insert(self): """ insert """ self.f.l.insert(3, 99) return def test_extend(self): """ extend """ self.f.l.append([99, 100]) return def test_remove(self): """ remove """ self.f.l.remove(5) return def test_reverse(self): """ reverse """ self.f.l.reverse() return def test_sort(self): """ sort """ self.f.l.sort() return def test_pop(self): """ remove """ self.f.l.pop() return def test_del_all(self): """ del all """ del self.f.l[:] return def test_assign_item(self): """ assign item """ self.f.l[3] = 99 return def test_del_item(self): """ del item """ del self.f.l[3] return def test_assign_slice(self): """ assign slice """ self.f.l[2:4] = [88, 99] return def test_del_slice(self): """ del slice """ del self.f.l[2:5] return def test_assign_extended_slice(self): """ assign extended slice """ self.f.l[2:6:2] = [88, 99] return def test_del_extended_slice(self): """ del extended slice """ del self.f.l[2:6:2] return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/plugin_test_case.py0000644000175100001440000003076011674464014023160 0ustar ischnellusers00000000000000""" Tests for plugins. """ # Standard library imports. import random, unittest from os.path import exists, join # Enthought library imports. from envisage.api import Application, ExtensionPoint from envisage.api import IPluginActivator, Plugin, contributes_to from traits.api import HasTraits, Instance, Int, Interface, List, Str from traits.api import implements def listener(obj, trait_name, old, new): """ A useful trait change handler for testing! """ listener.obj = obj listener.trait_name = trait_name listener.old = old listener.new = new return class TestApplication(Application): """ The type of application used in the tests. """ id = 'test' class PluginTestCase(unittest.TestCase): """ Tests for plugins. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_id_policy(self): """ id policy """ # If no Id is specified then use 'module_name.class_name'. p = Plugin() self.assertEqual('envisage.plugin.Plugin', p.id) # If an Id is specified make sure we use it! p = Plugin(id='wilma') self.assertEqual('wilma', p.id) # Make sure setting the name doesn't interfere with the Id. p = Plugin(name='fred', id='wilma') self.assertEqual('wilma', p.id) self.assertEqual('fred', p.name) return def test_name_policy(self): """ name policy """ # If name is specified then use the plugin's class name. p = Plugin() self.assertEqual('Plugin', p.name) # If a name is specified make sure we use it! p = Plugin(name='wilma') self.assertEqual('wilma', p.name) # Try a camel case plugin class. class ThisIsMyPlugin(Plugin): pass p = ThisIsMyPlugin() self.assertEqual('This Is My Plugin', p.name) return def test_plugin_activator(self): """ plugin activator. """ class NullPluginActivator(HasTraits): """ A plugin activator that does nothing! """ implements(IPluginActivator) def start_plugin(self, plugin): """ Start a plugin. """ self.started = plugin return def stop_plugin(self, plugin): """ Stop a plugin. """ self.stopped = plugin return class PluginA(Plugin): id = 'A' class PluginB(Plugin): id = 'B' plugin_activator = NullPluginActivator() a = PluginA(activator=plugin_activator) b = PluginB() application = TestApplication(plugins=[a, b]) application.start() # Make sure A's plugin activator was called. self.assertEqual(a, plugin_activator.started) # Stop the application. application.stop() # Make sure A's plugin activator was called. self.assertEqual(a, plugin_activator.stopped) return def test_service(self): """ service """ class Foo(HasTraits): pass class Bar(HasTraits): pass class Baz(HasTraits): pass class PluginA(Plugin): id = 'A' foo = Instance(Foo, (), service=True) bar = Instance(Bar, (), service=True) baz = Instance(Baz, (), service=True) a = PluginA() application = TestApplication(plugins=[a]) application.start() # Make sure the services were registered. self.assertNotEqual(None, application.get_service(Foo)) self.assertEqual(a.foo, application.get_service(Foo)) self.assertNotEqual(None, application.get_service(Bar)) self.assertEqual(a.bar, application.get_service(Bar)) self.assertNotEqual(None, application.get_service(Baz)) self.assertEqual(a.baz, application.get_service(Baz)) application.stop() # Make sure the service was unregistered. self.assertEqual(None, application.get_service(Foo)) self.assertEqual(None, application.get_service(Bar)) self.assertEqual(None, application.get_service(Baz)) return def test_service_protocol(self): """ service protocol """ class IFoo(Interface): pass class IBar(Interface): pass class Foo(HasTraits): implements(IFoo, IBar) class PluginA(Plugin): id = 'A' foo = Instance(Foo, (), service=True, service_protocol=IBar) a = PluginA() application = TestApplication(plugins=[a]) application.start() # Make sure the service was registered with the 'IBar' protocol. self.assertNotEqual(None, application.get_service(IBar)) self.assertEqual(a.foo, application.get_service(IBar)) application.stop() # Make sure the service was unregistered. self.assertEqual(None, application.get_service(IBar)) return def test_multiple_trait_contributions(self): """ multiple trait contributions """ class PluginA(Plugin): id = 'A' x = ExtensionPoint(List, id='x') class PluginB(Plugin): id = 'B' x = List([1, 2, 3], contributes_to='x') y = List([4, 5, 6], contributes_to='x') a = PluginA() b = PluginB() application = TestApplication(plugins=[a, b]) # We should get an error because the plugin has multiple traits # contributing to the same extension point. self.failUnlessRaises(ValueError, application.get_extensions, 'x') return def test_exception_in_trait_contribution(self): """ exception in trait contribution """ class PluginA(Plugin): id = 'A' x = ExtensionPoint(List, id='x') class PluginB(Plugin): id = 'B' x = List(contributes_to='x') def _x_default(self): """ Trait initializer. """ raise 1/0 a = PluginA() b = PluginB() application = TestApplication(plugins=[a, b]) # We should get an when we try to get the contributions to the # extension point. self.failUnlessRaises( ZeroDivisionError, application.get_extensions, 'x' ) return def test_contributes_to(self): """ contributes to """ class PluginA(Plugin): id = 'A' x = ExtensionPoint(List, id='x') class PluginB(Plugin): id = 'B' x = List([1, 2, 3], contributes_to='x') a = PluginA() b = PluginB() application = TestApplication(plugins=[a, b]) # We should get an error because the plugin has multiple traits # contributing to the same extension point. self.assertEqual([1, 2, 3], application.get_extensions('x')) return def test_contributes_to_decorator(self): """ contributes to decorator """ class PluginA(Plugin): id = 'A' x = ExtensionPoint(List, id='x') class PluginB(Plugin): id = 'B' @contributes_to('x') def _x_contributions(self): return [1, 2, 3] a = PluginA() b = PluginB() application = TestApplication(plugins=[a, b]) self.assertEqual([1, 2, 3], application.get_extensions('x')) return def test_contributes_to_decorator_ignored_if_trait_present(self): """ contributes to decorator ignored if trait present """ class PluginA(Plugin): id = 'A' x = ExtensionPoint(List, id='x') class PluginB(Plugin): id = 'B' x = List([1, 2, 3], contributes_to='x') @contributes_to('x') def _x_contributions(self): return [4, 5, 6] a = PluginA() b = PluginB() application = TestApplication(plugins=[a, b]) self.assertEqual([1, 2, 3], application.get_extensions('x')) return def test_add_plugins_to_empty_application(self): """ add plugins to empty application """ class PluginA(Plugin): id = 'A' x = ExtensionPoint(List(Int), id='x') def _x_items_changed(self, event): self.added = event.added self.removed = event.removed return class PluginB(Plugin): id = 'B' x = List(Int, [1, 2, 3], contributes_to='x') class PluginC(Plugin): id = 'C' x = List(Int, [4, 5, 6], contributes_to='x') a = PluginA() b = PluginB() c = PluginC() # Create an empty application. application = TestApplication() application.start() # Add the plugin that offers the extension point. application.add_plugin(a) ####################################################################### # fixme: Currently, we connect up extension point traits when the # plugin is started. Is this right? Should we start plugins by default # when we add them (and maybe have the ability to add a plugin without # starting it?). # # I think we should start the plugin, otherwise you have the wierdness # that the extension contributed by the plugin are available after # the call to 'add_plugin', but the plugin isn't started?!? ####################################################################### application.start_plugin(a) ####################################################################### # fixme: Currently, we only fire changed events if an extension point # has already been accessed! Is this right? ####################################################################### self.assertEqual([], a.x) # Add a plugin that contributes to the extension point. application.add_plugin(b) # Make sure that we pick up B's extensions and that the appropriate # trait event was fired. self.assertEqual([1, 2, 3], a.x) self.assertEqual([1, 2, 3], a.added) # Add another plugin that contributes to the extension point. application.add_plugin(c) self.assertEqual([1, 2, 3, 4, 5, 6], a.x) self.assertEqual([4, 5, 6], a.added) # Remove the first contributing plugin. application.remove_plugin(b) self.assertEqual([4, 5, 6], a.x) self.assertEqual([1, 2, 3], a.removed) # Remove the second contributing plugin. application.remove_plugin(c) self.assertEqual([], a.x) self.assertEqual([4, 5, 6], a.removed) return def test_home(self): """ home """ class PluginA(Plugin): id = 'A' class PluginB(Plugin): id = 'B' a = PluginA() b = PluginB() application = TestApplication(plugins=[a, b]) # Make sure that each plugin gets its own directory. self.assertEqual(join(application.home, 'plugins', a.id), a.home) self.assertEqual(join(application.home, 'plugins', b.id), b.home) # Make sure that the directories got created. self.assert_(exists(a.home)) self.assert_(exists(b.home)) # Create a new application with plugins with the same Id to make sure # that it all works when the directories already exist. a = PluginA() b = PluginB() application = TestApplication(plugins=[a, b]) # Make sure that each plugin gets its own directory. self.assertEqual(join(application.home, 'plugins', a.id), a.home) self.assertEqual(join(application.home, 'plugins', b.id), b.home) # Make sure the directories got created. self.assert_(exists(a.home)) self.assert_(exists(b.home)) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/extension_point_binding_test_case.py0000644000175100001440000001515411674464014026601 0ustar ischnellusers00000000000000""" Tests for extension point bindings. """ # Standard library imports. import unittest # Enthought library imports. from envisage.api import ExtensionPoint, ExtensionPointBinding from envisage.api import bind_extension_point from traits.api import Bool, HasTraits, Int, List, Float, Str # Local imports. # # We do these as absolute imports to allow nose to run from a different # working directory. from envisage.tests.mutable_extension_registry import ( MutableExtensionRegistry ) def listener(obj, trait_name, old, new): """ A useful trait change handler for testing! """ listener.obj = obj listener.trait_name = trait_name listener.old = old listener.new = new return class ExtensionPointBindingTestCase(unittest.TestCase): """ Tests for extension point binding. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ self.extension_registry = MutableExtensionRegistry() # Use the extension registry for all extension points and bindings. ExtensionPoint.extension_registry = self.extension_registry return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_untyped_extension_point(self): """ untyped extension point """ registry = self.extension_registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Add an extension. registry.add_extension('my.ep', 42) # Declare a class that consumes the extension. class Foo(HasTraits): x = List f = Foo() f.on_trait_change(listener) # Make some bindings. bind_extension_point(f, 'x', 'my.ep') # Make sure that the object was initialized properly. self.assertEqual(1, len(f.x)) self.assertEqual(42, f.x[0]) # Add another extension. registry.add_extension('my.ep', 'a string') # Make sure that the object picked up the new extension... self.assertEqual(2, len(f.x)) self.assert_(42 in f.x) self.assert_('a string' in f.x) # ... and that the correct trait change event was fired. self.assertEqual(f, listener.obj) self.assertEqual('x_items', listener.trait_name) self.assertEqual(1, len(listener.new.added)) self.assert_('a string' in listener.new.added) return def test_set_extensions_via_trait(self): """ set extensions via trait """ registry = self.extension_registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Add an extension. registry.add_extension('my.ep', 42) # Declare a class that consumes the extension. class Foo(HasTraits): x = List f = Foo() f.on_trait_change(listener) # Make some bindings. bind_extension_point(f, 'x', 'my.ep') # Make sure that the object was initialized properly. self.assertEqual(1, len(f.x)) self.assertEqual(42, f.x[0]) # Set the extensions. f.x = ['a string'] # Make sure that the object picked up the new extension... self.assertEqual(1, len(f.x)) self.assert_('a string' in f.x) self.assertEqual(1, len(registry.get_extensions('my.ep'))) self.assert_('a string' in registry.get_extensions('my.ep')) # ... and that the correct trait change event was fired. self.assertEqual(f, listener.obj) self.assertEqual('x', listener.trait_name) self.assertEqual(1, len(listener.new)) self.assert_('a string' in listener.new) return def test_set_extensions_via_registry(self): """ set extensions via registry """ registry = self.extension_registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Add an extension. registry.add_extension('my.ep', 42) # Declare a class that consumes the extension. class Foo(HasTraits): x = List f = Foo() f.on_trait_change(listener) # Make some bindings. bind_extension_point(f, 'x', 'my.ep') # Make sure that the object was initialized properly. self.assertEqual(1, len(f.x)) self.assertEqual(42, f.x[0]) # Set the extensions. registry.set_extensions('my.ep', ['a string']) # Make sure that the object picked up the new extension... self.assertEqual(1, len(f.x)) self.assert_('a string' in f.x) # ... and that the correct trait change event was fired. self.assertEqual(f, listener.obj) self.assertEqual('x', listener.trait_name) self.assertEqual(1, len(listener.new)) self.assert_('a string' in listener.new) return def test_explicit_extension_registry(self): """ explicit extension registry """ registry = self.extension_registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Add an extension. registry.add_extension('my.ep', 42) # Declare a class that consumes the extension. class Foo(HasTraits): x = List f = Foo() f.on_trait_change(listener) # Create an empty extension registry use that in the binding. extension_registry = MutableExtensionRegistry() # Make some bindings. bind_extension_point(f, 'x', 'my.ep', extension_registry) # Make sure that we pick up the empty extension registry and not the # default one. self.assertEqual(0, len(f.x)) return ########################################################################### # Private interface. ########################################################################### def _create_extension_point(self, id, trait_type=List, desc=''): """ Create an extension point. """ return ExtensionPoint(id=id, trait_type=trait_type, desc=desc) # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/extension_point_test_case.py0000644000175100001440000001751311674464014025110 0ustar ischnellusers00000000000000""" Tests for extension points. """ # Standard library imports. import unittest # Enthought library imports. from envisage.api import Application, ExtensionPoint from envisage.api import ExtensionRegistry from traits.api import HasTraits, Int, List, TraitError class TestBase(HasTraits): """ Base class for all test classes that use the 'ExtensionPoint' type. """ extension_registry = None class ExtensionPointTestCase(unittest.TestCase): """ Tests for extension points. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ # We do all of the testing via the application to make sure it offers # the same interface! self.registry = Application(extension_registry=ExtensionRegistry()) # Set the extension registry used by the test classes. TestBase.extension_registry = self.registry return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_invalid_extension_point_type(self): """ invalid extension point type """ # Extension points currently have to be 'List's of something! The # default is a list of anything. self.failUnlessRaises(TypeError, ExtensionPoint, Int, 'my.ep') return def test_no_reference_to_extension_registry(self): """ no reference to extension registry """ registry = self.registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Set the extensions. registry.set_extensions('my.ep', 'xxx') # Declare a class that consumes the extension. class Foo(HasTraits): x = ExtensionPoint(List(Int), id='my.ep') # We should get an exception because the object does not have an # 'extension_registry' trait. f = Foo() self.failUnlessRaises(ValueError, getattr, f, 'x') return def test_extension_point_changed(self): """ extension point changed """ registry = self.registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Declare a class that consumes the extension. class Foo(TestBase): x = ExtensionPoint(id='my.ep') def _x_changed(self): """ Static trait change handler. """ self.x_changed_called = True return f = Foo() # Connect the extension points on the object so that it can listen # for changes. ExtensionPoint.connect_extension_point_traits(f) # Set the extensions. registry.set_extensions('my.ep', [42, 'a string', True]) # Make sure that instances of the class pick up the extensions. self.assertEqual(3, len(f.x)) self.assertEqual([42, 'a string', True], f.x) # Make sure the trait change handler was called. self.assert_(f.x_changed_called) # Reset the change handler flag. f.x_changed_called = False # Disconnect the extension points on the object. ExtensionPoint.disconnect_extension_point_traits(f) # Set the extensions. registry.set_extensions('my.ep', [98, 99, 100]) # Make sure the trait change handler was *not* called. self.assertEqual(False, f.x_changed_called) return def test_untyped_extension_point(self): """ untyped extension point """ registry = self.registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Set the extensions. registry.set_extensions('my.ep', [42, 'a string', True]) # Declare a class that consumes the extension. class Foo(TestBase): x = ExtensionPoint(id='my.ep') # Make sure that instances of the class pick up the extensions. f = Foo() self.assertEqual(3, len(f.x)) self.assertEqual([42, 'a string', True], f.x) g = Foo() self.assertEqual(3, len(g.x)) self.assertEqual([42, 'a string', True], g.x) return def test_typed_extension_point(self): """ typed extension point """ registry = self.registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Set the extensions. registry.set_extensions('my.ep', [42, 43, 44]) # Declare a class that consumes the extension. class Foo(TestBase): x = ExtensionPoint(List(Int), id='my.ep') # Make sure that instances of the class pick up the extensions. f = Foo() self.assertEqual(3, len(f.x)) self.assertEqual([42, 43, 44], f.x) g = Foo() self.assertEqual(3, len(g.x)) self.assertEqual([42, 43, 44], g.x) return def test_invalid_extension_point(self): """ invalid extension point """ registry = self.registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Set the extensions. registry.set_extensions('my.ep', 'xxx') # Declare a class that consumes the extension. class Foo(TestBase): x = ExtensionPoint(List(Int), id='my.ep') # Make sure we get a trait error because the type of the extension # doesn't match that of the extension point. f = Foo() self.failUnlessRaises(TraitError, getattr, f, 'x') return def test_extension_point_with_no_id(self): """ extension point with no Id """ registry = self.registry def factory(): class Foo(TestBase): x = ExtensionPoint(List(Int)) self.failUnlessRaises(ValueError, factory) return def test_set_untyped_extension_point(self): """ set untyped extension point """ registry = self.registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Declare a class that consumes the extension. class Foo(TestBase): x = ExtensionPoint(id='my.ep') # Make sure that when we set the trait the extension registry gets # updated. f = Foo() f.x = [42] self.assertEqual([42], registry.get_extensions('my.ep')) return def test_set_typed_extension_point(self): """ set typed extension point """ registry = self.registry # Add an extension point. registry.add_extension_point(self._create_extension_point('my.ep')) # Declare a class that consumes the extension. class Foo(TestBase): x = ExtensionPoint(List(Int), id='my.ep') # Make sure that when we set the trait the extension registry gets # updated. f = Foo() f.x = [42] self.assertEqual([42], registry.get_extensions('my.ep')) return ########################################################################### # Private interface. ########################################################################### def _create_extension_point(self, id, trait_type=List, desc=''): """ Create an extension point. """ return ExtensionPoint(id=id, trait_type=trait_type, desc=desc) # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/__init__.py0000644000175100001440000000000011674464014021347 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/tests/plugin_manager_test_case.py0000644000175100001440000001175011674464014024650 0ustar ischnellusers00000000000000""" Tests for the plugin manager. """ # Standard library imports. import unittest # Enthought library imports. from envisage.api import Plugin, PluginManager from traits.api import Bool class SimplePlugin(Plugin): """ A simple plugin. """ #### 'SimplePlugin' interface ############################################# started = Bool(False) stopped = Bool(False) ########################################################################### # 'IPlugin' interface. ########################################################################### def start(self): """ Start the plugin. """ self.started = True self.stopped = False return def stop(self): """ Stop the plugin. """ self.started = False self.stopped = True return class BadPlugin(Plugin): """ A plugin that just causes trouble ;^). """ ########################################################################### # 'IPlugin' interface. ########################################################################### def start(self): """ Start the plugin. """ raise 1/0 def stop(self): """ Stop the plugin. """ raise 1/0 class PluginManagerTestCase(unittest.TestCase): """ Tests for the plugin manager. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_get_plugin(self): """ get plugin """ simple_plugin = SimplePlugin() plugin_manager = PluginManager(plugins=[simple_plugin]) # Get the plugin. plugin = plugin_manager.get_plugin(simple_plugin.id) self.assertEqual(plugin, simple_plugin) # Try to get a non-existent plugin. self.assertEqual(None, plugin_manager.get_plugin('bogus')) return ## def test_get_plugins(self): ## """ get plugins """ ## simple_plugin = SimplePlugin() ## plugin_manager = PluginManager(plugins=[simple_plugin]) ## # Get the plugin. ## plugins = plugin_manager.get_plugins() ## self.assertEqual([simple_plugin], plugins) ## # Mess with the list. ## plugins.append(BadPlugin()) ## # Make sure we didn't affect the plugin manager. ## plugins = plugin_manager.get_plugins() ## self.assertEqual([simple_plugin], plugins) ## return def test_iteration_over_plugins(self): """ iteration over plugins """ simple_plugin = SimplePlugin() bad_plugin = BadPlugin() plugin_manager = PluginManager(plugins=[simple_plugin, bad_plugin]) # Iterate over the plugin manager's plugins. plugins = [] for plugin in plugin_manager: plugins.append(plugin) self.assertEqual([simple_plugin, bad_plugin], plugins) return def test_start_and_stop(self): """ start and stop """ simple_plugin = SimplePlugin() plugin_manager = PluginManager(plugins=[simple_plugin]) # Start the plugin manager. This starts all of the plugin manager's # plugins. plugin_manager.start() # Make sure the plugin was started. self.assertEqual(True, simple_plugin.started) # Stop the plugin manager. This stops all of the plugin manager's # plugins. plugin_manager.stop() # Make sure the plugin was stopped. self.assertEqual(True, simple_plugin.stopped) return def test_start_and_stop_errors(self): """ start and stop errors """ simple_plugin = SimplePlugin() bad_plugin = BadPlugin() plugin_manager = PluginManager(plugins=[simple_plugin, bad_plugin]) # Start the plugin manager. This starts all of the plugin manager's # plugins. self.failUnlessRaises(ZeroDivisionError, plugin_manager.start) # Stop the plugin manager. This stops all of the plugin manager's # plugins. self.failUnlessRaises(ZeroDivisionError, plugin_manager.stop) # Try to start a non-existent plugin. self.failUnlessRaises( SystemError, plugin_manager.start_plugin, plugin_id='bogus' ) # Try to stop a non-existent plugin. self.failUnlessRaises( SystemError, plugin_manager.stop_plugin, plugin_id='bogus' ) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/extension_point_changed_test_case.py0000644000175100001440000002766111674464014026566 0ustar ischnellusers00000000000000""" Tests for the events fired when extension points are changed. """ # Standard library imports. import unittest # Enthought library imports. from envisage.api import ExtensionPoint # Local imports. # # We do these as absolute imports to allow nose to run from a different # working directory. from envisage.tests.application_test_case import ( PluginA, PluginB, PluginC, TestApplication, listener ) class ExtensionPointChangedTestCase(unittest.TestCase): """ Tests for the events fired when extension points are changed. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ # Make sure that the listener contents get cleand up before each test. listener.obj = None listener.trait_name = None listener.old = None listener.new = None return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_set_extension_point(self): """ set extension point """ a = PluginA() application = TestApplication(plugins=[a]) application.start() # Try to set the extension point. self.failUnlessRaises(SystemError, setattr, a, 'x', [1, 2, 3]) return def test_append(self): """ append """ a = PluginA(); a.on_trait_change(listener, 'x_items') b = PluginB() c = PluginC() application = TestApplication(plugins=[a, b, c]) application.start() # fixme: If the extension point has not been accessed then the # provider extension registry can't work out what has changed, so it # won't fire a changed event. self.assertEqual([1, 2, 3, 98, 99, 100], a.x) # Append a contribution. b.x.append(4) # Make sure we pick up the new contribution via the application. extensions = application.get_extensions('a.x') extensions.sort() self.assertEqual(7, len(extensions)) self.assertEqual([1, 2, 3, 4, 98, 99, 100], extensions) # Make sure we pick up the new contribution via the plugin. extensions = a.x[:] extensions.sort() self.assertEqual(7, len(extensions)) self.assertEqual([1, 2, 3, 4, 98, 99, 100], extensions) # Make sure we got a trait event telling us that the contributions # to the extension point have been changed. self.assertEqual(a, listener.obj) self.assertEqual('x_items', listener.trait_name) self.assertEqual([4], listener.new.added) self.assertEqual([], listener.new.removed) self.assertEqual(3, listener.new.index) return def test_remove(self): """ remove """ a = PluginA(); a.on_trait_change(listener, 'x_items') b = PluginB() c = PluginC() application = TestApplication(plugins=[a, b, c]) application.start() # fixme: If the extension point has not been accessed then the # provider extension registry can't work out what has changed, so it # won't fire a changed event. self.assertEqual([1, 2, 3, 98, 99, 100], a.x) # Remove a contribution. b.x.remove(3) # Make sure we pick up the correct contributions via the application. extensions = application.get_extensions('a.x') extensions.sort() self.assertEqual(5, len(extensions)) self.assertEqual([1, 2, 98, 99, 100], extensions) # Make sure we pick up the correct contributions via the plugin. extensions = a.x[:] extensions.sort() self.assertEqual(5, len(extensions)) self.assertEqual([1, 2, 98, 99, 100], extensions) # Make sure we got a trait event telling us that the contributions # to the extension point have been changed. self.assertEqual(a, listener.obj) self.assertEqual('x_items', listener.trait_name) self.assertEqual([], listener.new.added) self.assertEqual([3], listener.new.removed) self.assertEqual(2, listener.new.index) return def test_assign_empty_list(self): """ assign empty list """ a = PluginA(); a.on_trait_change(listener, 'x_items') b = PluginB() c = PluginC() application = TestApplication(plugins=[a, b, c]) application.start() # fixme: If the extension point has not been accessed then the # provider extension registry can't work out what has changed, so it # won't fire a changed event. self.assertEqual([1, 2, 3, 98, 99, 100], a.x) # Assign an empty list to one of the plugin's contributions. b.x = [] # Make sure we pick up the correct contribution via the application. extensions = application.get_extensions('a.x') extensions.sort() self.assertEqual(3, len(extensions)) self.assertEqual([98, 99, 100], extensions) # Make sure we pick up the correct contribution via the plugin. extensions = a.x[:] extensions.sort() self.assertEqual(3, len(extensions)) self.assertEqual([98, 99, 100], extensions) # Make sure we got a trait event telling us that the contributions # to the extension point have been changed. self.assertEqual(a, listener.obj) self.assertEqual('x_items', listener.trait_name) self.assertEqual([], listener.new.added) self.assertEqual([1, 2, 3], listener.new.removed) self.assertEqual(0, listener.new.index.start) self.assertEqual(3, listener.new.index.stop) return def test_assign_empty_list_no_event(self): """ assign empty list no event """ a = PluginA(); a.on_trait_change(listener, 'x_items') b = PluginB() c = PluginC() application = TestApplication(plugins=[a, b, c]) application.start() # Assign an empty list to one of the plugin's contributions. b.x = [] # Make sure we pick up the correct contribution via the application. extensions = application.get_extensions('a.x') extensions.sort() self.assertEqual(3, len(extensions)) self.assertEqual([98, 99, 100], extensions) # Make sure we pick up the correct contribution via the plugin. extensions = a.x[:] extensions.sort() self.assertEqual(3, len(extensions)) self.assertEqual([98, 99, 100], extensions) # We shouldn't get a trait event here because we haven't accessed the # extension point yet! self.assertEqual(None, listener.obj) return def test_assign_non_empty_list(self): """ assign non-empty list """ a = PluginA(); a.on_trait_change(listener, 'x_items') b = PluginB() c = PluginC() application = TestApplication(plugins=[a, b, c]) application.start() # fixme: If the extension point has not been accessed then the # provider extension registry can't work out what has changed, so it # won't fire a changed event. self.assertEqual([1, 2, 3, 98, 99, 100], a.x) # Assign a non-empty list to one of the plugin's contributions. b.x = [2, 4, 6, 8] # Make sure we pick up the new contribution via the application. extensions = application.get_extensions('a.x') extensions.sort() self.assertEqual(7, len(extensions)) self.assertEqual([2, 4, 6, 8, 98, 99, 100], extensions) # Make sure we pick up the new contribution via the plugin. extensions = a.x[:] extensions.sort() self.assertEqual(7, len(extensions)) self.assertEqual([2, 4, 6, 8, 98, 99, 100], extensions) # Make sure we got a trait event telling us that the contributions # to the extension point have been changed. self.assertEqual(a, listener.obj) self.assertEqual('x_items', listener.trait_name) self.assertEqual([2, 4, 6, 8], listener.new.added) self.assertEqual([1, 2, 3], listener.new.removed) self.assertEqual(0, listener.new.index.start) self.assertEqual(4, listener.new.index.stop) return def test_add_plugin(self): """ add plugin """ a = PluginA(); a.on_trait_change(listener, 'x_items') b = PluginB() c = PluginC() # Start off with just two of the plugins. application = TestApplication(plugins=[a, b]) application.start() # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') extensions.sort() self.assertEqual(3, len(extensions)) self.assertEqual([1, 2, 3], extensions) # Make sure we can get the contributions via the plugin. extensions = a.x[:] extensions.sort() self.assertEqual(3, len(extensions)) self.assertEqual([1, 2, 3], extensions) # Now add the other plugin. application.add_plugin(c) # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') extensions.sort() self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) # Make sure we can get the contributions via the plugin. extensions = a.x[:] extensions.sort() self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) # Make sure we got a trait event telling us that the contributions # to the extension point have been changed. self.assertEqual(a, listener.obj) self.assertEqual('x_items', listener.trait_name) self.assertEqual([98, 99, 100], listener.new.added) self.assertEqual([], listener.new.removed) self.assertEqual(3, listener.new.index) return def test_remove_plugin(self): """ remove plugin """ a = PluginA(); a.on_trait_change(listener, 'x_items') b = PluginB() c = PluginC() application = TestApplication(plugins=[a, b, c]) application.start() # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') extensions.sort() self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) # Make sure we can get the contributions via the plugin. extensions = a.x[:] extensions.sort() self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) # Now remove one plugin. application.remove_plugin(b) # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') extensions.sort() self.assertEqual(3, len(extensions)) self.assertEqual([98, 99, 100], extensions) # Make sure we can get the contributions via the plugin. extensions = a.x[:] extensions.sort() self.assertEqual(3, len(extensions)) self.assertEqual([98, 99, 100], extensions) # Make sure we got a trait event telling us that the contributions # to the extension point have been changed. self.assertEqual(a, listener.obj) self.assertEqual('x_items', listener.trait_name) self.assertEqual([], listener.new.added) self.assertEqual([1, 2, 3], listener.new.removed) self.assertEqual(0, listener.new.index) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/provider_extension_registry_test_case.py0000644000175100001440000004512611674464014027542 0ustar ischnellusers00000000000000""" Tests for the provider extension registry. """ # Standard imports import unittest # Enthought library imports. from envisage.api import ExtensionPoint, ExtensionProvider from envisage.api import ProviderExtensionRegistry from traits.api import Int, List # Local imports. from extension_registry_test_case import ExtensionRegistryTestCase class ProviderExtensionRegistryTestCase(ExtensionRegistryTestCase): """ Tests for the provider extension registry. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ self.registry = ProviderExtensionRegistry() return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_providers(self): """ providers """ registry = self.registry # Some providers. class ProviderA(ExtensionProvider): """ An extension provider. """ def get_extension_points(self): """ Return the extension points offered by the provider. """ return [ExtensionPoint(List, 'x')] def get_extensions(self, extension_point): """ Return the provider's contributions to an extension point. """ if extension_point == 'x': extensions = [42, 43] else: extensions = [] return extensions class ProviderB(ExtensionProvider): """ An extension provider. """ def get_extensions(self, extension_point): """ Return the provider's contributions to an extension point. """ if extension_point == 'x': extensions = [44, 45, 46] else: extensions = [] return extensions class ProviderC(ExtensionProvider): """ An empty provider! """ # Add the providers to the registry. registry.add_provider(ProviderA()) registry.add_provider(ProviderB()) registry.add_provider(ProviderC()) # The provider's extensions should now be in the registry. extensions = registry.get_extensions('x') self.assertEqual(5, len(extensions)) self.assertEqual(range(42, 47), extensions) # Make sure there's one and only one extension point. extension_points = registry.get_extension_points() self.assertEqual(1, len(extension_points)) self.assertEqual('x', extension_points[0].id) return def test_provider_extensions_changed(self): """ provider extensions changed """ registry = self.registry # Some providers. class ProviderA(ExtensionProvider): """ An extension provider. """ x = List(Int) def get_extension_points(self): """ Return the extension points offered by the provider. """ return [ExtensionPoint(List, 'my.ep')] def get_extensions(self, extension_point_id): """ Return the provider's contributions to an extension point. """ if extension_point_id == 'my.ep': return self.x else: extensions = [] return extensions def _x_changed(self, old, new): """ Static trait change handler. """ self._fire_extension_point_changed( 'my.ep', new, old, slice(0, len(old)) ) return def _x_items_changed(self, event): """ Static trait change handler. """ self._fire_extension_point_changed( 'my.ep', event.added, event.removed, event.index ) return class ProviderB(ExtensionProvider): """ An extension provider. """ x = List(Int) def get_extensions(self, extension_point_id): """ Return the provider's contributions to an extension point. """ if extension_point_id == 'my.ep': return self.x else: extensions = [] return extensions def _x_changed(self, old, new): """ Static trait change handler. """ self._fire_extension_point_changed( 'my.ep', new, old, slice(0, len(old)) ) return def _x_items_changed(self, event): """ Static trait change handler. """ self._fire_extension_point_changed( 'my.ep', event.added, event.removed, event.index ) return # Add the providers to the registry. a = ProviderA(x=[42]) b = ProviderB(x=[99, 100]) registry.add_provider(a) registry.add_provider(b) # The provider's extensions should now be in the registry. extensions = registry.get_extensions('my.ep') self.assertEqual(3, len(extensions)) self.assertEqual([42, 99, 100], extensions) # Add an extension listener to the registry. def listener(registry, event): """ A useful trait change handler for testing! """ listener.registry = registry listener.extension_point = event.extension_point_id listener.added = event.added listener.removed = event.removed listener.index = event.index return registry.add_extension_point_listener(listener, 'my.ep') # Add a new extension via the provider. a.x.append(43) # Make sure the listener got called. self.assertEqual('my.ep', listener.extension_point) self.assertEqual([43], listener.added) self.assertEqual([], listener.removed) self.assertEqual(1, listener.index) # Now we should get the new extension. extensions = registry.get_extensions('my.ep') self.assertEqual(4, len(extensions)) self.assertEqual([42, 43, 99, 100], extensions) # Insert a new extension via the other provider. b.x.insert(0, 98) # Make sure the listener got called. self.assertEqual('my.ep', listener.extension_point) self.assertEqual([98], listener.added) self.assertEqual([], listener.removed) self.assertEqual(2, listener.index) # Now we should get the new extension. extensions = registry.get_extensions('my.ep') self.assertEqual(5, len(extensions)) self.assertEqual([42, 43, 98, 99, 100], extensions) # Completely change a provider's extensions. b.x = [1, 2] # Make sure the listener got called. self.assertEqual('my.ep', listener.extension_point) self.assertEqual([1, 2], listener.added) self.assertEqual([98, 99, 100], listener.removed) self.assertEqual(2, listener.index.start) self.assertEqual(5, listener.index.stop) # Now we should get the new extension. extensions = registry.get_extensions('my.ep') self.assertEqual(4, len(extensions)) self.assertEqual([42, 43, 1, 2], extensions) return def test_add_provider(self): """ add provider """ registry = self.registry # A provider. class ProviderA(ExtensionProvider): """ An extension provider. """ def get_extension_points(self): """ Return the extension points offered by the provider. """ return [ExtensionPoint(List, 'x')] def get_extensions(self, extension_point): """ Return the provider's contributions to an extension point. """ if extension_point == 'x': return [42] else: extensions = [] return extensions def _x_items_changed(self, event): """ Static trait change handler. """ self._fire_extension_point_changed( 'x', event.added, event.removed, event.index ) return # Add the provider to the registry. registry.add_provider(ProviderA()) # The provider's extensions should now be in the registry. extensions = registry.get_extensions('x') self.assertEqual(1, len(extensions)) self.assert_(42 in extensions) # Add an extension listener to the registry. def listener(registry, event): """ A useful trait change handler for testing! """ listener.registry = registry listener.extension_point = event.extension_point_id listener.added = event.added listener.removed = event.removed listener.index = event.index return registry.add_extension_point_listener(listener, 'x') # Add a new provider. class ProviderB(ExtensionProvider): """ An extension provider. """ def get_extensions(self, extension_point): """ Return the provider's contributions to an extension point. """ if extension_point == 'x': extensions = [43, 44] else: extensions = [] return extensions registry.add_provider(ProviderB()) # Make sure the listener got called. self.assertEqual('x', listener.extension_point) self.assertEqual([43, 44], listener.added) self.assertEqual([], listener.removed) # Now we should get the new extensions. extensions = registry.get_extensions('x') self.assertEqual(3, len(extensions)) self.assert_(42 in extensions) self.assert_(43 in extensions) self.assert_(44 in extensions) return def test_get_providers(self): """ get providers """ registry = self.registry # Some providers. class ProviderA(ExtensionProvider): """ An extension provider. """ class ProviderB(ExtensionProvider): """ An extension provider. """ a = ProviderA() b = ProviderB() # Add the provider to the registry. registry.add_provider(a) registry.add_provider(b) # Make sure we can get them. self.assertEqual([a, b], registry.get_providers()) return def test_remove_provider(self): """ remove provider """ registry = self.registry # Some providers. class ProviderA(ExtensionProvider): """ An extension provider. """ def get_extension_points(self): """ Return the extension points offered by the provider. """ return [ExtensionPoint(List, 'x'), ExtensionPoint(List, 'y')] def get_extensions(self, extension_point): """ Return the provider's contributions to an extension point. """ if extension_point == 'x': return [42] else: extensions = [] return extensions def _x_items_changed(self, event): """ Static trait change handler. """ self._fire_extension_point_changed( 'x', event.added, event.removed, event.index ) return class ProviderB(ExtensionProvider): """ An extension provider. """ def get_extensions(self, extension_point): """ Return the provider's contributions to an extension point. """ if extension_point == 'x': extensions = [43, 44] else: extensions = [] return extensions # Add the providers to the registry. a = ProviderA() b = ProviderB() registry.add_provider(a) registry.add_provider(b) # The provider's extensions should now be in the registry. extensions = registry.get_extensions('x') self.assertEqual(3, len(extensions)) self.assert_(42 in extensions) self.assert_(43 in extensions) self.assert_(44 in extensions) # Add an extension listener to the registry. def listener(registry, event): """ A useful trait change handler for testing! """ listener.registry = registry listener.extension_point = event.extension_point_id listener.added = event.added listener.removed = event.removed return registry.add_extension_point_listener(listener, 'x') # Remove one of the providers. registry.remove_provider(b) # Make sure the listener got called. self.assertEqual('x', listener.extension_point) self.assertEqual([], listener.added) self.assertEqual([43, 44], listener.removed) # Make sure we don't get the removed extensions. extensions = registry.get_extensions('x') self.assertEqual(1, len(extensions)) self.assert_(42 in extensions) # Now remove the provider that declared the extension point. registry.remove_provider(a) # Make sure the extension point is gone. self.assertEqual(None, registry.get_extension_point('x')) # Make sure we don't get the removed extensions. extensions = registry.get_extensions('x') self.assertEqual(0, len(extensions)) # Make sure the listener got called. self.assertEqual('x', listener.extension_point) self.assertEqual([], listener.added) self.assertEqual([42], listener.removed) return def test_remove_provider_with_no_contributions(self): """ remove provider with no contributions """ registry = self.registry # Some providers. class ProviderA(ExtensionProvider): """ An extension provider. """ def get_extension_points(self): """ Return the extension points offered by the provider. """ return [ExtensionPoint(List, 'x'), ExtensionPoint(List, 'y')] def get_extensions(self, extension_point): """ Return the provider's contributions to an extension point. """ return [] # Add the provider to the registry. a = ProviderA() registry.add_provider(a) # The provider's extensions should now be in the registry. extensions = registry.get_extensions('x') self.assertEqual(0, len(extensions)) # Add an extension listener to the registry. def listener(registry, event): """ A useful trait change handler for testing! """ listener.registry = registry listener.extension_point = event.extension_point_id listener.added = event.added listener.removed = event.removed return registry.add_extension_point_listener(listener, 'x') # Remove the provider that declared the extension point. registry.remove_provider(a) # Make sure the extension point is gone. self.assertEqual(None, registry.get_extension_point('x')) # Make sure we don't get the removed extensions. extensions = registry.get_extensions('x') self.assertEqual(0, len(extensions)) # Make sure the listener did not get called (since the provider did # not make any contributions anyway!). self.assertEqual(None, getattr(listener, 'registry', None)) return def test_remove_non_existent_provider(self): """ remove provider """ registry = self.registry # Some providers. class ProviderA(ExtensionProvider): """ An extension provider. """ pass a = ProviderA() # Remove one of the providers. self.failUnlessRaises(ValueError, registry.remove_provider, a) return # Overriden to test differing behavior between the provider registry and # the base class. def test_set_extensions(self): """ set extensions """ registry = self.registry # Add an extension *point*. registry.add_extension_point(self._create_extension_point('my.ep')) # Set some extensions. self.failUnlessRaises( SystemError, registry.set_extensions, 'my.ep', [1, 2, 3] ) return def test_remove_non_empty_extension_point(self): """ remove non-empty extension point """ registry = self.registry # Some providers. class ProviderA(ExtensionProvider): """ An extension provider. """ def get_extension_points(self): """ Return the extension points offered by the provider. """ return [ExtensionPoint(List, 'x')] def get_extensions(self, extension_point): """ Return the provider's contributions to an extension point. """ if extension_point == 'x': extensions = [42, 43] else: extensions = [] return extensions # Add the provider to the registry. registry.add_provider(ProviderA()) # The provider's extensions should now be in the registry. extensions = registry.get_extensions('x') self.assertEqual(2, len(extensions)) self.assertEqual(range(42, 44), extensions) # Make sure there's one and only one extension point. extension_points = registry.get_extension_points() self.assertEqual(1, len(extension_points)) self.assertEqual('x', extension_points[0].id) # Remove the extension point. registry.remove_extension_point('x') # Make sure there are no extension points. extension_points = registry.get_extension_points() self.assertEqual(0, len(extension_points)) # And that the extensions are gone too. self.assertEqual([], registry.get_extensions('x')) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/tests/i_foo.py0000644000175100001440000000033711674464014020720 0ustar ischnellusers00000000000000""" A test class used to test adapters. """ # Enthought library imports. from traits.api import Interface class IFoo(Interface): pass #### EOF ###################################################################### envisage-4.1.0/envisage/tests/application_test_case.py0000644000175100001440000003364611674464014024173 0ustar ischnellusers00000000000000""" Tests for applications and plugins. """ # Standard library imports. import os, random, shutil, unittest # Enthought library imports. from traits.etsconfig.api import ETSConfig from envisage.api import Application, ExtensionPoint, IApplication from envisage.api import Plugin, PluginManager from traits.api import Bool, HasTraits, Instance, Int, Interface from traits.api import List, Str, implements # Local imports. # # We do these as absolute imports to allow nose to run from a different # working directory. from envisage.tests.event_tracker import EventTracker def listener(obj, trait_name, old, new): """ A useful trait change handler for testing! """ listener.obj = obj listener.trait_name = trait_name listener.old = old listener.new = new return def vetoer(event): """ A function that will veto an event. """ event.veto = True return class TestApplication(Application): """ The type of application used in the tests. """ id = 'test' class SimplePlugin(Plugin): """ A simple plugin. """ #### 'SimplePlugin' interface ############################################# started = Bool(False) stopped = Bool(False) ########################################################################### # 'IPlugin' interface. ########################################################################### def start(self): """ Start the plugin. """ self.started = True self.stopped = False return def stop(self): """ Stop the plugin. """ self.started = False self.stopped = True return class BadPlugin(Plugin): """ A plugin that just causes trouble ;^). """ ########################################################################### # 'IPlugin' interface. ########################################################################### def start(self): """ Start the plugin. """ raise 1/0 def stop(self): """ Stop the plugin. """ raise 1/0 class PluginA(Plugin): """ A plugin that offers an extension point. """ id = 'A' x = ExtensionPoint(List, id='a.x') class PluginB(Plugin): """ A plugin that contributes to an extension point. """ id = 'B' x = List(Int, [1, 2, 3], contributes_to='a.x') class PluginC(Plugin): """ Another plugin that contributes to an extension point! """ id = 'C' x = List(Int, [98, 99, 100], contributes_to='a.x') class ApplicationTestCase(unittest.TestCase): """ Tests for applications and plugins. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ # Make sure that the listener contents get cleand up before each test. listener.obj = None listener.trait_name = None listener.old = None listener.new = None return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_home(self): """ home """ application = TestApplication() # Make sure we get the right default value. self.assertEqual(ETSConfig.application_home, application.home) # Delete the directory. shutil.rmtree(application.home) # Create a new application. application = TestApplication() # Make sure the directory got created. self.assert_(os.path.exists(application.home)) # Delete the directory. shutil.rmtree(application.home) return def test_no_plugins(self): """ no plugins """ application = TestApplication() tracker = EventTracker( subscriptions = [ (application, 'starting'), (application, 'started'), (application, 'stopping'), (application, 'stopped') ] ) # Start the application. started = application.start() self.assertEqual(True, started) self.assertEqual(['starting', 'started'], tracker.event_names) # Stop the application. stopped = application.stop() self.assertEqual(True, stopped) self.assertEqual( ['starting', 'started', 'stopping', 'stopped'], tracker.event_names ) return def test_veto_starting(self): """ veto starting """ application = TestApplication() # This listener will veto the 'starting' event. application.on_trait_change(vetoer, 'starting') tracker = EventTracker( subscriptions = [ (application, 'starting'), (application, 'started'), (application, 'stopping'), (application, 'stopped') ] ) # Start the application. started = application.start() self.assertEqual(False, started) self.assert_('started' not in tracker.event_names) return def test_veto_stopping(self): """ veto stopping """ application = TestApplication() # This listener will veto the 'stopping' event. application.on_trait_change(vetoer, 'stopping') tracker = EventTracker( subscriptions = [ (application, 'starting'), (application, 'started'), (application, 'stopping'), (application, 'stopped') ] ) # Start the application. started = application.start() self.assertEqual(['starting', 'started'], tracker.event_names) self.assertEqual(True, started) # Stop the application. stopped = application.stop() self.assertEqual(False, stopped) self.assert_('stopped' not in tracker.event_names) return def test_start_and_stop_errors(self): """ start and stop errors """ simple_plugin = SimplePlugin() bad_plugin = BadPlugin() application = TestApplication(plugins=[simple_plugin, bad_plugin]) # Try to start the application - the bad plugin should barf. self.failUnlessRaises(ZeroDivisionError, application.start) # Try to stop the application - the bad plugin should barf. self.failUnlessRaises(ZeroDivisionError, application.stop) # Try to start a non-existent plugin. self.failUnlessRaises( SystemError, application.start_plugin, plugin_id='bogus' ) # Try to stop a non-existent plugin. self.failUnlessRaises( SystemError, application.stop_plugin, plugin_id='bogus' ) return def test_extension_point(self): """ extension point """ a = PluginA() b = PluginB() c = PluginC() application = TestApplication(plugins=[a, b, c]) application.start() # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) # Make sure we can get the contributions via the plugin. extensions = a.x self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) return def test_add_extension_point_listener(self): """ add extension point listener """ a = PluginA() b = PluginB() c = PluginC() # Start off with just two of the plugins. application = TestApplication(plugins=[a, b]) application.start() def listener(extension_registry, event): """ An extension point listener. """ listener.extension_point_id = event.extension_point_id listener.added = event.added listener.removed = event.removed return # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') self.assertEqual(3, len(extensions)) self.assertEqual([1, 2, 3], extensions) # Add the listener. application.add_extension_point_listener(listener, 'a.x') # Now add the other plugin. application.add_plugin(c) # Make sure the listener was called. self.assertEqual('a.x', listener.extension_point_id) self.assertEqual([], listener.removed) self.assertEqual([98, 99, 100], listener.added) return def test_remove_extension_point_listener(self): """ remove extension point listener """ a = PluginA() b = PluginB() c = PluginC() # Start off with just one of the plugins. application = TestApplication(plugins=[a]) application.start() def listener(extension_registry, event): """ An extension point listener. """ listener.extension_point_id = event.extension_point_id listener.added = event.added listener.removed = event.removed return # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') self.assertEqual(0, len(extensions)) # Add the listener. application.add_extension_point_listener(listener, 'a.x') # Now add one of the other plugins. application.add_plugin(b) # Make sure the listener was called. self.assertEqual('a.x', listener.extension_point_id) self.assertEqual([], listener.removed) self.assertEqual([1, 2, 3], listener.added) # Now remove the listener. listener.extension_point_id = None application.remove_extension_point_listener(listener, 'a.x') # Now add the final plugin. application.add_plugin(c) # Make sure the listener was *not* called. self.assertEqual(None, listener.extension_point_id) return def test_add_plugin(self): """ add plugin """ a = PluginA() b = PluginB() c = PluginC() # Start off with just two of the plugins. application = TestApplication(plugins=[a, b]) application.start() # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') self.assertEqual(3, len(extensions)) self.assertEqual([1, 2, 3], extensions) # Make sure we can get the contributions via the plugin. extensions = a.x self.assertEqual(3, len(extensions)) self.assertEqual([1, 2, 3], extensions) # Now add the other plugin. application.add_plugin(c) # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) # Make sure we can get the contributions via the plugin. extensions = a.x self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) return def test_get_plugin(self): """ get plugin """ a = PluginA() b = PluginB() c = PluginC() # Start off with just two of the plugins. application = TestApplication(plugins=[a, b, c]) application.start() # Make sure we can get the plugins. self.assertEqual(a, application.get_plugin('A')) self.assertEqual(b, application.get_plugin('B')) self.assertEqual(c, application.get_plugin('C')) # Make sure we can't get one that isn't there ;^) self.assertEqual(None, application.get_plugin('BOGUS')) return def test_remove_plugin(self): """ remove plugin """ a = PluginA() b = PluginB() c = PluginC() application = TestApplication(plugins=[a, b, c]) application.start() # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) # Make sure we can get the contributions via the plugin. extensions = a.x self.assertEqual(6, len(extensions)) self.assertEqual([1, 2, 3, 98, 99, 100], extensions) # Now remove one plugin. application.remove_plugin(b) # Make sure we can get the contributions via the application. extensions = application.get_extensions('a.x') self.assertEqual(3, len(extensions)) self.assertEqual([98, 99, 100], extensions) # Make sure we can get the contributions via the plugin. extensions = a.x self.assertEqual(3, len(extensions)) self.assertEqual([98, 99, 100], extensions) return def test_set_plugin_manager_at_contruction_time(self): """ set plugin manager at construction time""" a = PluginA() b = PluginB() c = PluginC() # Start off with just two of the plugins. application = TestApplication( plugin_manager=PluginManager(plugins=[a, b, c]) ) application.start() # Make sure we can get the plugins. self.assertEqual(a, application.get_plugin('A')) self.assertEqual(b, application.get_plugin('B')) self.assertEqual(c, application.get_plugin('C')) # Make sure we can't get one that isn't there ;^) self.assertEqual(None, application.get_plugin('BOGUS')) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/extension_point_changed_event.py0000644000175100001440000000126311674464014024561 0ustar ischnellusers00000000000000""" An event fired when an extension point's extensions have changed. """ # Enthought library imports. from traits.api import TraitListEvent class ExtensionPointChangedEvent(TraitListEvent): """ An event fired when an extension point's extensions have changed. """ def __init__ (self, extension_point_id=None, **kw): """ Constructor. """ # The base class has the 'index', 'removed' and 'added' attributes. super(ExtensionPointChangedEvent, self).__init__(**kw) # We add the extension point Id. self.extension_point_id = extension_point_id return #### EOF ###################################################################### envisage-4.1.0/envisage/i_extension_point_user.py0000644000175100001440000000104511674464014023253 0ustar ischnellusers00000000000000""" The interface for objects using the 'ExtensionPoint' trait type. """ # Enthought library imports. from traits.api import Instance, Interface # Local imports. from i_extension_registry import IExtensionRegistry class IExtensionPointUser(Interface): """ The interface for objects using the 'ExtensionPoint' trait type. """ # The extension registry that the object's extension points are stored in. extension_registry = Instance(IExtensionRegistry) #### EOF ###################################################################### envisage-4.1.0/envisage/twisted_application.py0000644000175100001440000000243311674464014022530 0ustar ischnellusers00000000000000""" A non-GUI application with a twisted reactor event loop. Nothing is imported from twisted until the application is started so this module can safely live in the Envisage core without twisted being installed. """ # Standard library imports. import logging # Enthought library imports. from envisage.api import Application # Logging. logger = logging.getLogger(__name__) class TwistedApplication(Application): """ A non-GUI application with a twisted reactor event loop. """ def start(self): """ Start the application. """ started = super(TwistedApplication, self).start() # Don't start the event loop if the start was vetoed. if started: from twisted.internet import reactor logger.debug('---------- reactor starting ----------') reactor.run() return started def stop(self): """ Stop the application. """ stopped = super(TwistedApplication, self).stop() # Don't stop the event loop if the stop was vetoed. if stopped: from twisted.internet import reactor logger.debug('---------- reactor stopping ----------') reactor.stop() return stopped #### EOF ###################################################################### envisage-4.1.0/envisage/ui/0000755000175100001440000000000011674464014016523 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/0000755000175100001440000000000011674464014021532 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/factory_definition.py0000644000175100001440000000073411674464014025767 0ustar ischnellusers00000000000000#Enthought imports from traits.api import HasTraits, Int, Str class FactoryDefinition(HasTraits): """ A project factory definition. An instance of the specified class is used to open and/or create new projects. The extension with the highest priority wins! In the event of a tie, the first instance wins. """ # The name of the class that implements the factory. class_name = Str # The priority of this factory priority = Int envisage-4.1.0/envisage/ui/single_project/TODO.txt0000644000175100001440000000057611674464014023050 0ustar ischnellusers00000000000000To-Do List: * Update README and other documentation/examples. * Implement a way to publish the ITreeNodeAdapters so that they don't have to be in the same file as the class which they adapt. * Improve the way we are binding dynamic objects and how they are being retrieved. * Improve the handling of children in the adapters to remove redudancy. * Lots of cleanup left. envisage-4.1.0/envisage/ui/single_project/api.py0000644000175100001440000000152211674464014022655 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2006 by Enthought, Inc. # All rights reserved. # # Author: Dave Peterson # #----------------------------------------------------------------------------- # IDs of services provided by this plugin from services import IPROJECT_MODEL, IPROJECT_UI # Commonly referred to classes within this plugin from factory_definition import FactoryDefinition from model_service import ModelService from project import Project from project_action import ProjectAction from project_factory import ProjectFactory from view.project_view import ProjectView # FIXME: Add back this import when it actually works :) #from editor.project_editor import ProjectEditor #### EOF ##################################################################### envisage-4.1.0/envisage/ui/single_project/editor/0000755000175100001440000000000011674464014023020 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/editor/project_editor.py0000644000175100001440000000546211674464014026415 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2005, 2006 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ A base class for editors that can be tracked by single project plugin projects. """ # Standard library imports. import logging # Enthought library imports from envisage.workbench import DecoratedEditor from traits.api import Instance # Application specific imports. from envisage.single_project.services import IPROJECT_MODEL # Setup a logger for this module. logger=logging.getLogger(__name__) class ProjectEditor(DecoratedEditor): """ A base class for editors that can be tracked by single project plugin projects. """ ######################################################################### # Attributes ######################################################################### ### public 'ProjectEditor' interface #################################### # The project containing the resource we're editing project = Instance('envisage.single_project.project.Project') ######################################################################### # `object` interface ######################################################################### #### operator methods ################################################### def __init__(self, **traits): """ Constructor. Extended to associate ourself with the current project. """ super(ProjectEditor, self).__init__(**traits) # Make sure the current project knows this editor is associated with # it's resources model_service = self.window.application.get_service(IPROJECT_MODEL) self.project = model_service.project self.project.register_editor(self.resource, self) return ######################################################################### # 'Editor' interface. ######################################################################### ### public 'Editor' interface ########################################### def destroy_control(self): """ Destroys the toolkit-specific control that represents the editor. Extended to ensure that the current project stops associating us with its resources. """ # Only do something if the editor is still open if self.control: logger.debug('Destroying control in ProjectEditor [%s]', self) # Unregister from the associated project immediately. self.project.register_editor(self.resource, self, remove=True) super(ProjectEditor, self).destroy_control() return #### EOF #################################################################### envisage-4.1.0/envisage/ui/single_project/editor/__init__.py0000644000175100001440000000000011674464014025117 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/preferences.ini0000644000175100001440000000007311674464014024534 0ustar ischnellusers00000000000000[enthought.envisage.ui.single_project] preferred_path = ''envisage-4.1.0/envisage/ui/single_project/default_path_preference_page.py0000644000175100001440000000266111674464014027743 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2006 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ Preference page for default path for a project """ # Enthought library imports from apptools.preferences.ui.api import PreferencesPage from traits.api import Directory, Str from traitsui.api import View, Item # Global assignment of ID ID = 'envisage.ui.single_project' #------------------------------------------------------------------------------- # DefaultPathPreferencePage Class #------------------------------------------------------------------------------- class DefaultPathPreferencePage(PreferencesPage): """ Preference page for default path for a plugin. """ # The page name (this is what is shown in the preferences dialog. name = 'Single Project' # The path to the preferences node that contains the preferences. preferences_path = 'envisage.ui.single_project' #### Preferences ########################################################## # Choose the unit system that needs to be used for the project preferred_path = Directory('') # Set the traits view traits_view = View(Item('preferred_path', style='custom', tooltip='Path that will be used for storing projects')) ### EOF ------------------------------------------------------------------------ envisage-4.1.0/envisage/ui/single_project/services.py0000644000175100001440000000103511674464014023726 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2006 by Enthought, Inc. # All rights reserved. # # Author: Dave Peterson # #----------------------------------------------------------------------------- # IDs of services provided by this plugin IPROJECT_MODEL = 'envisage.ui.single_project.model_service.ModelService' IPROJECT_UI = 'envisage.ui.single_project.ui_service.UiService' #### EOF ##################################################################### envisage-4.1.0/envisage/ui/single_project/project.py0000644000175100001440000005616511674464014023567 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2005-2007 by Enthought, Inc. # All rights reserved. # # Author: Dave Peterson # #----------------------------------------------------------------------------- """ A base class for projects that can be displayed by the single_project plugin. """ # Standard library imports. import logging import os import sys # Enthought library imports from traits.etsconfig.api import ETSConfig import apptools.sweet_pickle from apptools.io.api import File from traits.api import Any, Bool, Dict, Directory, HasTraits, \ Instance, Property, Str from traitsui.api import Group, View from traits.util.clean_strings import clean_filename # Local imports. #from envisage.ui.single_project.editor.project_editor import \ # ProjectEditor from envisage.api import Application # Setup a logger for this module. logger = logging.getLogger(__name__) class Project(HasTraits): """ A base class for projects that can be displayed by the single_project plugin. """ ########################################################################## # CLASS Attributes ########################################################################## #### public 'Project' class interface #################################### # Indicates whether instances of this project class are stored as files or # directories. The rest of the single_project plugin will follow this # setting when using this project class. # # This is meant to be a constant for the lifetime of this class! PROJECTS_ARE_FILES = True # Current envisage application. application = Instance(Application, transient=True) #### protected 'Project' class interface ################################# # Format used to create a unique name from a location and a counter. _unique_name_format = '%s_%s' ########################################################################## # Attributes ########################################################################## #### public 'Project' interface ########################################## # True if this project contains un-saved state (has been modified.) dirty = Bool(False, transient=True) # True if we allow save requests on the project. is_save_allowed = Bool(True, transient=True) # True if we allow save_as requests on the project. is_save_as_allowed = Bool(True, transient=True) # The location of this project on the filesystem. The default value # depends on the runtime environment so we use a traits default method to # set it. location = Directory # The name of this project. This is calculated from the project's current # location or, if there is no location, from a default value. See the # property's getter method. name = Property(Str) # The UI view to use when creating a new project traits_view = View( Group('location'), title = 'New Project', id = 'envisage.single_project.project.Project', buttons = [ 'OK', 'Cancel' ], width = 0.33, # Ensure closing via the dialog close button is the same # as clicking cancel. close_result = False, # Ensure the user can resize the dialog. resizable = True, ) #### protected 'Project' interface ####################################### # A list of editors currently open to visualize our resources # FIXME: Re-add the ProjectEditor's(if we need them) once they are fixed. #_editors = Dict(Any, ProjectEditor, transient=True) # The cache of this project's name. We can't just initialize it to a # default value since the location may be cleared at any time. _name = Str(transient=True) ########################################################################## # 'Object' interface. ########################################################################## #### operator methods #################################################### def __getstate__(self): """ Get the state of this object for pickling. Extended to limit which attributes get pickled and also to add version numbers to our pickle. It is STRONGLY recommended that derived classes not leverage the pickling mechanism if they wish to store additional data in OTHER files as part of their project. Instead, they should override the *_save* method. Extending this method in derived classes IS appropriate if you want to store additional data in the SAME pickle file as the project. """ # Determine the starting point for our state. state = super(Project, self).__getstate__().copy() # Remove any transient traits. for trait_name in self.trait_names(transient=True): state.pop(trait_name, None) # Add in our current version number. Note use a different attribute # name from any base or derived class so that our numbers don't # override theirs. state['_project_version_major'] = 1 state['_project_version_minor'] = 0 return state def __setstate__(self, state): """ Restore the state of this object during unpickling. Extended to upgrade pickles to the current Project version. It is STRONGLY recommended that derived classes not leverage the unpickling mechanism if they wish to load data from additional pickle files. Instead, they should override the *_load* method. Extending this method in derived classes IS appropriate if you want to load additional data from the SAME pickle file as the project. """ # Get the version info out of the state dictionary. major = state.pop('_project_version_major', 0) minor = state.pop('_project_version_minor', 0) # Upgrade to version 1. if major < 1: # Remove any old attributes. # - name is now a calculated property instead of stored value. for key in ['name']: state.pop(key, None) # Restore our state. return super(Project, self).__setstate__(state) def __str__(self): """ Return the unofficial string representation of this object. """ result ='%s(name=%s)' % (super(Project, self).__str__(), self.name) return result ########################################################################## # 'Project' interface. ########################################################################## #### public interface #################################################### def get_default_project_location(self, application): """ Return the default location for a new project. """ path = self.get_default_path(application) name = clean_filename(self.get_default_name()) location = os.path.join(path, name) location = self._make_location_unique(location) return location def get_default_path(cls, application): """ Return the default path to the parent directory for a new project. """ # When unpickling, we don't have a reference to the current application, so we # fallback on application_home. if application is None: return ETSConfig.application_home app_preferences = application.preferences path_id = 'envisage.ui.' \ 'single_project.preferred_path' path = app_preferences.get(path_id) # If the 'preferred_path' variable isn't set in the user's preferences, # then we set to the the application home by default. if len(path) == 0: app_home = ETSConfig.application_home app_preferences.set(path_id, app_home) return app_home return path get_default_path = classmethod(get_default_path) def get_default_name(self): """ Return the default name for a new project. """ return 'New Project' def get_pickle_filename(cls, location): """ Generate the project's pickle filename given a source location. By default, the filename IS the specified location or, when saving projects as directories, a file called 'project' within a directory that is the specified location, Derived classes may wish to use the location as the basis for identifying the real pickle file. """ if cls.PROJECTS_ARE_FILES: result = location else: result = os.path.join(location, 'project') return result get_pickle_filename = classmethod(get_pickle_filename) def get_pickle_package(cls): """ Returns the pickle package to use for pickling and unpickling projects. Implementors can override this to customize the way in which projects are pickled and unpickled. This implementation returns the apptools.sweet_pickle package which supports versioning and refactoring of classes. """ return apptools.sweet_pickle get_pickle_package = classmethod(get_pickle_package) def load(cls, location, application): """ Load a project from a specified location. The loaded project's location is always set to the location the project was actually loaded from. Additionally, the dirty flag is cleared on the loaded project. An exception will be raised to indicate a failure. """ # Load the project in a manner that derived classes can modify. project = cls._load(location) # Ensure the project's location reflects where the project was loaded # from and that the dirty flag is not set. project.location = location project.dirty = False # Set the project's 'application' to the running application passed in. project.application = application return project load = classmethod(load) def register_editor(self, resource, editor, remove=False): """ Inform us that an editor has been opened for what is believed to be a resource in this project. Note that if this project can be represented as a hierarchy, the resource may not be a top level object in that hierarchy! """ # Warn if the resource is not part of this project if not self._contains_resource(resource): logger.warn('This Project [%s] does not contain resource [%s]' % \ (self, resource)) # Add or remove from our set of editors as requested if not remove: self._editors[resource] = editor else: del self._editors[resource] def save(self, location=None, overwrite=False): """ Save this project. The project is saved to its current location, identified by the value of the *location* trait, unless a new location is explicitly provided. The specification of a new location is used to do a 'save as' operation. If a new location is provided, and a file or directory already exists at that location, then an *AssertionError* exception is raised unless the overwrite flag is True. This ensures that users won't accidentally overwrite existing data. This method requires the overwrite flag because prompting the user to confirm the overwrite requires GUI interaction and thus should not be done at the model level. Note that, because we can rely on the location of a loaded project always being set to the location it was loaded from, there is no reason to try to force the *location* trait within a saved project to the location we are trying to save to. Instead, we update the value in the in-memory version of the project only if the save completed successfully. The dirty flag is always cleared upon a succesfull save of the project. An exception will be raised to indicate a failure. """ # Ensure saving (or save as) is allowed at this time. if location is None or location == self.location: if not self.is_save_allowed: raise AssertionError('Saving is currently not allowed.') elif location != self.location: if not self.is_save_as_allowed: raise AssertionError('Save as is currently not allowed.') # Use the internally-specified location unless a new location was # explicitly provided. The new location can not contain any starting # or trailing whitespace and it cannot overwrite an existing file or # directory unless that was explicitly allowed. loc = self.location if location is not None: location = location.strip() if len(location) > 0 and location != self.location: # Ensure we never overwrite existing files / directories just # because someone specified a new location. (Confirmation or # correction of overwriting requires prompting of the user and # is thus not part of the project model.) if os.path.exists(location) and overwrite is False: raise AssertionError('Can not overwrite existing ' + \ 'location [%s]' % location) # The requested location is valid so let's use it. loc = location # Ensure all necessary directories exist. If we're saving a file, then # these are the path upto the file name. If we're saving to a directory # then the path is the complete location. if self.PROJECTS_ARE_FILES: path, filename = os.path.split(loc) else: path = loc if len(path) > 0: f = File(path) if f.is_file: f.delete() if not f.exists: f.create_folders() # Save this project in a manner that derived classes can modify. self._save(loc) # If the save succeeds (no exceptions were raised), then update the # location of the project and clear the dirty flag. self.location = loc self.dirty = False return def start(self): """ Notify this project that it is now the 'current' project. This call should only be made by the project plugin framework! This call *could* happen multiple times to a project, but only if interwoven with paired calls to the 'stop' method. Derived classes should override this, and chain the base implementation, if they need to do anything when a project becomes current. """ logger.debug('Project [%s] started', self) # Ensure we start with an empty set of editors self._editors = {} def stop(self): """ Called only by the project plugin framework to notify this project it is no longer the current project. This call *could* happen multiple times to a project, but only if interwoven with paired calls to the 'start' method. Derived classes should override this, and chain the base implementation, if they need to do anything when a project stops being current. """ # Close all of the editors displaying our resources self._close_all_editors() logger.debug('Project [%s] stopped', self) #### protected interface ################################################# def _close_all_editors(self): """ Called to close all editors associated with this project. """ # NOTE: The close() method on the editor will call back to remove # itself from our set of registered editors. (This assumes the # editor is derived from ProjectEditor.) for editor in self._editors.values(): logger.debug('Project requesting close of ProjectEditor [%s]', editor) editor.close() def _close_resource_editors(self, resource): """ Close any editors associated with the specified resource(s). The passed value may be a single resource or a list of resources. The resources should be parts of this project but no error is generated if they are not, nor if they are not currently associated with an editor. """ # Ensure we're dealing with a list of resources. if not isinstance(resource, list): resource = [resource] # Close any editors associated with the resources for r in resource: editor = self._editors.get(r, None) if editor is not None: logger.debug('Requesting close of ProjectEditor [%s] from ' + \ 'Project [%s]', editor, self) editor.close() return def _contains_resource(self, resource): """ Called to determine if this project contains the specified resource. Note that if this project can be represented as a hierarchy, the resource may not be a top level object in that hierarchy! Derived classes must implement this! """ return False def _get_name(self): """ Returns the current name for this project. The name is always the last part of the path that is the project's location. If we have no location, then a default name is returned. """ # Prefer to use the cached version of the name if self._name is not None and len(self._name) > 0: result = self._name # Use (and cache) a name from our current location else: # Strip any trailing path separator off the current location so # that we use the last directory name if our location is a # directory location = self.location.rstrip(os.path.sep) # The project name is then the basename of the location self._name = os.path.basename(location) result = self._name return result def _load(cls, location): """ Load a project from the specified location. This method exists purely to allow derived classes to have an easy way to override or extend the loading of a project. The default behavior is to load the project from a file using the unpickle mechanism. The caller is notified of loading errors by raised exceptions. """ # Allow derived classes to determine the actual pickle file given the # requested source location. filename = cls.get_pickle_filename(location) logger.debug('Loading Project of class [%s] from [%s]', cls, filename) # Try to unpickle the project while making sure to close any file we # opened. fh = None try: fh = file(filename, 'rb') pickle_package = cls.get_pickle_package() project = pickle_package.load(fh) # Allow derived classes to customize behavior after unpickling # is complete. project._load_hook(location) logger.debug('Loaded Project [%s] from location [%s]', project, filename) # Ensure any opened file is closed finally: if fh: try: fh.close() except: logger.exception('Unable to close project file [%s]', filename) return project _load = classmethod(_load) def _load_hook(self, location): """ Finish loading of a project. This method exists purely to allow derived classes to customize the steps that finish the loading of a project. Note that the project's internal location value does not yet reflect the location the project was loaded from, nor do we guarantee the dirty flag isn't set. (Doing the right thing to both of these is done by the framework after this method!) """ pass def _location_default(self): """ Generates the default value for our location trait. """ return self.get_default_project_location(self.application) def _make_location_unique(cls, location): """ Return a location, based off the specified location, that does not already exist on the filesystem. """ result = location counter = 1 while os.path.exists(result): result = cls._unique_name_format % (location, counter) counter+=1 return result _make_location_unique = classmethod(_make_location_unique) def _save(self, location): """ Save this project to the specified location. This method exists purely to allow derived classes to have an easy way to override or extend the saving of a project. The default behavior is to save this project to a file using the pickle mechanism. The caller is notified of saving errors by raised exceptions. """ # Allow derived classes to determine the actual pickle file from the # specified location. filename = self.get_pickle_filename(location) logger.debug('Saving Project [%s] to [%s]', self, filename) # Pickle the object to a file while making sure to close any file we # open. Note that we can't just log or ignore errors here as the # caller needs to know whether we succeeded or not, and could possibly # handle the exception if they knew what it was. fh = None try: # Allow derived classes to customize behavior before pickling is # applied. self._save_hook(location) fh = file(filename, 'wb') pickle_package = self.get_pickle_package() pickle_package.dump(self, fh, 1) logger.debug('Saved Project [%s] to [%s]', self, filename) finally: try: if fh is not None: fh.close() except: logger.exception('Unable to close project pickle file [%s]', filename) return def _save_hook(self, location): """ Start saving a project. This method exists purely to allow derived classes to customize the steps that initiate the saving of a project. Note that the project's internal location value does not reflect the target location for the save. """ pass #### trait handlers ###################################################### def _location_changed(self, old, new): """ Called whenever the project's location changes. """ logger.debug('Location changed from [%s] to [%s] for Project [%s]', old, new, self) # Invalidate any cached project name old_name = self._name self._name = '' self.trait_property_changed('name', old_name, self.name) # Indicate this project is now dirty self.dirty = True #### EOF ##################################################################### envisage-4.1.0/envisage/ui/single_project/project_runnable.py0000644000175100001440000000664111674464014025447 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2006-2007 by Enthought, Inc. # All rights reserved. # # Author: Dave Peterson # #----------------------------------------------------------------------------- """ A runnable that restores the last opened project. """ # Standard library imports import logging # Enthought library imports. from envisage import Runnable from envisage.workbench.services import IWORKBENCH from pyface.api import information # Application imports from services import IPROJECT_MODEL, IPROJECT_UI # Setup a logger for this module. logger = logging.getLogger(__name__) class ProjectRunnable(Runnable): """ A runnable that restores the last opened project. """ ########################################################################## # 'Runnable' interface. ########################################################################## #### public interface #################################################### def run(self, application): """ Run this runnable. Overridden here to: (a) ensure the UI service monitors for the closing of the application, and (b) restore the last opened project. """ # Ensure our UI service is listening for the application to close. # FIXME: This ugly hack (doing this here) is necessary only because # this plugin contributes to the workbench plugin and that means the # workbench insists on starting us first which means our UI service # can't directly reference the workbench service until after # everything has been started. ui_service = application.get_service(IPROJECT_UI) ui_service.listen_for_application_exit() # Load the project we were using when we last shutdown. model_service = application.get_service(IPROJECT_MODEL) location = model_service.preferences.get('project location', default=None) if location and len(location) > 0: logger.info("Opening last project from location [%s]", location) try: project = model_service.factory.open(location) except: logger.exception('Error during opening of last project.') project = None if project is not None: model_service.project = project else: information(self._get_parent_window(application), 'Unable to open last project from location:\t\n' '\t%s\n' % (location) + '\n\n' 'The project may no longer exist.', 'Can Not Open Last Project', ) else: logger.info('No previous project to open') return #### protected interface ################################################ def _get_parent_window(self, application): """ Find and return a reference to the application window. If one can not be found, then 'None' is returned. """ window = None try: workbench = application.get_service(IWORKBENCH) window = workbench.active_window.control except: logger.warn('Unable to retrieve application window reference.') return window #### EOF ###################################################################### envisage-4.1.0/envisage/ui/single_project/project_plugin.py0000644000175100001440000003504011674464014025132 0ustar ischnellusers00000000000000""" The Envisage single project plugin. """ # Standard library imports import logging # Enthought library imports. from envisage.api import ExtensionPoint, Plugin, ServiceOffer from envisage.ui.single_project.api import FactoryDefinition from pyface.action.api import MenuManager from pyface.workbench.api import Perspective from traits.api import Callable, List # Local imports. from model_service import ModelService from project_action_set import ProjectActionSet from services import IPROJECT_MODEL, IPROJECT_UI from ui_service_factory import UIServiceFactory # This module's package. PKG = '.'.join(__name__.split('.')[:-1]) # Setup a logger for this module. logger = logging.getLogger(__name__) ############################################################################### # `ProjectPerspective` class. ############################################################################### class ProjectPerspective(Perspective): """ A default perspective for the single_project plugin. """ # The perspective's name. name = 'Project' # Should this perspective be enabled or not? enabled = True # Should the editor area be shown in this perspective? show_editor_area = True # The contents of the perspective. # TODO: Setup the PerspectiveItems based on the areas in our perspective. #contents = [] ############################################################################## # 'ProjectPlugin' class. ############################################################################## class ProjectPlugin(Plugin): """ The single-project plugin. """ # The Ids of the extension points that this plugin offers. ACTION_SETS = 'envisage.ui.workbench.action_sets' FACTORY_DEFINITIONS = 'envisage.ui.single_project.factory_definitions' UI_SERVICE_FACTORY = 'envisage.ui.single_project.ui_service_factory' # The Ids of the extension points that this plugin contributes to. PERSPECTIVES = 'envisage.ui.workbench.perspectives' PREFERENCES = 'envisage.preferences' PREFERENCES_PAGES = 'envisage.ui.workbench.preferences_pages' SERVICE_OFFERS = 'envisage.service_offers' VIEWS = 'envisage.ui.workbench.views' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'envisage.ui.single_project' # The plugin's name (suitable for displaying to the user). name = 'Single Project' #### Extension points offered by this plugin ############################## # Factory definitions. factory_definitions = ExtensionPoint( List(Callable), id=FACTORY_DEFINITIONS, desc=""" A project factory definition. An instance of the specified class is used to open and/or create new projects. The extension with the highest priority wins! In the event of a tie, the first instance wins. """ ) # Ui service factories. ui_service_factory = ExtensionPoint( List(Callable), id=UI_SERVICE_FACTORY, desc=""" A ui service factory definition. """ ) #### Contributions to extension points made by this plugin ################ # Action sets. action_sets = List(contributes_to=ACTION_SETS) def _action_sets_default(self): """ Default project actions. """ return [ProjectActionSet] # Factory definitions. my_factory_definitions = List(contributes_to=FACTORY_DEFINITIONS) def _my_factory_definitions_default(self): """ Default factory definition. """ factory_definition = FactoryDefinition( class_name = PKG + '.project_factory.ProjectFactory', priority = 0, ) return [factory_definition] # Perspectives. perspectives = List(contributes_to=PERSPECTIVES) def _perspectives_default(self): """ Default project perspective. """ return [ProjectPerspective] # Service offers. service_offers = List(contributes_to=SERVICE_OFFERS) def _service_offers_default(self): """ Our service contributions. """ model_service = ServiceOffer( protocol = IPROJECT_MODEL, factory = self._create_model_service ) ui_service = ServiceOffer( protocol = IPROJECT_UI, factory = self._create_ui_service ) # FIXME: Eventually we will register the services here intead # of in the plugin's start() method. #return [model_service, ui_service] return [] # Ui service factories. my_ui_service_factory = List(contributes_to=UI_SERVICE_FACTORY) def _my_ui_service_factory_default(self): """ Default ui service factory. """ ui_service_factory = UIServiceFactory( class_name = PKG + '.ui_service_factory.UIServiceFactory', priority = 0, ) return [ui_service_factory] # Preferences. my_preferences = List(contributes_to=PREFERENCES) def _my_preferences_default(self): """ Default preferences. """ return ['pkgfile://%s/preferences.ini' % PKG] # Preference pages. my_preferences_pages = List(contributes_to=PREFERENCES_PAGES) def _my_preferences_pages_default(self): """ Default preference page. """ from default_path_preference_page import DefaultPathPreferencePage return [DefaultPathPreferencePage] # Views. views = List(contributes_to=VIEWS) def _views_default(self): """ Add our project views. """ return [self._project_view_factory] ### protected interface ################################################## def start(self): """ Starts the plugin. Overridden here to start up our services and load the project that was open when we were last shut-down. """ super(ProjectPlugin, self).start() # FIXME: We eventually won't have to explicitly register the # services ourselves, since we contribute them as service offers # so they are instantiated when they are invoked, but since they are # not used anywhere else yet, I had to use this same old approach # just to test and make sure they were working correctly. # Create and register the model service we offer model_service = self._create_model_service() self.application.register_service(IPROJECT_MODEL, model_service) # Create and register the ui service we offer ui_service = self._create_ui_service(model_service) self.application.register_service(IPROJECT_UI, ui_service) # Set up any listeners interested in the current project selection # FIXME: Register the selection listeners for the current project selection. #self._register_selection_listeners(model_service) return ###################################################################### # Private methods. def _project_view_factory(self, window, **traits): """ Factory method for project views. """ from pyface.workbench.traits_ui_view import \ TraitsUIView from envisage.ui.single_project.api import \ ProjectView project_view = ProjectView(application=window.application) tui_project_view = TraitsUIView(obj=project_view, id='envisage.ui.single_project.view.project_view.ProjectView', name='Project View', window=window, position='left', **traits ) return tui_project_view def _create_model_service(self): """ Creates a model service for this plugin. """ # Determine which contributed project factory to use. factory = self._get_contributed_project_factory() # Make sure the factory has a reference to our Envisage application. factory.application = self.application # Create the project service instance. result = ModelService(self.application, factory) return result def _create_ui_service(self, model_service): """ Creates a UI service for this plugin. """ # Create the menu manager representing the context menu we show when # nothing is selected in the project view. menu_manager = self._get_no_selection_context_menu_manager() # Get the UI service factory. ui_service_factory = self._get_contributed_ui_service_factory() # Create the ui service instance ui_service = ui_service_factory.create_ui_service(model_service, menu_manager) return ui_service def _get_contributed_project_factory(self): """ Retrieves the instance of the project factory to use with this plugin. The instance is generated from the contributed factory definition that was the first one with the highest priority. """ # Retrieve all the factory definition contributions extensions = self.application.get_extensions('envisage.ui.single_project.factory_definitions') # Find the winning contribution definition = None for extension in extensions: if not definition or extension.priority > definition.priority: definition = extension # Create an instance of the winning project factory logger.info("Using ProjectFactory [%s]", definition.class_name) klass = self.application.import_symbol(definition.class_name) factory = klass() return factory def _get_contributed_ui_service_factory(self): """ Retrieves the instance of the UiService factory to use with this plugin. The instance is generated from the contributed factory definition that was the first one with the highest priority. """ # Retrieve all the factory definition contributions extensions = self.get_extensions('envisage.ui.single_project.ui_service_factory') # Find the winning contribution definition = None for extension in extensions: if not definition or extension.priority > definition.priority: definition = extension # Create an instance of the winning factory logger.info("Using UiService Factory [%s]", definition.class_name) class_name = definition.class_name klass = self.application.import_symbol(class_name) factory = klass() return factory def _get_no_selection_context_menu_manager(self): """ Generates a menu manager representing the context menu shown when nothing is selected within the project view. That is, when the user right clicks on any empty space within our associated UI. """ # Retrieve all contributions for the no-selection context menu. extensions = self.get_extensions(ProjectActionSet) # Populate a menu manager from the extensions. menu_manager = MenuManager() if len(extensions) > 0: action_set_manager = ActionSetManager(action_sets=extensions) menu_builder = DefaultMenuBuilder(application=self.application) menu_builder.initialize_menu_manager(menu_manager, action_set_manager, NO_SELECTION_MENU_ID) return menu_manager def _register_selection_listeners(self, model_service): """ Registers any extension-requested listeners on the project selection. """ for sps in self.get_extensions(SyncProjectSelection): object = self.application.lookup_application_object(sps.uol) if object is not None: name = sps.name self._register_selection_handler(object, name, model_service) else: logger.error('Could not resolve the SyncProjectSelection ' + \ 'UOL: "%s"', sps.uol ) return def _register_selection_handler(self, object, name, model_service): """ Creates a handler and registers it. """ def handler(): # The key to this method is to realize that our goal is to # make it as easy as possible to create recipients for # notification. Using traits as the recipients makes # creation very simple because we can rely on the type # knowledge within that trait to ensure only valid values # get assigned to the recipient. That is the recipient # doesn't need to do anything complex to validate the # values they get assigned. This method also works if the # recipient isn't a trait, but in that case, they will # have to handle multiple selection of the project # bindings. # # First, try to provide the recipient with a multiple # selection type value i.e. a list of bindings. try: setattr(object, name, model_service.selection) return except: pass # If that didn't work, remove the binding wrappers and try # notification of the resulting list. selection = [s.obj for s in model_service.selection] try: setattr(object, name, selection) return except: pass # If that didn't work, and only a single item is selected, # then try to provide that item to the recipient. if len(selection) == 1: try: setattr(object, name, selection[0]) return except: pass # The recipient must not be accepting the type of the # current selection, so let's clear its current selection # instead. If this fails, then something has gone wrong # with the declaration of the recipient. try: setattr(object, name, None) except: logger.debug('Error informing object [%s] of project ' 'selection change via attribute [%s]', object, name) model_service.on_trait_change(handler, 'selection') model_service.on_trait_change(handler, 'selection_items') return ### EOF ###################################################################### envisage-4.1.0/envisage/ui/single_project/ui_service.py0000644000175100001440000007033611674464014024252 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2005-2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ A service to enable UI interactions with the single project plugin. """ # Standard library imports. import logging import os import shutil # Enthought library imports from apptools.preferences.api import bind_preference from apptools.io.api import File from apptools.naming.api import Context from pyface.api import CANCEL, confirm, ConfirmationDialog, \ DirectoryDialog, error, FileDialog, information, NO, OK, YES from pyface.action.api import MenuManager from pyface.timer.api import do_later, Timer from traits.api import Any, Event, HasTraits, Instance, Int # Local imports. from model_service import ModelService # Setup a logger for this module. logger = logging.getLogger(__name__) class UiService(HasTraits): """ A service to enable UI interactions with the single project plugin. """ ########################################################################## # Attributes ########################################################################## #### public 'UiService' interface ######################################## # The manager of the default context menu default_context_menu_manager = Instance(MenuManager) # A reference to our plugin's model service. model_service = Instance(ModelService) # The project control (in our case a tree). This is created by the # project view. Provided here so that sub-classes may access it. project_control = Any # Fired when a new project has been created. The value should be the # project instance that was created. project_created = Event # A timer to implement automatic project saving. timer = Instance(Timer) # The interval (minutes)at which automatic saving should occur. autosave_interval = Int(5) ########################################################################## # 'object' interface. ########################################################################## #### operator methods #################################################### def __init__(self, model_service, menu_manager, **traits): """ Constructor. Extended to require a reference to the plugin's model service to create an instance. """ super(UiService, self).__init__( model_service = model_service, default_context_menu_manager = menu_manager, **traits ) try: # Bind the autosave interval to the value specified in the # single project preferences p = self.model_service.preferences bind_preference(self, 'autosave_interval', 5, p) except: logger.exception('Failed to bind autosave_interval in [%s] to ' 'preferences.' % self) return ########################################################################## # 'UiService' interface. ########################################################################## #### public interface #################################################### def close(self, event): """ Close the current project. """ # Ensure any current project is ready for this change. if self.is_current_project_saved(event.window.control): # If we have a current project, close it. current = self.model_service.project if current is not None: logger.debug("Closing Project [%s]", current.name) self.model_service.project = None return def create(self, event): """ Create a new project. """ # Ensure any current project is ready for this change. if self.is_current_project_saved(event.window.control): # Use the registered factory to create a new project project = self.model_service.factory.create() if project is not None: # Allow the user to customize the new project dialog = project.edit_traits( parent = event.window.control, # FIXME: Due to a bug in traits, using a wizard dialog # causes all of the Instance traits on the object being # edited to be replaced with new instances without any # listeners on those traits being called. Since we can't # guarantee that our project's don't have Instance traits, # we can't use the wizard dialog type. #kind = 'wizard' kind = 'livemodal' ) # If the user closed the dialog with an ok, make it the # current project. if dialog.result: logger.debug("Created Project [%s]", project.name) self.model_service.project = project self.project_created = project return def display_default_context_menu(self, parent, event): """ Display the default context menu for the plugin's ui. This is the context menu used when neither a project nor the project's contents are right-clicked. """ # Determine the current workbench window. This should be safe since # we're only building a context menu when the user clicked on a # control that is contained in a window. workbench = self.model_service.application.get_service('envisage.ui.workbench.workbench.Workbench') window = workbench.active_window # Build our menu from envisage.workbench.action.action_controller import \ ActionController menu = self.default_context_menu_manager.create_menu(parent, controller = ActionController(window=window)) # Popup the menu (if an action is selected it will be performed # before before 'PopupMenu' returns). if menu.GetMenuItemCount() > 0: menu.show(event.x, event.y) return def delete_selection(self): """ Delete the current selection within the current project. """ # Only do something if we have a current project and a non-empty # selection current = self.model_service.project selection = self.model_service.selection[:] if current is not None and len(selection) > 0: logger.debug('Deleting selection from Project [%s]', current) # Determine the context for the current project. Raise an error # if we can't treat it as a context as then we don't know how # to delete anything. context = self._get_context_for_object(current) if context is None: raise Exception('Could not treat Project ' + \ '[%s] as a context' % current) # Filter out any objects in the selection that can NOT be deleted. deletables = [] for item in selection: rt = self._get_resource_type_for_object(item.obj) nt = rt.node_type if nt.can_delete(item): deletables.append(item) else: logger.debug('Node type reports selection item [%s] is ' 'not deletable.', nt) if deletables != []: # Confirm the delete operation with the user names = '\n\t'.join([b.name for b in deletables]) message = ('You are about to delete the following selected ' 'items:\n\t%s\n\n' 'Are you sure?') % names title = 'Delete Selected Items?' action = confirm(None, message, title) if action == YES: # Unbind all the deletable nodes if len(deletables) > 0: self._unbind_nodes(context, deletables) return def is_current_project_saved(self, parent_window): """ Give the user the option to save any modifications to the current project prior to closing it. If the user wanted to cancel the closing of the current project, this method returns False. Otherwise, it returns True. """ # The default is the user okay'd the closing of the project result = True # If the current project is dirty, handle that now by challenging the # user for how they want to handle them. current = self.model_service.project if not(self._get_project_state(current)): dialog = ConfirmationDialog( parent = parent_window, cancel = True, title = 'Unsaved Changes', message = 'Do you want to save the changes to project "%s"?' \ % (current.name), ) action = dialog.open() if action == CANCEL: result = False elif action == YES: result = self._save(current, parent_window) elif action == NO: # Delete the autosaved file as the user does not wish to # retain the unsaved changes. self._clean_autosave_location(current.location.strip()) return result def listen_for_application_exit(self): """ Ensure that we get notified of any attempts to, and thus have a chance to veto, the closing of the application. FIXME: Normally this should be called during startup of this plugin, however, Envisage won't let us find the workbench service then because we've made a contribution to its extension points and it insists on starting us first. """ workbench = self.model_service.application.get_service('envisage.ui.workbench.workbench.Workbench') workbench.on_trait_change(self._workbench_exiting, 'exiting') return def open(self, event): """ Open a project. """ # Ensure any current project is ready for this change. if self.is_current_project_saved(event.window.control): # Query the user for the location of the project to be opened. path = self._show_open_dialog(event.window.control) if path is not None: logger.debug("Opening project from location [%s]", path) project = self.model_service.factory.open(path) if project is not None: logger.debug("Opened Project [%s]", project.name) self.model_service.project = project else: msg = 'Unable to open %s as a project.' % path error(event.window.control, msg, title='Project Open Error') return def save(self, event): """ Save a project. """ current = self.model_service.project if current is not None: self._save(current, event.window.control) return def save_as(self, event): """ Save the current project to a different location. """ current = self.model_service.project if current is not None: self._save(current, event.window.control, prompt_for_location=True) return #### protected interface ################################################# def _auto_save(self, project): """ Called periodically by the timer's Notify function to automatically save the current project. The auto-saved project has the extension '.autosave'. """ # Save the project only if it has been modified. if project.dirty and project.is_save_as_allowed: location = project.location.strip() if not(location is None or len(location) < 1): autosave_loc = self._get_autosave_location(location) try: # We do not want the project's location and name to be # updated. project.save(autosave_loc, overwrite=True, autosave=True) msg = '[%s] auto-saved to [%s]' % (project, autosave_loc) logger.debug(msg) except: logger.exception('Error auto-saving project [%s]'% project) else: logger.exception('Error auto-saving project [%s] in ' 'location %s' % (project, location)) return def _clean_autosave_location(self, location): """ Removes any existing autosaved files or directories for the project at the specified location. """ autosave_loc = self._get_autosave_location(location) if os.path.exists(autosave_loc): self.model_service.clean_location(autosave_loc) return def _get_autosave_location(self, location): """ Returns the path for auto-saving the project in location. """ return os.path.join(os.path.dirname(location), os.path.basename(location) + '.autosave') def _get_context_for_object(self, obj): """ Return the context for the specified object. """ if isinstance(obj, Context): context = obj else: context = None resource_type = self._get_resource_type_for_object(obj) if resource_type is not None: factory = resource_type.context_adapter_factory if factory is not None: # FIXME: We probably should use a real environment and # context (parent context?) context = factory.adapt(obj, Context, {}, None) return context def _get_resource_type_for_object(self, obj): """ Return the resource type for the specified object. If no type could be found, returns None. """ resource_manager = self.model_service.resource_manager return resource_manager.get_type_of(obj) def _get_project_state(self, project): """ Returns True if the project is clean: i.e., the dirty flag is False and all autosaved versions have been deleted from the filesystem. """ result = True if project is not None: autosave_loc = self._get_autosave_location( project.location.strip()) if project.dirty or os.path.exists(autosave_loc): result = False return result def _get_user_location(self, project, parent_window): """ Prompt the user for a new location for the specified project. Returns the chosen location or, if the user cancelled, an empty string. """ # The dialog to use depends on whether we're prompting for a file or # a directory. if self.model_service.are_projects_files(): dialog = FileDialog(parent = parent_window, title = 'Save Project As', default_path = project.location, action = 'save as', ) title_type = 'File' else: dialog = DirectoryDialog(parent = parent_window, message = 'Choose a Directory for the Project', default_path = project.location, action = 'open' ) title_type = 'Directory' # Prompt the user for a new location and then validate we're not # overwriting something without getting confirmation from the user. result = "" while(dialog.open() == OK): location = dialog.path.strip() # If the chosen location doesn't exist yet, we're set. if not os.path.exists(location): logger.debug('Location [%s] does not exist yet.', location) result = location break # Otherwise, confirm with the user that they want to overwrite the # existing files or directories. If they don't want to, then loop # back and prompt them for a new location. else: logger.debug('Location [%s] exists. Prompting for overwrite ' 'permission.', location) message = 'Overwrite %s?' % location title = 'Project %s Exists' % title_type action = confirm(parent_window, message, title) if action == YES: # Only use the location if we successfully remove the # existing files or directories at that location. try: self.model_service.clean_location(location) result = location break # Otherwise, display the remove error to the user and give # them another chance to pick another location except Exception, e: msg = str(e) title = 'Unable To Overwrite %s' % location information(parent_window, msg, title) logger.debug('Returning user location [%s]', result) return result def _restore_from_autosave(self, project, autosave_loc): """ Restores the project from the version saved in autosave_loc. """ workbench = self.model_service.application.get_service( 'envisage.ui.workbench.workbench.Workbench') window = workbench.active_window app_name = workbench.branding.application_name message = ('The app quit unexpectedly when [%s] was being modified.\n' 'An autosaved version of this project exists.\n' 'Do you want to restore the project from the ' 'autosaved version ?' % project.name) title = '%s-%s' % (app_name, project.name) action = confirm(window.control, message, title, cancel=True, default=YES) if action == YES: try: saved_project = self.model_service.factory.open(autosave_loc) if saved_project is not None: # Copy over the autosaved version to the current project's # location, switch the model service's project, and delete # the autosaved version. loc = project.location.strip() saved_project.save(loc, overwrite=True) self.model_service.clean_location(autosave_loc) self.model_service.project = saved_project else: logger.debug('No usable project found in [%s].' % autosave_loc) except: logger.exception( 'Unable to restore project from [%s]' % autosave_loc) self._start_timer(self.model_service.project) return def _save(self, project, parent_window, prompt_for_location=False): """ Save the specified project. If *prompt_for_location* is True, or the project has no known location, then the user is prompted to provide a location to save to. Returns True if the project was saved successfully, False if not. """ location = project.location.strip() # If the project's existing location is valid, check if there are any # autosaved versions. autosave_loc = '' if location is not None and os.path.exists(location): autosave_loc = self._get_autosave_location(location) # Ask the user to provide a location if we were told to do so or # if the project has no existing location. if prompt_for_location or location is None or len(location) < 1: location = self._get_user_location(project, parent_window) # Rename any existing autosaved versions to the new project # location. if location is not None and len(location) > 0: self._clean_autosave_location(location) new_autosave_loc = self._get_autosave_location(location) if os.path.exists(autosave_loc): shutil.move(autosave_loc, new_autosave_loc) # If we have a location to save to, try saving the project. if location is not None and len(location) > 0: try: project.save(location) saved = True msg = '"%s" saved to %s' % (project.name, project.location) information(parent_window, msg, 'Project Saved') logger.debug(msg) except Exception, e: saved = False logger.exception('Error saving project [%s]', project) error(parent_window, str(e), title='Save Error') else: saved = False # If the save operation was successful, delete any autosaved files that # exist. if saved: self._clean_autosave_location(location) return saved def _show_open_dialog(self, parent): """ Show the dialog to open a project. """ # Determine the starting point for browsing. It is likely most # projects will be stored in the default path used when creating new # projects. default_path = self.model_service.get_default_path() project_class = self.model_service.factory.PROJECT_CLASS if self.model_service.are_projects_files(): dialog = FileDialog(parent=parent, default_directory=default_path, title='Open Project') if dialog.open() == OK: path = dialog.path else: path = None else: dialog = DirectoryDialog(parent=parent, default_path=default_path, message='Open Project') if dialog.open() == OK: path = project_class.get_pickle_filename(dialog.path) if File(path).exists: path = dialog.path else: error(parent, 'Directory does not contain a recognized ' 'project') path = None else: path = None return path def _start_timer(self, project): """ Resets the timer to work on auto-saving the current project. """ if self.timer is None: if self.autosave_interval > 0: # Timer needs the interval in millisecs self.timer = Timer(self.autosave_interval*60000, self._auto_save, project) return def _unbind_nodes(self, context, nodes): """ Unbinds all of the specified nodes that can be found within this context or any of its sub-contexts. This uses a breadth first algorithm on the assumption that the user will have likely selected peer nodes within a sub-context that isn't the deepest context. """ logger.debug('Unbinding nodes [%s] from context [%s] within ' 'UiService [%s]', nodes, context, self) # Iterate through all of the selected nodes looking for ones who's # name is within our context. context_names = context.list_names() for node in nodes[:]: if node.name in context_names: # Ensure we've found a matching node by matching the objects # as well. binding = context.lookup_binding(node.name) if id(node.obj) == id(binding.obj): # Remove the node from the context -AND- from the list of # nodes that are still being searched for. context.unbind(node.name) nodes.remove(node) # Stop if we've unbound the last node if len(nodes) < 1: break # If we haven't unbound the last node, then search any sub-contexts # for more nodes to unbind. else: # Build a list of all current sub-contexts of this context. subs = [] for name in context.list_names(): if context.is_context(name): obj = context.lookup_binding(name).obj sub_context = self._get_context_for_object(obj) if sub_context is not None: subs.append(sub_context) # Iterate through each sub-context, stopping as soon as possible # if we've run out of nodes. for sub in subs: self._unbind_nodes(sub, nodes) if len(nodes) < 1: break def _workbench_exiting(self, event): """ Handle the workbench polling to see if it can exit and shutdown the application. """ logger.debug('Detected workbench closing event in [%s]', self) # Determine if the current project is dirty, or if an autosaved file # exists for this project (i.e., the project has changes which were # captured in the autosave operation but were not saved explicitly by # the user). If so, let the user # decide whether to veto the closing event, save the project, or # ignore the dirty state. current = self.model_service.project if not(self._get_project_state(current)): # Find the active workbench window to be our dialog parent and # the application name to use in our dialog title. workbench = self.model_service.application.get_service('envisage.ui.workbench.workbench.Workbench') window = workbench.active_window app_name = workbench.branding.application_name # Show a confirmation dialog to the user. message = 'Do you want to save changes before exiting?' title = '%s - %s' % (current.name, app_name) action = confirm(window.control, message, title, cancel=True, default=YES) if action == YES: # If the save is successful, the autosaved file is deleted. if not self._save(current, window.control): event.veto = True elif action == NO: # Delete the autosaved file as the user does not wish to # retain the unsaved changes. self._clean_autosave_location(current.location.strip()) elif action == CANCEL: event.veto = True #### Trait change handlers ############################################### def _autosave_interval_changed(self, old, new): """ Restarts the timer when the autosave interval changes. """ self.timer = None if new > 0 and self.model_service.project is not None: self._start_timer(self.model_service.project) return def _project_changed_for_model_service(self, object, name, old, new): """ Detects if an autosaved version exists for the project, and displays a dialog to confirm restoring the project from the autosaved version. """ if old is not None: self.timer = None if new is not None: # Check if an autosaved version exists and if so, display a dialog # asking if the user wishes to restore the project from the # autosaved version. # Note: An autosaved version should exist only if the app crashed # unexpectedly. Regular exiting of the workbench should cause the # autosaved version to be deleted. autosave_loc = self._get_autosave_location(new.location.strip()) if (os.path.exists(autosave_loc)): # Issue a do_later command here so as to allow time for the # project view to be updated first to reflect the current # project's state. do_later(self._restore_from_autosave, new, autosave_loc) else: self._start_timer(new) return #### EOF ##################################################################### envisage-4.1.0/envisage/ui/single_project/model_service.py0000644000175100001440000001035311674464014024726 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2005-2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ The Envisage service providing the model state for the single project plugin. """ # Standard imports import logging import os import shutil # Enthought library imports from envisage.api import IApplication from apptools.preferences.api import IPreferences from traits.api import Any, HasTraits, Instance, List # Setup a logger for this module. logger = logging.getLogger(__name__) class ModelService(HasTraits): """ The Envisage service providing the model state for the single project plugin. """ ########################################################################## # Attributes (Traits) ########################################################################## ### public 'ModelService' interface ###################################### # The Envisage application that this service is part of. application = Instance(IApplication) # The factory to use for creating new projects factory = Instance('envisage.ui.single_project.project_factory.' 'ProjectFactory') # The preferences to be exposed through this service. preferences = Instance(IPreferences) # The currently open project project = Instance('envisage.ui.single_project.project.Project') # The current selection within the current project. selection = List(Any) ########################################################################## # 'object' interface. ########################################################################## ### operator methods ##################################################### def __init__(self, application, factory, **traits): """ Constructor. We require a reference to an Envisage application and a project factory to create an instance. """ super(ModelService, self).__init__(application = application, factory = factory, **traits) return ########################################################################## # 'ModelService' interface. ########################################################################## ### public interface ##################################################### def are_projects_files(self): """ Returns True if project instances are saved as files and False if they are saved as directories. """ return self.factory.PROJECT_CLASS.PROJECTS_ARE_FILES def clean_location(self, location): """ Ensures that there are no existing files or directories at the specified location by removing them. Exceptions are raised if there are any errors cleaning out existing files or directories. """ logger.debug('Trying to clean location [%s]', location) if os.path.isfile(location): os.path.remove(location) else: shutil.rmtree(location) return def get_default_path(self): """ Return the default location for projects. """ return self.factory.PROJECT_CLASS.get_default_path(self.application) ### trait handlers ####################################################### def _project_changed(self, old, new): """ Called whenever the current project is changed. We hook this to make sure the new project knows it's current and the old project knows it's not. """ logger.debug('Detected project change from [%s] to [%s] in ' 'ModelService [%s]', old, new, self) if old is not None: old.stop() self.selection = [] if new is not None: new.start() return def _selection_changed(self, old, new): """ Called whenever the selection within the project is changed. Implemented simply to log the change. """ logger.debug('ModelService [%s] selection changed from [%s] to [%s] ', self, old, new) return ### EOF ###################################################################### envisage-4.1.0/envisage/ui/single_project/DESIGN.txt0000644000175100001440000000464011674464014023250 0ustar ischnellusers00000000000000These are some design notes for the E3 version of the single_project plugin, including a rough background adapated from the README of the E2 single_project plugin, and plans for implementing various aspects of the new plugin. *Note: This is very much a WIP and will probably be updated/modified heavily in a short period of time. BACKGROUND: ----------- This plugin is designed to work with a single project at a time and build up 'state' within that project until the user explicitly saves the project. The plugin contributes two services to an Envisage application -- one for the model and one for the UI. Additionally, the plugin contributes a 'Project' perspective, 'Project' view, and a number of actions to the UI so that the user can create, open, save, save as, and close projects. Finally, it should be noted that the plugin manages an indicator applied to the application window(s) titlebar as a representation that the current project has unsaved modifications. The current project is visualized by a TreeEditor by default, but the user can contribute additional Views. By contributing your own Project factory, the user can define your own custom projects. E2 single_projects vs. E3 single_projects: ----------------------------------------- As described by Martin Chilvers: "domain-objects" are at the highest level of abstraction in your design and hence are the objects that are understood by the user (e.g. Book, Person, Log, LogSuite, Well etc). The original single_project plugin used resources and resource types to adapt domain-objects to add certain behaviours to them that various Envisage plugins expected. However, this approach restricted the addition of new behaviours to resource types, as well as added a lot of cruft to the process of registering new resources/resource types. The E3 single_project plugin uses Traits Adapters and takes advantage of the new ITreeNode interface. The new TreeEditor has been extended to support handling unknown domain-objects by adapting them to the ITreeNode interface. An ITreeNodeAdapter needs to be defined for any object that you want to be displayed in the TreeEditor, such as your Project class and it's sub-nodes. The Adapter exposes certain key ITreeNode interface methods, such as get_children, when_children_changed, get_lable, etc... This eliminates the extra cruft that was necessary in the E2 single_project plugin, such as the node monitor, node resource type, etc... envisage-4.1.0/envisage/ui/single_project/README.txt0000644000175100001440000001516611674464014023241 0ustar ischnellusers00000000000000Last updated: 2006.02.05 BACKGROUND: ----------- This plugin is designed to work with a single project at a time and build up 'state' within that project until the user explicitly saves the project. The plugin contributes two services to an Envisage application -- one for the model and one for the UI. Additionally, the plugin contributes a 'Project' perspective, 'Project' view, and a number of actions to the UI so that the user can create, open, save, save as, and close projects. Finally, it should be noted that the plugin manages an indicator applied to the application window(s) titlebar as a representation that the current project has unsaved modifications. The current project is visualized using a ResourceTree control and thus supports all the visualization and interaction customization of resources. This also makes makes it easy to build a hierarchy of nodes within the tree by implementing the apptools.naming.Context interface. Finally, this plugin contributes a single extension point which provides the capability to define your own custom projects. PRE-REQUISITES: --------------- This plugin requires the use of the envisage framework and the following plugins: - envisage.core - envisage.resource - envisage.workbench - envisage.plugins.python_shell HOW TO USE: ----------- This plugin provides a base class for projects but, as of now, that class has no capability to contain any data. So for this plugin to be useful within an Envisage application you have to complete the following: - Contribute a project_plugin_definition.FactoryDefinition to the Envisage application. This definition should point to a class derived from project_factory.ProjectFactory which will be used to create new projects as well as handle opening of persisted projects. To do that, your ProjectFactory should override the 'create' and 'open' methods as appropriate to return an instance of a class derived from project.Project. Note that multiple plugins can contribute FactoryDefinitions but only the first contributed definition with the highest priority will be used. - You will need to derive a class from project.Project which will be used to contain your project's data. This class should: - override the trait_view trait to provide the UI content that will be shown by the plugin (within a wizard dialog) to allow a user to initialize a newly created project. - override the _contains_resource() method so that the plugin can close editors for resources in your project when your project closes. - set the 'dirty' trait to True anytime modifications are made to your project data - optionally override the Project.start() and Project.stop() methods to handle any work needing to be done when a project becomes the current project or is no longer the current project. For example, the base Project uses the stop() method to close any editors associated with resources contained in the project. - optionally override the _load_hook() and _save() methods if you wish to use the base class's infrastructure for loading and saving projects but have additional work that needs to be accomplished during those events. Note that the plugin's UI service calls the save() method and the ProjectFactory calls the load() method. - optionally override the 'load()' and 'save()' methods if you want to completely replace the base class's infrastructure for loading and saving projects. Note that the plugin's UI service calls the save() method and the ProjectFactory calls the load() method. - You will likely want to register resource types -- and associated classes such as node types, monitors, and resource references -- for the resources that can be contained within your project. This will allow you to take maximum advantage of the infrastructure of the Project view's ResourceTree control. If you do this, you should note that this plugin registers a ProjectResourceType, pointing to a ProjectNodeType, that is used to visualize the root project node. You don't need to derive from these unless you want to customize the resource definition of the project node. - Another option for implementing the visualization of project contents would be to derive from ProjectView and override the _create_project_control() and _update_project_control() methods to replace the ResourceTree control with some other UI control. If you do the later, you will likely need to create your own project plugin definition but you should be able to reuse almost all of the infrastructure classes contained in this plugin. - If the resources within your project can be edited in Editors, you should derive Editor classes from ProjectEditor so that the project plugin framework can close these editors when the project closes. KNOWN ISSUES: ------------- - Due to the current capabilities of the workbench plugin, this plugin can't do the ideal closing hook whereby, if the current project is modified, the user gets prompted to save it, close it, or cancel the closing of the window. The best we can do is follow the prompt to close the workbench window with a dialog querying the user whether they want to save the current project or not. There is an Enthought Trac ticket to add the necessary capability to the workbench plugin and this plugin will be 'fixed' shortly thereafter. - The Project class doesn't support any sort of versioning framework in its saving and loading. This will cause problems as the content and capabilities of projects evolve throughout the software development cycle of an application that uses this plugin. TO-DO: ------ - It would be nice if the Project class was modified such that it could actually be used without needing to be derived from. One possibility for this would be to make it a full-fledged folder type Context in and of itself including support for binding and unbinding. If this was done, it should be easy enough to re-use resource types, node types, etc. defined for other Envisage plugins within projects. - It might be nice if editors that were open when a project was saved were restored when the project was re-loaded. One mechanism to do this would be to modify the Project._editors trait to contain ResourceReferences rather than Resources as the keys. Then when pickling, we would simple dump the editor references and persist just these keys. Upon loading, iterate through the keys/resource references and open an editor for each. One question about this mechanism is that currently we don't track order or position of editors so that info wouldn't be recovered. envisage-4.1.0/envisage/ui/single_project/action/0000755000175100001440000000000011674464014023007 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/action/close_project_action.py0000644000175100001440000000276311674464014027561 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2005, 2006 by Enthought, Inc. # All rights reserved. # # Author: Dave Peterson # #----------------------------------------------------------------------------- """ An action to close the current project. This is only enabled when there is a current project. """ # Enthought library imports from envisage.ui.single_project.project_action import ProjectAction from pyface.api import ImageResource ############################################################################## # class 'CloseProjectAction' ############################################################################## class CloseProjectAction(ProjectAction): """ An action to close the current project. This is only enabled when there is a current project. """ # The universal object locator (UOL). uol = 'envisage.ui.single_project.ui_service.UiService' # The name of the method to invoke on the object. method_name = 'close' # A longer description of the action. description = 'Close the current project' # The action's image (displayed on tool bar tools etc). image = ImageResource('close_project') # The action's name (displayed on menus/tool bar tools etc). name = 'Close' # A short description of the action used for tooltip text etc. tooltip = 'Close this project' #### EOF ##################################################################### envisage-4.1.0/envisage/ui/single_project/action/images/0000755000175100001440000000000011674464014024254 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/action/images/open_project.png0000644000175100001440000000115111674464014027447 0ustar ischnellusers00000000000000PNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxbd```.ˀJ>h@ ? qs1 31#~I0r ܊@2x/!W؀C@>ӿ>  q2N1H; h(#+Xُ[{`W]h3j?5ge`bv;5\ۇ p/wyW8D H~aՎ )@C?$a/ o~%H3_ 4~<?°7b? ? `Qǁ@ x3î? V z+~lalH!PHw :t @۫ D@L cĠ&D@?y(8^ `DC @L3(0IENDB`envisage-4.1.0/envisage/ui/single_project/action/images/save_as_project.png0000644000175100001440000000076211674464014030136 0ustar ischnellusers00000000000000PNG  IHDRabKGDhv|ay pHYs B(xtIME  )4nsmIDAT8ˍJAn#6QSGIaeeO#bRQ,E$ok1ͯz`s* ABr8 + 1P4~/٣yrUR Z\veorx8K;w0(6 >A7RSK_N}+ "D#,{ ,6(PO(j2g Va/0._:(MAlH(Tظh&+g-c".oܪI!IJs.oOFQX=g* €.eUpo§tVmf1?Ú. o:گz4I$SW&BNFjKlT9׈|)ZqmƒDxB 6'wQi1bT^&n ?MKϐ3MzH~U"`Y`Z)Ai}h!|ޔߣDDR E!6*4t;_NR>5KGuY`1 aԵ {BP2Ž#D="/O\ۨIENDB`envisage-4.1.0/envisage/ui/single_project/action/images/new_project.png0000644000175100001440000000103411674464014027277 0ustar ischnellusers00000000000000PNG  IHDRabKGDhv|ay pHYs B(xtIME  :Xa#IDAT8˕kA?{9A?« lka#BZD`kRBVp6Ebqfw޼g1qg~107H=3 ̝,RïsQ׀EcH9m7g]Q85U?Bf* _{ln/*B!'T-ZTt y6cIENDB`envisage-4.1.0/envisage/ui/single_project/action/images/close_project.png0000644000175100001440000000102511674464014027613 0ustar ischnellusers00000000000000PNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxbd```, ־Rc@15址 YH'^{ "(5h_d@~aÚU @@Pkn#. 2 ~+}  o{S,f+@A x?00D3 #aj'@[v + 5>Bbh H(j;`ÀBFpXq R@ 6( ]qD q? P%K-` H @l@,D@|,chvaPb 4r@2s^IENDB`envisage-4.1.0/envisage/ui/single_project/action/api.py0000644000175100001440000000045311674464014024134 0ustar ischnellusers00000000000000from new_project_action import NewProjectAction from open_project_action import OpenProjectAction from save_project_action import SaveProjectAction from save_as_project_action import SaveAsProjectAction from close_project_action import CloseProjectAction from switch_to_action import SwitchToAction envisage-4.1.0/envisage/ui/single_project/action/save_as_project_action.py0000644000175100001440000000667411674464014030102 0ustar ischnellusers00000000000000""" An action that saves the current project to a different location. """ # Enthought library imports. from envisage.ui.single_project.project_action import ProjectAction from pyface.api import ImageResource ############################################################################## # class 'SaveAsProjectAction' ############################################################################## class SaveAsProjectAction(ProjectAction): """ An action that saves the current project to a different location. """ # The universal object locator (UOL). uol = 'envisage.ui.single_project.ui_service.UiService' # The name of the method to invoke on the object. method_name = 'save_as' # A longer description of the action. description = 'Save the current project to a different location' # The action's image (displayed on tool bar tools etc). image = ImageResource('save_as_project') # The action's name (displayed on menus/tool bar tools etc). name = 'Save As...' # A short description of the action used for tooltip text etc. tooltip = 'Save this project to a different location' #### public interface #################################################### def refresh(self): """ Refresh the enabled state of this action. This implementation enables the action when there is a current project which is marked as being allowed to do a 'save as' operation. """ self.enabled = self._refresh_project_exists() and \ self._refresh_is_save_as_allowed() return #### trait handlers ###################################################### def _on_project_changed(self, obj, trait_name, old, new): """ Handle changes to the value of the current project. Extended to ensure that we listen for changes to the is_save_as_allowed flag on the current project. """ if old is not None: self._update_project_listeners(old, remove=True) if new is not None: self._update_project_listeners(new, remove=False) super(SaveAsAction, self)._on_project_changed(obj, trait_name, old, new) ########################################################################## # 'SaveAsAction' interface ########################################################################## #### protected interface ################################################# def _refresh_is_save_as_allowed(self): """ Return the refresh state according to whether the current project is marked as being capable of doing a 'save as'. Returns True if the action should be enabled and False otherwise. """ return self.model_service.project.is_save_as_allowed def _update_project_listeners(self, project, remove): """ Update listeners on the specified project. """ logger.debug( (remove and 'Removing ' or 'Adding ') + \ 'listeners on project [%s] for SaveAsAction [%s]', project, self) project.on_trait_change(self._on_is_save_as_allowed, 'is_save_as_allowed', remove=remove) return #### trait handlers ###################################################### def _on_is_save_as_allowed(self, obj, trait_name, old, new): """ Handle changes to the value of the current project's is_save_as_allowed. """ self.refresh() return envisage-4.1.0/envisage/ui/single_project/action/save_project_action.py0000644000175100001440000000634411674464014027411 0ustar ischnellusers00000000000000""" An action that saves the current project. """ # Enthought library imports. from envisage.ui.single_project.project_action import ProjectAction from pyface.api import ImageResource ############################################################################## # class 'SaveProjectAction' ############################################################################## class SaveProjectAction(ProjectAction): """ An action that saves the current project. """ # The universal object locator (UOL). uol = 'envisage.ui.single_project.ui_service.UiService' # The name of the method to invoke on the object. method_name = 'save' # A longer description of the action. description = 'Save the current project' # The action's image (displayed on tool bar tools etc). image = ImageResource('save_project') # The action's name (displayed on menus/tool bar tools etc). name = 'Save' # A short description of the action used for tooltip text etc. tooltip = 'Save this project' #### public interface #################################################### def refresh(self): """ Refresh the enabled state of this action. This implementation enables the action when there is a current project which is marked as saveable. """ self.enabled = self._refresh_project_exists() and \ self._refresh_is_save_allowed() return #### trait handlers ###################################################### def _on_project_changed(self, obj, trait_name, old, new): """ Handle changes to the value of the current project. Extended to ensure that we listen for changes to the saveable flag on the current project. """ if old is not None: self._update_project_listeners(old, remove=True) if new is not None: self._update_project_listeners(new, remove=False) super(SaveAction, self)._on_project_changed(obj, trait_name, old, new) ########################################################################## # 'SaveAction' interface ########################################################################## #### protected interface ################################################# def _refresh_is_save_allowed(self): """ Return the refresh state according to whether the current project is marked as saveable. Returns True if the action should be enabled and False otherwise. """ return self.model_service.project.is_save_allowed def _update_project_listeners(self, project, remove): """ Update listeners on the specified project. """ logger.debug( (remove and 'Removing ' or 'Adding ') + \ 'listeners on project [%s] for SaveAction [%s]', project, self) project.on_trait_change(self._on_is_save_allowed, 'is_save_allowed', remove=remove) return #### trait handlers ###################################################### def _on_is_save_allowed(self, obj, trait_name, old, new): """ Handle changes to the value of the current project's is_save_allowed. """ self.refresh() return envisage-4.1.0/envisage/ui/single_project/action/new_project_action.py0000644000175100001440000000176311674464014027244 0ustar ischnellusers00000000000000""" An action that creates a new project. """ # Enthought library imports. from envisage.ui.single_project.project_action import ProjectAction from pyface.api import ImageResource ############################################################################## # class 'NewProjectAction' ############################################################################## class NewProjectAction(ProjectAction): """ An action that creates a new project. """ # The universal object locator (UOL). uol = 'envisage.ui.single_project.ui_service.UiService' # The name of the method to invoke on the object. method_name = 'create' # A longer description of the action. description = 'Create a project' # The action's image (displayed on tool bar tools etc). image = ImageResource('new_project') # The action's name (displayed on menus/tool bar tools etc). name = 'New...' # A short description of the action used for tooltip text etc. tooltip = 'Create a project' envisage-4.1.0/envisage/ui/single_project/action/open_project_action.py0000644000175100001440000000175711674464014027417 0ustar ischnellusers00000000000000""" An action that opens a project. """ # Enthought library imports. from envisage.ui.single_project.project_action import ProjectAction from pyface.api import ImageResource ############################################################################## # class 'OpenProjectAction' ############################################################################## class OpenProjectAction(ProjectAction): """ An action that opens a project. """ # The universal object locator (UOL). uol = 'envisage.ui.single_project.ui_service.UiService' # The name of the method to invoke on the object. method_name = 'open' # A longer description of the action. description = 'Open an existing project' # The action's image (displayed on tool bar tools etc). image = ImageResource('open_project') # The action's name (displayed on menus/tool bar tools etc). name = 'Open...' # A short description of the action used for tooltip text etc. tooltip = 'Open a project' envisage-4.1.0/envisage/ui/single_project/action/configure_action.py0000644000175100001440000000236411674464014026704 0ustar ischnellusers00000000000000""" An action that configures an item in the project tree. """ # Enthought library imports. from envisage.ui.single_project.project_action import ProjectAction ############################################################################## # class 'ConfigureAction' ############################################################################## class ConfigureAction(ProjectAction): """ An action that configures an item in the project tree. 'Configures' in this sense means pop up a trait sheet! """ ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): """ Performs the action. """ # fixme: We would like to use "kind='modal'" here, but it doesn't # work! The bug we see is that when the dialog is complete the # viscosity model assigned to the trait is NOT the same as the # viscosity model in the material's '_dirty_objects' collection! ui = event.node.obj.edit_traits( parent=event.window.control, kind='livemodal' ) return #### EOF ###################################################################### envisage-4.1.0/envisage/ui/single_project/action/rename_action.py0000644000175100001440000000436611674464014026176 0ustar ischnellusers00000000000000""" An action that renames an item in the project tree. """ # Enthought library imports. from envisage.ui.single_project.project_action import ProjectAction class RenameAction(ProjectAction): """ Renames an item in the project tree. """ #### 'Action' interface ################################################### # The action's name (displayed on menus/tool bar tools etc). name = 'Rename' ########################################################################### # 'Action' interface. ########################################################################### def perform (self, event): """ Performs the action. """ event.widget.edit_label(event.node) return # fixme: This should be a selection listener action that probably is only # enabled if there is exactly ONE item in the selection and it is editable. ## ########################################################################### ## # 'Action' interface. ## ########################################################################### ## def refresh(self): ## """ Refresh the enabled/disabled state of the action etc. ## This is called whenever the workbench window that the action is in ## and/or the selection in that window have been changed. ## """ ## resource_manager = self.window.application.get_service( ## 'envisage.resource.IResourceManager' ## ) ## # fixme: It seems there is a glitch in the tree selection handling. ## # When the selection changes we get an empty selection first, then ## # the new selection. ## if len(self.window.selection) > 0: ## for node in self.window.selection: ## resource_type = resource_manager.get_type_of(node.obj) ## if resource_type is None or resource_type.node_type is None: ## self.enabled = False ## break ## if not resource_type.node_type.is_editable(node.obj): ## self.enabled = False ## break ## else: ## self.enabled = True ## return #### EOF ###################################################################### envisage-4.1.0/envisage/ui/single_project/action/__init__.py0000644000175100001440000000000011674464014025106 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/action/switch_to_action.py0000644000175100001440000000151711674464014026725 0ustar ischnellusers00000000000000""" An action that switches the project perspective. """ # Enthought library imports. from envisage.ui.single_project.project_action import ProjectAction from pyface.api import ImageResource class SwitchToAction(ProjectAction): """ An action that switches the project perspective. """ # A longer description of the action. description = 'View the current project in the Project perspective' # The action's image (displayed on tool bar tools etc). image = ImageResource('switch_project') # The action's name (displayed on menus/tool bar tools etc). name = 'Switch To Project' # A short description of the action used for tooltip text etc. tooltip = 'Go to the Project perspective' def perform(self, event): """ Perform the action. """ self.window.application.about() return envisage-4.1.0/envisage/ui/single_project/project_action.py0000644000175100001440000001650511674464014025116 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2005-2007 by Enthought, Inc. # All rights reserved. # # Author: Dave Peterson # #----------------------------------------------------------------------------- """ A base class for actions that determine their enabled status based on the state of the current project. """ # Standard library imports import logging import inspect # Enthought library imports from envisage.api import Application from envisage.ui.workbench.api import WorkbenchWindow from pyface.action.api import Action from traits.api import Instance, Str # Local imports. from envisage.ui.single_project.services import IPROJECT_MODEL # Setup a logger for this module. logger = logging.getLogger(__name__) class ProjectAction(Action): """ A base class for actions that determine their enabled status based on the state of the current project. This class is architected such that implementors can override the 'refresh' method without losing the default logic that determines the enabled state as a function of the current project. """ #### 'ProjectAction' interface #################################### # The application that the action is part of. This is a convenience # property and is equivalent to 'self.window.application'. application = Instance(Application) # The project model service we refresh our state against. model_service = Instance(IPROJECT_MODEL) # The universal object locator (UOL). This string is used to locate an # instance to invoke a method on. # # UOLs can currently have one of the following forms: # # * ``'service://a_service_identifier'`` # * ``'name://a/path/through/the/naming/service'`` # * ``'file://the/pathname/of/a/file/containing/a/UOL'`` # * ``'http://a/URL/pointing/to/a/text/document/containing/a/UOL'`` uol = Str # The name of the method to invoke on the object. method_name = Str ########################################################################## # 'object' interface ########################################################################## def __init__(self, *args, **kws): """ Constructor. Extended to setup a listener on the project model service so that we can refresh whenever the project changes. """ # Retrieve the project model service and register ourself to listen # for project state changes. This is done first to avoid errors # during any refresh calls triggered by further initialization. # FIXME: I don't think my implementation of the ProjectAction class is correct # because I can't see to get a reference to the current application. Because of # this, I'm not able to setup the listeners yet but this needs to be done eventually! """ if 'model_service' in kws: self.model_service = kws['model_service'] del kws['model_service'] else: self.model_service = self.window.application.get_service(IPROJECT_MODEL) self._update_model_service_listeners(remove=False) """ super(ProjectAction, self).__init__(*args, **kws) return ########################################################################## # 'Action' interface ########################################################################## #### public interface #################################################### def destroy(self): """ Destroy this action. Overridden here to remove our project model service listeners. """ self._update_model_service_listeners(remove=True) return ########################################################################## # 'ProjectAction' interface ########################################################################## #### public interface #################################################### def refresh(self): """ Refresh the enabled state of this action. This default implementation enables the action only when there is a current project. """ self.enabled = self._refresh_project_exists() return def perform(self, event): """ Performs the action. This implementation simply performs the action specified by **uol** and **method_name**. Override this method to add additional work to the performance of this action. """ self._perform_uol_action(event) return ########################################################################### # Private interface. ########################################################################### def _perform_uol_action(self, event): """ Called to perform the configured UOL action. """ # Find the object. object = event.window.application.get_service(self.uol) if object is not None: method = getattr(object, self.method_name) # If the only argument is 'self' then don't pass the event. This # makes it easier to hook up actions that invoke NON-UI methods. # # fixme: Should we check the argument spec of the method more # closely and only pass the event iff there is exactly one argument # called 'event'? args, varargs, varkw, dflts = inspect.getargspec(method) if len(args) == 1: method() else: method(event) else: logger.error("Cannot resolve UOL: %s" % self.uol) return #### protected interface ################################################# def _refresh_project_exists(self): """ Return the refresh state according to whether the model service has a current project. Returns True if this action should be enabled. False otherwise. """ enabled = False if self.model_service is not None \ and self.model_service.project is not None: enabled = True return enabled def _update_model_service_listeners(self, remove=False): """ Update our listeners on the project model service. These are done as individual listener methods so that derived classes can change the behavior when a single event occurs. """ logger.debug( (remove and 'Removing ' or 'Adding ') + \ 'listeners on project model service for ProjectAction [%s]', self) self.model_service.on_trait_change(self._on_project_changed, 'project', remove=remove) self.model_service.on_trait_change(self._on_project_selection_changed, 'selection', remove=remove) return #### trait handlers ###################################################### def _on_project_changed(self, obj, trait_name, old, new): """ Handle changes to the value of the current project. """ self.refresh() return def _on_project_selection_changed(self, obj, trait_name, old, new): """ Handle changes to the selection value within the current project. """ self.refresh() return #### EOF ##################################################################### envisage-4.1.0/envisage/ui/single_project/__init__.py0000644000175100001440000000000011674464014023631 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/ui_service_factory.py0000644000175100001440000000200311674464014025763 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2006-2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ The default UI service factory. """ # Enthought library imports. from traits.api import HasTraits, Int, Str # Local imports. from ui_service import UiService class UIServiceFactory(HasTraits): """ The default UI service factory. """ # The name of the class that implements the factory. class_name = Str # The priority of this factory priority = Int ########################################################################### # 'UIServiceFactory' interface. ########################################################################### def create_ui_service(self, *args, **kw): """ Create the UI service. """ return UiService(*args, **kw) #### EOF ###################################################################### envisage-4.1.0/envisage/ui/single_project/view/0000755000175100001440000000000011674464014022504 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/view/project_view.py0000644000175100001440000002666011674464014025570 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2005, 2006 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ The single project plugin's project view """ # Standard library imports. import logging from string import rfind # Enthought library imports from apptools.naming.api import Binding from traits.api import adapts, Any, HasTraits, Instance, Str from traitsui.api import Item, Group, TreeEditor, ITreeNode, \ ITreeNodeAdapter, View # Application specific imports. from envisage.api import IApplication from envisage.ui.single_project.project import Project from envisage.ui.single_project.services import IPROJECT_MODEL, \ IPROJECT_UI # Setup a logger for this module. logger=logging.getLogger(__name__) # Dummy EmptyProject class for when the ProjectView doesn't have a reference # to a Project. class EmptyProject(Project): pass class EmptyProjectAdapter(ITreeNodeAdapter): """ Adapter for our EmptyProject. """ adapts(EmptyProject, ITreeNode) #-- ITreeNodeAdapter Method Overrides -------------------------------------- def get_label(self): """ Gets the label to display for a specified object. """ return 'No project loaded.' class ProjectAdapter(ITreeNodeAdapter): """ Base ProjectAdapter for the root of the tree. """ adapts(Project, ITreeNode) #-- ITreeNodeAdapter Method Overrides -------------------------------------- def allows_children(self): """ Returns whether this object can have children. """ return False def has_children(self): """ Returns whether the object has children. """ return False def get_children(self): """ Gets the object's children. """ return [] def get_label(self): """ Gets the label to display for a specified object. """ return self.adaptee.name def get_tooltip(self): """ Gets the tooltip to display for a specified object. """ return "Project" def get_icon(self, is_expanded): """ Returns the icon for a specified object. """ return '' def can_auto_close(self): """ Returns whether the object's children should be automatically closed. """ return True class ProjectView(HasTraits): """ The single project plugin's project view """ ########################################################################## # Traits ########################################################################## #### public 'ProjectView' interface ###################################### # The Envisage application that this service is part of. application = Instance(IApplication) # The suffix currently applied to our name name_suffix = Str('') # The suffix applied to titles when the current project is dirty. title_suffix = Str('*') # Root node for the project. root = Instance(Project) # The traits view to display: view = View( Item('root', editor = TreeEditor(editable=False, auto_open=1), show_label = False, ), resizable = True ) ########################################################################## # 'View' interface. ########################################################################## def __init__(self, **traits): super(ProjectView, self).__init__(**traits) # Make sure our view stays in sync with the current project model_service = self._get_model_service() model_service.on_trait_change(self._on_project_changed, 'project') model_service.on_trait_change(self._on_project_selection_changed, 'selection') # Make sure our control is initialized to the current project. self._switch_projects(EmptyProject(), model_service.project) ########################################################################## # 'ProjectView' interface. ########################################################################## #### protected 'ProjectView' interface ################################# def _are_list_contents_different(self, list1, list2): """ Convenience method to determine if two lists contain different items. Returns True if the lists are different and False otherwise. """ set1 = set(list1) set2 = set(list2) return set1 != set2 def _clear_state(self): """ Clears out all indications of any project state from this view. """ #self.name_suffix = '' # Set the root to an EmptyProject. self.root = EmptyProject() return def _get_model_service(self): """ Return a reference to the single project plugin's model service. """ return self.application.get_service(IPROJECT_MODEL) def _get_ui_service(self): """ Return a reference to the single project plugin's UI service. """ return self.window.application.get_service(IPROJECT_UI) def _switch_projects(self, old, new): """ Switches this view to the specified new project from the old project. Either value may be None. """ # Remove listeners on the old project, if any. if old is not None and not isinstance(old, EmptyProject): self._update_project_listeners(old, remove=True) # Update our state according to what the new project is, making sure # to add listeners to any new project. if new is not None: logger.debug("Changing ProjectView to Project [%s]", new.name) self._sync_state_to_project(new) self._update_project_listeners(new) else: logger.debug("Changing ProjectView to no project") self._clear_state() return def _sync_state_to_project(self, project): """ Sync the state of this view to the specified project's state. """ logger.debug('Syncing ProjectView [%s] to project state [%s]', self, project) # Update our Project reference. self.root = project # Update our name suffix based on the dirty state of the project. #self.name_suffix = (project.dirty and self.title_suffix) or '' return def _update_project_listeners(self, project, remove=False): """ Update listeners on the specified project instance. If remove is False then listeners are added, else listeners are removed. """ project.on_trait_change(self._on_project_name_changed, 'name', remove) project.on_trait_change(self._on_project_dirty_changed, 'dirty', remove) return #### trait handlers ###################################################### def _name_suffix_changed(self, old, new): """ Handle changes to our name suffix. """ logger.debug('Detected change in name suffix to [%s] within ' + \ 'ProjectView [%s]', new, self) # Update our own name by removing the old suffix, if any, and adding # on the new suffix, if any. name = self.name if old is not None and len(old) > 0: index = rfind(name, " " + old) if index > -1: name = name[0:index] if new is not None and len(new) > 0: name = name + ' ' + new self.name = name # Update the containing window's suffix as well self.window.title_suffix = new return def _on_control_right_clicked (self, event): """ Handle events when the tree control itself is right-clicked. """ logger.debug('ProjectView control right-clicked') self._get_ui_service().display_default_context_menu(self.control, event) return def _on_key_pressed_changed(self, event): """ Handle key presses while our control has focus. """ logger.debug("ProjectView key pressed [%s]", event) # If the delete key was pressed, then delete the current selected # object. if event.key_code == 127: self._get_ui_service().delete_selection() return def _on_node_activated_changed(self, node): """ Handle nodes being activated (i.e. double-clicked.) """ logger.debug("ProjectView node activated [%s]", node) return def _on_project_changed(self, obj, trait_name, old, new): """ Handle when the current project changes. """ logger.debug('\n\n ***************** \n\n') logger.debug('Detected project changed from [%s] to [%s] in ' 'ProjectView [%s]', old, new, self) self._switch_projects(old, new) return def _on_project_dirty_changed(self, obj, trait_name, old, new): """ Handle the open project's dirty flag changing. """ logger.debug('Detected change in project dirty to [%s] within ' + \ 'ProjectView [%s]', new, self) suffix = (new and self.title_suffix) or '' #self.name_suffix = suffix return def _on_project_name_changed(self, obj, trait_name, old, new): """ Handle the open project's name changing. """ self._project_control.root.name = new return def _on_project_selection_changed(self, obj, trait_name, old, new): """ Handle the current project's selection changing. """ logger.debug('Detected project selection changed from [%s] ' + \ 'to [%s] within ProjectView [%s]', old, new, self) # Ensure that the Tree control's selection matches the selection in # the project. control_selection = self._project_control.selection if self._are_list_contents_different(new, control_selection): logger.debug(' Updating selection on tree control for ' + \ 'ProjectView [%s]', self) self._project_control.set_selection(new) # Ensure that this view's selection contains whatever was selected # within the project. if self._are_list_contents_different(new, self.selection): logger.debug(' Updating selection on ProjectView [%s]', self) self.selection = new return def _on_selection_changed(self, obj, trait_name, old, new): """ Handle selection changes in our tree control. """ logger.debug('Detected tree control selection change from [%s] ' + \ 'to [%s] within ProjectView [%s]', old, new, self) # Ensure that the project model service's record of selection contains # the same elements as the tree control. model_service = self._get_model_service() if self._are_list_contents_different(new, model_service.selection): logger.debug(' Updating selection on project model service') model_service.selection = new # Note that we don't have to update this view's selection record as # we do that through our listener on the project selection. return def _on_closing_changed(self, old, new): """ Handle when this view closes. """ logger.debug("ProjectView [%s] closing!", self) return #### EOF ##################################################################### envisage-4.1.0/envisage/ui/single_project/view/__init__.py0000644000175100001440000000000011674464014024603 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/single_project/project_action_set.py0000644000175100001440000000665011674464014025771 0ustar ischnellusers00000000000000""" Single project action set. """ # Enthought library imports. from envisage.ui.action.api import Action, Group, Menu, ToolBar from envisage.ui.workbench.api import WorkbenchActionSet # This module's package. PKG = '.'.join(__name__.split('.')[:-1]) class ProjectActionSet(WorkbenchActionSet): """ Action set of a default Project. """ # The action set's globally unique identifier. id = 'envisage.ui.single_project.action_set' # List of menus we provide. menus = [ Menu( id='ProjectMenu', name='&Project', path='MenuBar/File', group='ProjectGroup', ), ] # List of groups we provide. groups = [ Group( id='OpenGroup', path='MenuBar/File/ProjectMenu' ), Group( id='SaveGroup', path='MenuBar/File/ProjectMenu' ), Group( id='CloseGroup', path='MenuBar/File/ProjectMenu' ), Group( id='ProjectGroup', path='MenuBar/File', before='ExitGroup' ), ] # List of toolbars we provide. tool_bars = [ ToolBar( name='Project', groups=['PerspectiveGroup', 'ProjectGroup'] ), ] # List of actions we provide. actions = [ # File menu actions. Action( class_name=PKG + '.action.api:NewProjectAction', group='OpenGroup', path='MenuBar/File/ProjectMenu', ), Action( class_name=PKG + '.action.api:OpenProjectAction', group='OpenGroup', path='MenuBar/File/ProjectMenu', ), Action( class_name=PKG + '.action.api:SaveProjectAction', group='SaveGroup', path='MenuBar/File/ProjectMenu', ), Action( class_name=PKG + '.action.api:SaveAsProjectAction', group='SaveGroup', path='MenuBar/File/ProjectMenu', ), Action( class_name=PKG + '.action.api:CloseProjectAction', group='CloseGroup', path='MenuBar/File/ProjectMenu', ), # Toolbar actions. Action( class_name=PKG + '.action.api:SwitchToAction', group='PerspectiveGroup', path='ToolBar/Project', ), Action( class_name=PKG + '.action.api:NewProjectAction', group='ProjectGroup', path='ToolBar/Project', ), Action( class_name=PKG + '.action.api:OpenProjectAction', group='ProjectGroup', path='ToolBar/Project', ), Action( class_name=PKG + '.action.api:SaveProjectAction', group='ProjectGroup', path='ToolBar/Project', ), Action( class_name=PKG + '.action.api:SaveAsProjectAction', group='ProjectGroup', path='ToolBar/Project', ), Action( class_name=PKG + '.action.api:CloseProjectAction', group='ProjectGroup', path='ToolBar/Project', ), ] #### 'WorkbenchActionSet' interface ####################################### # The Ids of the perspectives that the action set is enabled in. enabled_for_perspectives = ['Project'] # The Ids of the perspectives that the action set is visible in. visible_for_perspectives = ['Project'] envisage-4.1.0/envisage/ui/single_project/project_factory.py0000644000175100001440000000504711674464014025307 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2005-2007 by Enthought, Inc. # All rights reserved. # # Author: Dave Peterson # #----------------------------------------------------------------------------- """ A base class for project factories. """ # Standard library imports import logging # Enthought library imports from envisage.api import IApplication from traits.api import HasTraits, Instance # Local imports. from project import Project # Setup a logger for this module. logger = logging.getLogger(__name__) class ProjectFactory(HasTraits): """ A base class for project factories. """ ########################################################################## # Attributes ########################################################################## #### public 'ProjectFactory' interface ################################### # The class of the project created by this factory. # # This is provided so that the single_project services can call class # methods. # # This value is meant to be constant for the lifetime of this class! PROJECT_CLASS = Project # Current envisage application. application = Instance(IApplication) ########################################################################## # 'ProjectFactory' interface. ########################################################################## #### public method ####################################################### def create(self): """ Create a new project from scratch. This must return an instance of a Project or 'None'. A return value of 'None' indicates that no project could be created. The plugin will display the default traits view to the user so that they can configure this new project. """ return self.PROJECT_CLASS(application=self.application) def open(self, location): """ Open a project from the specified location. This must return an instance of a Project or 'None'. A return value of 'None' indicates that no project could be opened from the specified location. """ try: project = self.PROJECT_CLASS.load(location, self.application) except: logger.exception('Unable to load Project from location %s', location) project = None return project #### EOF ##################################################################### envisage-4.1.0/envisage/ui/workbench/0000755000175100001440000000000011674464014020505 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/workbench/workbench_action_manager_builder.py0000644000175100001440000001425111674464014027601 0ustar ischnellusers00000000000000""" The action manager builder used to build the workbench menu/tool bars. """ # Standard library imports. import weakref # Enthought library imports. from envisage.ui.action.api import AbstractActionManagerBuilder from pyface.action.api import Action, Group, MenuManager from pyface.workbench.action.api import MenuBarManager from pyface.workbench.action.api import ToolBarManager from traits.api import Any, Instance class WorkbenchActionManagerBuilder(AbstractActionManagerBuilder): """ The action manager builder used to build the workbench menu/tool bars. """ #### 'WorkbenchActionManagerBuilder' interface ############################ # The workbench window that we build the menu and tool bars for. window = Instance('envisage.ui.workbench.api.WorkbenchWindow') #### Private interface #################################################### # All action implementations. _actions = Any ########################################################################### # Protected 'AbstractActionManagerBuilder' interface. ########################################################################### def _create_action(self, definition): """ Create an action implementation from an action definition. """ traits = {'window' : self.window} # Override any traits that can be set in the definition. if len(definition.name) > 0: traits['name'] = definition.name if len(definition.class_name) > 0: action = self._actions.get(definition.class_name) if action is None: klass = self._import_symbol(definition.class_name) action = klass(**traits) self._actions[definition.class_name] = action # fixme: Do we ever actually do this? It seems that in Envisage 3.x # we always specify an action class!?! else: action = Action(**traits) # fixme: We need to associate the action set with the action to # allow for dynamic enabling/disabling etc. This is a *very* hacky # way to do it! action._action_set_ = definition._action_set_ return action def _create_group(self, definition): """ Create a group implementation from a group definition. """ traits = {} # Override any traits that can be set in the definition. if len(definition.id) > 0: traits['id'] = definition.id if len(definition.class_name) > 0: klass = self._import_symbol(definition.class_name) else: klass = Group group = klass(**traits) # fixme: We need to associate the action set with the action to # allow for dynamic enabling/disabling etc. This is a *very* hacky # way to do it! group._action_set_ = definition._action_set_ return group def _create_menu_manager(self, definition): """ Create a menu manager implementation from a menu definition. """ # fixme: 'window' is not actually a trait on 'MenuManager'! We set # it here to allow the 'View' menu to be created. However, it seems # that menus and actions etc should *always* have a reference to # the window that they are in?!? traits = {'window' : self.window} # Override any traits that can be set in the definition. if len(definition.id) > 0: traits['id'] = definition.id if len(definition.name) > 0: traits['name'] = definition.name if len(definition.class_name) > 0: klass = self._import_symbol(definition.class_name) else: klass = MenuManager menu_manager = klass(**traits) # Add any groups to the menu. for group in definition.groups: group._action_set_ = definition._action_set_ menu_manager.insert(-1, self._create_group(group)) # fixme: We need to associate the action set with the action to # allow for dynamic enabling/disabling etc. This is a *very* hacky # way to do it! menu_manager._action_set_ = definition._action_set_ return menu_manager def _create_menu_bar_manager(self): """ Create a menu bar manager from the builder's action sets. """ return MenuBarManager(window=self.window) def _create_tool_bar_manager(self, definition): """ Create a tool bar manager implementation from a definition. """ traits = { 'window' : self.window, 'show_tool_names' : False } # Override any traits that can be set in the definition. if len(definition.id) > 0: traits['id'] = definition.id if len(definition.name) > 0: traits['name'] = definition.name if len(definition.class_name) > 0: klass = self._import_symbol(definition.class_name) else: klass = ToolBarManager # fixme: 'window' is not actually a trait on 'ToolBarManager'! We # set it here because it is set on the 'MenuManager'! However, it # seems that menus and actions etc should *always* have a reference # to the window that they are in?!? tool_bar_manager = klass(**traits) # Add any groups to the tool bar. for group in definition.groups: group._action_set_ = definition._action_set_ tool_bar_manager.insert(-1, self._create_group(group)) # fixme: We need to associate the action set with the action to # allow for dynamic enabling/disabling etc. This is a *very* hacky # way to do it! tool_bar_manager._action_set_ = definition._action_set_ return tool_bar_manager ########################################################################### # Private interface. ########################################################################### def __actions_default(self): """ Trait initializer. """ return weakref.WeakValueDictionary() def _import_symbol(self, symbol_path): """ Import a symbol. """ return self.window.application.import_symbol(symbol_path) #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/workbench_plugin.py0000644000175100001440000001756011674464014024430 0ustar ischnellusers00000000000000""" The Envisage workbench plugin. """ # Enthought library imports. from envisage.api import ExtensionPoint, Plugin, ServiceOffer from traits.api import Callable, List # This module's package. PKG = '.'.join(__name__.split('.')[:-1]) class WorkbenchPlugin(Plugin): """ The Envisage workbench plugin. The workbench plugin uses the PyFace workbench to provide the basis of an IDE-like user interface. The interface is made up of perspectives, views and editors. Note that this is not intended to be a 'general-purpose' plugin for user interfaces - it provides an IDE-like style and that is all. If your application requires another style of interface then write another plugin (you can still re-use all the menu, group and action contribution stuff!). """ # The Ids of the extension points that this plugin offers. ACTION_SETS = PKG + '.action_sets' PERSPECTIVES = PKG + '.perspectives' PREFERENCES_PAGES = PKG + '.preferences_pages' WORKBENCH_SERVICE_OFFERS = PKG + '.service_offers' VIEWS = PKG + '.views' # The Ids of the extension points that this plugin contributes to. PREFERENCES = 'envisage.preferences' SERVICE_OFFERS = 'envisage.service_offers' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'envisage.ui.workbench' # The plugin's name (suitable for displaying to the user). name = 'Workbench' #### Extension points offered by this plugin ############################## action_sets = ExtensionPoint( List(Callable), id=ACTION_SETS, desc=""" An action set contains the toobars, menus, groups and actions that you would like to add to top-level workbench windows (i.e. the main application window). You can create new toolbars, menus and groups and/or add to existing ones. Each contribution to this extension point must be a factory that creates an action set, where 'factory' means any callable with the following signature:: callable(**traits) -> IActionSet The easiest way to contribute such a factory is to create a class that derives from 'envisage.ui.action.api.ActionSet'. """ ) perspectives = ExtensionPoint( List(Callable), id=PERSPECTIVES, desc=""" A perspective is simply an arrangment of views around the (optionally hidden) editor area. Each contribution to this extension point must be a factory that creates a perspective, where 'factory' means any callable with the following signature:: callable(**traits) -> IPerspective The easiest way to contribute such a factory is to create a class that derives from 'pyface.workbench.api.IPerspective'. """ ) preferences_pages = ExtensionPoint( List(Callable), id=PREFERENCES_PAGES, desc=""" A preferences page appears in the preferences dialog to allow the user to manipulate some preference values. Each contribution to this extension point must be a factory that creates a preferences page, where 'factory' means any callable with the following signature:: callable(**traits) -> IPreferencesPage The easiest way to contribute such a factory is to create a class that derives from 'apptools.preferences.ui.api.IPreferencesPage'. """ ) service_offers = ExtensionPoint( List(ServiceOffer), id = WORKBENCH_SERVICE_OFFERS, desc = """ Services are simply objects that a plugin wants to make available to other plugins. This extension point allows you to offer 'per window' services that are created 'on-demand' (where 'on demand' means the first time somebody looks up a service of the appropriate protocol). . e.g. my_service_offer = ServiceOffer( protocol = 'acme.IMyService', factory = an_object_or_a_callable_that_creates_one, properties = {'a dictionary' : 'that is passed to the factory'} ) Any properties specified are passed as keywrod arguments to the factory, i.e. the factory signature is:: callable(**properties) """ ) views = ExtensionPoint( List(Callable), id=VIEWS, desc=""" A view provides information to the user to support their current task. Views can contain anything you like(!) and are arranged around the (optionally hidden) editor area. The user can re-arrange views as he/she sees fit. Each contribution to this extension point must be a factory that creates a view, where 'factory' means any callable with the following signature:: callable(**traits) -> IView The easiest way to contribute such a factory is to create a class that derives from 'pyface.workbench.api.View'. It is also common to use a simple function (especially when a view is a representation of a service) e.g:: def foo_view_factory(**traits): ' Create a view that is a representation of a service. ' foo = self.application.get_service('IFoo') return FooView(foo=foo, **traits) """ ) #### Contributions to extension points made by this plugin ################ my_action_sets = List(contributes_to=ACTION_SETS) def _my_action_sets_default(self): """ Trait initializer. """ from default_action_set import DefaultActionSet return [DefaultActionSet] my_preferences = List(contributes_to=PREFERENCES) def _my_preferences_default(self): """ Trait initializer. """ return ['pkgfile://envisage.ui.workbench/preferences.ini'] my_preferences_pages = List(contributes_to=PREFERENCES_PAGES) def _my_preferences_pages_default(self): """ Trait initializer. """ from workbench_preferences_page import WorkbenchPreferencesPage return [WorkbenchPreferencesPage] my_service_offers = List(contributes_to=SERVICE_OFFERS) def _my_service_offers_default(self): """ Trait initializer. """ preferences_manager_service_offer = ServiceOffer( protocol = 'apptools.preferences.ui.preferences_manager' '.PreferencesManager', factory = self._create_preferences_manager_service ) workbench_service_offer = ServiceOffer( protocol = 'envisage.ui.workbench.workbench.Workbench', factory = self._create_workbench_service ) return [preferences_manager_service_offer, workbench_service_offer] ########################################################################### # Private interface. ########################################################################### def _create_preferences_manager_service(self, **properties): """ Factory method for the preferences manager service. """ from apptools.preferences.ui.api import PreferencesManager preferences_manager = PreferencesManager( pages=[factory() for factory in self.preferences_pages] ) return preferences_manager def _create_workbench_service(self, **properties): """ Factory method for the workbench service. """ # We don't actually create the workbench here, we just return a # reference to it. # # fixme: This guard is really just for testing when we have the # workbench plugin as a source egg (i.e. if the egg is on our path # then we get the plugin for any egg-based application, even if it is # not a workbench application!). return getattr(self.application, 'workbench', None) ### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/workbench_editor_manager.py0000644000175100001440000000265711674464014026113 0ustar ischnellusers00000000000000""" An editor manager that uses contributed editors. """ # Enthought library imports. from pyface.workbench.api import EditorManager, TraitsUIEditor class WorkbenchEditorManager(EditorManager): """ An editor manager that uses contributed editors. """ ########################################################################### # 'IEditorManager' interface. ########################################################################### def create_editor(self, window, obj, kind): """ Create an editor for an object. For now, the 'kind' is actually a factory that produces editors. It should be a callable with the following signature:: callable(window=window, obj=obj) -> IEditor """ if kind is None: kind = TraitsUIEditor editor = kind(window=window, obj=obj) self.add_editor(editor, kind) return editor ########################################################################### # 'Protected' 'EditorManager' interface. ########################################################################### def _is_editing(self, editor, obj, kind): """ Return True if the editor is editing the object. """ if kind is None: kind = TraitsUIEditor return self.get_editor_kind(editor) is kind and editor.obj == obj #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/images/0000755000175100001440000000000011674464014021752 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/workbench/images/about.png0000644000175100001440000002106611674464014023577 0ustar ischnellusers00000000000000PNG  IHDRP\m:sBIT|dtEXtSoftwarewww.inkscape.org< IDATxyxU'OIMtoi)dw6·~:#^|μ.̫36ਠ((PZR( M,mf_n.K4<虿f*++vܙUSS#p\dg2rYa^je'.coW c?򫟗: ΄ HUs'5AwrXR l:Z ǒqyvM[SǸaP1XԜ@HP?.ϯifˍcܰLu@}r:$VKtӉfffb;r9C&9d1_8A (M^줫jzbb355}|ZMS4CxL;ZP~3֏UrxY@5Qav<_kOZ,ɓJQOO 5srr7nh!̽{&^tI۶mx=V*,M6X>A EjkkO?l[ְ!aRVV&lllj4^1|߮l\SS*a}L&III+ ao>;~|8h4T*,RɪmٲeHNcĩT*r֮]\~}O{8N:t(`0P%$C,;v;YV3V+nᇔQ"D<[LP+mZҦ8;vH|@,;֭[*,, ^R̎oꫯ6Df GiiTs)] {ymhh544!Ν7v;zYAyy?H6lؠx?8*@ y䑶DǃpvޝfZ)Lf}:nٲe mp[|tGiiiJAǏ'I֮]a2xNj/ܩ) Q\\l۷ou:ŋ555BFH)L&ׯq8M---\EJ E,`|l޼yAyyxB5B233ͯJ@sM70RGGqسgOo&##QZZ޻wo2;hA *jjL.\\J8L %l/dNVTl6۳hѢpZdL&̋/FAf^6h#٘P.찻GWw]M8peJ%##Á(_wuu1rssݮ"ɬ׮];;;ֻ$pfj6MKKp|MѴFyVkT xsTyl5isd21B0 nO4PԐZ:g \.7p^ww7=ܹŘ\mjPs;zBכԀ}?輠؝c#l&lj v`Ͱ`&bh4NK V Hhth-&U(}|Ȏy!^; .,|nWV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`ɔ_ǓdǕdŔdÒdba`^\ZXU.]s:Pvvߩfڟfٟd؝c֛b՚aә^ї\ЕZΓX̑UʏSȍQƋMćKÅGFB~A|iȘsʝ-bs:s: M KY_˔aȔlʚnʛmȚlŘk×jifdba_W x@s:>|ynܤhڠh٠fםd֜cԛaҙ_З\ϔ[͓XˑUɎSnjPʼnMÇJGDYs˞Ut:s:s:8 N L K9v`ʕdʖv΢v͡u˟tȝsƜqĚo˜nkifd8fs:z@dԛx߫jڢkڡjؠg֞f՝dӛbљ_Ж]Δ[̒XʐTȍRƋOĈL†ILr˞nɚIs:s: M{ LMSċ`ʔl̛ѧ~Ϧ|ͥ{ˣyɠxǟvĝsšqnkfLs:Rvܩyݪmڣn٢kנi֞gԝeқbј_ϖ]͔ZʑWȏTƌQĉM‡^ǒr͟s̞3fs:s:s:N M L \^ɓ`ʔdʗҩҬЩͧ˥~ɣ|ƠxÞvroczCs:!Xlՠxݪtۦmءl֠i՞gӜdљbϗ_͕\˒YɐVǍWǍpΞuΠo˜2es:s:s:BN M LYQŠ`ʔaȔyϣ԰ҮЫͩ˧Ȥ}ơzÞviR| x@s: DONJxܩxڨj֟[ѕWΒcљdЙaΖ[˒\ʓ^ʔpϟtϡ\ÎMs:s:s:cN- M LN9v_ɔ`ȓ^ő^ÑfĔwɠΩzǡoj[][*[r:s:s:+cmҟw٧wاwצnԡkҝnӟsӢuңtѢrΟuFzK~Fx r= p< o;pm:s:4s:s:s:s:s:s:t;s:s:s:s:s:s:s:W M L J I H G F E ~D |C zA x@ v? t> r=s:s:ls:s:s:s:s:s:s:s:s:- K JA I H G F E }D |B zA9 x@s: s:??envisage-4.1.0/envisage/ui/workbench/images/image_LICENSE.txt0000644000175100001440000000047411674464014024744 0ustar ischnellusers00000000000000These are my best guesses at where each icon came from, this file should be updated whenever icons change. filename source -------------------------------------------------------------- about.png Python Software Foundation application.ico Gael Varoquaux envisage-4.1.0/envisage/ui/workbench/api.py0000644000175100001440000000052011674464014021625 0ustar ischnellusers00000000000000""" Envisage package Copyright 2003, 2004, 2005 Enthought, Inc. """ from workbench import Workbench from workbench_action_set import WorkbenchActionSet from workbench_application import WorkbenchApplication from workbench_window import WorkbenchWindow #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/workbench.py0000644000175100001440000000335611674464014023050 0ustar ischnellusers00000000000000""" The Envisage workbench. """ # Enthought library imports. import pyface.workbench.api as pyface from envisage.api import IApplication from pyface.api import YES from traits.api import Delegate, Instance # Local imports. from workbench_preferences import WorkbenchPreferences from workbench_window import WorkbenchWindow class Workbench(pyface.Workbench): """ The Envisage workbench. There is (usually) exactly *one* workbench per application. The workbench can create any number of workbench windows. """ #### 'pyface.Workbench' interface ######################################### # The factory that is used to create workbench windows. window_factory = WorkbenchWindow #### 'Workbench' interface ################################################ # The application that the workbench is part of. application = Instance(IApplication) # Should the user be prompted before exiting the workbench? prompt_on_exit = Delegate('_preferences') #### Private interface #################################################### # The workbench preferences. _preferences = Instance(WorkbenchPreferences, ()) ########################################################################### # Private interface. ########################################################################### def _exiting_changed(self, event): """ Called when the workbench is exiting. """ if self.prompt_on_exit: answer = self.active_window.confirm( "Exit %s?" % self.active_window.title, "Confirm Exit" ) if answer != YES: event.veto = True return #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/preferences.ini0000644000175100001440000000007011674464014023504 0ustar ischnellusers00000000000000[enthought.envisage.ui.workbench] prompt_on_exit = True envisage-4.1.0/envisage/ui/workbench/workbench_window.py0000644000175100001440000002076411674464014024441 0ustar ischnellusers00000000000000""" An extensible workbench window. """ # Standard library imports. import logging # Enthought library imports. import pyface.workbench.api as pyface from envisage.api import IExtensionPointUser, IExtensionRegistry from envisage.api import IServiceRegistry from envisage.api import ExtensionPoint, ServiceRegistry from envisage.ui.action.api import ActionSet from pyface.action.api import StatusBarManager from traits.api import Delegate, Instance, List, Property, implements # Local imports. from workbench_action_manager_builder import WorkbenchActionManagerBuilder from workbench_editor_manager import WorkbenchEditorManager # Logging. logger = logging.getLogger(__name__) class WorkbenchWindow(pyface.WorkbenchWindow): """ An extensible workbench window. """ implements(IServiceRegistry, IExtensionPointUser) # Extension point Ids. ACTION_SETS = 'envisage.ui.workbench.action_sets' VIEWS = 'envisage.ui.workbench.views' PERSPECTIVES = 'envisage.ui.workbench.perspectives' SERVICE_OFFERS = 'envisage.ui.workbench.service_offers' #### 'WorkbenchWindow' interface ########################################## # The application that the window is part of. # # This is equivalent to 'self.workbench.application', and is provided just # as a convenience since windows often want access to the application. application = Delegate('workbench', modify=True) # The action sets that provide the toolbars, menus groups and actions # used in the window. action_sets = List(Instance(ActionSet)) # The service registry for 'per window' services. service_registry = Instance(IServiceRegistry, factory=ServiceRegistry) #### 'IExtensionPointUser' interface ###################################### # The extension registry that the object's extension points are stored in. extension_registry = Property(Instance(IExtensionRegistry)) #### Private interface #################################################### # The workbench menu and tool bar builder. # # The builder is used to create the window's tool bar and menu bar by # combining all of the contributed action sets. _action_manager_builder = Instance(WorkbenchActionManagerBuilder) # Contributed action sets (each contribution is actually a factory). _action_sets = ExtensionPoint(id=ACTION_SETS) # Contributed views (each contribution is actually a factory). _views = ExtensionPoint(id=VIEWS) # Contributed perspectives (each contribution is actually a factory). _perspectives = ExtensionPoint(id=PERSPECTIVES) # Contributed service offers. _service_offers = ExtensionPoint(id=SERVICE_OFFERS) # The Ids of the services that were automatically registered. _service_ids = List ########################################################################### # 'IExtensionPointUser' interface. ########################################################################### def _get_extension_registry(self): """ Trait property getter. """ return self.application ########################################################################### # 'pyface.Window' interface. ########################################################################### #### Trait initializers ################################################### def _menu_bar_manager_default(self): """ Trait initializer. """ return self._action_manager_builder.create_menu_bar_manager('MenuBar') def _status_bar_manager_default(self): """ Trait initializer. """ return StatusBarManager() def _tool_bar_managers_default(self): """ Trait initializer. """ return self._action_manager_builder.create_tool_bar_managers('ToolBar') #### Trait change handlers ################################################ def _opening_changed(self): """ Static trait change handler. """ self._service_ids = self._register_service_offers(self._service_offers) return def _closed_changed(self): """ Static trait change handler. """ self._unregister_service_offers(self._service_ids) return ########################################################################### # 'pyface.WorkbenchWindow' interface. ########################################################################### #### Trait initializers ################################################### def _editor_manager_default(self): """ Trait initializer. """ return WorkbenchEditorManager(window=self) def _icon_default(self): """ Trait initializer. """ return self.workbench.application.icon def _perspectives_default(self): """ Trait initializer. """ return [factory() for factory in self._perspectives] def _title_default(self): """ Trait initializer. """ return self.workbench.application.name def _views_default(self): """ Trait initializer. """ return [factory(window=self) for factory in self._views] ########################################################################### # 'WorkbenchWindow' interface. ########################################################################### def _action_sets_default(self): """ Trait initializer. """ return [factory(window=self) for factory in self._action_sets] ########################################################################### # 'IServiceRegistry' interface. ########################################################################### def get_service(self, protocol, query='', minimize='', maximize=''): """ Return at most one service that matches the specified query. """ service = self.service_registry.get_service( protocol, query, minimize, maximize ) return service def get_service_properties(self, service_id): """ Return the dictionary of properties associated with a service. """ return self.service_registry.get_service_properties(service_id) def get_services(self, protocol, query='', minimize='', maximize=''): """ Return all services that match the specified query. """ services = self.service_registry.get_services( protocol, query, minimize, maximize ) return services def register_service(self, protocol, obj, properties=None): """ Register a service. """ service_id = self.service_registry.register_service( protocol, obj, properties ) return service_id def set_service_properties(self, service_id, properties): """ Set the dictionary of properties associated with a service. """ self.service_registry.set_service_properties(service_id, properties) return def unregister_service(self, service_id): """ Unregister a service. """ self.service_registry.unregister_service(service_id) return ########################################################################### # Private interface. ########################################################################### def __action_manager_builder_default(self): """ Trait initializer. """ action_manager_builder = WorkbenchActionManagerBuilder( window=self, action_sets=self.action_sets ) return action_manager_builder def _register_service_offers(self, service_offers): """ Register all service offers. """ return map(self._register_service_offer, service_offers) def _register_service_offer(self, service_offer): """ Register a service offer. """ # Add the window to the service offer properties (this is so that it # is available to the factory when it is called to create the actual # service). service_offer.properties['window'] = self service_id = self.register_service( protocol = service_offer.protocol, obj = service_offer.factory, properties = service_offer.properties ) return service_id def _unregister_service_offers(self, service_ids): """ Unregister all service offers. """ # Unregister the services in the reverse order that we registered # them. service_ids_copy = service_ids[:] service_ids_copy.reverse() for service_id in service_ids_copy: self.unregister_service(service_id) return #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/workbench_application.py0000644000175100001440000001404411674464014025427 0ustar ischnellusers00000000000000""" The entry point for an Envisage Workbench application. """ # Standard library imports. import logging # Enthought library imports. # # fixme: The ordering of these imports is critical. We don't use traits UI in # this module, but it must be imported *before* any 'HasTraits' class whose # instances might want to have 'edit_traits' called on them. # # fixme: Just importing the package is enought (see above). import traitsui # Enthought library imports. from envisage.api import Application from pyface.api import AboutDialog, Dialog, GUI, ImageResource from pyface.api import SplashScreen from pyface.workbench.api import IWorkbench from traits.api import Callable, Instance, Str, Tuple # Local imports. from workbench import Workbench # Logging. logger = logging.getLogger(__name__) class WorkbenchApplication(Application): """ The entry point for an Envisage Workbench application. i.e. a GUI application whose user interface is provided by the workbench plugin. This class handles the common case for Workbench applications, and it is intended to be subclassed to change start/stop behaviour etc. In fact, I generally create a subclass for every Workbench application I write since it is a good place to put branding information etc. """ #### 'WorkbenchApplication' interface ##################################### # The PyFace GUI for the application (this is here to make it easy for # parts of the application to get a reference to the GUI so they can get # system metrics, etc. gui = Instance(GUI) # The workbench. workbench = Instance(IWorkbench) # The factory for creating the workbench (used *instead* of providing a # workbench explicitly). workbench_factory = Callable(Workbench) # Branding information. # # The 'About' dialog. about_dialog = Instance(Dialog) # The icon used on window title bars etc. icon = Instance(ImageResource, ImageResource('application.ico')) # The name of the application (also used on window title bars etc). name = Str('Workbench') # The splash screen (None, the default, if no splash screen is required). splash_screen = Instance(SplashScreen) # The default position of the main window. window_position = Tuple((200, 200)) # The default size of the main window. window_size = Tuple((800, 600)) ########################################################################### # 'IApplication' interface. ########################################################################### def run(self): """ Run the application. This does the following (so you don't have to ;^):- 1) Starts the application 2) Creates and opens a workbench window 3) Starts the GUI event loop 4) When the event loop terminates, stops the application """ logger.debug('---------- workbench application ----------') # Make sure the GUI has been created (so that, if required, the splash # screen is shown). gui = self.gui # Start the application. if self.start(): # Create and open the first workbench window. window = self.workbench.create_window( position=self.window_position, size=self.window_size ) window.open() # We stop the application when the workbench has exited. self.workbench.on_trait_change(self._on_workbench_exited, 'exited') # Start the GUI event loop. # # THIS CALL DOES NOT RETURN UNTIL THE GUI IS CLOSED. gui.start_event_loop() return ########################################################################### # 'WorkbenchApplication' interface. ########################################################################### #### Initializers ######################################################### def _about_dialog_default(self): """ Trait initializer. """ return AboutDialog(image=ImageResource('about')) def _gui_default(self): """ Trait initializer. """ return GUI(splash_screen=self.splash_screen) def _workbench_default(self): """ Trait initializer. """ return self.create_workbench() #### Methods ############################################################## def about(self): """ Display the about dialog. """ # fixme: We really need to create a new 'about dialog' every time so # that it can have the active window as its parent. self.about_dialog.open() return # fixme: Is this needed on the public API? Why can't we just do this in # the default initializer (_workbench_default)? def create_workbench(self): """ Create the workbench. """ logger.debug('workbench factory %s', self.workbench_factory) return self.workbench_factory(application=self) def exit(self): """ Exit the application. This closes all open windows and hence exits the GUI event loop. """ self.workbench.exit() return ########################################################################### # Private interface. ########################################################################### def _on_workbench_exited(self): """ Dynamic trait change handler. """ # We don't invoke 'stop' directly because:- # # The workbench is often exited via a user action (either by closing # the last open window, or by choosing 'File/Exit'). If this happens # then the workbench 'exit' method is called from within an event # handler which would cause the 'stop' method to get called *before* # the handling of the window 'closed' event is complete. Hance, this # might mean that somebody listening for the window being closed would # get the event *after* the application had already stopped! self.gui.invoke_later(self.stop) return #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/workbench_preferences_page.py0000644000175100001440000000237111674464014026421 0ustar ischnellusers00000000000000""" The main preferences page for the workbench. """ # Enthought library imports. from apptools.preferences.ui.api import PreferencesPage from traits.api import Bool from traitsui.api import View class WorkbenchPreferencesPage(PreferencesPage): """ The main preferences page for the workbench. """ #### 'PreferencesPage' interface ########################################## # The page's category (e.g. 'General/Appearance'). The empty string means # that this is a top-level page. category = '' # The page's help identifier (optional). If a help Id *is* provided then # there will be a 'Help' button shown on the preference page. help_id = '' # The page name (this is what is shown in the preferences dialog. name = 'General' # The path to the preferences node that contains the preferences. preferences_path = 'envisage.ui.workbench' #### Preferences ########################################################## # Should the user be prompted before exiting the workbench? prompt_on_exit = Bool(True) #### Traits UI views ###################################################### trait_view = View('prompt_on_exit') #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/workbench_preferences.py0000644000175100001440000000130211674464014025416 0ustar ischnellusers00000000000000""" The workbench preferences. """ # Enthought library imports. from apptools.preferences.api import PreferencesHelper from traits.api import Bool class WorkbenchPreferences(PreferencesHelper): """ Helper for the workbench preferences. """ #### 'PreferencesHelper' interface ######################################## # The path to the preferences node that contains the preferences. preferences_path = 'envisage.ui.workbench' #### Preferences ########################################################## # Should the user be prompted before exiting the workbench? prompt_on_exit = Bool(True) #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/workbench_action_set.py0000644000175100001440000001553611674464014025263 0ustar ischnellusers00000000000000""" An action set in a workbench window. """ # Enthought library imports. from envisage.ui.action.api import ActionSet from traits.api import Instance, List, Str class WorkbenchActionSet(ActionSet): """ An action set in a workbench window. This class adds a 'window' trait which is the workbench window that the action set is in. The trait is set by the framework when the action set is added to the window. It also adds a simple way for the action set to be enabled and/or visible in specific perspectives. """ ########################################################################### # 'WorkbenchActionSet' interface. ########################################################################### # It is common for an action set to be enabled and/or visible only in a # particular perspective (or group of perspectives). The following traits # allow you to say which by specifiying a list of the appropriate # perspective *Ids*. # # For finer control over the enablement/visibility simply override the # 'initialize' method. enabled_for_perspectives = List(Str) visible_for_perspectives = List(Str) # It is common for an action set to be enabled and/or visible only when # particular view (or group of views) is visible. The following traits # allow you to say which by specifiying a list of the appropriate view # *Ids*. # # For finer control over the enablement/visibility simply override the # 'initialize' method. enabled_for_views = List(Str) visible_for_views = List(Str) # The workbench window that the action set is in. # # The framework sets this trait when the action set is first added to a # window. window = Instance('envisage.ui.workbench.api.WorkbenchWindow') ########################################################################### # 'ActionSet' interface. ########################################################################### def _enabled_changed(self, trait_name, old, new): """ Static trait change handler. """ if self.window is not None: self._update_tool_bars(self.window, 'enabled', new) self._update_actions(self.window, 'enabled', new) return def _visible_changed(self, trait_name, old, new): """ Static trait change handler. """ if self.window is not None: self._update_tool_bars(self.window, 'visible', new) self._update_actions(self.window, 'visible', new) return ########################################################################### # 'WorkbenchActionSet' interface. ########################################################################### def initialize(self): """ Called when the action set has been added to a window. Use this method to hook up any listeners that you need to control the enabled and/or visible state of the action set. By default, we listen to the window being opened and the active perspective and active view being changed. """ # We use dynamic trait handlers here instead of static handlers (or # @on_trait_change) because sub-classes might have a completely # different way to determine the anabled and/or visible state, hence # we might want to hook up completely different events. self.window.on_trait_change(self._refresh, 'opened') self.window.on_trait_change(self._refresh, 'active_part') self.window.on_trait_change(self._refresh, 'active_perspective') return ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ def _window_changed(self): """ Static trait change handler. """ # fixme: We put the code into an 'initialize' method because it seems # easier to explain that we expect it to be overridden. It seems a bit # smelly to say that a trait change handfler needs to be overridden. self.initialize() return #### Methods ############################################################## def _refresh(self): """ Refresh the enabled/visible state of the action set. """ window = self.window if len(self.enabled_for_perspectives) > 0: self.enabled = window is not None \ and window.active_perspective is not None \ and window.active_perspective.id in \ self.enabled_for_perspectives if len(self.visible_for_perspectives) > 0: self.visible = window is not None \ and window.active_perspective is not None \ and window.active_perspective.id in \ self.visible_for_perspectives if len(self.enabled_for_views) > 0: self.enabled = window is not None \ and window.active_part is not None \ and window.active_part.id in \ self.enabled_for_views if len(self.visible_for_views) > 0: self.visible = window is not None \ and window.active_part is not None \ and window.active_part.id in \ self.visible_for_views return def _update_actions(self, window, trait_name, value): """ Update the state of the tool bars in the action set. """ def visitor(item): """ Called when we visit each item in an action manager. """ # fixme: The 'additions' group gets created by default and hence # has no '_action_set_' attribute. This smells because of the fact # that we 'tag' the '_action_set_' attribute onto all items to be # ble to find them later. This link should be maintained externally # (maybe in the action set itself?). if hasattr(item, '_action_set_'): if item._action_set_ is self: setattr(item, trait_name, value) return # Update actions on the menu bar. window.menu_bar_manager.walk(visitor) # Update actions on the tool bars. for tool_bar_manager in window.tool_bar_managers: tool_bar_manager.walk(visitor) return def _update_tool_bars(self, window, trait_name, value): """ Update the state of the tool bars in the action set. """ for tool_bar_manager in window.tool_bar_managers: if tool_bar_manager._action_set_ is self: setattr(tool_bar_manager, trait_name, value) return #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/action/0000755000175100001440000000000011674464014021762 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/workbench/action/images/0000755000175100001440000000000011674464014023227 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/workbench/action/images/preferences.png0000644000175100001440000000150611674464014026240 0ustar ischnellusers00000000000000PNG  IHDRa IDAT8uSMle}M/^gel)RDOR/(M`HЖ8Pz(BJF*@8Eij5v&'GF{yf@D;FE- nb~~޿~Xt;N/!˲0=="#"@,,x_j'GF"BW^?5ð^=r/J}:595 I+vFNTUU*W*T3 2- Z^^ζ$Z:7Ǿ'ǁ (O(R4m`- VΙ3#Qw" ^N?666P7ûgϾ}sd*lmӃkT(黥%Ep xsU?P,Q:iUOԉ/\;Cö۷nc\^?hDi?ᢟ;NLطprDSFNz@T 8F ib1>Q|$<|D"qc^cM+|zʴ(_(/FJ=ޤͿOwe_6|pve0 K%(yBZSvݿgY$IAપ cvTU8>>dY,Nd>U(eIY? q!ݗ}sZ2S.{pmp'E"H$q\o;? /q IENDB`envisage-4.1.0/envisage/ui/workbench/action/images/exit.png0000644000175100001440000000155411674464014024713 0ustar ischnellusers00000000000000PNG  IHDRa3IDAT8m_L[`RBKmˈs,721LpaJF4Abq^M6$ȦƘm:-0aȟB7HKmm)9NDxJkygy!ycfw*=k@zÝO_}gv~# 'o7ffy_c?إl+c-"7f.[?]_0G=3pB{ $B<^xIRs1,'N9e,'H M À@]Ef;EOkg_=<ټ̐zSs +%Ȥ!fU Zi1b*JKzS-"  b#Ɲ T._|^~ ri6ҜrlLv %2ʛA D= CdsTC*"5ɄbE hkFx)I9Pwo誂MQ m;@^/1sф6fn.l١AW(} ܭ54Qx%:53eADx_1*eI_1r9I!Cۥ璻NU4g5 ŪcӺ 柯cuTƠtHwWF-aC YN(q51n- 8>?D&_;fn;4`55fIf˯m=|`/7(9q*{.{p4ߍf3?Z`p]IENDB`envisage-4.1.0/envisage/ui/workbench/action/images/image_LICENSE.txt0000644000175100001440000000067211674464014026221 0ustar ischnellusers00000000000000The icons are mostly derived work from other icons. As such they are licensed accordingly to the original license: CP (Crystal Project Icons): LGPL license as described in image_LICENSE_CP.txt Unless stated in this file, icons are work of enthought, and are released under BSD-like license. Files and orginal authors: -------------------------------------------------------------------- exit.png CP preferences.png CP envisage-4.1.0/envisage/ui/workbench/action/api.py0000644000175100001440000000020211674464014023077 0ustar ischnellusers00000000000000from about_action import AboutAction from edit_preferences_action import EditPreferencesAction from exit_action import ExitAction envisage-4.1.0/envisage/ui/workbench/action/edit_preferences_action.py0000644000175100001440000000300711674464014027177 0ustar ischnellusers00000000000000""" An action that displays the preferences dialog. """ # Enthought library imports. from pyface.api import ImageResource from pyface.action.api import Action class EditPreferencesAction(Action): """ An action that displays the preferences dialog. """ #### 'Action' interface ################################################### # A longer description of the action. description = 'Manage Preferences' # The action's image (displayed on tool bar tools etc). image = ImageResource('preferences') # The action's name (displayed on menus/tool bar tools etc). name = 'Preferences' # A short description of the action used for tooltip text etc. tooltip = 'Manage Preferences' ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): """ Performs the action. """ from apptools.preferences.ui.api import PreferencesManager # Lookup the preferences manager service. manager = event.window.application.get_service(PreferencesManager) ui = manager.edit_traits(parent=event.window.control, kind='modal') # If the user hit the "Ok" button, then save the preferences in case # application crashes before it exits! if ui.result: self.window.application.preferences.save() return #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/action/about_action.py0000644000175100001440000000173411674464014025010 0ustar ischnellusers00000000000000""" An action that shows the 'About' dialog. """ # Enthought library imports. from pyface.action.api import Action class AboutAction(Action): """ An action that shows the 'About' dialog. """ #### 'Action' interface ################################################### # A longer description of the action. description = 'Display information about the application' # The action's name (displayed on menus/tool bar tools etc). name = 'About' # A short description of the action used for tooltip text etc. tooltip = 'Display information about the application' ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): """ Perform the action. """ self.window.application.about() return #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/action/__init__.py0000644000175100001440000000000011674464014024061 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/workbench/action/exit_action.py0000644000175100001440000000205111674464014024640 0ustar ischnellusers00000000000000""" An action that exits the workbench. """ # Enthought library imports. from pyface.api import ImageResource from pyface.action.api import Action class ExitAction(Action): """ An action that exits the workbench. """ #### 'Action' interface ################################################### # A longer description of the action. description = 'Exit the application' # The action's image (displayed on tool bar tools etc). image = ImageResource('exit') # The action's name (displayed on menus/tool bar tools etc). name = 'Exit' # A short description of the action used for tooltip text etc. tooltip = 'Exit the application' ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): """ Perform the action. """ self.window.application.exit() return #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/default_action_set.py0000644000175100001440000000243011674464014024712 0ustar ischnellusers00000000000000""" The default workbench action set. """ # Enthought library imports. from envisage.ui.action.api import Action, ActionSet, Menu # This module's package. PKG = '.'.join(__name__.split('.')[:-1]) class DefaultActionSet(ActionSet): """ The default workbench action set. """ menus = [ Menu( name='&File', path='MenuBar', groups=['OpenGroup', 'SaveGroup', 'ImportGroup', 'ExitGroup'] ), Menu( path='MenuBar', class_name='pyface.workbench.action.api:ViewMenuManager' ), Menu( name='&Tools', path='MenuBar', groups=['PreferencesGroup'] ), Menu( name='&Help', path='MenuBar', groups=['AboutGroup'] ) ] actions = [ Action( path='MenuBar/File', group='ExitGroup', class_name=PKG + '.action.api:ExitAction' ), Action( path='MenuBar/Tools', group='PreferencesGroup', class_name=PKG + '.action.api:EditPreferencesAction' ), Action( path='MenuBar/Help', group='AboutGroup', class_name=PKG + '.action.api:AboutAction' ), ] #### EOF ###################################################################### envisage-4.1.0/envisage/ui/workbench/__init__.py0000644000175100001440000000000011674464014022604 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/action/0000755000175100001440000000000011674464014020000 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/action/tests/0000755000175100001440000000000011674464014021142 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/action/tests/dummy_action_manager_builder.py0000644000175100001440000000361011674464014027404 0ustar ischnellusers00000000000000""" A menu builder that doesn't build real actions! """ # Standard library imports. import unittest # Enthought library imports. from envisage.ui.action.api import AbstractActionManagerBuilder from pyface.action.api import Action, Group, MenuManager from pyface.action.api import MenuBarManager class DummyActionManagerBuilder(AbstractActionManagerBuilder): """ An action manager builder that doesn't build real actions! This makes it very easy to test! """ ########################################################################### # 'DummyActionManagerBuilder' interface. ########################################################################### def create_menu_bar_manager(self, root): """ Create a menu bar manager from the builder's action sets. """ menu_bar_manager = MenuBarManager(id='MenuBar') self.initialize_action_manager(menu_bar_manager, root) return menu_bar_manager ########################################################################### # Protected 'AbstractActionManagerBuilder' interface. ########################################################################### def _create_action(self, action_definition): """ Create an action implementation from a definition. """ return Action(name=action_definition.class_name) def _create_group(self, group_definition): """ Create a group implementation from a definition. """ return Group(id=group_definition.id) def _create_menu_manager(self, menu_definition): """ Create a menu manager implementation from a definition. """ menu_manager = MenuManager(id=menu_definition.id) for group_definition in menu_definition.groups: menu_manager.insert(-1, Group(id=group_definition.id)) return menu_manager #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/tests/action_manager_builder_test_case.py0000644000175100001440000006141311674464014030230 0ustar ischnellusers00000000000000""" Tests for the action manager builder. """ # Standard library imports. import unittest # fixme: Workaround for traits bug introduced by themes. import traitsui.wx # Enthought library imports. from envisage.ui.action.api import Action, ActionSet, Group, Menu # Local imports. from dummy_action_manager_builder import DummyActionManagerBuilder class ActionManagerBuilderTestCase(unittest.TestCase): """ Tests for the action manager builder. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_action_with_nonexistent_group(self): """ action with non-existent group """ action_sets = [ ActionSet( actions = [ Action( class_name = 'Exit', path = 'MenuBar/File', group = 'Bogus' ), ] ), ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. self.failUnlessRaises( ValueError, builder.create_menu_bar_manager, 'MenuBar' ) return def test_action_with_nonexistent_sibling(self): """ action with non-existent sibling """ action_sets = [ ActionSet( actions = [ Action( class_name = 'Exit', path = 'MenuBar/File', before = 'NonExistentAction' ), ] ), ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. self.failUnlessRaises( ValueError, builder.create_menu_bar_manager, 'MenuBar' ) return def test_group_with_nonexistent_sibling(self): """ group with non-existent sibling """ action_sets = [ ActionSet( groups = [ Group(id='FileMenuGroup', path='MenuBar', before='Bogus') ] ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. self.failUnlessRaises( ValueError, builder.create_menu_bar_manager, 'MenuBar' ) return def test_menu_with_nonexistent_sibling(self): """ menu with non-existent sibling """ action_sets = [ ActionSet( menus = [ Menu(name='&File', path='MenuBar', before='Bogus') ] ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. self.failUnlessRaises( ValueError, builder.create_menu_bar_manager, 'MenuBar' ) return def test_action_with_path_component_that_is_not_a_menu(self): """ action with path component that is not a menu """ action_sets = [ ActionSet( actions = [ Action( class_name = 'Exit', path = 'MenuBar/File' ), Action( class_name = 'Broken', path = 'MenuBar/File/Exit', ), ] ), ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. self.failUnlessRaises( ValueError, builder.create_menu_bar_manager, 'MenuBar' ) return def test_single_top_level_menu_with_no_group(self): """ single top level menu with no group """ action_sets = [ ActionSet( menus = [ Menu(name='&File', path='MenuBar'), ] ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_bar_manager = builder.create_menu_bar_manager('MenuBar') # Make sure that the 'File' menu was added to the 'additions' group # of the menubar. self.assertEqual(1, len(menu_bar_manager.groups)) group = menu_bar_manager.find_group('additions') ids = [item.id for item in group.items] self.assertEqual(['File'], ids) return def test_single_top_level_group(self): """ single top level group """ action_sets = [ ActionSet( groups = [ Group(id='FileMenuGroup', path='MenuBar'), ] ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_bar_manager = builder.create_menu_bar_manager('MenuBar') # Make sure that the group was added before the 'additions' group. self.assertEqual(2, len(menu_bar_manager.groups)) ids = [group.id for group in menu_bar_manager.groups] self.assertEqual(['FileMenuGroup', 'additions'], ids) return def test_top_level_menus_with_no_groups(self): """ top level menus with_no groups """ action_sets = [ ActionSet( menus = [ Menu(name='&File', path='MenuBar'), Menu(name='&Edit', path='MenuBar'), Menu(name='&Tools', path='MenuBar'), Menu(name='&Help', path='MenuBar') ], ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_bar_manager = builder.create_menu_bar_manager('MenuBar') # Make sure that all of the menus were added the the 'additions' group # of the menubar (and in the right order!). self.assertEqual(1, len(menu_bar_manager.groups)) group = menu_bar_manager.find_group('additions') ids = [item.id for item in group.items] self.assertEqual(['File', 'Edit', 'Tools', 'Help'], ids) return def test_top_level_menus_no_groups_before_and_after(self): """ top level menus no groups, before and after """ action_sets = [ ActionSet( menus = [ Menu(name='&Edit', path='MenuBar', after='File'), ], ), ActionSet( menus = [ Menu(name='&File', path='MenuBar'), ], ), ActionSet( menus = [ Menu(name='&Help', path='MenuBar') ], ), ActionSet( menus = [ Menu(name='&Tools', path='MenuBar', before='Help'), ], ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure that all of the menus were added the the 'additions' group # of the menubar. self.assertEqual(1, len(menu_manager.groups)) additions = menu_manager.find_group('additions') ids = [item.id for item in additions.items] self.assertEqual(['File', 'Edit', 'Tools', 'Help'], ids) return def test_top_level_menu_non_existent_group(self): """ top level menu non-existent group """ action_sets = [ ActionSet( menus = [ Menu(name='&File', path='MenuBar', group='FileMenuGroup'), ], ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. self.failUnlessRaises( ValueError, builder.create_menu_bar_manager, 'MenuBar' ) return def test_top_level_menu_group(self): """ top level menu group """ action_sets = [ ActionSet( groups = [ Group(id='FileMenuGroup', path='MenuBar') ], menus = [ Menu(name='&File', path='MenuBar', group='FileMenuGroup'), ], ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure that the 'File' menu was added to the 'FileMenuGroup' # group of the menubar. self.assertEqual(2, len(menu_manager.groups)) ids = [group.id for group in menu_manager.groups] self.assertEqual(['FileMenuGroup', 'additions'], ids) group = menu_manager.find_group('FileMenuGroup') self.assertEqual('File', group.items[0].id) return def test_sub_menus_no_groups(self): """ sub-menus no groups """ # We split the contributions into different action sets just because # that is how it might end up in an actual application... not because # you *have* to split them up this way! action_sets = [ ActionSet( menus = [ Menu(name='&File', path='MenuBar'), Menu(name='&Edit', path='MenuBar'), Menu(name='&Tools', path='MenuBar'), Menu(name='&Help', path='MenuBar') ], ), ActionSet( menus = [ Menu(name='&New', path='MenuBar/File'), ], ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure the 'New' sub-menu got added to the 'additions' group # of the 'File' menu. menu = menu_manager.find_item('File') additions = menu.find_group('additions') self.assertEqual('New', additions.items[0].id) return def test_actions_no_groups(self): """ actions no groups """ # We split the contributions into different action sets just because # that is how it might end up in an actual application... not because # you *have* to split them up this way! action_sets = [ ActionSet( menus = [ Menu(name='&File', path='MenuBar'), Menu(name='&Edit', path='MenuBar'), Menu(name='&Tools', path='MenuBar'), Menu(name='&Help', path='MenuBar') ] ), ActionSet( actions = [ Action(class_name='Exit', path='MenuBar/File'), Action(class_name='About', path='MenuBar/Help') ] ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure the 'ExitAction' action got added to the 'additions' group # of the 'File' menu. menu = menu_manager.find_item('File') additions = menu.find_group('additions') self.assertEqual('Exit', additions.items[0].id) # Make sure the 'AboutAction' action got added to the 'additions' group # of the 'File' menu. menu = menu_manager.find_item('Help') additions = menu.find_group('additions') self.assertEqual('About', additions.items[0].id) return def test_actions_make_submenus(self): """ actions make submenus """ action_sets = [ ActionSet( actions = [ Action(class_name='Folder', path='MenuBar/File/New'), Action(class_name='File', path='MenuBar/File/New') ] ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure the 'File' menu got added to the 'additions' group of the # menubar. self.assertEqual(1, len(menu_manager.groups)) additions = menu_manager.find_group('additions') self.assertEqual('File', additions.items[0].id) # Make sure the 'New' sub-menu got added to the 'additions' group # of the 'File' menu. menu = menu_manager.find_item('File') additions = menu.find_group('additions') self.assertEqual('New', additions.items[0].id) # Make sure the new 'Folder' and 'File' actions got added to the # 'additions' group of the 'New' menu. menu = menu_manager.find_item('File/New') additions = menu.find_group('additions') self.assertEqual('Folder', additions.items[0].id) self.assertEqual('File', additions.items[1].id) return def test_actions_make_submenus_before_and_after(self): """ actions make submenus before and after """ action_sets = [ ActionSet( actions = [ Action( class_name = 'File', path = 'MenuBar/File/New', after = 'Folder' ), Action( class_name = 'Project', path = 'MenuBar/File/New', before = 'Folder' ), Action( class_name = 'Folder', path = 'MenuBar/File/New', ), ] ) ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure the 'File' menu got added to the 'additions' group of the # menubar. self.assertEqual(1, len(menu_manager.groups)) additions = menu_manager.find_group('additions') self.assertEqual('File', additions.items[0].id) # Make sure the 'New' sub-menu got added to the 'additions' group # of the 'File' menu. menu = menu_manager.find_item('File') additions = menu.find_group('additions') self.assertEqual('New', additions.items[0].id) # Make sure the new 'Folder' and 'File' actions got added to the # 'additions' group of the 'New' menu. menu = menu_manager.find_item('File/New') additions = menu.find_group('additions') ids = [item.id for item in additions.items] self.assertEqual(['Project', 'Folder', 'File'], ids) return def test_explicit_groups(self): """ explicit groups """ action_sets = [ ActionSet( menus = [ Menu(name='&File', path='MenuBar'), Menu(name='&Edit', path='MenuBar'), Menu(name='&Tools', path='MenuBar'), Menu(name='&Help', path='MenuBar') ], ), ActionSet( menus = [ Menu(name='&New', path='MenuBar/File', group='NewGroup'), ], ), ActionSet( actions = [ Action( class_name = 'Exit', path = 'MenuBar/File', group = 'ExitGroup' ), ] ), ActionSet( groups = [ Group( id = 'ExitGroup', path = 'MenuBar/File' ), Group( id = 'SaveGroup', path = 'MenuBar/File', after = 'NewGroup' ), Group( id = 'NewGroup', path = 'MenuBar/File', before = 'ExitGroup' ), ] ), ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure that all of the menus were added the the 'additions' group # of the menubar. self.assertEqual(1, len(menu_manager.groups)) additions = menu_manager.find_group('additions') ids = [item.id for item in additions.items] self.assertEqual(['File', 'Edit', 'Tools', 'Help'], ids) # Make sure the 'File' menu has got 3 groups, 'NewGroup', 'ExitGroup' # and 'additions' (and in that order!). menu = menu_manager.find_item('File') self.assertEqual(4, len(menu.groups)) ids = [group.id for group in menu.groups] self.assertEqual( ['NewGroup', 'SaveGroup', 'ExitGroup', 'additions'], ids ) # Make sure the 'New' sub-menu got added to the 'NewGroup' group # of the 'File' menu. menu = menu_manager.find_item('File') group = menu.find_group('NewGroup') self.assertEqual('New', group.items[0].id) # Make sure the 'Exit' action got added to the 'ExitGroup' group # of the 'File' menu. menu = menu_manager.find_item('File') group = menu.find_group('ExitGroup') self.assertEqual('Exit', group.items[0].id) return def test_actions_and_menus_in_groups(self): """ actions and menus in groups """ action_sets = [ ActionSet( menus = [ Menu( name = '&File', path = 'MenuBar', groups = ['NewGroup', 'ExitGroup'] ), Menu(name='&Edit', path='MenuBar'), Menu(name='&Tools', path='MenuBar'), Menu(name='&Help', path='MenuBar') ], ), ActionSet( menus = [ Menu(name='&New', path='MenuBar/File', group='NewGroup'), ], ), ActionSet( actions = [ Action( class_name = 'Exit', path = 'MenuBar/File', group = 'ExitGroup' ), ] ), ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure that all of the menus were added the the 'additions' group # of the menubar. self.assertEqual(1, len(menu_manager.groups)) additions = menu_manager.find_group('additions') ids = [item.id for item in additions.items] self.assertEqual(['File', 'Edit', 'Tools', 'Help'], ids) # Make sure the 'File' menu has got 3 groups, 'NewGroup', 'ExitGroup' # and 'additions' (and in that order!). menu = menu_manager.find_item('File') self.assertEqual(3, len(menu.groups)) ids = [group.id for group in menu.groups] self.assertEqual(['NewGroup', 'ExitGroup', 'additions'], ids) # Make sure the 'New' sub-menu got added to the 'NewGroup' group # of the 'File' menu. menu = menu_manager.find_item('File') group = menu.find_group('NewGroup') self.assertEqual('New', group.items[0].id) # Make sure the 'Exit' action got added to the 'ExitGroup' group # of the 'File' menu. menu = menu_manager.find_item('File') group = menu.find_group('ExitGroup') self.assertEqual('Exit', group.items[0].id) return def test_duplicate_menu(self): """ duplicate menu """ action_sets = [ ActionSet( menus = [ Menu( name = '&File', path = 'MenuBar', groups = ['NewGroup', 'ExitGroup'] ), ], ), ActionSet( menus = [ Menu( name = '&File', path = 'MenuBar', groups = ['ExtraGroup'] ), ], ), ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure that all of the menus were added the the 'additions' group # of the menubar. self.assertEqual(1, len(menu_manager.groups)) # Make sure we only get *one* 'File' menu. additions = menu_manager.find_group('additions') ids = [item.id for item in additions.items] self.assertEqual(['File'], ids) # Make sure the 'File' menu has got 4 groups, 'NewGroup', 'ExitGroup', # 'ExtraGroup' and 'additions' (and in that order!). menu = menu_manager.find_item('File') self.assertEqual(4, len(menu.groups)) ids = [group.id for group in menu.groups] self.assertEqual( ['NewGroup', 'ExitGroup', 'ExtraGroup', 'additions'], ids ) return def test_duplicate_group(self): """ duplicate group """ action_sets = [ ActionSet( menus = [ Menu( name = '&File', path = 'MenuBar', groups = ['NewGroup', 'ExitGroup'] ), ], ), ActionSet( menus = [ Menu( name = '&File', path = 'MenuBar', groups = ['NewGroup'] ), ], ), ] # Create a builder containing the action set. builder = DummyActionManagerBuilder(action_sets=action_sets) # Create a menu bar manager for the 'MenuBar'. menu_manager = builder.create_menu_bar_manager('MenuBar') # Make sure that all of the menus were added the the 'additions' group # of the menubar. self.assertEqual(1, len(menu_manager.groups)) # Make sure we only get *one* 'File' menu. additions = menu_manager.find_group('additions') ids = [item.id for item in additions.items] self.assertEqual(['File'], ids) # Make sure the 'File' menu has got 3 groups, 'NewGroup', 'ExitGroup' # and 'additions' (and in that order!). menu = menu_manager.find_item('File') self.assertEqual(3, len(menu.groups)) ids = [group.id for group in menu.groups] self.assertEqual( ['NewGroup', 'ExitGroup', 'additions'], ids ) return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/abstract_action_manager_builder.py0000644000175100001440000003535011674464014026720 0ustar ischnellusers00000000000000""" Builds menus, menu bars and tool bars from action sets. """ # Enthought library imports. from pyface.action.api import ActionManager, MenuManager from traits.api import HasTraits, Instance, List, implements # Local imports. from action_set import ActionSet from action_set_manager import ActionSetManager from group import Group from i_action_manager_builder import IActionManagerBuilder class AbstractActionManagerBuilder(HasTraits): """ Builds menus, menu bars and tool bars from action sets. This class *must* be subclassed, and the following methods implemented:: _create_action _create_group _create_menu_manager """ implements(IActionManagerBuilder) #### 'IActionManagerBuilder' interface #################################### # The action sets used by the builder. action_sets = List(ActionSet) #### Private interface #################################################### _action_set_manager = Instance(ActionSetManager, ()) ########################################################################### # 'IActionManagerBuilder' interface. ########################################################################### def create_menu_bar_manager(self, root): """ Create a menu bar manager from the builder's action sets. """ menu_bar_manager = self._create_menu_bar_manager() self.initialize_action_manager(menu_bar_manager, root) return menu_bar_manager # fixme: V3 refactor loooong (and confusing) method! def create_tool_bar_managers(self, root): """ Creates all tool bar managers from the builder's action sets. """ ######################################## # New style (i.e multi) tool bars. ######################################## tool_bar_managers = [] for tool_bar in self._action_set_manager.get_tool_bars(root): # Get all of the groups for the tool bar. groups = [] for group in self._action_set_manager.get_groups(root): if group.path.startswith('%s/%s' % (root, tool_bar.name)): group.path = '/'.join(action.path.split('/')[1:]) groups.append(group) # Get all of the actions for the tool bar. actions = [] for action in self._action_set_manager.get_actions(root): if action.path.startswith('%s/%s' % (root, tool_bar.name)): action.path = '/'.join(action.path.split('/')[1:]) actions.append(action) # We don't add the tool bar if it is empty! if len(groups) + len(actions) > 0: tool_bar_manager = self._create_tool_bar_manager(tool_bar) # Add all groups and menus. self._add_groups_and_menus(tool_bar_manager, groups) # Add all of the actions ot the menu manager. self._add_actions(tool_bar_manager, actions) # Include the tool bar! tool_bar_managers.append(tool_bar_manager) ###################################################################### # Scoop up old groups and actions for the old style (single) tool bar. ###################################################################### # Get all of the groups for the tool bar. groups = [] for group in self._action_set_manager.get_groups(root): if group.path == root: groups.append(group) # Get all of the actions for the tool bar. actions = [] for action in self._action_set_manager.get_actions(root): if action.path == root: actions.append(action) # We don't add the tool bar if it is empty! if len(groups) + len(actions) > 0: from tool_bar import ToolBar tool_bar_manager = self._create_tool_bar_manager( ToolBar(name='Tool Bar', path=root, _action_set_=None) ) # Add all groups and menus. self._add_groups_and_menus(tool_bar_manager, groups) # Add all of the actions ot the menu manager. self._add_actions(tool_bar_manager, actions) # Include the tool bar! tool_bar_managers.insert(0, tool_bar_manager) return tool_bar_managers def initialize_action_manager(self, action_manager, root): """ Initialize an action manager from the builder's action sets. """ # Get all of the groups and menus for the specified root (for toolbars # there will **only** be groups). groups_and_menus = self._action_set_manager.get_groups(root) groups_and_menus.extend(self._action_set_manager.get_menus(root)) # Add all groups and menus. self._add_groups_and_menus(action_manager, groups_and_menus) # Get all actions for the specified root. actions = self._action_set_manager.get_actions(root) # Add all of the actions ot the menu manager. self._add_actions(action_manager, actions) return ########################################################################### # Protected 'AbstractActionManagerBuilder' interface. ########################################################################### def _create_action(self, action_definition): """ Creates an action implementation from a definition. """ raise NotImplementedError def _create_group(self, group_definition): """ Creates a group implementation from a definition. """ raise NotImplementedError def _create_menu_manager(self, menu_manager_definition): """ Creates a menu manager implementation from a definition. """ raise NotImplementedError def _create_menu_bar_manager(self): """ Creates a menu bar manager implementation. """ raise NotImplementedError def _create_tool_bar_manager(self, tool_bar_definition): """ Creates a tool bar manager implementation from a definition. """ raise NotImplementedError ########################################################################### # Private interface. ########################################################################### #### Trait change handler ################################################# def _action_sets_changed(self, old, new): """ Static trait change handler. """ self._action_set_manager.action_sets = new return #### Methods ############################################################## def _add_actions(self, action_manager, actions): """ Add the specified actions to an action manager. """ while len(actions) > 0: start = len(actions) for action in actions[:]: # Resolve the action's path to find the action manager that it # should be added to. # # If any of the menus in path are missing then this creates # them automatically (think 'mkdirs'!). target = self._make_submenus(action_manager, action.path) # Attempt to place the action. # # If the action needs to be placed 'before' or 'after' some # other action, but the other action has not yet been added # then we will try again later! if self._add_action(target, action): actions.remove(action) end = len(actions) # If we didn't succeed in placing *any* actions then we must have a # problem! if start == end: raise ValueError('Could not place %s' % actions) return def _add_action(self, action_manager, action): """ Add an action to an action manager. Return True if the action was added successfully. Return False if the action needs to be placed 'before' or 'after' some other action, but the other action has not yet been added. """ group = self._find_group(action_manager, action.group) if group is None: msg = 'No such group (%s) for %s' % (action.group, action) raise ValueError(msg) if len(action.before) > 0: item = group.find(action.before) if item is None: return False index = group.items.index(item) elif len(action.after) > 0: item = group.find(action.after) if item is None: return False index = group.items.index(item) + 1 else: index = len(group.items) group.insert(index, self._create_action(action)) return True def _add_groups_and_menus(self, action_manager, groups_and_menus): """ Add the specified groups and menus to an action manager. """ # The reason we put the groups and menus together is that as we iterate # over the list trying to add them, we might need to add a group before # we can add a menu and we might need to add a menu before we can add a # group! Hence, we take multiple passes over the list and we only barf # if, in any single iteration, we cannot add anything. while len(groups_and_menus) > 0: start = len(groups_and_menus) for item in groups_and_menus[:]: # Resolve the path to find the menu manager that we are about # to add the sub-menu or group to. target = self._find_action_manager(action_manager, item.path) if target is not None: # Attempt to place a group. if isinstance(item, Group): if self._add_group(target, item): groups_and_menus.remove(item) # Attempt to place a menu. elif self._add_menu(target, item): groups_and_menus.remove(item) end = len(groups_and_menus) # If we didn't succeed in adding *any* menus or groups then we # must have a problem! if start == end: raise ValueError('Could not place %s' % groups_and_menus) return def _add_group(self, action_manager, group): """ Add a group to an action manager. Return True if the group was added successfully. Return False if the group needs to be placed 'before' or 'after' some other group, but the other group has not yet been added. """ # Does the group already exist in the menu? If not then add it, # otherwise do nothing. if action_manager.find_group(group.id) is None: if len(group.before) > 0: item = action_manager.find_group(group.before) if item is None: return False index = action_manager.groups.index(item) elif len(group.after) > 0: item = action_manager.find_group(group.after) if item is None: return False index = action_manager.groups.index(item) + 1 else: # If the menu manger has an 'additions' group then make sure # that it is always the last one! In Pyface, the 'additions' # groups is created by default, so unless someone has # explicitly removed it, it *will* be there! additions = action_manager.find_group('additions') if additions is not None: index = action_manager.groups.index(additions) else: index = len(action_manager.groups) action_manager.insert(index, self._create_group(group)) return True def _add_menu(self, menu_manager, menu): """ Add a menu manager to a errr, menu manager. Return True if the menu was added successfully. Return False if the menu needs to be placed 'before' or 'after' some other item, but the other item has not yet been added. """ group = self._find_group(menu_manager, menu.group) if group is None: return False if len(menu.before) > 0: item = group.find(menu.before) if item is None: return False index = group.items.index(item) elif len(menu.after) > 0: item = group.find(menu.after) if item is None: return False index = group.items.index(item) + 1 else: index = len(group.items) # If the menu does *not* already exist in the group then add it. menu_item = group.find(menu.id) if menu_item is None: group.insert(index, self._create_menu_manager(menu)) # Otherwise, add all of the new menu's groups to the existing one. else: for group in menu.groups: self._add_group(menu_item, group) return True def _find_group(self, action_manager, id): """ Find the group with the specified ID. """ if len(id) > 0: group = action_manager.find_group(id) else: group = action_manager.find_group('additions') return group def _find_action_manager(self, action_manager, path): """ Return the action manager at the specified path. Returns None if the action manager cannot be found. """ components = path.split('/') if len(components) == 1: action_manager = action_manager else: action_manager = action_manager.find_item('/'.join(components[1:])) return action_manager def _make_submenus(self, menu_manager, path): """ Retutn the menu manager identified by the path. Make any intermediate menu-managers that are missing. """ components = path.split('/') # We skip the first component, because if the path is of length 1, then # the target menu manager is the menu manager passed in. for component in components[1:]: item = menu_manager.find_item(component) # If the menu manager does *not* contain an item with this ID then # create a sub-menu automatically. if item is None: item = MenuManager(id=component, name=component) menu_manager.append(item) # If the menu manager *does* already contain an item with this ID # then make sure it is a menu and not an action! elif not isinstance(item, ActionManager): msg = '%s is not a menu in path %s' % (item, path) raise ValueError(msg) menu_manager = item return menu_manager #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/api.py0000644000175100001440000000046011674464014021123 0ustar ischnellusers00000000000000from i_action_set import IActionSet from i_action_manager_builder import IActionManagerBuilder from abstract_action_manager_builder import AbstractActionManagerBuilder from action import Action from action_set import ActionSet from group import Group from menu import Menu from tool_bar import ToolBar envisage-4.1.0/envisage/ui/action/action_set_manager.py0000644000175100001440000000661511674464014024204 0ustar ischnellusers00000000000000""" Manages a collection of action sets. """ # Enthought library imports. from traits.api import HasTraits, List # Local imports. from action_set import ActionSet class ActionSetManager(HasTraits): """ Manages a collection of action sets. """ #### 'ActionSetManager' interface ######################################### # The action sets that this manager manages. action_sets = List(ActionSet) ########################################################################### # 'ActionSetManager' interface. ########################################################################### def get_actions(self, root): """ Return all action definitions for a root. """ return self._get_items(self.action_sets, 'actions', root) def get_groups(self, root): """ Return all group definitions for a root. """ return self._get_items(self.action_sets, 'groups', root) def get_menus(self, root): """ Return all menu definitions for a root. """ return self._get_items(self.action_sets, 'menus', root) def get_tool_bars(self, root): """ Return all tool bar definitions for a root. """ return self._get_items(self.action_sets, 'tool_bars', root) ########################################################################### # 'Private' interface. ########################################################################### def _get_items(self, action_sets, attribute_name, root): """ Return all actions, groups or menus for a particular root. e.g. To get all of the groups:: self._get_items(action_sets, 'groups', root) """ items = [] for action_set in action_sets: for item in getattr(action_set, attribute_name): if self._get_root(item.path, action_set.aliases) == root: items.append(item) # fixme: Hacky, but the model needs to maintain the # action set that contributed the item. item._action_set_ = action_set # fixme: Even hackier if this is a menu then we need to # tag the action set onto all of the groups. if attribute_name in ['menus', 'toolbars']: for group in item.groups: group._action_set_ = action_set return items def _get_root(self, path, aliases): """ Return the effective root for a path. If the first component of the path matches an alias, then we return the value of the alias. e.g. If the aliases are:: {'MenuBar' : 'envisage.ui.workbench.menubar'} and the path is:: 'MenuBar/File/New' Then the effective root is:: 'envisage.ui.workbench.menubar' If the first component of the path does *not* match an alias, then it is returned as is. e.g. If the aliases are:: {'ToolBar' : 'envisage.ui.workbench.toolbar'} and the path is:: 'MenuBar/File/New' Then the effective root is:: 'MenuBar' """ components = path.split('/') if components[0] in aliases: root = aliases[components[0]] else: root = components[0] return root #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/action_set.py0000644000175100001440000000623411674464014022507 0ustar ischnellusers00000000000000""" An action set is a collection of menus, groups, and actions. """ # Standard library imports. import logging # Enthought library imports. from traits.api import Bool, Dict, HasTraits, List, Str, implements from traits.util.camel_case import camel_case_to_words # Local imports. from action import Action from group import Group from i_action_set import IActionSet from menu import Menu from tool_bar import ToolBar # Logging. logger = logging.getLogger(__name__) class ActionSet(HasTraits): """ An action set is a collection of menus, groups, and actions. """ implements(IActionSet) # The action set's globally unique identifier. id = Str # The action set's name. # # fixme: This is not currently used, but in future it will be the name that # is shown to the user when they are customizing perspectives by adding or # removing action sets etc. name = Str # The actions in this set. actions = List(Action) # The groups in this set. groups = List(Group) # The menus in this set. menus = List(Menu) # The tool bars in this set. tool_bars = List(ToolBar) # Are the actions and menus in this set enabled (if they are disabled they # will be greyed out). Tool bars are generally not greyed out themselves, # but the actions within them are. enabled = Bool(True) # Are the actions, menus and tool bars in this set visible? visible = Bool(True) # A mapping from human-readable names to globally unique IDs. # # This mapping is used when interpreting the first item in a location path # (i.e., the **path** trait of a **Location** instance). # # When the path is intepreted, the first component (i.e., the first item # before any '/') is checked to see if it is in the mapping, and if so it # is replaced with the value in the map. # # This technique allows paths to start with human readable names, as # opposed to IDs (which are required in order to manage the namespace of # all action sets). # # For example, in the Envisage workbench, the menu bar ID is: # # ``'envisage.workbench.menubar'`` # # Without aliases, you must specify a location like this: # # ``Location(path='envisage.workbench.menubar/ASubMenu/AGroup')`` # # This is a bit long-winded! Instead, you can define an alias: # # ``aliases = { 'MenuBar' : 'envisage.workbench.menubar' }`` # # In that case, you can specify a location like this: # # ``Location(path='MenuBar/ASubMenu/AGroup')`` # aliases = Dict(Str, Str) #### Trait initializers ################################################### def _id_default(self): """ Trait initializer. """ id = '%s.%s' % (type(self).__module__, type(self).__name__) logger.warn('action set %s has no Id - using <%s>' % (self, id)) return id def _name_default(self): """ Trait initializer. """ name = camel_case_to_words(type(self).__name__) logger.warn('action set %s has no name - using <%s>' % (self, name)) return name #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/group.py0000644000175100001440000000202611674464014021506 0ustar ischnellusers00000000000000""" The *definition* of a group in a tool bar or menu. """ # Enthought library imports. from traits.api import Bool, Str # Local imports. from location import Location class Group(Location): """ The *definition* of a group in a tool bar or menu. """ # The group's unique identifier (unique within the tool bar, menu bar or # menu that the group is to be added to). id = Str # Does this group require a separator? separator = Bool(True) # The optional name of a class that implements the group. The class must # support the **pyface.action.Group** protocol. class_name = Str ########################################################################### # 'object' interface ########################################################################### def __str__(self): """ Return the 'informal' string representation of the object. """ return 'Group(%s)' % self.id __repr__ = __str__ #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/action.py0000644000175100001440000000163511674464014021634 0ustar ischnellusers00000000000000""" The *definition* of an action in a tool bar or menu. """ # Enthought library imports. from traits.api import Str # Local imports. from location import Location class Action(Location): """ The *definition* of an action in a tool bar or menu. """ #### Action implementation ################################################ # The action's name (appears on menus and toolbars etc). name = Str # The name of the class that implements the action. class_name = Str ########################################################################### # 'object' interface ########################################################################### def __str__(self): """ Return the 'informal' string representation of the object. """ return 'Action(%s)' % self.name __repr__ = __str__ #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/menu.py0000644000175100001440000000445711674464014021330 0ustar ischnellusers00000000000000""" The *definition* of a menu in a menu bar or menu. """ # Enthought library imports. from traits.api import Instance, List, Str # Local imports. from group import Group from location import Location class CGroup(Instance): """ A trait type for a 'Group' or anything that can be cast to a 'Group'. Currently, the only cast allowed is from string -> Group using the string as the group's ID. """ ########################################################################### # 'object' interface. ########################################################################### def __init__(self, **kw): """ Constructor. """ super(CGroup, self).__init__(klass=Group, **kw) return ########################################################################### # 'TraitType' interface. ########################################################################### def validate(self, object, name, value): """ Validate a value. """ if isinstance(value, basestring): value = Group(id=value) return super(CGroup, self).validate(object, name, value) class Menu(Location): """ The *definition* of a menu in a menu bar or menu. """ # The menu's unique identifier (unique within the group that the menu is to # be added to). id = Str # The menu name (appears on the menu bar or menu). name = Str # The groups in the menu. groups = List(CGroup) # The optional name of a class that implements the menu. The class must # support the **pyface.action.MenuManager** protocol. class_name = Str ########################################################################### # 'object' interface ########################################################################### def __str__(self): """ Return the 'informal' string representation of the object. """ return 'Menu(%s)' % self.name __repr__ = __str__ ########################################################################### # 'Menu' interface ########################################################################### def _id_default(self): """ Trait initializer. """ return self.name.strip('&') #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/tool_bar.py0000644000175100001440000000521011674464014022151 0ustar ischnellusers00000000000000""" The *definition* of a tool bar. """ # Enthought library imports. from traits.api import Instance, List, Str # Local imports. from group import Group from location import Location # fixme: Remove duplication (in menu.py too!) class CGroup(Instance): """ A trait type for a 'Group' or anything that can be cast to a 'Group'. Currently, the only cast allowed is from string -> Group using the string as the group's ID. """ ########################################################################### # 'object' interface. ########################################################################### def __init__(self, **kw): """ Constructor. """ super(CGroup, self).__init__(klass=Group, **kw) return ########################################################################### # 'TraitType' interface. ########################################################################### def validate(self, object, name, value): """ Validate a value. """ if isinstance(value, basestring): value = Group(id=value) return super(CGroup, self).validate(object, name, value) class ToolBar(Location): """ The *definition* of a menu in a menu bar or menu. """ # The tool bars's unique identifier (unique within the multi-toolbar # that the tool bar is to be added to). id = Str # The tool bar name (appears when the tool bar is 'undocked'). name = Str # The groups in the tool bar. groups = List(CGroup) # The optional name of a class that implements the tool bar. The class must # support the **pyface.action.ToolBarManager** protocol. class_name = Str ########################################################################### # 'object' interface ########################################################################### def __str__(self): """ Return the 'informal' string representation of the object. """ return 'ToolBar(%s)' % self.name __repr__ = __str__ ########################################################################### # 'Location' interface ########################################################################### def _path_default(self): """ Trait initializer. """ return 'ToolBar' ########################################################################### # 'ToolBar' interface ########################################################################### def _id_default(self): """ Trait initializer. """ return self.name #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/location.py0000644000175100001440000000246011674464014022164 0ustar ischnellusers00000000000000""" The location of a group, menu, or action, within an action hierarchy. """ # Enthought library imports. from traits.api import HasTraits, Str class Location(HasTraits): """ The location of a group, menu, or action, within an action hierarchy. """ # A forward-slash-separated path through the action hierarchy to the menu # to add the action, group or menu to. # # Examples # -------- # # * To add an item to the menu bar: ``path = "MenuBar"`` # # * To add an item to the tool bar: ``path = "ToolBar"`` # # * To add an item to a sub-menu: ``path = "MenuBar/File/New"`` # path = Str #### Placement of the action within the menu specified by the path ######## # The ID of the group to add the action or menu to (you can't have nested # groups). group = Str # The item appears after the item with this ID. # # - for groups, this is the ID of another group. # - for menus and actions, this is the ID of another menu or action. after = Str # The action appears before the item with this ID. # # - for groups, this is the ID of another group. # - for menus and actions, this is the ID of another menu or action. before = Str #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/i_action_set.py0000644000175100001440000000416211674464014023015 0ustar ischnellusers00000000000000""" The action set interface. """ # Enthought library imports. from traits.api import Dict, Interface, List, Str # Local imports. from action import Action from group import Group from menu import Menu from tool_bar import ToolBar class IActionSet(Interface): """ The action set interface. An action set is a collection of menus, groups, and actions. """ # The action set's globally unique identifier. id = Str # The action set's name. # # fixme: This is not currently used, but in future it will be the name that # is shown to the user when they are customizing perspectives by adding or # removing action sets etc. name = Str # The actions in this set. actions = List(Action) # The groups in this set. groups = List(Group) # The menus in this set. menus = List(Menu) # The tool bars in this set. tool_bars = List(ToolBar) # A mapping from human-readable names to globally unique IDs. # # This mapping is used when interpreting the first item in a location path # (i.e., the **path** trait of a **Location** instance). # # When the path is intepreted, the first component (i.e., the first item # before any '/') is checked to see if it is in the mapping, and if so it # is replaced with the value in the map. # # This technique allows paths to start with human readable names, as # opposed to IDs (which are required in order to manage the namespace of # all action sets). # # For example, in the Envisage workbench, the menu bar ID is: # # ``'envisage.workbench.menubar'`` # # Without aliases, you must specify a location like this: # # ``Location(path='envisage.workbench.menubar/ASubMenu/AGroup')`` # # This is a bit long-winded! Instead, you can define an alias: # # ``aliases = { 'MenuBar' : 'envisage.workbench.menubar' }`` # # In that case, you can specify a location like this: # # ``Location(path='MenuBar/ASubMenu/AGroup')`` # aliases = Dict(Str, Str) #### EOF ###################################################################### envisage-4.1.0/envisage/ui/action/__init__.py0000644000175100001440000000000011674464014022077 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/action/i_action_manager_builder.py0000644000175100001440000000135511674464014025343 0ustar ischnellusers00000000000000""" The interface for action manager builders. """ # Enthought library imports. from traits.api import Interface, List # Local imports. from action_set import ActionSet class IActionManagerBuilder(Interface): """ The interface for action manager builders. An action manager builder populates action managers (i.e. menus, menu bars and tool bars) from the menus, groups and actions defined in its action sets. """ # The action sets used by the builder. action_sets = List(ActionSet) def initialize_action_manager(self, action_manager, root): """ Initialize an action manager from the builder's action sets. """ #### EOF ###################################################################### envisage-4.1.0/envisage/ui/tasks/0000755000175100001440000000000011674464014017650 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/tasks/tasks_application.py0000644000175100001440000004233211674464014023736 0ustar ischnellusers00000000000000# Standard library imports. import cPickle import logging import os.path # Enthought library imports. from envisage.api import Application, ExtensionPoint from pyface.api import GUI, SplashScreen from pyface.image_resource import ImageResource from pyface.tasks.api import TaskLayout, TaskWindowLayout from traits.api import Bool, Callable, Directory, Event, HasStrictTraits, \ Instance, Int, List, Property, Str, Unicode, Vetoable from traits.etsconfig.api import ETSConfig # Local imports from task_window import TaskWindow from task_window_event import TaskWindowEvent, VetoableTaskWindowEvent # Logging. logger = logging.getLogger(__name__) class TasksApplication(Application): """ The entry point for an Envisage Tasks application. This class handles the common case for Tasks applications and is intended to be subclassed to modify its start/stop behavior, etc. """ # Extension point IDs. TASK_FACTORIES = 'envisage.ui.tasks.tasks' TASK_EXTENSIONS = 'envisage.ui.tasks.task_extensions' #### 'TasksApplication' interface ######################################### # The active task window (the last one to get focus). active_window = Instance(TaskWindow) # The PyFace GUI for the application. gui = Instance(GUI) # Icon for the whole application. Will be used to override all taskWindows # icons to have the same. icon = Instance(ImageResource, allow_none=True) #Any # The name of the application (also used on window title bars). name = Unicode # The splash screen for the application. By default, there is no splash # screen. splash_screen = Instance(SplashScreen) # The directory on the local file system used to persist window layout # information. state_location = Directory # Contributed task factories. This attribute is primarily for run-time # inspection; to instantiate a task, use the 'create_task' method. task_factories = ExtensionPoint(id=TASK_FACTORIES) # Contributed task extensions. task_extensions = ExtensionPoint(id=TASK_EXTENSIONS) # The list of task windows created by the application. windows = List(TaskWindow) # The factory for creating task windows. window_factory = Callable(TaskWindow) #### Application layout ################################################### # The default layout for the application. If not specified, a single window # will be created with the first available task factory. default_layout = List(TaskWindowLayout) # Whether to always apply the default *application level* layout when the # application is started. Even if this is False, the layout state of # individual tasks will be restored. always_use_default_layout = Bool(False) #### Application lifecycle events ######################################### # Fired after the initial windows have been created and the GUI event loop # has been started. application_initialized = Event # Fired immediately before the extant windows are destroyed and the GUI # event loop is terminated. application_exiting = Event # Fired when a task window has been created. window_created = Event(TaskWindowEvent) # Fired when a task window is opening. window_opening = Event(VetoableTaskWindowEvent) # Fired when a task window has been opened. window_opened = Event(TaskWindowEvent) # Fired when a task window is closing. window_closing = Event(VetoableTaskWindowEvent) # Fired when a task window has been closed. window_closed = Event(TaskWindowEvent) #### Protected interface ################################################## # An 'explicit' exit is when the the 'exit' method is called. # An 'implicit' exit is when the user closes the last open window. _explicit_exit = Bool(False) # Application state. _state = Instance('envisage.ui.tasks.tasks_application.' 'TasksApplicationState') ########################################################################### # 'IApplication' interface. ########################################################################### def run(self): """ Run the application. Returns: -------- Whether the application started successfully (i.e., without a veto). """ # Make sure the GUI has been created (so that, if required, the splash # screen is shown). gui = self.gui started = self.start() if started: # Create windows from the default or saved application layout. self._create_windows() # Start the GUI event loop. gui.set_trait_later(self, 'application_initialized', self) gui.start_event_loop() return started ########################################################################### # 'TasksApplication' interface. ########################################################################### def create_task(self, id): """ Creates the Task with the specified ID. Returns: -------- The new Task, or None if there is not a suitable TaskFactory. """ # Get the factory for the task. factory = self._get_task_factory(id) if factory is None: return None # Create the task using suitable task extensions. extensions = [ ext for ext in self.task_extensions if ext.task_id == id or not ext.task_id ] task = factory.create_with_extensions(extensions) task.id = factory.id return task def create_window(self, layout=None, restore=True, **traits): """ Creates a new TaskWindow, possibly with some Tasks. Parameters: ----------- layout : TaskWindowLayout, optional The layout to use for the window. The tasks described in the layout will be created and added to the window automatically. If not specified, the window will contain no tasks. restore : bool, optional (default True) If set, the application will restore old size and positions for the window and its panes, if possible. If a layout is not provided, this parameter has no effect. **traits : dict, optional Additional parameters to pass to ``window_factory()`` when creating the TaskWindow. Returns: -------- The new TaskWindow. """ window = self.window_factory(application=self, **traits) # Listen for the window events. window.on_trait_change(self._on_window_activated, 'activated') window.on_trait_change(self._on_window_opening, 'opening') window.on_trait_change(self._on_window_opened, 'opened') window.on_trait_change(self._on_window_closing, 'closing') window.on_trait_change(self._on_window_closed, 'closed') # Event notification. self.window_created = TaskWindowEvent(window=window) if layout: # Create and add tasks. for task_id in layout.get_tasks(): task = self.create_task(task_id) if task: window.add_task(task) else: logger.error('Missing factory for task with ID %r', task_id) # Apply a suitable layout. if restore: layout = self._restore_layout_from_state(layout) window.set_window_layout(layout) return window def exit(self, force=False): """ Exits the application, closing all open task windows. Each window is sent a veto-able closing event. If any window vetoes the close request, no window will be closed. Otherwise, all windows will be closed and the GUI event loop will terminate. This method is not called when the user clicks the close button on a window or otherwise closes a window through his or her window manager. It is only called via the File->Exit menu item. It can also, of course, be called programatically. Parameters: ----------- force : bool, optional (default False) If set, windows will receive no closing events and will be destroyed unconditionally. This can be useful for reliably tearing down regression tests, but should be used with caution. Returns: -------- A boolean indicating whether the application exited. """ self._explicit_exit = True try: if not force: for window in reversed(self.windows): window.closing = event = Vetoable() if event.veto: return False self._prepare_exit() for window in reversed(self.windows): window.destroy() window.closed = True finally: self._explicit_exit = False return True ########################################################################### # Protected interface. ########################################################################### def _create_windows(self): """ Called at startup to create TaskWindows from the default or saved application layout. """ # Build a list of TaskWindowLayouts. self._load_state() if self.always_use_default_layout or \ not self._state.previous_window_layouts: window_layouts = self.default_layout else: # Choose the stored TaskWindowLayouts, but only if all the task IDs # are still valid. window_layouts = self._state.previous_window_layouts for layout in window_layouts: for task_id in layout.get_tasks(): if not self._get_task_factory(task_id): logger.warning('Saved application layout references ' 'non-existent task %r. Falling back to ' 'default application layout.' % task_id) window_layouts = self.default_layout break else: continue break # Create a TaskWindow for each TaskWindowLayout. for window_layout in window_layouts: window = self.create_window(window_layout, restore=self.always_use_default_layout) window.open() def _get_task_factory(self, id): """ Returns the TaskFactory with the specified ID, or None. """ for factory in self.task_factories: if factory.id == id: return factory return None def _prepare_exit(self): """ Called immediately before the extant windows are destroyed and the GUI event loop is terminated. """ self.application_exiting = self self._save_state() def _load_state(self): """ Loads saved application state, if possible. """ state = TasksApplicationState() filename = os.path.join(self.state_location, 'application_memento') if os.path.exists(filename): # Attempt to unpickle the saved application state. try: with open(filename, 'r') as f: restored_state = cPickle.load(f) if state.version == restored_state.version: state = restored_state else: logger.warn('Discarding outdated application layout') except: # If anything goes wrong, log the error and continue. logger.exception('Restoring application layout from %s', filename) self._state = state def _restore_layout_from_state(self, layout): """ Restores an equivalent layout from saved application state. """ # First, see if a window layout matches exactly. match = self._state.get_equivalent_window_layout(layout) if match: # The active task is not part of the equivalency relation, so we # ensure that it is correct. match.active_task = layout.get_active_task() layout = match # If that fails, at least try to restore the layout of individual tasks. else: layout = layout.clone_traits() for i, item in enumerate(layout.items): id = item if isinstance(item, basestring) else item.id match = self._state.get_task_layout(id) if match: layout.items[i] = match return layout def _save_state(self): """ Saves the application state. """ # Grab the current window layouts. window_layouts = [ w.get_window_layout() for w in self.windows ] self._state.previous_window_layouts = window_layouts # Attempt to pickle the application state. filename = os.path.join(self.state_location, 'application_memento') try: with open(filename, 'w') as f: cPickle.dump(self._state, f) except: # If anything goes wrong, log the error and continue. logger.exception('Saving application layout') #### Trait initializers ################################################### def _default_layout_default(self): window_layout = TaskWindowLayout() if self.task_factories: window_layout.items = [ self.task_factories[0].id ] return [ window_layout ] def _gui_default(self): return GUI(splash_screen=self.splash_screen) def _state_location_default(self): state_location = os.path.join(ETSConfig.application_home, 'tasks', ETSConfig.toolkit) if not os.path.exists(state_location): os.makedirs(state_location) logger.debug('Tasks state location is %s', state_location) return state_location #### Trait change handlers ################################################ def _on_window_activated(self, window, trait_name, event): self.active_window = window def _on_window_opening(self, window, trait_name, event): # Event notification. self.window_opening = window_event = VetoableTaskWindowEvent( window=window) if window_event.veto: event.veto = True def _on_window_opened(self, window, trait_name, event): self.windows.append(window) # Event notification. self.window_opened = TaskWindowEvent(window=window) def _on_window_closing(self, window, trait_name, event): # Event notification. self.window_closing = window_event = VetoableTaskWindowEvent( window=window) if window_event.veto: event.veto = True else: # Store the layout of the window. window_layout = window.get_window_layout() self._state.push_window_layout(window_layout) # If we're exiting implicitly and this is the last window, save # state, because we won't get another chance. if len(self.windows) == 1 and not self._explicit_exit: self._prepare_exit() def _on_window_closed(self, window, trait_name, event): self.windows.remove(window) # Event notification. self.window_closed = TaskWindowEvent(window=window) # Was this the last window? if len(self.windows) == 0: # Invoke later to ensure that 'closed' event handlers get called # before 'stop()' does. self.gui.invoke_later(self.stop) class TasksApplicationState(HasStrictTraits): """ A class used internally by TasksApplication for saving and restoring application state. """ # TaskWindowLayouts for the windows extant at application exit. Only used if # 'always_use_default_layout' is disabled. previous_window_layouts = List(TaskWindowLayout) # A list of TaskWindowLayouts accumulated throughout the application's # lifecycle. window_layouts = List(TaskWindowLayout) # The "version" for the state data. This should be incremented whenever a # backwards incompatible change is made to this class or any of the layout # classes. This ensures that loading application state is always safe. version = Int(1) def get_equivalent_window_layout(self, window_layout): """ Gets an equivalent TaskWindowLayout, if there is one. """ for layout in self.window_layouts: if layout.is_equivalent_to(window_layout): return layout return None def get_task_layout(self, task_id): """ Gets a TaskLayout with the specified ID, there is one. """ for window_layout in self.window_layouts: for layout in window_layout.items: if layout.id == task_id: return layout return None def push_window_layout(self, window_layout): """ Merge a TaskWindowLayout into the accumulated list. """ self.window_layouts = [ layout for layout in self.window_layouts if not layout.is_equivalent_to(window_layout) ] self.window_layouts.insert(0, window_layout) envisage-4.1.0/envisage/ui/tasks/api.py0000644000175100001440000000040211674464014020767 0ustar ischnellusers00000000000000from preferences_category import PreferencesCategory from preferences_pane import PreferencesPane from task_extension import TaskExtension from task_factory import TaskFactory from task_window import TaskWindow from tasks_application import TasksApplication envisage-4.1.0/envisage/ui/tasks/task_window.py0000644000175100001440000000335411674464014022560 0ustar ischnellusers00000000000000# Enthought library imports. from pyface.image_resource import ImageResource from pyface.tasks.api import TaskWindow as PyfaceTaskWindow from traits.api import Instance, Property class TaskWindow(PyfaceTaskWindow): """ A TaskWindow for use with the Envisage Tasks plugin. """ # The application that created and is managing this window. application = Instance('envisage.ui.tasks.api.TasksApplication') # The window's icon. We override it so it can delegate to the application # icon if the window's icon is not set. icon = Property(Instance(ImageResource), depends_on='_icon') #### Protected interface ################################################## _icon = Instance(ImageResource, allow_none=True) ########################################################################### # Protected 'TaskWindow' interface. ########################################################################### def _get_title(self): """ If the application has a name, add it to the title. Otherwise, behave like the base class. """ if self._title or self.active_task is None: return self._title title = self.active_task.name if self.application.name: title = u'%s - %s' % (title, self.application.name) return title def _get_icon(self): """If we have an icon return it, else delegate to the application. """ if self._icon is not None: return self._icon elif self.application is not None: return self.application.icon else: return None def _set_icon(self, icon): """Explicitly set the icon to use. None is allowed. """ self._icon = icon envisage-4.1.0/envisage/ui/tasks/task_extension.py0000644000175100001440000000113711674464014023262 0ustar ischnellusers00000000000000# Enthought library imports. from pyface.tasks.action.api import SchemaAddition from traits.api import Callable, HasTraits, List, Str class TaskExtension(HasTraits): """ A bundle of items for extending a Task. """ # The ID of the task to extend. If the ID is omitted, the extension applies # to all tasks. task_id = Str # A list of menu bar and tool bar items to add to the set provided # by the task. actions = List(SchemaAddition) # A list of dock pane factories that will extend the dock panes provided by # the task. dock_pane_factories = List(Callable) envisage-4.1.0/envisage/ui/tasks/task_factory.py0000644000175100001440000000213411674464014022713 0ustar ischnellusers00000000000000# Enthought library imports. from traits.api import Callable, HasTraits, Str, Unicode class TaskFactory(HasTraits): """ A factory for creating a Task with some additional metadata. """ # The task factory's unique identifier. This ID is assigned to all tasks # created by the factory. id = Str # The task factory's user-visible name. name = Unicode # A callable with the following signature: # # callable(**traits) -> Task # # Often this attribute will simply be a Task subclass. factory = Callable def create(self, **traits): """ Creates the Task. The default implementation simply calls the 'factory' attribute. """ return self.factory(**traits) def create_with_extensions(self, extensions, **traits): """ Creates the Task using the specified TaskExtensions. """ task = self.create(**traits) for extension in extensions: task.extra_actions.extend(extension.actions) task.extra_dock_pane_factories.extend(extension.dock_pane_factories) return task envisage-4.1.0/envisage/ui/tasks/task_window_event.py0000644000175100001440000000065011674464014023755 0ustar ischnellusers00000000000000# Enthought library imports. from traits.api import HasTraits, Instance, Vetoable # Local imports. from task_window import TaskWindow class TaskWindowEvent(HasTraits): """ A task window lifecycle event. """ # The window that the event occurred on. window = Instance(TaskWindow) class VetoableTaskWindowEvent(TaskWindowEvent, Vetoable): """ A vetoable task window lifecycle event. """ pass envisage-4.1.0/envisage/ui/tasks/action/0000755000175100001440000000000011674464014021125 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/tasks/action/api.py0000644000175100001440000000022511674464014022247 0ustar ischnellusers00000000000000from task_window_launch_group import TaskWindowLaunchAction, \ TaskWindowLaunchGroup from task_window_toggle_group import TaskWindowToggleGroup envisage-4.1.0/envisage/ui/tasks/action/preferences_action.py0000644000175100001440000000321111674464014025332 0ustar ischnellusers00000000000000# Enthought library imports. from pyface.action.api import Action, Group class PreferencesAction(Action): """ An action that displays the preferences dialog. """ #### 'Action' interface ################################################### # A longer description of the action. description = 'Open the preferences dialog' # The action's name (displayed on menus/tool bar tools etc). name = 'Prefere&nces...' # A short description of the action used for tooltip text etc. tooltip = 'Open the preferences dialog' ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): from envisage.ui.tasks.preferences_dialog import \ PreferencesDialog window = event.task.window dialog = window.application.get_service(PreferencesDialog) ui = dialog.edit_traits(parent=window.control, kind='livemodal') if ui.result: window.application.preferences.save() class PreferencesGroup(Group): """ A group that contains the preferences action. """ #### 'Action' interface ################################################### # The group's identifier (unique within action manager). id = 'PreferencesGroup' ########################################################################### # 'object' interface. ########################################################################### def __init__(self, **traits): super(PreferencesGroup, self).__init__(PreferencesAction(), **traits) envisage-4.1.0/envisage/ui/tasks/action/task_window_launch_group.py0000644000175100001440000000434611674464014026605 0ustar ischnellusers00000000000000# Enthought library imports. from pyface.action.api import ActionItem, Group from pyface.tasks.api import TaskWindowLayout from pyface.tasks.action.api import TaskAction from traits.api import List, Str class TaskWindowLaunchAction(TaskAction): """ An Action that creates a task window with a single task. """ #### 'TaskWindowLaunchAction' interface ################################### task_id = Str ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): application = event.task.window.application window = application.create_window(TaskWindowLayout(self.task_id)) window.open() ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ def _task_changed(self, task): """ Name the action (unless a name has already been assigned). """ if task and not self.name: name = unicode() for factory in task.window.application.task_factories: if factory.id == self.task_id: name = factory.name break self.name = name class TaskWindowLaunchGroup(Group): """ A Group for creating task windows with a single task. """ #### 'Group' interface #################################################### id = 'TaskWindowLaunchGroup' items = List ########################################################################### # Private interface. ########################################################################### def _items_default(self): manager = self while isinstance(manager, Group): manager = manager.parent application = manager.controller.task.window.application items = [] for factory in application.task_factories: action = TaskWindowLaunchAction(task_id=factory.id) items.append(ActionItem(action=action)) return items envisage-4.1.0/envisage/ui/tasks/action/__init__.py0000644000175100001440000000000011674464014023224 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/tasks/action/exit_action.py0000644000175100001440000000144311674464014024007 0ustar ischnellusers00000000000000# Enthought library imports. from pyface.api import ImageResource from pyface.action.api import Action class ExitAction(Action): """ An action that exits the application. """ #### 'Action' interface ################################################### # A longer description of the action. description = 'Exit the application' # The action's name (displayed on menus/tool bar tools etc). name = 'E&xit' # A short description of the action used for tooltip text etc. tooltip = 'Exit the application' ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): event.task.window.application.exit() envisage-4.1.0/envisage/ui/tasks/action/task_window_toggle_group.py0000644000175100001440000000733611674464014026616 0ustar ischnellusers00000000000000# Enthought library imports. from pyface.action.api import Action, ActionItem, Group from traits.api import Any, Bool, Instance, List, Property, Unicode, \ on_trait_change class TaskWindowToggleAction(Action): """ An action for activating an application window. """ #### 'Action' interface ################################################### name = Property(Unicode, depends_on='window.active_task.name') style = 'toggle' #### 'TaskWindowToggleAction' interface ################################### # The window to use for this action. window = Instance('envisage.ui.tasks.task_window.TaskWindow') ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event=None): if self.window: self.window.activate() ########################################################################### # Private interface. ########################################################################### def _get_name(self): if self.window.active_task: return self.window.active_task.name return unicode() @on_trait_change('window:activated') def _window_activated(self): self.checked = True @on_trait_change('window:deactivated') def _window_deactivated(self): self.checked = False class TaskWindowToggleGroup(Group): """ A Group for toggling the activation state of an application's windows. """ #### 'Group' interface #################################################### id = 'TaskWindowToggleGroup' items = List #### 'TaskWindowToggleGroup' interface #################################### # The application that contains the group. application = Instance('envisage.ui.tasks.tasks_application.' 'TasksApplication') # The ActionManager to which the group belongs. manager = Any ########################################################################### # 'Group' interface. ########################################################################### def destroy(self): """ Called when the group is no longer required. """ super(TaskWindowToggleGroup, self).destroy() if self.application: self.application.on_trait_change( self._rebuild, 'window_opened, window_closed', remove=True) ########################################################################### # Private interface. ########################################################################### def _get_items(self): items = [] for window in self.application.windows: active = window == self.application.active_window action = TaskWindowToggleAction(window=window, checked=active) items.append(ActionItem(action=action)) return items def _rebuild(self): # Clear out the old group, then build the new one. for item in self.items: item.destroy() self.items = self._get_items() # Inform our manager that it needs to be rebuilt. self.manager.changed = True #### Trait initializers ################################################### def _application_default(self): return self.manager.controller.task.window.application def _items_default(self): self.application.on_trait_change(self._rebuild, 'window_opened, window_closed') return self._get_items() def _manager_default(self): manager = self while isinstance(manager, Group): manager = manager.parent return manager envisage-4.1.0/envisage/ui/tasks/preferences_pane.py0000644000175100001440000000553411674464014023535 0ustar ischnellusers00000000000000# Enthought library imports. from apptools.preferences.api import IPreferences, PreferencesHelper from traits.api import Callable, Dict, HasTraits, Instance, Str from traitsui.api import Controller class PreferencesPane(Controller): """ A panel for configuring application preferences. """ #### 'Controller' interface ############################################### # The preferences helper for which this pane is a view. model = Instance(PreferencesHelper) #### 'PreferencesPane' interface ########################################## # An identifier for the pane (unique within a category). id = Str # The ID of the category in which to place the pane. category = Str('General') # The pane appears after the pane with this ID. before = Str # The pane appears after the pane with this ID. after = Str # The preferences dialog to which the pane belongs. Set by the framework. dialog = Instance( 'envisage.ui.tasks.preferences_dialog.PreferencesDialog') # # The factory to use for creating the preferences model object, of form: # callable(**traits) -> PreferencesHelper # If not specified, the preferences helper must be supplied manually. model_factory = Callable #### Private interface #################################################### _model = Instance(PreferencesHelper) ########################################################################### # 'HasTraits' interface. ########################################################################### def trait_context ( self ): """ Re-implemented to use a copy of the model that is not connected to the preferences node. """ if self.model is None: if self.model_factory is not None: preferences = self.dialog.application.preferences self.model = self.model_factory(preferences = preferences) else: raise ValueError('A preferences pane must have a model!') self._model = self.model.clone_traits() self._model.preferences = None return { 'object': self._model, 'controller': self, 'handler': self } ########################################################################### # 'Handler' interface. ########################################################################### def apply(self, info=None): """ Handles the Apply button being clicked. """ trait_names = filter(self._model._is_preference_trait, self._model.trait_names()) self.model.copy_traits(self._model, trait_names) def close(self, info, is_ok): """ Handles the user attempting to close a dialog-based user interface. """ if is_ok: self.apply() return super(PreferencesPane, self).close(info, is_ok) envisage-4.1.0/envisage/ui/tasks/__init__.py0000644000175100001440000000000011674464014021747 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/ui/tasks/preferences_category.py0000644000175100001440000000141011674464014024414 0ustar ischnellusers00000000000000# Enthought library imports. from traits.api import HasTraits, Str, Unicode class PreferencesCategory(HasTraits): """ The description for a container of PreferencesPanes. """ # The globally unique identifier for the category. id = Str # The user-visible name of the category. name = Unicode # The category appears after the category with this ID. before = Str # The category appears after the category with this ID. after = Str ########################################################################### # Protected interface. ########################################################################### def _name_default(self): """ By default, use the ID for the name. """ return self.id envisage-4.1.0/envisage/ui/tasks/preferences_dialog.py0000644000175100001440000001017511674464014024046 0ustar ischnellusers00000000000000# Enthought library imports. from traits.api import Bool, HasTraits, Instance, List, Unicode, \ on_trait_change from traitsui.api import Item, Handler, ListEditor, View from pyface.tasks.topological_sort import before_after_sort # Local imports. from preferences_category import PreferencesCategory from preferences_pane import PreferencesPane class PreferencesTab(HasTraits): """ An object used internally by PreferencesDialog. """ name = Unicode panes = List(PreferencesPane) view = View(Item('panes', editor = ListEditor(style = 'custom'), show_label = False, style = 'readonly'), resizable = True) class PreferencesDialog(Handler): """ A dialog for editing preferences. """ #### 'PreferencesDialog' interface ######################################## # The application that created and is managing this dialog. application = Instance('envisage.ui.tasks.api.TasksApplication') # The list of categories to use when building the dialog. categories = List(PreferencesCategory) # The list of panes to use when building the dialog. panes = List(PreferencesPane) # Should the Apply button be shown? show_apply = Bool(False) #### Private interface #################################################### _tabs = List(PreferencesTab) ########################################################################### # 'HasTraits' interface. ########################################################################### def trait_context ( self ): """ Returns the default context to use for editing or configuring traits. """ return { 'object': self, 'handler': self } def traits_view(self): """ Build the dynamic dialog view. """ buttons = ['OK', 'Cancel'] if self.show_apply: buttons = ['Apply'] + buttons # Only show the tab bar if there is more than one category. tabs_style = 'custom' if len(self._tabs) > 1 else 'readonly' return View(Item('_tabs', editor = ListEditor(page_name = '.name', style ='custom', use_notebook = True), show_label = False, style = tabs_style), buttons = buttons, kind = 'livemodal', resizable = True, title = 'Preferences') ########################################################################### # 'Handler' interface. ########################################################################### def apply(self, info=None): """ Handles the Apply button being clicked. """ for tab in self._tabs: for pane in tab.panes: pane.apply() def close(self, info, is_ok): """ Handles the user attempting to close a dialog-based user interface. """ if is_ok: self.apply() return super(PreferencesDialog, self).close(info, is_ok) ########################################################################### # Protected interface. ########################################################################### @on_trait_change('categories, panes') def _update_tabs(self): # Build a { category id -> [ PreferencePane ] } map. categories = self.categories[:] category_map = dict((category.id, []) for category in categories) for pane in self.panes: if pane.category in category_map: category_map[pane.category].append(pane) else: categories.append(PreferencesCategory(id=pane.category)) category_map[pane.category] = [ pane ] # Construct the appropriately sorted list of preference tabs. tabs = [] for category in before_after_sort(categories): panes = before_after_sort(category_map[category.id]) tabs.append(PreferencesTab(name = category.name, panes=panes)) self._tabs = tabs envisage-4.1.0/envisage/ui/tasks/tasks_plugin.py0000644000175100001440000001152511674464014022731 0ustar ischnellusers00000000000000# Enthought library imports. from envisage.api import ExtensionPoint, Plugin, ServiceOffer from traits.api import Callable, List # Local imports. from preferences_category import PreferencesCategory from task_factory import TaskFactory from task_extension import TaskExtension # Constants. PKG = '.'.join(__name__.split('.')[:-1]) class TasksPlugin(Plugin): """ The Envisage Tasks plugin. The Tasks plugin uses PyFace Tasks to provide an extensible framework for building user interfaces. For more information, see the Tasks User Manual. """ # The IDs of the extension point that this plugin offers. PREFERENCES_CATEGORIES = PKG + '.preferences_categories' PREFERENCES_PANES = PKG + '.preferences_panes' TASKS = PKG + '.tasks' TASK_EXTENSIONS = PKG + '.task_extensions' # The IDs of the extension points that this plugin contributes to. SERVICE_OFFERS = 'envisage.service_offers' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'envisage.ui.tasks' # The plugin's name (suitable for displaying to the user). name = 'Tasks' #### Extension points offered by this plugin ############################## preferences_categories = ExtensionPoint( List(PreferencesCategory), id=PREFERENCES_CATEGORIES, desc=""" This extension point makes preference categories available to the application. Note that preference categories will be created automatically if necessary; this extension point is useful when one wants to ensure that a category is inserted at a specific location. """) preferences_panes = ExtensionPoint( List(Callable), id=PREFERENCES_PANES, desc=""" A preferences pane appears in the preferences dialog to allow the user manipulate certain preference values. Each contribution to this extension point must be a factory that creates a preferences pane, where 'factory' means any callable with the following signature:: callable(**traits) -> PreferencesPane The easiest way to contribute such a factory is to create a class that derives from 'envisage.ui.tasks.api.PreferencesPane'. """) tasks = ExtensionPoint( List(TaskFactory), id=TASKS, desc=""" This extension point makes tasks avaiable to the application. Each contribution to the extension point must be an instance of 'envisage.tasks.api.TaskFactory. """) task_extensions = ExtensionPoint( List(TaskExtension), id=TASK_EXTENSIONS, desc=""" This extension point permits the contribution of new actions and panes to existing tasks (without creating a new task). Each contribution to the extension point must be an instance of 'envisage.tasks.api.TaskExtension'. """) #### Contributions to extension points made by this plugin ################ my_service_offers = List(contributes_to=SERVICE_OFFERS) def _my_service_offers_default(self): preferences_dialog_service_offer = ServiceOffer( protocol = 'envisage.ui.tasks.preferences_dialog.' 'PreferencesDialog', factory = self._create_preferences_dialog_service) return [ preferences_dialog_service_offer ] my_task_extensions = List(contributes_to=TASK_EXTENSIONS) def _my_task_extensions_default(self): from action.exit_action import ExitAction from action.preferences_action import PreferencesGroup from pyface.tasks.action.api import DockPaneToggleGroup, \ SchemaAddition actions = [ SchemaAddition(id='Exit', factory=ExitAction, path='MenuBar/File'), SchemaAddition(id='Preferences', factory=PreferencesGroup, path='MenuBar/Edit'), SchemaAddition(id='DockPaneToggleGroup', factory=DockPaneToggleGroup, path='MenuBar/View') ] return [ TaskExtension(actions=actions) ] ########################################################################### # Private interface. ########################################################################### def _create_preferences_dialog_service(self): """ Factory method for preferences dialog service. """ from preferences_dialog import PreferencesDialog dialog = PreferencesDialog(application = self.application) dialog.trait_set(categories = self.preferences_categories, panes = [ factory(dialog = dialog) for factory in self.preferences_panes ]) return dialog envisage-4.1.0/envisage/ui/__init__.py0000644000175100001440000000000011674464014020622 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/import_manager.py0000644000175100001440000000422011674464014021462 0ustar ischnellusers00000000000000""" The default import manager implementation. """ # Enthought library imports. from traits.api import HasTraits, implements # Local imports. from i_import_manager import IImportManager class ImportManager(HasTraits): """ The default import manager implementation. Its just a guess, but I think using an import manager to do all imports will make debugging easier (as opposed to just letting imports happen from all over the place). """ implements(IImportManager) ########################################################################### # 'IImportManager' interface. ########################################################################### def import_symbol(self, symbol_path): """ Import the symbol defined by the specified symbol path. """ if ':' in symbol_path: module_name, symbol_name = symbol_path.split(':') module = self._import_module(module_name) symbol = eval(symbol_name, module.__dict__) else: components = symbol_path.split('.') module_name = '.'.join(components[:-1]) symbol_name = components[-1] module = __import__( module_name, globals(), locals(), [symbol_name] ) symbol = getattr(module, symbol_name) # Event notification. self.symbol_imported = symbol return symbol ########################################################################### # Private interface. ########################################################################### def _import_module(self, module_name): """ Import the module with the specified (and possibly dotted) name. Returns the imported module. This method is copied from the documentation of the '__import__' function in the Python Library Reference Manual. """ module = __import__(module_name) components = module_name.split('.') for component in components[1:]: module = getattr(module, component) return module #### EOF ###################################################################### envisage-4.1.0/envisage/extension_provider.py0000644000175100001440000000312011674464014022402 0ustar ischnellusers00000000000000""" The default base class for extension providers. """ # Enthought library imports. from traits.api import Event, HasTraits, implements # Local imports. from extension_point_changed_event import ExtensionPointChangedEvent from i_extension_provider import IExtensionProvider class ExtensionProvider(HasTraits): """ The default base class for extension providers. """ implements(IExtensionProvider) #### 'IExtensionProvider' interface ####################################### # The event fired when one of the provider's extension points has been # changed (where 'changed' means that the provider has added or removed # contributions to or from an extension point). extension_point_changed = Event(ExtensionPointChangedEvent) def get_extension_points(self): """ Return the extension points offered by the provider. """ return [] def get_extensions(self, extension_point_id): """ Return the provider's extensions to an extension point. """ return [] ##### Protected 'ExtensionProvider' interface ############################# def _fire_extension_point_changed( self, extension_point_id, added, removed, index ): """ Fire an extension point changed event. """ self.extension_point_changed = ExtensionPointChangedEvent( extension_point_id = extension_point_id, added = added, removed = removed, index = index ) return #### EOF ###################################################################### envisage-4.1.0/envisage/api.py0000644000175100001440000000311611674464014017232 0ustar ischnellusers00000000000000""" Envisage package Copyright 2003-2007 Enthought, Inc. """ from i_application import IApplication from i_extension_point import IExtensionPoint from i_extension_point_user import IExtensionPointUser from i_extension_provider import IExtensionProvider from i_extension_registry import IExtensionRegistry from i_import_manager import IImportManager from i_plugin import IPlugin from i_plugin_activator import IPluginActivator from i_plugin_manager import IPluginManager from i_service_registry import IServiceRegistry from application import Application from category import Category from class_load_hook import ClassLoadHook from egg_plugin_manager import EggPluginManager from extension_registry import ExtensionRegistry from extension_point import ExtensionPoint, contributes_to from extension_point_binding import ExtensionPointBinding, bind_extension_point from extension_provider import ExtensionProvider from extension_point_changed_event import ExtensionPointChangedEvent from import_manager import ImportManager from plugin import Plugin from plugin_activator import PluginActivator from plugin_extension_registry import PluginExtensionRegistry from plugin_manager import PluginManager from provider_extension_registry import ProviderExtensionRegistry from service import Service from service_offer import ServiceOffer from service_registry import ServiceRegistry from twisted_application import TwistedApplication from unknown_extension import UnknownExtension from unknown_extension_point import UnknownExtensionPoint #### EOF ###################################################################### envisage-4.1.0/envisage/plugin_manager.py0000644000175100001440000001307211674464014021453 0ustar ischnellusers00000000000000""" The default plugin manager implementation. """ # Standard library imports. import logging # Enthought library imports. from traits.api import Event, HasTraits, Instance, List, implements # Local imports. from i_application import IApplication from i_plugin import IPlugin from i_plugin_manager import IPluginManager from plugin_event import PluginEvent # Logging. logger = logging.getLogger(__name__) class PluginManager(HasTraits): """ The default plugin manager implementation. """ implements(IPluginManager) #### 'IPluginManager' interface ########################################### #### Events #### # Fired when a plugin has been added to the manager. plugin_added = Event(PluginEvent) # Fired when a plugin has been removed from the manager. plugin_removed = Event(PluginEvent) #### 'PluginManager' interface ############################################ # The application that the plugin manager is part of. application = Instance(IApplication) #### Private interface #################################################### # The plugins that the manager manages! _plugins = List(IPlugin) ########################################################################### # 'object' interface. ########################################################################### def __init__(self, plugins=None, **traits): """ Constructor. """ super(PluginManager, self).__init__(**traits) # We allow the caller to specify an initial list of plugins, but the # list itself is not part of the public API. To add and remove plugins # after construction, use the 'add_plugin' and 'remove_plugin' methods # respectively. The manager is also iterable, so to iterate over the # plugins use 'for plugin in plugin_manager'. if plugins is not None: self._plugins = plugins return def __iter__(self): """ Return an iterator over the manager's plugins. """ return iter(self._plugins) ########################################################################### # 'IPluginManager' interface. ########################################################################### def add_plugin(self, plugin): """ Add a plugin to the manager. """ self._plugins.append(plugin) self.plugin_added = PluginEvent(plugin=plugin) return def get_plugin(self, plugin_id): """ Return the plugin with the specified Id. """ for plugin in self._plugins: if plugin_id == plugin.id: break else: plugin = None return plugin def remove_plugin(self, plugin): """ Remove a plugin from the manager. """ self._plugins.remove(plugin) self.plugin_removed = PluginEvent(plugin=plugin) return def start(self): """ Start the plugin manager. """ map(lambda plugin: self.start_plugin(plugin), self._plugins) return def start_plugin(self, plugin=None, plugin_id=None): """ Start the specified plugin. """ plugin = plugin or self.get_plugin(plugin_id) if plugin is not None: logger.debug('plugin %s starting', plugin.id) plugin.activator.start_plugin(plugin) logger.debug('plugin %s started', plugin.id) else: raise SystemError('no such plugin %s' % plugin_id) return def stop(self): """ Stop the plugin manager. """ # We stop the plugins in the reverse order that they were started. stop_order = self._plugins[:] stop_order.reverse() map(lambda plugin: self.stop_plugin(plugin), stop_order) return def stop_plugin(self, plugin=None, plugin_id=None): """ Stop the specified plugin. """ plugin = plugin or self.get_plugin(plugin_id) if plugin is not None: logger.debug('plugin %s stopping', plugin.id) plugin.activator.stop_plugin(plugin) logger.debug('plugin %s stopped', plugin.id) else: raise SystemError('no such plugin %s' % plugin_id) return ########################################################################### # 'PluginManager' interface. ########################################################################### def _application_changed(self, trait_name, old, new): """ Static trait change handler. """ self._update_plugin_application([], self._plugins) return ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ def __plugins_changed(self, trait_name, old, new): """ Static trait change handler. """ self._update_plugin_application(old, new) return def __plugins_items_changed(self, trait_name, old, new): """ Static trait change handler. """ self._update_plugin_application(new.removed, new.added) return #### Methods ############################################################## def _update_plugin_application(self, removed, added): """ Update the 'application' trait of plugins added/removed. """ for plugin in removed: plugin.application = None for plugin in added: plugin.application = self.application return #### EOF ###################################################################### envisage-4.1.0/envisage/category.py0000644000175100001440000000107211674464014020275 0ustar ischnellusers00000000000000""" A definition of a category to be added to a class. """ # Enthought library imports. from traits.api import HasTraits, Str class Category(HasTraits): """ A definition of a category to be added to a class. """ #### 'Category' interface ################################################# # The name of the category class (the class that you want to add). class_name = Str # The name of the class that you want to add the category to. target_class_name = Str #### EOF ###################################################################### envisage-4.1.0/envisage/egg_utils.py0000644000175100001440000000452211674464014020445 0ustar ischnellusers00000000000000""" Utility functions for working with Python Eggs. """ # Standard library imports. import pkg_resources # Enthought library imports. from traits.util.toposort import topological_sort def get_entry_points_in_egg_order(working_set, entry_point_name): """ Return entry points in Egg dependency order. """ # Find all distributions that actually contain contributions to the # entry point. distributions = get_distributions_with_entry_point( working_set, entry_point_name ) # Order them in dependency order (i.e. ordered by their requirements). distributions = get_distributions_in_egg_order(working_set, distributions) entry_points = [] for distribution in distributions: map = distribution.get_entry_map(entry_point_name) entry_points.extend(map.values()) return entry_points def get_distributions_with_entry_point(working_set, entry_point_name): """ Return all distributions that contribute to an entry point. """ distributions = [] for distribution in working_set: if len(distribution.get_entry_map(entry_point_name)) > 0: distributions.append(distribution) return distributions def get_distributions_in_egg_order(working_set, distributions=None): """ Return all distributions in Egg dependency order. """ # If no specific list of distributions is specified then use all # distributions in the working set. if distributions is None: distributions = working_set # Build a dependency graph. graph = {} for distribution in distributions: arcs = graph.setdefault(distribution, []) arcs.extend(get_requires(working_set, distribution)) distributions = topological_sort(graph) distributions.reverse() return distributions def get_requires(working_set, distribution): """ Return all of the other distributions that a distribution requires. """ requires = [] for requirement in distribution.requires(): required = working_set.find(requirement) # fixme: For some reason, the resolution of requirements sometimes # results in 'None' being returned instead of a distribution. if required is not None: requires.append(working_set.find(requirement)) return requires #### EOF ###################################################################### envisage-4.1.0/envisage/i_plugin_activator.py0000644000175100001440000000172111674464014022343 0ustar ischnellusers00000000000000""" The plugin activator interface. """ # Enthought library imports. from traits.api import Interface class IPluginActivator(Interface): """ The plugin activator interface. A plugin activator is really just a collection of two strategies - one to start the plugin and one to stop it. We use an activator so that the framework can implement default start and stop strategies without forcing the plugin writer to call 'super' if they override the 'start' and 'stop' methods on 'IPlugin'. I'm not sure that having to call 'super' is such a burden, but some people seem to like it this way, and it does mean one less thing for a plugin writer to have to remember to do! """ def start_plugin(self, plugin): """ Start the specified plugin. """ def stop_plugin(self, plugin): """ Stop the specified plugin. """ #### EOF ###################################################################### envisage-4.1.0/envisage/developer/0000755000175100001440000000000011674464014020073 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/ui/0000755000175100001440000000000011674464014020510 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/ui/api.py0000644000175100001440000000005611674464014021634 0ustar ischnellusers00000000000000from view.plugin_browser import browse_plugin envisage-4.1.0/envisage/developer/ui/developer_ui_plugin.py0000644000175100001440000000341511674464014025125 0ustar ischnellusers00000000000000""" The developer UI plugin. """ # Enthought library imports. from envisage.api import Plugin from traits.api import List class DeveloperUIPlugin(Plugin): """ The developer UI plugin. This plugin contains the UI part of the tools that (hopefully) help developers to inspect and debug a running Envisage workbench application. """ # The plugin Id. ID = 'envisage.developer.ui' # Extension points Ids. PERSPECTIVES = 'envisage.ui.workbench.perspectives' VIEWS = 'envisage.ui.workbench.views' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = ID # The plugin's name (suitable for displaying to the user). name = 'Developer UI' #### 'DeveloperUIPlugin' interface ######################################## #### Extension points offered by this plugin ############################## # None. #### Contributions to extension points made by this plugin ################ perspectives = List(contributes_to=PERSPECTIVES) def _perspectives_default(self): """ Trait initializer. """ from envisage.developer.ui.perspective.api import ( DeveloperPerspective ) return [DeveloperPerspective] views = List(contributes_to=VIEWS) def _views_default(self): """ Trait initializer. """ from view.api import ( ApplicationBrowserView, ExtensionRegistryBrowserView, ServiceRegistryBrowserView ) views = [ ApplicationBrowserView, ExtensionRegistryBrowserView, ServiceRegistryBrowserView ] return views #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/__init__.py0000644000175100001440000000000011674464014022607 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/ui/perspective/0000755000175100001440000000000011674464014023041 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/ui/perspective/api.py0000644000175100001440000000006711674464014024167 0ustar ischnellusers00000000000000from developer_perspective import DeveloperPerspective envisage-4.1.0/envisage/developer/ui/perspective/developer_perspective.py0000644000175100001440000000273411674464014030017 0ustar ischnellusers00000000000000""" The Developer perspective. """ # Enthought library imports. from pyface.workbench.api import Perspective, PerspectiveItem class DeveloperPerspective(Perspective): """ The Developer perspective. This perspective is intented to contain views and editors useful for inspecting and debugging a running Envisage application. """ # The root of all view Ids in this package. ROOT = 'envisage.developer.ui.view' # View Ids. APPLICATION_BROWSER_VIEW = ROOT + '.application_browser_view' EXTENSION_REGISTRY_BROWSER_VIEW = ROOT + '.extension_registry_browser_view' SERVICE_REGISTRY_BROWSER_VIEW = ROOT + '.service_registry_browser_view' # The perspective's name. name = 'Developer' # Should the editor area be shown in this perspective? show_editor_area = True # The contents of the perspective. contents = [ PerspectiveItem( id = APPLICATION_BROWSER_VIEW, position = 'left' ), PerspectiveItem( id = EXTENSION_REGISTRY_BROWSER_VIEW, position = 'bottom', relative_to = APPLICATION_BROWSER_VIEW ), PerspectiveItem( id = 'Python', position = 'bottom', ), PerspectiveItem( id = SERVICE_REGISTRY_BROWSER_VIEW, position = 'right', ), ] #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/perspective/__init__.py0000644000175100001440000000000011674464014025140 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/ui/view/0000755000175100001440000000000011674464014021462 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/ui/view/extension_registry_browser_view.py0000644000175100001440000000404111674464014030574 0ustar ischnellusers00000000000000""" A view that allows a developer to browse the extension registry. """ # Enthought library imports. from pyface.workbench.api import TraitsUIView from traits.api import Instance # The code browser protocol. CODE_BROWSER = 'envisage.developer.code_browser.api.CodeBrowser' class ExtensionRegistryBrowserView(TraitsUIView): """ A view that allows a developer to browse the extension registry. """ #### 'IWorkbenchPart' interface ########################################### # The part's globally unique identifier. id = 'envisage.developer.ui.view.extension_registry_browser_view' # The part's name (displayed to the user). name = 'Extension Points' #### 'IView' interface #################################################### # The category that the view belongs to (this can used to group views when # they are displayed to the user). category = 'Developer' #### 'ExtensionRegistryBrowserView' interface ############################# # The code browser used to parse Python code. code_browser = Instance(CODE_BROWSER) ########################################################################### # 'TraitsUIView' interface. ########################################################################### def _obj_default(self): """ Trait initializer. """ # Local imports. from extension_registry_browser import ExtensionRegistryBrowser extension_registry_browser = ExtensionRegistryBrowser( application = self.window.application, code_browser = self.code_browser ) return extension_registry_browser ########################################################################### # 'ExtensionRegistryBrowserView' interface. ########################################################################### def _code_browser_default(self): """ Trait initializer. """ return self.window.application.get_service(CODE_BROWSER) #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/view/service_registry_browser.py0000644000175100001440000001522411674464014027173 0ustar ischnellusers00000000000000""" A view showing a summary of the running application. """ # Standard library imports. import inspect # Enthought library imports. from envisage.api import IApplication, IExtensionPoint from envisage.api import IServiceRegistry from envisage.developer.code_browser.api import CodeBrowser from apptools.io.api import File from traits.api import Any, HasTraits, Instance from traitsui.api import Item, TreeEditor, View # fixme: non-api import. from envisage.plugins.text_editor.editor.text_editor import TextEditor # Local imports. from service_registry_browser_tree import \ service_registry_browser_tree_nodes service_registry_browser_view = View( Item( name = 'service_registry_model', show_label = False, editor = TreeEditor( nodes = service_registry_browser_tree_nodes, editable = False, orientation = 'vertical', hide_root = True, show_icons = True, on_dclick = 'object.dclick' ) ), resizable = True, style = 'custom', title = 'Service Registry', width = .1, height = .1 ) class ServiceRegistryBrowser(HasTraits): """ An extension registry browser. Actually, this class exists just because to use a trait editor we have to have a trait to edit! """ #### 'ServiceRegistryBrowser' interface ################################# # The application that whose extension registry we are browsing. application = Instance(IApplication) # The code browser that we use to parse plugin source code. code_browser = Instance(CodeBrowser) # The extension registry that we are browsing. service_registry = Instance(IServiceRegistry) # The extension registry that we are browsing. service_registry_model = Any#Instance(IServiceRegistry) # The workbench service. workbench = Instance('envisage.ui.workbench.api.Workbench') # The default traits UI view. traits_view = service_registry_browser_view ########################################################################### # 'ServiceRegistryBrowser' interface. ########################################################################### #### Trait initializers ################################################### def _service_registry_default(self): """ Trait initializer. """ return self.application.service_registry def _service_registry_model_default(self): """ Trait initializer. """ from service_registry_browser_tree import ServiceRegistryModel return ServiceRegistryModel(service_registry=self.service_registry) def _workbench_default(self): """ Trait initializer. """ workbench = self.application.get_service( 'envisage.ui.workbench.workbench.Workbench' ) return workbench #### Methods ############################################################## def dclick(self, obj): """ Called when an object in the tree is double-clicked. """ if hasattr(obj, '_service_id_'): protocol = obj._protocol_ id = obj._service_id_ service = obj.value for plugin in self.application: if id in plugin._service_ids: self.dclick_service(plugin, protocol, service) break else: self.workbench.information( 'Service not created by a plugin (%s)' % repr(service) ) return def dclick_service(self, plugin, protocol, obj): """ Called when an extension is double-clicked. """ # Parse the plugin source code. module = self._parse_plugin(plugin) # Get the plugin klass. klass = self._get_plugin_klass(module, plugin) # Edit the plugin. editor = self.workbench.edit( self._get_file_object(plugin), kind=TextEditor ) # Was the service offered declaratively? trait_name = self._get_service_trait(plugin, protocol, obj) if trait_name is not None: # Does the trait have a default initializer? initializer = klass.methods.get('_%s_default' % trait_name) if initializer is not None: lineno = initializer.lineno else: attribute = klass.attributes.get(trait_name) lineno = attribute.lineno else: lineno = klass.lineno editor.select_line(lineno) return ########################################################################### # Private interface. ########################################################################### def _get_service_trait(self, plugin, protocol, obj): """ Return the servicetrait with the specifed Id. Return None if the service was not declared via a trait. """ service_traits = plugin.traits(service=True) protocol = self.application.import_symbol(protocol) for trait_name, trait in service_traits.items(): if protocol == self._get_service_protocol(trait): break else: trait_name = None return trait_name def _get_service_protocol(self, trait): """ Determine the protocol to register a service trait with. """ # If a specific protocol was specified then use it. if trait.service_protocol is not None: protocol = trait.service_protocol # Otherwise, use the type of the objects that can be assigned to the # trait. # # fixme: This works for 'Instance' traits, but what about 'AdaptsTo' # and 'AdaptedTo' traits? else: # Note that in traits the protocol can be an actual class or # interfacem or the *name* of a class or interface. This allows # us to lazy load them! protocol = trait.trait_type.klass return protocol def _get_plugin_klass(self, module, plugin): """ Get the klass that defines the plugin. """ for name, klass in module.klasses.items(): if name == type(plugin).__name__: break else: klass = None return klass def _get_file_object(self, obj): """ Return a 'File' object for the object's source file. """ return File(path=inspect.getsourcefile(type(obj))) def _parse_plugin(self, plugin): """ Parse the plugin source code. """ filename = self._get_file_object(plugin).path return self.code_browser.read_file(filename) #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/view/plugin_browser.py0000644000175100001440000001576111674464014025107 0ustar ischnellusers00000000000000""" A UI for browsing a plugin. """ # Enthought library imports. from envisage.api import ExtensionPoint, IPlugin from traits.api import Delegate, HasTraits, Instance, List, Property from traits.api import Code, Str from traitsui.api import Item, TableEditor, View, VGroup from traitsui.table_column import ObjectColumn # fixme: non-api! class ExtensionPointModel(Hastraits): """ A model for browsing an extension point. """ # The plugin that offered the extension point. plugin = Instance(IPlugin) # The extension point. extension_point = Instance(IExtensionPoint) #### 'ExtensionPointModel' interface ###################################### class ExtensionModel(Hastraits): """ A model for browsing a contribution to an extension point. """ # The plugin that made the contribution. plugin = Instance(IPlugin) #### 'ContributionModel' interface ######################################## # The Id of the extension point that the contribution is for. extension_point_id = Str # The contributions to the extension point. contributions = List ########################################################################### # 'ApplicationModel' interface. ########################################################################### #### Trait initializers ################################################### def _contributions_default(self): """ Trait initializer. """ return plugin.application.get_extensions(self.extension_point_id) class PluginModel(HasTraits): """ A model for browsing a plugin. """ # The plugin that we are a model for. plugin = Instance(IPlugin) #### 'PluginModel' interface ############################################## # Models for each of the plugin's extension points. extension_point_models = List(ExtensionPointModel) # Models for each of the plugin's contributions to extension points. extension_models = List(ExtensionModel) ########################################################################### # 'ApplicationModel' interface. ########################################################################### #### Trait initializers ################################################### def _extension_models_default(self): """ Trait initializer. """ extension_modelss = [ ExtensionModel( plugin = plugin, extension_point_id = extension_point.id ) for extension_point in plugin.get_extension_points() ] return extension_models def _extension_point_models_default(self): """ Trait initializer. """ extension_point_models = [ ExtensionPointModel( plugin = plugin, extension_point = extension_point ) for extension_point in plugin.get_extension_points() ] return extension_point_models class ApplicationModel(HasTraits): """ A model for browsing an application. """ # The application that we are a model for. application = Instance(IApplication) #### 'ApplicationModel' interface ######################################### # Models for each of the application's plugins. plugin_models = List(PluginModel) ########################################################################### # 'ApplicationModel' interface. ########################################################################### #### Trait initializers ################################################### def _plugin_models_default(self): """ Trait initializer. """ return [PluginModel(plugin=plugin) for plugin in self.application] extension_point_table_editor = TableEditor( columns = [ ObjectColumn(name='id'), #ObjectColumn(name='desc') ], # selected = 'extension_point_selected', editable = True, edit_view = View(Item(name='desc', show_label=False), style='custom') ) plugin_browser_view = View( VGroup( Item(name='id'), Item(name='name'), label='General' ), VGroup( Item( name = 'extension_points', editor = extension_point_table_editor, show_label = False ), label='Extension Points', ), width = .8, height = .6 ) class ExtensionPointBrowser(HasTraits): """ The model used to view extension points. This browser is required because 'ExatenionPoint' instances are trait *types* and therefore do not have traits themselves and so this class is really just a 'traitified' wrapper. """ #### 'ExtensionPointBrowser' interface #################################### # The extension point that we are browsing. extension_point = Instance(ExtensionPoint) # The extension point's globally unique Id. id = Str # The extension point's description. desc = Code#Str ########################################################################### # 'ExtensionPoint' browser interface. ########################################################################### def _id_default(self): """ Trait initializer. """ return self.extension_point.id def _desc_default(self): """ Trait initializer. """ desc = self.extension_point.desc.strip() lines = [line.replace(' ', '', 2) for line in desc.splitlines()] return '\n'.join(lines) # Convenience trait to delegate an attribute to a plugin. DelegatedToPlugin = Delegate('plugin', modify=True) class PluginBrowser(HasTraits): """ A plugin browser. Actually, this class exists just because to use a trait editor we have to have a trait to edit! """ #### 'IPlugin' interface ################################################## # The plugins Id. id = DelegatedToPlugin # The plugin name. name = DelegatedToPlugin #### 'PluginBrowser' interface ############################################ # The extension points offered by the plugin. extension_points = Property(List) # The plugin that we are browsing. plugin = Instance(IPlugin) # The default traits UI view. traits_view = plugin_browser_view ########################################################################### # 'PluginBrowser' interface. ########################################################################### def _get_extension_points(self): """ Property getter. """ extension_points = [ ExtensionPointBrowser(extension_point=extension_point) for extension_point in self.plugin.extension_points ] return extension_points def browse_plugin(plugin): """ Browse a plugin. """ import inspect if inspect.isclass(plugin): plugin = plugin() plugin_browser = PluginBrowser(plugin=plugin) plugin_browser.configure_traits(view=plugin_browser_view) return #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/view/service_registry_browser_tree.py0000644000175100001440000000730411674464014030212 0ustar ischnellusers00000000000000""" The nodes used in the service registry browser tree. """ # Enthought library imports. from envisage.api import IExtensionPoint, IServiceRegistry from traits.api import Any, Dict, HasTraits, Instance, Int, List from traits.api import Property, Str, Undefined from traitsui.api import TreeNode # fixme: non-api imports. from traitsui.value_tree import SingleValueTreeNodeObject from traitsui.value_tree import value_tree_nodes class ServiceModel(HasTraits): """ A model of a registered service. """ # The service Id. id = Int # The service object. obj = Any # The service properties. properties = Dict class ProtocolModel(HasTraits): """ A model of all of the services of a single protocol. """ # The protocol (i.e. type) name. name = Str # All of the services offered for the protocol. services = List(ServiceModel) class ServiceRegistryModel(HasTraits): """ A model of a service registry. This model groups services by protocol. """ # The service registry that we are a model of. service_registry = Instance(IServiceRegistry) # The protocols contained in the registry. protocols = Property(List(ProtocolModel)) ########################################################################### # 'ServiceRegistryModel' interface. ########################################################################### def _get_protocols(self): """ Trait property getter. """ # fixme: Reaching into service registry. Not only is it ugly, but it # only works for the default implementation. Need to make this kind # of information available via the public API. all_services = self.service_registry._services.items() protocols = {} for service_id, (protocol_name, obj, properties) in all_services: protocol = protocols.get(protocol_name) if protocol is None: protocol = ProtocolModel(name=protocol_name) protocols[protocol_name] = protocol service_model = ServiceModel( id = service_id, obj = obj, properties = properties ) protocol.services.append(service_model) return protocols.values() class ProtocolModelTreeNode(TreeNode): """ A tree node for a protocol model. """ ########################################################################### # 'TreeNode' interface. ########################################################################### def allows_children(self, obj): """ Return True if this object allows children. """ return True def get_children(self, obj): """ Get the object's children. """ svtno = SingleValueTreeNodeObject() nodes = [] for service in obj.services: node = svtno.node_for(repr(service.obj), service.obj) node._protocol_ = obj.name node._service_id_ = service.id nodes.append(node) return nodes service_registry_browser_tree_nodes = [ TreeNode( node_for = [ServiceRegistryModel], auto_open = True, label = '=Services', children = 'protocols', rename = False, copy = False, delete = False, insert = False, menu = None, ), ProtocolModelTreeNode( node_for = [ProtocolModel], auto_open = True, label = 'name', rename = False, copy = False, delete = False, insert = False, menu = None, ), ] + value_tree_nodes #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/view/api.py0000644000175100001440000000031211674464014022601 0ustar ischnellusers00000000000000from application_browser_view import ApplicationBrowserView from extension_registry_browser_view import ExtensionRegistryBrowserView from service_registry_browser_view import ServiceRegistryBrowserView envisage-4.1.0/envisage/developer/ui/view/application_browser_tree.py0000644000175100001440000001216711674464014027130 0ustar ischnellusers00000000000000""" The tree editor used in the application browser. """ # Enthought library imports. from envisage.api import IApplication, IExtensionPoint, IPlugin from traits.api import Any, HasTraits, List, Str, Undefined from traitsui.api import TreeEditor, TreeNode # fixme: non-api imports. from traitsui.value_tree import value_tree_nodes class Container(HasTraits): """ A container. """ # The object that contains the container ;^) parent = Any # The contents of the container. contents = List # The label. label = Str class IApplicationTreeNode(TreeNode): """ A tree node for an Envisage application. """ ########################################################################### # 'TreeNode' interface. ########################################################################### def allows_children(self, obj): """ Return True if this object allows children. """ return True def get_children(self, obj): """ Get the object's children. """ return [plugin for plugin in obj] def is_node_for(self, obj): """ Return whether this is the node that handles a specified object. """ return IApplication(obj, Undefined) is obj class IPluginTreeNode(TreeNode): """ A tree node for a Envisage plugins. """ ########################################################################### # 'TreeNode' interface. ########################################################################### def allows_children(self, obj): """ Return True if this object allows children. """ return False#True def get_children(self, obj): """ Get the object's children. """ extension_points = Container( label = 'Extension Points', parent = obj, contents = obj.get_extension_points() ) extensions = Container( label = 'Extensions', parent = obj, contents = self._get_extensions(obj) ) return [extension_points, extensions] def is_node_for(self, obj): """ Return whether this is the node that handles a specified object. """ return IPlugin(obj, Undefined) is obj def _get_extensions(self, plugin): from traitsui.value_tree import ListNode, StringNode class MyListNode(ListNode): label = Str def format_value(self, value): return self.label extensions = [] for trait_name, trait in plugin.traits().items(): if trait.extension_point is not None: node = MyListNode(label=trait.extension_point, value=plugin.get_extensions(trait.extension_point)) extensions.append(node) return extensions class IExtensionPointTreeNode(TreeNode): """ A tree node for an extension point. """ ########################################################################### # 'TreeNode' interface. ########################################################################### def allows_children(self, obj): """ Return True if this object allows children. """ return False def get_children(self, obj): """ Get the object's children. """ return [] def get_label(self, obj): """ Get the object's label. """ return obj.id def when_label_changed(self, obj, callback, remove): return def is_node_for(self, obj): """ Return whether this is the node that handles a specified object. """ return IExtensionPoint(obj, Undefined) is obj class ContainerTreeNode(TreeNode): """ A tree node for a Envisage plugins. """ ########################################################################### # 'TreeNode' interface. ########################################################################### def allows_children(self, obj): """ Return True if this object allows children. """ return True def get_children(self, obj): """ Get the object's children. """ return obj.contents def is_node_for(self, obj): """ Return whether this is the node that handles a specified object. """ return isinstance(obj, Container) application_browser_tree_nodes = [ IApplicationTreeNode( auto_open = True, label = 'id', rename = False, copy = False, delete = False, insert = False, menu = None, ), IExtensionPointTreeNode( rename = False, copy = False, delete = False, insert = False, menu = None, ), IPluginTreeNode( label = 'name', rename = False, copy = False, delete = False, insert = False, menu = None, ), ContainerTreeNode( label = 'label', rename = False, copy = False, delete = False, insert = False, menu = None, ), ] + value_tree_nodes #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/view/application_browser.py0000644000175100001440000001007711674464014026107 0ustar ischnellusers00000000000000""" A view showing a summary of the running application. """ # Standard library imports. import inspect # Enthought library imports. from envisage.api import IApplication, IPlugin from envisage.developer.code_browser.api import CodeBrowser from apptools.io.api import File from traits.api import Any, HasTraits, Instance from traitsui.api import Item, TreeEditor, View # fixme: non-api import. from envisage.plugins.text_editor.editor.text_editor import TextEditor # Local imports. from application_browser_tree import application_browser_tree_nodes application_browser_view = View( Item( name = 'application', show_label = False, editor = TreeEditor( nodes = application_browser_tree_nodes, editable = False, orientation = 'vertical', hide_root = True, show_icons = True, selected = 'selection', on_dclick = 'object.dclick' ) ), resizable = True, style = 'custom', title = 'Application', width = .1, height = .1 ) class ApplicationBrowser(HasTraits): """ An application browser. Actually, this class exists just because to use a trait editor we have to have a trait to edit! """ # The application that we are browsing. application = Instance(IApplication) # The code browser that we use to parse plugin source code. code_browser = Instance(CodeBrowser) # The workbench service. workbench = Instance('envisage.ui.workbench.api.Workbench') # The object that is currently selected in the tree. selection = Any # The default traits UI view. traits_view = application_browser_view ########################################################################### # 'ApplicationBrowser' interface. ########################################################################### #### Trait initializers ################################################### def _code_browser_default(self): """ Trait initializer. """ return self.application.get_service(CodeBrowser) def _workbench_default(self): """ Trait initializer. """ from envisage.ui.workbench.api import Workbench return self.application.get_service(Workbench) #### Trait change handlers ################################################ def _selection_changed(self, trait_name, old, new): """ Static trait change handler. """ #print 'Selection changed', trait_name, old, new return #### Methods ############################################################## def dclick(self, obj): """ Called when an object in the tree is double-clicked. """ if IPlugin(obj, None) is not None: # Parse the plugin source code. module = self._parse_plugin(obj) # Get the plugin klass. klass = self._get_plugin_klass(module, obj) # Edit the plugin. editor = self.workbench.edit( self._get_file_object(obj), kind=TextEditor ) # Move to the class definition. editor.select_line(klass.lineno) return ########################################################################### # Private interface. ########################################################################### def _get_file_object(self, obj): """ Return a 'File' object for an object's source file. """ return File(path=inspect.getsourcefile(type(obj))) def _get_plugin_klass(self, module, plugin): """ Get the klass that defines the plugin. """ for name, klass in module.klasses.items(): if name == type(plugin).__name__: break else: klass = None return klass def _parse_plugin(self, plugin): """ Parse the plugin source code. """ filename = self._get_file_object(plugin).path return self.code_browser.read_file(filename) #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/view/application_browser_view.py0000644000175100001440000000374611674464014027146 0ustar ischnellusers00000000000000""" A view that allows a developer to browse the current application. """ # Enthought library imports. from pyface.workbench.api import TraitsUIView from traits.api import Instance # The code browser protocol. CODE_BROWSER = 'envisage.developer.code_browser.api.CodeBrowser' class ApplicationBrowserView(TraitsUIView): """ A view that allows a developer to browse the current application. """ #### 'IWorkbenchPart' interface ########################################### # The part's globally unique identifier. id = 'envisage.developer.ui.view.application_browser_view' # The part's name (displayed to the user). name = 'Plugins' #### 'IView' interface #################################################### # The category that the view belongs to (this can used to group views when # they are displayed to the user). category = 'Developer' #### 'ApplicationBrowserView' interface ################################### # The code browser used to parse Python code. code_browser = Instance(CODE_BROWSER) ########################################################################### # 'TraitsUIView' interface. ########################################################################### def _obj_default(self): """ Trait initializer. """ # Local imports. from application_browser import ApplicationBrowser application_browser = ApplicationBrowser( application = self.window.application, code_browser = self.code_browser ) return application_browser ########################################################################### # 'ApplicationBrowserView' interface. ########################################################################### def _code_browser_default(self): """ Trait initializer. """ return self.window.application.get_service(CODE_BROWSER) #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/view/extension_registry_browser.py0000644000175100001440000001671511674464014027555 0ustar ischnellusers00000000000000""" A view showing a summary of the running application. """ # Standard library imports. import inspect # Enthought library imports. from envisage.api import IApplication, IExtensionPoint from envisage.api import IExtensionRegistry from envisage.developer.code_browser.api import CodeBrowser from apptools.io.api import File from traits.api import HasTraits, Instance from traitsui.api import Item, TreeEditor, View # fixme: non-api import. from envisage.plugins.text_editor.editor.text_editor import TextEditor # Local imports. from extension_registry_browser_tree import \ extension_registry_browser_tree_nodes extension_registry_browser_view = View( Item( name = 'extension_registry', show_label = False, editor = TreeEditor( nodes = extension_registry_browser_tree_nodes, editable = False, orientation = 'vertical', hide_root = True, show_icons = True, on_dclick = 'object.dclick' ) ), resizable = True, style = 'custom', title = 'Extension Registry', width = .1, height = .1 ) class ExtensionRegistryBrowser(HasTraits): """ An extension registry browser. Actually, this class exists just because to use a trait editor we have to have a trait to edit! """ #### 'ExtensionRegistryBrowser' interface ################################# # The application that whose extension registry we are browsing. application = Instance(IApplication) # The code browser that we use to parse plugin source code. code_browser = Instance(CodeBrowser) # The extension registry that we are browsing. extension_registry = Instance(IExtensionRegistry) # The workbench service. workbench = Instance('envisage.ui.workbench.api.Workbench') # The default traits UI view. traits_view = extension_registry_browser_view ########################################################################### # 'ExtensionRegistryBrowser' interface. ########################################################################### #### Trait initializers ################################################### def _extension_registry_default(self): """ Trait initializer. """ return self.application def _workbench_default(self): """ Trait initializer. """ from envisage.ui.workbench.api import Workbench return self.application.get_service(Workbench) #### Methods ############################################################## def dclick(self, obj): """ Called when an object in the tree is double-clicked. """ # Double-click on an extension point. if IExtensionPoint(obj, None) is not None: self.dclick_extension_point(obj) # Double-click on an extension. elif IExtensionPoint(obj.parent.value, None) is not None: self.dclick_extension(obj) return def dclick_extension_point(self, obj): """ Called when an extension point is double-clicked. """ # Find the plugin that offered the extension point. plugin = self._get_plugin(obj) # Parse the plugin source code. module = self._parse_plugin(plugin) # Get the plugin klass. klass = self._get_plugin_klass(module, plugin) # Edit the plugin. editor = self.workbench.edit( self._get_file_object(plugin), kind=TextEditor ) # Was the extension point offered declaratively via a trait? trait_name = self._get_extension_point_trait(plugin, obj.id) if trait_name is not None: attribute = klass.attributes.get(trait_name) lineno = attribute.lineno else: lineno = klass.lineno editor.select_line(lineno) return def dclick_extension(self, obj): """ Called when an extension is double-clicked. """ extension_point = obj.parent.value index = obj.parent._index extension_registry = self.extension_registry extensions = extension_registry.extension_registry._extensions total = 0 provider_index = 0 for l in extensions[extension_point.id]: total = total + len(l) if index < total: break provider_index += 1 plugin = extension_registry.extension_registry._providers[provider_index] # Parse the plugin source code. module = self._parse_plugin(plugin) # Get the plugin klass. klass = self._get_plugin_klass(module, plugin) # Edit the plugin. editor = self.workbench.edit( self._get_file_object(plugin), kind=TextEditor ) # Was the extension offered declaratively? trait_name = self._get_extension_trait(plugin, extension_point.id) if trait_name is not None: # Does the trait have a default initializer? initializer = klass.methods.get('_%s_default' % trait_name) if initializer is not None: lineno = initializer.lineno else: attribute = klass.attributes.get(trait_name) lineno = attribute.lineno else: lineno = klass.lineno editor.select_line(lineno) return ########################################################################### # Private interface. ########################################################################### def _get_extension_trait(self, plugin, id): """ Return the extension trait with the specifed Id. Return None if the extension point was not declared via a trait. """ extension_traits = plugin.traits(contributes_to=id) if len(extension_traits) > 0: # There is *at most* one extension point trait per extension point. trait_name = extension_traits.keys()[0] else: trait_name = None return trait_name def _get_extension_point_trait(self, plugin, id): """ Return the extension point trait with the specifed Id. Return None if the extension point was not declared via a trait. """ extension_point_traits = plugin.traits(__extension_point__=True) for trait_name, trait in extension_point_traits.items(): if trait.trait_type.id == id: break else: trait_name = None return trait_name def _get_plugin(self, extension_point): """ Return the plugin that offered an extension point. """ for plugin in self.application: if extension_point in plugin.get_extension_points(): break else: plugin = None return plugin def _get_plugin_klass(self, module, plugin): """ Get the klass that defines the plugin. """ for name, klass in module.klasses.items(): if name == type(plugin).__name__: break else: klass = None return klass def _get_file_object(self, obj): """ Return a 'File' object for the object's source file. """ return File(path=inspect.getsourcefile(type(obj))) def _parse_plugin(self, plugin): """ Parse the plugin source code. """ filename = self._get_file_object(plugin).path return self.code_browser.read_file(filename) #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/view/service_registry_browser_view.py0000644000175100001440000000400511674464014030220 0ustar ischnellusers00000000000000""" A view that allows a developer to browse the service registry. """ # Enthought library imports. from pyface.workbench.api import TraitsUIView from traits.api import Instance # The code browser protocol. CODE_BROWSER = 'envisage.developer.code_browser.api.CodeBrowser' class ServiceRegistryBrowserView(TraitsUIView): """ A view that allows a developer to browse the service registry. """ #### 'IWorkbenchPart' interface ########################################### # The part's globally unique identifier. id = 'envisage.developer.ui.view.service_registry_browser_view' # The part's name (displayed to the user). name = 'Services' #### 'IView' interface #################################################### # The category that the view belongs to (this can used to group views when # they are displayed to the user). category = 'Developer' #### 'ExtensionRegistryBrowserView' interface ############################# # The code browser used to parse Python code. code_browser = Instance(CODE_BROWSER) ########################################################################### # 'TraitsUIView' interface. ########################################################################### def _obj_default(self): """ Trait initializer. """ # Local imports. from service_registry_browser import ServiceRegistryBrowser service_registry_browser = ServiceRegistryBrowser( application = self.window.application, code_browser = self.code_browser ) return service_registry_browser ########################################################################### # 'ServiceRegistryBrowserView' interface. ########################################################################### def _code_browser_default(self): """ Trait initializer. """ return self.window.application.get_service(CODE_BROWSER) #### EOF ###################################################################### envisage-4.1.0/envisage/developer/ui/view/__init__.py0000644000175100001440000000000011674464014023561 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/ui/view/extension_registry_browser_tree.py0000644000175100001440000000744211674464014030571 0ustar ischnellusers00000000000000""" The nodes used in the extension registry browser tree. """ # Enthought library imports. from envisage.api import IExtensionPoint, IExtensionRegistry from traits.api import Undefined from traitsui.api import TreeNode # fixme: non-api imports. from traitsui.value_tree import SingleValueTreeNodeObject from traitsui.value_tree import value_tree_nodes class IExtensionRegistryTreeNode(TreeNode): """ A tree node for an extension registry. """ ########################################################################### # 'TreeNode' interface. ########################################################################### def allows_children(self, obj): """ Return True if this object allows children. """ return True def get_children(self, obj): """ Get the object's children. """ extension_points = obj.get_extension_points() # Tag the extension registry onto the extension points. for extension_point in extension_points: extension_point.__extension_registry__ = obj return extension_points def is_node_for(self, obj): """ Return whether this is the node that handles a specified object. """ return IExtensionRegistry(obj, Undefined) is obj class IExtensionPointTreeNode(TreeNode): """ A tree node for an extension point. """ ########################################################################### # 'TreeNode' interface. ########################################################################### def allows_children(self, obj): """ Return True if this object allows children. """ return True def get_children(self, obj): """ Get the object's children. """ # fixme: This could be uglier, but I can't work out how ;^) index = 0 children = [] for extension in obj.__extension_registry__.get_extensions(obj.id): parent = SingleValueTreeNodeObject(value=obj, _index=index) children.append(parent.node_for('', extension)) index += 1 return children def get_label(self, obj): """ Get the object's label. """ return obj.id def is_node_for(self, obj): """ Return whether this is the node that handles a specified object. """ return IExtensionPoint(obj, Undefined) is obj # We override the following methods because 'ExtensionPoint' instances # are trait *types* and hence do not actually have traits themselves (i.e. # they do not inherit from 'HasTraits'). The default implementations of # these methods in 'TreeNode' attempt to call 'on_trait_change' to hook # up the listenrs, but obviously, if they don't have traits they don't have # 'on_trait_change' either ;^) # # fixme: If we make this node readonly will these go away?!? def when_label_changed(self, obj, callback, remove): """ Set up or remove listeners for label changes. """ return def when_children_replaced(self, obj, callback, remove): """ Set up or remove listeners for children being replaced. """ return def when_children_changed(self, obj, callback, remove): """ Set up or remove listenrs for children being changed. """ return extension_registry_browser_tree_nodes = [ IExtensionRegistryTreeNode( auto_open = True, label = '=Extension Points', rename = False, copy = False, delete = False, insert = False, menu = None, ), IExtensionPointTreeNode( rename = False, copy = False, delete = False, insert = False, menu = None, ), ] + value_tree_nodes #### EOF ###################################################################### envisage-4.1.0/envisage/developer/charm/0000755000175100001440000000000011674464014021165 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/charm/charm.py0000644000175100001440000000620011674464014022627 0ustar ischnellusers00000000000000""" Charm - the model for a simple Python IDE. """ # Enthought library imports. from envisage.developer.api import CodeBrowser, Module from traits.api import Event, HasTraits, Instance, Str class Charm(HasTraits): """ Charm - the model for a simple Python IDE. """ #### 'Charm' interface #################################################### # The code browser. code_browser = Instance(CodeBrowser) # The filename of the code database. filename = Str('code_database.pickle') # The current module. module = Instance(Module) #### Events #### # Fired when a module is about to be parsed. parsing_module = Event # Fired when a module has been parsed. parsed_module = Event ########################################################################### # 'Charm' interface. ########################################################################### #### Trait initializers ################################################### def _code_browser_default(self): """ Trait initializer. """ code_browser = CodeBrowser(filename=self.filename) self._setup_code_browser(code_browser) return code_browser #### Methods ############################################################## def load(self): """ Loads the code database. """ self.code_browser.load() return def save(self): """ Saves the code database. """ self.code_browser.save() return ########################################################################### # Private interface. ########################################################################### def _setup_code_browser(self, code_browser): """ Adds trait change listeners to a code browser. """ code_browser.on_trait_change(self._on_parsing_module, 'parsing_module') code_browser.on_trait_change(self._on_parsed_module, 'parsed_module') return def _tear_down_code_browser(self, code_browser): """ Removes trait change listeners from a code browser. """ code_browser.on_trait_change( self._on_parsing_module, 'parsing_module', remove=True ) code_browser.on_trait_change( self._on_parsed_module, 'parsed_module', remove=True ) return #### Trait change handlers ################################################ def _code_browser_changed(self, old, new): """ Static trait change handler. """ if old is not None: self._tear_down_code_browser(old) if new is not None: self._setup_code_browser(new) return def _filename_changed(self, old, new): """ Static trait change handler. """ self.code_browser.filename = new return def _on_parsing_module(self, event): """ Dysnamic trait change handler. """ self.parsing_module = event return def _on_parsed_module(self, event): """ Dysnamic trait change handler. """ self.parsed_module = event return #### EOF ###################################################################### envisage-4.1.0/envisage/developer/charm/api.py0000644000175100001440000000003011674464014022301 0ustar ischnellusers00000000000000from charm import Charm envisage-4.1.0/envisage/developer/charm/run.py0000644000175100001440000000010311674464014022335 0ustar ischnellusers00000000000000import wx; app = wx.PySimpleApp() from ui.main import main; main() envisage-4.1.0/envisage/developer/charm/__init__.py0000644000175100001440000000000011674464014023264 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/developer_plugin.py0000644000175100001440000000273011674464014024012 0ustar ischnellusers00000000000000""" The developer plugin. """ # Enthought library imports. from envisage.api import Plugin, ServiceOffer from traits.api import List # The package that this module is in. PKG = '.'.join(__name__.split('.')[:-1]) class DeveloperPlugin(Plugin): """ The developer plugin. This plugin contains the non-GUI part of the tools that (hopefully) help developers to inspect and debug a running Envisage workbench application. """ # The Ids of the extension points that this plugin contributes to. SERVICE_OFFERS = 'envisage.service_offers' #### 'IPlugin' interface ################################################## # The plugin's globally unique identifier. id = 'envisage.developer' # The plugin's name (suitable for displaying to the user). name = 'Developer' #### Extension points offered by this plugin ############################## # None. #### Contributions to extension points made by this plugin ################ service_offers = List(contributes_to=SERVICE_OFFERS) def _service_offers_default(self): """ Trait initializer. """ code_browser_class = PKG + '.code_browser.api.CodeBrowser' code_browser_service_offer = ServiceOffer( protocol = code_browser_class, factory = code_browser_class, scope = 'application' ) return [code_browser_service_offer] #### EOF ###################################################################### envisage-4.1.0/envisage/developer/__init__.py0000644000175100001440000000000011674464014022172 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/code_browser/0000755000175100001440000000000011674464014022550 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/code_browser/code_browser.py0000644000175100001440000001552711674464014025611 0ustar ischnellusers00000000000000""" A simple traits-aware code browser. """ # Standard library imports. import cPickle, imp, logging, os, stat, warnings # Enthought library imports. from apptools.io.api import File from traits.api import Any, Bool, Event, HasTraits, Str # Local imports. from module import ModuleFactory from package import Package # Logging. logger = logging.getLogger(__name__) # Filter future warnings for maxint, since it causes warnings when compiling # anything that has RGBA colors defined as hex values. warnings.filterwarnings( "ignore", r'hex/oct constants > sys\.maxint .*', FutureWarning ) class CodeBrowser(HasTraits): """ A simple, traits-aware code browser. """ #### 'ClassBrowser' interface ############################################# # The filename of the (optional, persistent) code 'database'. filename = Str #### Events #### # Fired when a module is about to be parsed. parsing_module = Event # Fired when a module has been parsed. parsed_module = Event #### Private interface #################################################### # The code 'database' that contains every module that has been parsed. _database = Any # Has the code database been changed (i.e., do we need to save it)? _database_changed = Bool(False) ########################################################################### # 'CodeBrowser' interface. ########################################################################### def load(self): """ Load the code browser 'database'. """ # If a persisted code database exists then load it... if os.path.isfile(self.filename): logger.debug('loading code database...') f = file(self.filename, 'rb') self._database = cPickle.load(f) f.close() logger.debug('code database loaded.') # ... otherwise we have a nice, fresh and very empty database. else: self._database = {} return def save(self): """ Save the code browser 'database' to disk. """ if self._database_changed: logger.debug('saving code database...') f = file(self.filename, 'wb') cPickle.dump(self._database, f, 1) f.close() self._database_changed = False logger.debug('code database saved.') else: logger.debug('code database unchanged - nothing saved.') return def read_package(self, package_name): """ Parse every module in the specified package. """ filename = self.find_module(package_name) if filename is None: raise ValueError("no such package '%s'" % package_name) package = Package(filename=filename, name=package_name) self.read_directory(filename, package) return package def read_directory(self, filename, package=None): """ Parse every module in the specified directory. """ directory = File(filename) if not directory.is_folder: raise ValueError("%s is NOT a directory." % filename) if package is not None: contents = package.contents else: contents = [] for child in directory.children: # If the child is a Python file then parse it. if child.ext == '.py': contents.append(self.read_file(child.path, package)) # If the child is a sub-package then recurse! elif child.is_package: if package is not None: sub_package_name = '%s.%s' % (package.name, child.name) sub_package = Package( filename = child.path, name = sub_package_name, parent = package ) else: sub_package = Package(filename=child.path, name=child.name) self.read_directory(child.path, sub_package) contents.append(sub_package) return contents def read_file(self, filename, namespace=None): """ Parse a file. """ # Only parse the file if we haven't parsed it before or it has been # modified since we last parsed it! module, mod_time = self._database.get(filename, (None, None)) if module is None or mod_time != os.stat(filename)[stat.ST_MTIME]: # Event notification. self.parsing_module = filename logger.debug('parsing module %s' % filename) module_factory = ModuleFactory() try: module = module_factory.from_file(filename, namespace) # Event notification. self.parsed_module = module logger.debug('parsed module %s' % filename) # Add the parsed module to the database. self._database[filename] = ( module, os.stat(filename)[stat.ST_MTIME] ) self._database_changed = True except 'ddd': logger.debug('error parsing module %s' % filename) return module ## def read_module(self, module_name): ## """ Parses a module. """ ## filename = self.find_module(module_name) ## if filename is not None: ## module = self.read_file(filename) ## else: ## module = None ## return module def find_module(self, module_name, path=None): """ Return the filename for the specified module. """ components = module_name.split('.') try: # Look up the first component of the module name (of course it # could be the *only* component). f, filename, description = imp.find_module(components[0], path) # If the module is in a package then go down each level in the # package hierarchy in turn. if len(components) > 0: for component in components[1:]: f, filename, description = imp.find_module( component, [filename] ) except ImportError: filename = None return filename ########################################################################### # Private interface. ########################################################################### #### Trait initializers ################################################### def __database_default(self): """ Trait initializer. """ return {} #### Trait change handlers ################################################ def _filename_changed(self): """ Called when the filename of the code database is changed. """ # Load the contents of the database. self.load() return #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/tests/0000755000175100001440000000000011674464014023712 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/code_browser/tests/example_1.py0000644000175100001440000000071611674464014026143 0ustar ischnellusers00000000000000""" Example code used to test the code browser. """ # Enthought library imports. from traits.api import HasTraits, Int class Base(HasTraits): """ A class that inherits from 'Hastraits' directly. """ # Some traits that explicitly specify a trait type. x = Int y = Int def foo(self): """ A method. """ def bar(self): """ A method. """ #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/tests/code_browser_test_case.py0000644000175100001440000000616311674464014031001 0ustar ischnellusers00000000000000""" Tests for the Enthought code browser. """ # Standard library imports. import os.path import logging # Log to stidout (for now!). logger = logging.getLogger() logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.DEBUG) # Standard library imports. import inspect, unittest # Enthought library imports. from traits.util.resource import get_path from envisage.developer.code_browser.api import CodeBrowser class CodeBrowserTestCase(unittest.TestCase): """ Tests for the Enthought code browser. """ ########################################################################### # 'TestCase' interface. ########################################################################### def setUp(self): """ Prepares the test fixture before each test method is called. """ self.code_browser = CodeBrowser() return def tearDown(self): """ Called immediately after each test method has been called. """ return ########################################################################### # Tests. ########################################################################### def test_browse_this_module(self): """ browse this module """ # We don't use '__file__' as the filename here as it could refer to the # '.pyc' file (we could just strip the 'c' of course, but inspect just # seems more intentional ;^). filename = inspect.getsourcefile(CodeBrowserTestCase) module = self.code_browser.read_file(filename) # Check the module name and documentation. self.assertEqual('code_browser_test_case', module.name) self.assertEqual(" Tests for the Enthought code browser. ", module.doc) # Check that the module contains this class! klass = module.klasses['CodeBrowserTestCase'] self.assertEqual(" Tests for the Enthought code browser. ", klass.doc) # And that the class contains this method. method = klass.methods['test_browse_this_module'] self.assertEqual(" browse this module ", method.doc) return def test_has_traits(self): """ has traits """ module = self.code_browser.read_file( os.path.join( get_path(CodeBrowserTestCase), 'example_1.py')) # Check the module name and documentation. self.assertEqual('example_1', module.name) # Check that the module contains the specified class. klass = module.klasses.get('Base') self.assertNotEqual(None, klass) # Check the class' base class. self.assertEqual(['HasTraits'], klass.bases) # Check that the class has the appropriate traits and methods. self.assertEqual(2, len(klass.traits)) x = klass.traits['x'] y = klass.traits['y'] self.assertEqual(2, len(klass.methods)) foo = klass.methods['foo'] bar = klass.methods['bar'] return # Entry point for stand-alone testing. if __name__ == '__main__': unittest.main() #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/api.py0000644000175100001440000000025311674464014023673 0ustar ischnellusers00000000000000from assign import Assign from code_browser import CodeBrowser from function import Function from klass import Klass from module import Module from package import Package envisage-4.1.0/envisage/developer/code_browser/package.py0000644000175100001440000000366411674464014024526 0ustar ischnellusers00000000000000""" Classes used to represent packages. """ # Standard library imports. from os.path import join # Enthought library imports. from apptools.io.api import File from traits.api import Instance, List, Str # Local imports. from namespace import Namespace class Package(Namespace): """ A package. """ #### 'Package' interface ################################################## # The namespace that the package is defined in. # # fixme: This is always None for packages so why should we have this trait! # If I remember correctly it is something to do with trait identification! namespace = Instance(Namespace) # The package contents (modules and sub-packages). contents = List # The absolute filename of the package. filename = Str # The package name. name = Str # The package's parent package (None if this is a top level package). parent = Instance('Package') ########################################################################### # 'Package' interface. ########################################################################### def create_sub_package(self, name): """ Creates a sub-package with the specified name. """ sub_package = File(join(self.filename, name)) sub_package.create_package() return def delete_sub_package(self, name): """ Deletes the sub-package with the specified name. """ sub_package = File(join(self.filename, name)) sub_package.delete() return ########################################################################### # Private interface ########################################################################### def _name_changed(self, name): """ Called when the package name has been changed. """ ##print '**** Package name changed', self.name return #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/enclbr.py0000644000175100001440000001031511674464014024367 0ustar ischnellusers00000000000000""" The Enthought class browser module. """ # Standard library imports. import cPickle, imp, logging, os, stat, warnings # Enthought library imports. from apptools.io.api import File # Local imports. from module import ModuleFactory from package import Package # Logging. logger = logging.getLogger(__name__) # Filter future warnings for maxint, since it causes warnings when compiling # anything that has RGBA colors defined as hex values. warnings.filterwarnings( "ignore", r'hex/oct constants > sys\.maxint .*', FutureWarning ) # A cache that contains every module that has been parsed. MODULES = {} # Has the cache been modified in this process? MODULES_CHANGED = False def save_cache(filename): """ Saves the module cache to disk. """ global MODULES global MODULES_CHANGED if MODULES_CHANGED: logger.debug('saving cache...') f = file(filename, 'wb') cPickle.dump(MODULES, f, 1) f.close() logger.debug('cache saved') return def load_cache(filename): """ Loads the module cache from disk. """ global MODULES if os.path.isfile(filename): logger.debug('loading cache...') f = file(filename, 'rb') MODULES = cPickle.load(f) f.close() logger.debug('cache loaded...') else: MODULES = {} return def read_package(package_name): """ Parse every module in the specified package. """ filename = find_module(package_name) if filename is None: raise ValueError("no such package '%s'" % package_name) package = Package(filename=filename, name=package_name) read_directory(filename, package) return package def read_directory(filename, package=None): """ Parse every module in the specified directory. """ directory = File(filename) if not directory.is_folder: raise ValueError("%s is NOT a directory." % filename) if package is not None: contents = package.contents else: contents = [] for child in directory.children: if child.ext == '.py': contents.append(read_file(child.path, package)) elif child.is_package: if package is not None: sub_package_name = '%s.%s' % (package.name, child.name) sub_package = Package( filename=child.path, name=sub_package_name, parent=package ) else: sub_package = Package(filename=child.path, name=child.name) read_directory(child.path, sub_package) contents.append(sub_package) return contents def read_file(filename, namespace=None): """ Parses a file. """ global MODULES global MODULES_CHANGED module, mod_time = MODULES.get(filename, (None, None)) if module is None or mod_time != os.stat(filename)[stat.ST_MTIME]: logger.debug('parsing module %s' % filename) module_factory = ModuleFactory() try: module = module_factory.from_file(filename, namespace) # Add the parsed module to the cache. MODULES[filename] = (module, os.stat(filename)[stat.ST_MTIME]) MODULES_CHANGED = True except: logger.exception('error parsing file %s' % filename) return module def read_module(module_name): """ Parses a module. """ filename = find_module(module_name) if filename is not None: module = read_file(filename) else: module = None return module def find_module(module_name, path=None): """ Returns the filename for the specified module. """ components = module_name.split('.') try: # Look up the first component of the module name (of course it could be # the *only* component). f, filename, description = imp.find_module(components[0], path) # If the module is in a package then go down each level in the package # hierarchy in turn. if len(components) > 0: for component in components[1:]: f,filename,description = imp.find_module(component, [filename]) except ImportError: filename = None return filename #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/assign.py0000644000175100001440000001026411674464014024411 0ustar ischnellusers00000000000000""" Classes used to represent assignment statements. """ # Standard library imports. import compiler from compiler.visitor import ASTVisitor # Enthought library imports. from traits.api import Any, Bool, HasTraits, Instance, Int, List, Str class Assign(HasTraits): """ An assignment statement. """ #### 'Assign' interface ################################################### # The namespace that the assignment statement is in. namespace = Instance( 'envisage.developer.code_browser.namespace.Namespace' ) # The line number within the module at which the assignment statement # appears. lineno = Int # The names being assigned to (in Python there can be more than one). targets = List(Str) # The expression being assigned to the targets (an AST node). expr = Any # We only care about assignments to trait types, not literals or # expressions etc. source = Str # Is this a trait assignment? is_trait = Bool(False) ########################################################################### # 'object' interface. ########################################################################### def __str__(self): """ Returns an informal string representation of the object. """ return 'Assign %s at %d' % (', '.join(self.targets), self.lineno) class AssignFactory(HasTraits): """ A factory for assignment statements. """ ########################################################################### # 'AssignFactory' interface. ########################################################################### def from_ast(self, namespace, node): """ Creates an assignment statement from an AST node. """ # Create a new assignment statement. assign = Assign( namespace = namespace, lineno = node.lineno, expr = node.expr ) # Walk the AST picking out the things we care about! compiler.walk(node, AssignVisitor(assign)) return assign class AssignVisitor(ASTVisitor): """ An AST visitor for assigment statements. """ ########################################################################### # 'object' interface. ########################################################################### def __init__(self, assign): """ Creates a new visitor. """ self.assign = assign return ########################################################################### # 'ASTVisitor' interface. ########################################################################### def visitAssName(self, node): """ Visits an assignment node. """ self.assign.targets.append(node.name) return def visitCallFunc(self, node): """ Visits a function call node. """ function_name = self._get_name(node.node) self.assign.source = function_name return def visitName(self, node): """ Visits a name node. """ self.assign.source = node.name return def visitGetattr(self, node): """ Visits a getattr node. """ self.assign.source = self._get_name(node) return ########################################################################### # Private interface. ########################################################################### def _get_name(self, node): """ Returns the (possibly dotted) name from a node. """ # fixme: Work out when node can be none here!!!!! I think it is safe # to ignore it in terms of working out what is a trait, but it would # be nice to know what is going on ;^) if node is not None: if isinstance(node, basestring): name = node elif not hasattr(node, 'getType'): name = '' elif node.getType() == compiler.ast.Name: name = node.name else: names = [self._get_name(child) for child in node.getChildren()] name = '.'.join(names) else: name = '' return name #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/function.py0000644000175100001440000000323211674464014024747 0ustar ischnellusers00000000000000""" Classes used to represent functions and methods. """ # Enthought library imports. from traits.api import Any, HasTraits, Instance, Int, Str # Local imports. from namespace import Namespace class Function(Namespace): """ A function. """ #### 'Function' interface ################################################# # The namespace that the function is defined in. namespace = Instance(Namespace) # The line number in the module at which the function appears. lineno = Int # The name of the function. name = Str # The function's doc-string (None if there is no doc string, a string if # there is). doc = Any ########################################################################### # 'object' interface. ########################################################################### def __str__(self): """ Returns an informal string representation of the object. """ return 'Function %s at %d' % (self.name, self.lineno) class FunctionFactory(HasTraits): """ A factory for classes. """ ########################################################################### # 'FunctionFactory' interface. ########################################################################### def from_ast(self, namespace, node): """ Creates a class from an AST node. """ # Create a new function. function = Function( namespace = namespace, lineno = node.lineno, name = node.name, doc = node.doc ) return function #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/klass.py0000644000175100001440000001272411674464014024245 0ustar ischnellusers00000000000000""" Classes used to represent classes. """ # Standard library imports. import compiler from compiler.visitor import ASTVisitor # Enthought library imports. from traits.api import Any, Dict, HasTraits, Instance, Int, List from traits.api import Property, Str # Local imports. from assign import AssignFactory from function import FunctionFactory from namespace import Namespace class Klass(Namespace): """ A class. """ #### 'Klass' interface #################################################### # The namespace that the class is defined in (this is *usually* a module, # but of course classes can be defined anywhere in Python). namespace = Instance(Namespace) # The line number in the module at which the class appears. lineno = Int # The name of the class. name = Str # The class' doc-string (None if there is no doc string, a string if there # is). doc = Any # The class' base classes. bases = List(Str) # The class' attributes. attributes = Dict # The class' traits. traits = Dict # The class' methods. methods = Dict ########################################################################### # 'object' interface. ########################################################################### def __str__(self): """ Returns an informal string representation of the object. """ return 'Klass %s at %d' % (self.name, self.lineno) def __getstate__(self): """ Returns the state of the object for pickling. """ state = {} state['namespace'] = self.namespace state['lineno'] = self.lineno state['name'] = self.name state['doc'] = self.doc state['bases'] = self.bases state['attributes'] = self.attributes state['traits'] = self.traits state['methods'] = self.methods return state def __setstate__(self, state): """ Sets the state object duting unpickling. """ self.namespace = state['namespace'] self.lineno = state['lineno'] self.name = state['name'] self.doc = state['doc'] self.bases = state['bases'] self.attributes = state['attributes'] self.traits = state['traits'] self.methods = state['methods'] return class KlassFactory(HasTraits): """ A factory for classes. """ ########################################################################### # 'KlassFactory' interface. ########################################################################### def from_ast(self, namespace, node): """ Creates a class from an AST node. """ # Create a new class. klass = Klass( namespace = namespace, lineno = node.lineno, name = node.name, doc = node.doc, bases = [self._get_name(base) for base in node.bases] ) # Walk the AST picking out the things we care about! compiler.walk(node, KlassVisitor(klass)) return klass ########################################################################### # Private interface. ########################################################################### # fixme: This same method is used in 'AssignVisitor'. def _get_name(self, node): """ Returns the (possibly dotted) name from a node. """ if isinstance(node, basestring): name = node elif hasattr(node, 'getType') and node.getType() == compiler.ast.Name: name = node.name else: names = [self._get_name(child) for child in node.getChildren()] name = '.'.join(names) return name class KlassVisitor(ASTVisitor): """ An AST visitor for classes. """ ########################################################################### # 'object' interface. ########################################################################### def __init__(self, klass): """ Creates a new visitor. """ self.klass = klass # Factories used to create klasses, functions and assignments from # AST nodes. self._function_factory = FunctionFactory() self._assign_factory = AssignFactory() return ########################################################################### # 'ASTVisitor' interface. ########################################################################### def visitFunction(self, node): """ Visits a function node. """ function = self._function_factory.from_ast(self.klass, node) self.klass.locals[node.name] = function self.klass.methods[node.name] = function return def visitAssign(self, node): """ Visits an assignment node. """ assign = self._assign_factory.from_ast(self.klass, node) # Does the assigment look like it *might* be a trait? (i.e., it is NOT # an expression or a constant etc.). if len(assign.source) > 0: assign.is_trait = self.klass.is_trait(assign.source) else: assign.is_trait = False for target in assign.targets: self.klass.locals[target] = assign self.klass._is_trait[target] = assign.is_trait if assign.is_trait: self.klass.traits[target] = assign else: self.klass.attributes[target] = assign return #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/namespace.py0000644000175100001440000001103011674464014025051 0ustar ischnellusers00000000000000""" A Python namespace. """ # Standard library imports. import os, sys # Enthought library imports. from traits.api import Dict, HasTraits class Namespace(HasTraits): """ A Python namespace. """ #### 'Namespace' interface ################################################ # All of the names defined within the module. locals = Dict # All of the names imported into the module. imports = Dict # fixme: This is a dict from name -> bool indicating whether a name in # locals is a trait or not. Should locals be a dict containing a tuple? _is_trait = Dict ########################################################################### # 'Namespace' interface. ########################################################################### def is_trait(self, name): """ Attempt to resolve a name to see if it is a trait. """ # fixme: We might want to be a bit cleverer than this ;^) return True # Try the namespace's locals first. if name in self.locals: # These are the definitive traits markers! if name in ['TraitFactory', 'Trait', 'Instance']: is_trait = True # The name won't be in the '_is_trait' dictionary if it was not # defined by an assignment i.e., it is a class or function! elif not self._is_trait.get(name, False): is_trait = False else: next = self.locals[name] if len(next.source) > 0: is_trait = self.is_trait(next.source) else: is_trait = False # Is the name imported? elif self.is_imported(name): module_name = self.get_next_module_name(name) module = self.get_next_module(module_name) if module is not None: components = name.split('.') is_trait = module.is_trait(components[-1]) else: is_trait = False # If we have a parent namespace then try that. elif self.namespace is not None: is_trait = self.namespace.is_trait(name) # Otherwise give up! else: is_trait = False return is_trait def is_imported(self, name): """ Returns TRUE if a name is imported. """ components = name.split('.') return components[0] in self.imports def get_next_module_name(self, symbol): """ Returns the name of the module that a symbol was imported from. """ components = symbol.split('.') if len(components) == 1: module_name = self.imports[symbol] else: path = [] # The first component MUST have been imported. # # An empty string means 'import' as opposed to 'from' used. value = self.imports[components[0]] if len(value) > 0: path.append(value) module_name = '.'.join(path) return module_name path.append(components[0]) for component in components[1:-1]: path.append(component) module_name = '.'.join(path) return module_name def get_next_module(self, module_name): """ Returns a parsed module with the specified name. Returns None if the module cannot be found or is 'ignored'. We ignore all modules in the Python core, extension modules etc. """ # fixme: Circular imports! from enclbr import find_module, read_file # Try to find the module that the symbol came from. dirname = os.path.dirname(self.filename) filename = find_module(module_name, [dirname] + sys.path) if filename is not None: # If the filename refers to a directory then it must be a # package. if os.path.isdir(filename): filename = os.path.join(filename, '__init__.py') # fixme: We should probably put in some more formal filter # mechanism here! # # Ignore extension modules. if filename.endswith('.pyd') or filename.endswith('.so'): module = None # Ignore standard modules. elif filename.startswith(sys.prefix): module = None # Parse it! else: module = read_file(filename) else: module = None return module #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/module.py0000644000175100001440000001517511674464014024420 0ustar ischnellusers00000000000000""" Classes used to represent modules. """ # Standard library imports. import compiler, os from compiler.visitor import ASTVisitor # Enthought library imports. from apptools.io.api import File from traits.api import Any, Dict, HasTraits, Instance, Str # Local imports. from assign import Assign, AssignFactory from function import Function, FunctionFactory from klass import Klass, KlassFactory from namespace import Namespace class Module(Namespace): """ A module. """ #### 'Module' interface ################################################### # The namespace that the module is defined in. If the module is in a # package then this will be the appropriate 'Package' instance, otherwise # it will be None. namespace = Instance(Namespace) # The absolute filename of the module. filename = Str # The name of the module (this is currently the fully qualified name i.e., # it includes the names of the packages that the module is contained in). name = Str # The module's doc-string (None if there is no doc string, a string if # there is). doc = Any # The module-level attributes. attributes = Dict # The classes defined in the module. klasses = Dict # The module-level functions. functions = Dict ########################################################################### # 'object' interface. ########################################################################### def __str__(self): """ Returns an informal string representation of the object. """ return 'Module %s' % self.filename def __getstate__(self): """ Returns the state of the object for pickling. """ state = {} state['namespace'] = self.namespace state['filename'] = self.filename state['name'] = self.name state['doc'] = self.doc state['attributes'] = self.attributes state['klasses'] = self.klasses state['functions'] = self.functions return state def __setstate__(self, state): """ Sets the state object duting unpickling. """ self.namespace = state['namespace'] self.filename = state['filename'] self.name = state['name'] self.doc = state['doc'] self.attributes = state['attributes'] self.klasses = state['klasses'] self.functions = state['functions'] return class ModuleFactory(HasTraits): """ A factory for modules. """ ########################################################################### # 'ModuleFactory' interface. ########################################################################### def from_file(self, filename, namespace=None): """ Creates a module by parsing a file. """ # Parse the file. node = compiler.parseFile(filename) # Create a new module. module = Module( namespace = namespace, filename = filename, name = self._get_module_name(filename), doc = node.doc, ) # Walk the AST picking out the things we care about! compiler.walk(node, ModuleVisitor(module)) return module ########################################################################### # Private interface. ########################################################################### def _get_module_name(self, filename): """ Get the fully qualified module name for a filename. e.g. if the filename is:- '/enthought/envisage/core/core_plugin_definition.py' we would return:- 'envisage.core.core_plugin_definition' """ # Get the name of the module minus the '.py' module, ext = os.path.splitext(os.path.basename(filename)) # Start with the actual module name. module_path = [module] # If the directory is a Python package then add it to the module path. parent = File(os.path.dirname(filename)) while parent.is_package: module_path.insert(0, parent.name) parent = parent.parent return '.'.join(module_path) class ModuleVisitor(ASTVisitor): """ An AST visitor for top-level modules. """ ########################################################################### # 'object' interface. ########################################################################### def __init__(self, module): """ Creates a new visitor. """ self.module = module # Factories used to create klasses, functions and assignments from # AST nodes. self._klass_factory = KlassFactory() self._function_factory = FunctionFactory() self._assign_factory = AssignFactory() return ########################################################################### # 'ASTVisitor' interface. ########################################################################### def visitClass(self, node): """ Visits a class node. """ klass = self._klass_factory.from_ast(self.module, node) self.module.locals[node.name] = klass self.module.klasses[node.name] = klass return def visitFunction(self, node): """ Visits a function node. """ function = self._function_factory.from_ast(self.module, node) self.module.locals[node.name] = function self.module.functions[node.name] = function return def visitAssign(self, node): """ Visits an assignment node. """ assign = self._assign_factory.from_ast(self.module, node) # Does the assigment look like it *might* be a trait? (i.e., it is NOT # an expression or a constant etc.). if len(assign.source) > 0: assign.is_trait = self.module.is_trait(assign.source) else: assign.is_trait = False for target in assign.targets: self.module.locals[target] = assign self.module.attributes[target] = assign self.module._is_trait[target] = assign.is_trait return def visitFrom(self, node): """ Visits a from node. """ for name, what in node.names: self.module.imports[name] = node.modname return def visitImport(self, node): """ Visits an import node. """ for name, what in node.names: # fixme: We currently use the fact that we add an empty string to # the imports dictionary to tell the difference later on between # 'import' and 'from import'. self.module.imports[name] = '' return #### EOF ###################################################################### envisage-4.1.0/envisage/developer/code_browser/__init__.py0000644000175100001440000000000011674464014024647 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/developer/code_browser/example.py0000644000175100001440000000167611674464014024567 0ustar ischnellusers00000000000000""" An example of using the Enthought class browser (enclbr) module. """ # Standard library imports. import sys, time # Enthought library imports. from envisage.developer.code_browser.api import CodeBrowser def main(argv): """ Do it! """ if len(argv) != 2: print 'Usage: python example.py module_name' print print 'e.g., python example.py traits' else: # Create a code browser. code_browser = CodeBrowser(filename='data.pickle') # Parse the specified package. start = time.time() contents = code_browser.read_package(sys.argv[1]) stop = time.time() print 'Time taken to parse', sys.argv[1], 'was', stop - start, 'secs' # Save the cache. code_browser.save('data.pickle') return # Entry point for testing. if __name__ == '__main__': main(sys.argv) #### EOF ###################################################################### envisage-4.1.0/envisage/plugin.py0000644000175100001440000003421111674464014017757 0ustar ischnellusers00000000000000""" The default implementation of the 'IPlugin' interface. """ # Standard library imports. import inspect, logging, os from os.path import exists, join # Enthought library imports. from traits.api import Instance, List, Property, Str, implements from traits.util.camel_case import camel_case_to_words # Local imports. from extension_point import ExtensionPoint from extension_provider import ExtensionProvider from i_application import IApplication from i_extension_point_user import IExtensionPointUser from i_extension_registry import IExtensionRegistry from i_plugin import IPlugin from i_plugin_activator import IPluginActivator from i_service_registry import IServiceRegistry from i_service_user import IServiceUser from plugin_activator import PluginActivator # Logging. logger = logging.getLogger(__name__) class Plugin(ExtensionProvider): """ The default implementation of the 'IPlugin' interface. This class is intended to be subclassed for each plugin that you create. """ implements(IPlugin, IExtensionPointUser, IServiceUser) #### 'IPlugin' interface ################################################## # The activator used to start and stop the plugin. # # By default the *same* activator instance is used for *all* plugins of # this type. activator = Instance(IPluginActivator, PluginActivator()) # The application that the plugin is part of. application = Instance(IApplication) # The name of a directory (created for you) that the plugin can read and # write to at will. home = Str # The plugin's unique identifier. # # If no identifier is specified then the module and class name of the # plugin are used to create an Id with the form 'module_name.class_name'. id = Str # The plugin's name (suitable for displaying to the user). # # If no name is specified then the plugin's class name is used with an # attempt made to turn camel-case class names into words separated by # spaces (e.g. if the class name is 'MyPlugin' then the name would be # 'My Plugin'). Of course, if you really care about the actual name, then # just set it! name = Str #### 'IExtensionPointUser' interface ###################################### # The extension registry that the object's extension points are stored in. extension_registry = Property(Instance(IExtensionRegistry)) #### 'IServiceUser' interface ############################################# # The service registry that the object's services are stored in. service_registry = Property(Instance(IServiceRegistry)) #### Private interface #################################################### # The Ids of the services that were automatically registered. _service_ids = List ########################################################################### # 'IExtensionPointUser' interface. ########################################################################### def _get_extension_registry(self): """ Trait property getter. """ return self.application ########################################################################### # 'IServiceUser' interface. ########################################################################### def _get_service_registry(self): """ Trait property getter. """ return self.application ########################################################################### # 'IExtensionProvider' interface. ########################################################################### def get_extension_points(self): """ Return the extension points offered by the provider. """ extension_points = [ trait.trait_type for trait in self.traits(__extension_point__=True).values() ] return extension_points def get_extensions(self, extension_point_id): """ Return the provider's extensions to an extension point. """ # Each class can have at most *one* trait that contributes to a # particular extension point. # # fixme: We make this restriction in case that in future we can wire up # the list traits directly. If we don't end up doing that then it is # fine to allow mutiple traits! trait_names = self.trait_names(contributes_to=extension_point_id) # FIXME: This is a temporary fix, which was necessary due to the # namespace refactor, but should be removed at some point. if len(trait_names) == 0: old_id = 'enthought.' + extension_point_id trait_names = self.trait_names(contributes_to=old_id) # if trait_names: # print 'deprecated:', old_id if len(trait_names) == 0: # If there is no contributing trait then look for any decorated # methods. extensions = self._harvest_methods(extension_point_id) # FIXME: This is a temporary fix, which was necessary due to the # namespace refactor, but should be removed at some point. if not extensions: old_id = 'enthought.' + extension_point_id extensions = self._harvest_methods(old_id) # if extensions: # print 'deprecated:', old_id elif len(trait_names) == 1: extensions = self._get_extensions_from_trait(trait_names[0]) else: raise self._create_multiple_traits_exception(extension_point_id) return extensions ########################################################################### # 'IPlugin' interface. ########################################################################### #### Trait initializers ################################################### def _home_default(self): """ Trait initializer. """ # Each plugin gets a sub-directory of a 'plugins' directory in # 'application.home'. # # i.e. .../my.application.id/plugins/ plugins_dir = join(self.application.home, 'plugins') if not exists(plugins_dir): os.mkdir(plugins_dir) # Now create the 'home' directory of this plugin. home_dir = join(plugins_dir, self.id) if not exists(home_dir): os.mkdir(home_dir) return home_dir def _id_default(self): """ Trait initializer. """ id = '%s.%s' % (type(self).__module__, type(self).__name__) logger.warn('plugin %s has no Id - using <%s>' % (self, id)) return id def _name_default(self): """ Trait initializer. """ name = camel_case_to_words(type(self).__name__) logger.warn('plugin %s has no name - using <%s>' % (self, name)) return name #### Methods ############################################################## def start(self): """ Start the plugin. This method will *always* be empty so that you never have to call 'super(xxx, self).start()' if you provide an implementation in a derived class. The framework does what it needs to do when it starts a plugin by means of the plugin's activator. """ pass def stop(self): """ Stop the plugin. This method will *always* be empty so that you never have to call 'super(xxx, self).stop()' if you provide an implementation in a derived class. The framework does what it needs to do when it stops a plugin by means of the plugin's activator. """ pass ########################################################################### # 'Plugin' interface. ########################################################################### def connect_extension_point_traits(self): """ Connect all of the plugin's extension points. This means that the plugin will be notified if and when contributions are add or removed. """ ExtensionPoint.connect_extension_point_traits(self) return def disconnect_extension_point_traits(self): """ Disconnect all of the plugin's extension points.""" ExtensionPoint.disconnect_extension_point_traits(self) return def register_services(self): """ Register the services offered by the plugin. """ for trait_name, trait in self.traits(service=True).items(): logger.warn( 'DEPRECATED: Do not use the "service=True" metadata anymore. ' 'Services should now be offered using the service ' 'offer extension point (envisage.service_offers) ' 'from the core plugin. ' 'Plugin %s trait <%s>' % (self, trait_name) ) # Register a service factory for the trait. service_id = self._register_service_factory(trait_name, trait) # We save the service Id so that so that we can unregister the # service when the plugin is stopped. self._service_ids.append(service_id) return def unregister_services(self): """ Unregister any service offered by the plugin. """ # Unregister the services in the reverse order that we registered # them. service_ids = self._service_ids[:] service_ids.reverse() for service_id in service_ids: self.application.unregister_service(service_id) # Just in case the plugin is started again! self._service_ids = [] return ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ def _anytrait_changed(self, trait_name, old, new): """ Static trait change handler. """ # Ignore the '_items' part of the trait name (if it is there!), and get # the actual trait. base_trait_name = trait_name.split('_items')[0] trait = self.trait(base_trait_name) # If the trait is one that contributes to an extension point then fire # an appropriate 'extension point changed' event. if trait.contributes_to is not None: if trait_name.endswith('_items'): added = new.added removed = new.removed index = new.index else: added = new removed = old index = slice(0, max(len(old), len(new))) # Let the extension registry know about the change. self._fire_extension_point_changed( trait.contributes_to, added, removed, index ) return #### Methods ############################################################## def _create_multiple_traits_exception(self, extension_point_id): """ Create the exception raised when multiple traits are found. """ exception = ValueError( 'multiple traits for extension point <%s> in plugin <%s>' % ( extension_point_id, self.id ) ) return exception def _get_extensions_from_trait(self, trait_name): """ Return the extensions contributed via the specified trait. """ try: extensions = getattr(self, trait_name) except: logger.exception( 'getting extensions from %s, trait <%s>' % (self, trait_name) ) raise return extensions def _get_service_protocol(self, trait): """ Determine the protocol to register a service trait with. """ # If a specific protocol was specified then use it. if trait.service_protocol is not None: protocol = trait.service_protocol # Otherwise, use the type of the objects that can be assigned to the # trait. # # fixme: This works for 'Instance' traits, but what about 'AdaptsTo' # and 'AdaptedTo' traits? else: # Note that in traits the protocol can be an actual class or # interfacem or the *name* of a class or interface. This allows # us to lazy load them! protocol = trait.trait_type.klass return protocol def _harvest_methods(self, extension_point_id): """ Harvest all method-based contributions. """ extensions = [] for name, value in inspect.getmembers(self): if self._is_extension_method(value, extension_point_id): result = getattr(self, name)() if not isinstance(result, list): result = [result] extensions.extend(result) return extensions def _is_extension_method(self, value, extension_point_id): """ Return True if the value is an extension method. i.e. If the method is one that makes a contribution to the extension point. Currently there is exactly one way to make a method make a contribution, and that is to mark it using the 'contributes_to' decorator, e.g:: @contributes_to('acme.motd.messages') def get_messages(self): ... messages = [...] ... return messages """ is_extension_method = inspect.ismethod(value) \ and extension_point_id == getattr(value,'__extension_point__',None) return is_extension_method def _register_service_factory(self, trait_name, trait): """ Register a service factory for the specified trait. """ # Determine the protocol that the service should be registered with. protocol = self._get_service_protocol(trait) # Register a factory for the service so that it will be lazily loaded # the first time somebody asks for a service with the same protocol # (this could obviously be a lambda function, but I thought it best to # be more explicit 8^). def factory(**properties): """ A service factory. """ return getattr(self, trait_name) return self.application.register_service(protocol, factory) #### EOF ###################################################################### envisage-4.1.0/envisage/core_plugin.py0000644000175100001440000001773311674464014021001 0ustar ischnellusers00000000000000""" The Envisage core plugin. """ # Enthought library imports. from envisage.api import ExtensionPoint, Plugin, ServiceOffer from traits.api import List, Instance, Str class CorePlugin(Plugin): """ The Envisage core plugin. The core plugin offers facilities that are generally useful when building extensible applications such as adapters, categories and hooks etc. It does not contain anything to do with user interfaces! The core plugin should be started before any other plugin. It is up to the plugin manager to do this. """ # Extension point Ids. CATEGORIES = 'envisage.categories' CLASS_LOAD_HOOKS = 'envisage.class_load_hooks' PREFERENCES = 'envisage.preferences' SERVICE_OFFERS = 'envisage.service_offers' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'envisage.core' # The plugin's name (suitable for displaying to the user). name = 'Core' #### Extension points offered by this plugin ############################## # Categories are actually implemented via standard 'ClassLoadHooks', but # for (hopefully) readability and convenience we have a specific extension # point. categories = ExtensionPoint( List(Instance('envisage.category.Category')), id = CATEGORIES, desc = """ Traits categories allow you to dynamically extend a Python class with extra attributes, methods and events. Contributions to this extension point allow you to import categories *lazily* when the class to be extended is imported or created. Each contribution contains the name of the category class that you want to add (the 'class_name') and the name of the class that you want to extend (the 'target_class_name'). e.g. To add the 'FooCategory' category to the 'Foo' class:: Category( class_name = 'foo_category.FooCategory', target_class_name = 'foo.Foo' ) """ ) class_load_hooks = ExtensionPoint( List(Instance('envisage.class_load_hook.ClassLoadHook')), id = CLASS_LOAD_HOOKS, desc = """ Class load hooks allow you to be notified when any 'HasTraits' class is imported or created. See the documentation for 'ClassLoadHook' for more details. """ ) preferences = ExtensionPoint( List(Str), id = PREFERENCES, desc = """ Preferences files allow plugins to contribute default values for user preferences. Each contributed string must be the URL of a file-like object that contains preferences values. e.g. 'pkgfile://envisage/preferences.ini' - this looks for the 'preferences.ini' file in the 'envisage' package. 'file://C:/tmp/preferences.ini' - this looks for the 'preferences.ini' file in 'C:/tmp' 'http://some.website/preferences.ini' - this looks for the 'preferences.ini' document on the 'some.website' web site! The files themselves are parsed using the excellent 'ConfigObj' package. For detailed documentation please go to:- http://www.voidspace.org.uk/python/configobj.html """ ) service_offers = ExtensionPoint( List(ServiceOffer), id = SERVICE_OFFERS, desc = """ Services are simply objects that a plugin wants to make available to other plugins. This extension point allows you to offer services that are created 'on-demand'. e.g. my_service_offer = ServiceOffer( protocol = 'acme.IMyService', factory = an_object_or_a_callable_that_creates_one, properties = {'a dictionary' : 'that is passed to the factory'} ) See the documentation for 'ServiceOffer' for more details. """ ) #### Contributions to extension points made by this plugin ################ # None. ########################################################################### # 'IPlugin' interface. ########################################################################### def start(self): """ Start the plugin. """ # Load all contributed preferences files into the application's root # preferences node. self._load_preferences(self.application.preferences) # Connect all class load hooks. self._connect_class_load_hooks(self.class_load_hooks) # Add class load hooks for all of the contributed categories. The # category will be imported and added when the associated target class # is imported/created. self._add_category_class_load_hooks(self.categories) # Register all service offers. # # These services are unregistered by the default plugin activation # strategy (due to the fact that we store the service ids in this # specific trait!). self._service_ids = self._register_service_offers(self.service_offers) return ########################################################################### # Private interface. ########################################################################### def _add_category_class_load_hooks(self, categories): """ Add class load hooks for a list of categories. """ for category in categories: class_load_hook = self._create_category_class_load_hook(category) class_load_hook.connect() return def _connect_class_load_hooks(self, class_load_hooks): """ Connect all class load hooks. """ for class_load_hook in class_load_hooks: class_load_hook.connect() return def _create_category_class_load_hook(self, category): """ Create a category class load hook. """ # Local imports. from class_load_hook import ClassLoadHook def import_and_add_category(cls): """ Import a category and add it to a class. This is a closure that binds 'self' and 'category'. """ category_cls = self.application.import_symbol(category.class_name) cls.add_trait_category(category_cls) return category_class_load_hook = ClassLoadHook( class_name = category.target_class_name, on_load = import_and_add_category ) return category_class_load_hook def _load_preferences(self, preferences): """ Load all contributed preferences into a preferences node. """ # Enthought library imports. from envisage.resource.api import ResourceManager # We add the plugin preferences to the default scope. The default scope # is a transient scope which means that (quite nicely ;^) we never # save the actual default plugin preference values. They will only get # saved if a value has been set in another (persistent) scope - which # is exactly what happens in the preferences UI. default = preferences.node('default/') # The resource manager is used to find the preferences files. resource_manager = ResourceManager() for resource_name in self.preferences: f = resource_manager.file(resource_name) try: default.load(f) finally: f.close() return def _register_service_offers(self, service_offers): """ Register a list of service offers. """ return map(self._register_service_offer, service_offers) def _register_service_offer(self, service_offer): """ Register a service offer. """ service_id = self.application.register_service( protocol = service_offer.protocol, obj = service_offer.factory, properties = service_offer.properties ) return service_id ### EOF ###################################################################### envisage-4.1.0/envisage/i_extension_provider.py0000644000175100001440000000175611674464014022727 0ustar ischnellusers00000000000000""" The interface for extension providers. """ # Enthought library imports. from traits.api import Event, Interface # Local imports. from extension_point_changed_event import ExtensionPointChangedEvent class IExtensionProvider(Interface): """ The interface for extension providers. """ # The event fired when one of the provider's extension points has changed. extension_point_changed = Event(ExtensionPointChangedEvent) def get_extension_points(self): """ Return the extension points offered by the provider. Return an empty list if the provider does not offer any extension points. """ def get_extensions(self, extension_point_id): """ Return the provider's extensions to an extension point. The return value *must* be a list. Return an empty list if the provider does not contribute any extensions to the extension point. """ #### EOF ###################################################################### envisage-4.1.0/envisage/i_service_registry.py0000644000175100001440000001042711674464014022364 0ustar ischnellusers00000000000000""" The service registry interface. """ # Enthought library imports. from traits.api import Event, Interface class IServiceRegistry(Interface): """ The service registry interface. The service registry provides a 'Yellow Pages' style mechanism, in that services are published and looked up by protocol (meaning, *interface*, *type*, or *class* (for old-style classes!). It is called a 'Yellow Pages' mechanism because it is just like looking up a telephone number in the 'Yellow Pages' phone book. You use the 'Yellow Pages' instead of the 'White Pages' when you don't know the *name* of the person you want to call but you do know what *kind* of service you require. For example, if you have a leaking pipe, you know you need a plumber, so you pick up your 'Yellow Pages', go to the 'Plumbers' section and choose one that seems to fit the bill based on price, location, certification, etc. The service registry does exactly the same thing as the 'Yellow Pages', only with objects, and it even allows you to publish your own entries for free (unlike the *real* one)! """ # An event that is fired when a service is registered. registered = Event # An event that is fired when a service is unregistered. unregistered = Event def get_service(self, protocol, query='', minimize='', maximize=''): """ Return at most one service that matches the specified query. The protocol can be an actual class or interface, or the *name* of a class or interface in the form '.'. Return None if no such service is found. If no query is specified then a service that provides the specified protocol is returned (if one exists). NOTE: If more than one service exists that match the criteria then Don't try to guess *which* one it will return - it is random! """ def get_service_from_id(self, service_id): """ Return the service with the specified id. If no such service exists a 'ValueError' exception is raised. """ def get_services(self, protocol, query='', minimize='', maximize=''): """ Return all services that match the specified query. The protocol can be an actual class or interface, or the *name* of a class or interface in the form '.'. If no services match the query, then an empty list is returned. If no query is specified then all services that provide the specified protocol are returned (if any exist). """ def get_service_properties(self, service_id): """ Return the dictionary of properties associated with a service. If no such service exists a 'ValueError' exception is raised. The properties returned are 'live' i.e. changing them immediately changes the service registration. """ def register_service(self, protocol, obj, properties=None): """ Register a service. The protocol can be an actual class or interface, or the *name* of a class or interface in the form:: 'foo.bar.baz' Which is turned into the equivalent of an import statement that looks like:: from foo.bar import baz Return a service Id that can be used to unregister the service and to get/set any service properties. If 'obj' does not implement the specified protocol then it is treated as a 'service factory' that will be called the first time a service of the appropriate type is requested. A 'service factory' is simply a callable that takes the properties specified here as keyword arguments and returns an object. For *really* lazy loading, the factory can also be specified as a string which is used to import the callable. """ def set_service_properties(self, service_id, properties): """ Set the dictionary of properties associated with a service. If no such service exists a 'ValueError' exception is raised. """ def unregister_service(self, service_id): """ Unregister a service. If no such service exists a 'ValueError' exception is raised. """ #### EOF ###################################################################### envisage-4.1.0/envisage/service_registry.py0000644000175100001440000002127711674464014022061 0ustar ischnellusers00000000000000""" The service registry. """ # Standard library imports. import logging # Enthought library imports. from traits.api import Dict, Event, HasTraits, Int, Interface, \ Undefined, implements from traits.protocols.interfaces import Protocol # Local imports. from i_service_registry import IServiceRegistry from import_manager import ImportManager # Logging. logger = logging.getLogger(__name__) class ServiceRegistry(HasTraits): """ The service registry. """ implements(IServiceRegistry) #### IServiceRegistry interface ########################################## # An event that is fired when a service is registered. registered = Event # An event that is fired when a service is unregistered. unregistered = Event #### Private interface ################################################### # The services in the registry. # # { service_id : (protocol_name, obj, properties) } # # where: # # 'protocol_name' is the (possible dotted) name of the interface, type or # class that the object is registered against. # # 'obj' is the object that is registered (any old, Python object!). # # 'properties' is the arbitrary dictionary of properties that were # registered with the object. _services = Dict # The next service Id (service Ids are never persisted between process # invocations so this is simply an ever increasing integer!). _service_id = Int ########################################################################### # 'IServiceRegistry' interface. ########################################################################### def get_service(self, protocol, query='', minimize='', maximize=''): """ Return at most one service that matches the specified query. """ services = self.get_services(protocol, query, minimize, maximize) if len(services) > 0: service = services[0] else: service = None return service def get_service_from_id(self, service_id): """ Return the service with the specified id. """ try: protocol, obj, properties = self._services[service_id] except KeyError: raise ValueError('no service with id <%d>' % service_id) return obj def get_services(self, protocol, query='', minimize='', maximize=''): """ Return all services that match the specified query. """ services = [] for service_id, (name, obj, properties) in self._services.items(): if self._get_protocol_name(protocol) == name: # If the protocol is a string then we need to import it! if isinstance(protocol, basestring): actual_protocol = ImportManager().import_symbol(protocol) # Otherwise, it is an actual protocol, so just use it! else: actual_protocol = protocol # If the registered service is actually a factory then use it # to create the actual object. obj = self._resolve_factory( actual_protocol, name, obj, properties, service_id ) # If a query was specified then only add the service if it # matches it! if len(query) == 0 or self._eval_query(obj, properties, query): services.append(obj) # Are we minimizing or maximising anything? If so then sort the list # of services by the specified attribute/property. if minimize != '': services.sort(None, lambda x: getattr(x, minimize)) elif maximize != '': services.sort(None, lambda x: getattr(x, maximize), reverse=True) return services def get_service_properties(self, service_id): """ Return the dictionary of properties associated with a service. """ try: protocol, obj, properties = self._services[service_id] properties = properties.copy() except KeyError: raise ValueError('no service with id <%d>' % service_id) return properties def register_service(self, protocol, obj, properties=None): """ Register a service. """ protocol_name = self._get_protocol_name(protocol) # Make sure each service gets its own properties dictionary. if properties is None: properties = {} service_id = self._next_service_id() self._services[service_id] = (protocol_name, obj, properties) self.registered = service_id logger.debug('service <%d> registered %s', service_id, protocol_name) return service_id def set_service_properties(self, service_id, properties): """ Set the dictionary of properties associated with a service. """ try: protocol, obj, old_properties = self._services[service_id] self._services[service_id] = protocol, obj, properties.copy() except KeyError: raise ValueError('no service with id <%d>' % service_id) return def unregister_service(self, service_id): """ Unregister a service. """ try: protocol, obj, properties = self._services.pop(service_id) self.unregistered = service_id logger.debug('service <%d> unregistered', service_id) except KeyError: raise ValueError('no service with id <%d>' % service_id) return ########################################################################### # Private interface. ########################################################################### def _create_namespace(self, service, properties): """ Create a namespace in which to evaluate a query. """ namespace = {} namespace.update(service.__dict__) namespace.update(properties) return namespace def _eval_query(self, service, properties, query): """ Evaluate a query over a single service. Return True if the service matches the query, otherwise return False. """ namespace = self._create_namespace(service, properties) try: result = eval(query, namespace) except: result = False return result def _get_protocol_name(self, protocol_or_name): """ Returns the full class name for a protocol. """ if isinstance(protocol_or_name, basestring): name = protocol_or_name else: name = '%s.%s' % ( protocol_or_name.__module__, protocol_or_name.__name__ ) return name def _is_service_factory(self, protocol, obj): """ Is the object a factory for services supporting the protocol? """ # fixme: Should we have a formal notion of service factory with an # appropriate API, or is this good enough? An API might have lifecycle # methods to both create and destroy the service?!? # # If the protocol is a PyProtocols protocol (try saying that five times # fast ;^), then the object is deemed to be a factory if it does not # explicitly provide and cannot be adapted to the protocol. if isinstance(protocol, Protocol): is_service_factory = protocol(obj, Undefined) is Undefined # Otherwise, the protocol is a normal Python class so the object is # deemed to be a factory if it is not an instance of that class. else: is_service_factory = not isinstance(obj, protocol) return is_service_factory def _next_service_id(self): """ Returns the next service ID. """ self._service_id += 1 return self._service_id def _resolve_factory(self, protocol, name, obj, properties, service_id): """ If 'obj' is a factory then use it to create the actual service. """ # Is the registered service actually a service *factory*? if self._is_service_factory(protocol, obj): # A service factory is any callable that takes two arguments, the # first is the protocol, the second is the (possibly empty) # dictionary of properties that were registered with the service. # # If the factory is specified as a symbol path then import it. if isinstance(obj, basestring): obj = ImportManager().import_symbol(obj) obj = obj(**properties) # The resulting service object replaces the factory in the cache # (i.e. the factory will not get called again unless it is # unregistered first). self._services[service_id] = (name, obj, properties) return obj #### EOF ###################################################################### envisage-4.1.0/envisage/service_offer.py0000644000175100001440000000216611674464014021306 0ustar ischnellusers00000000000000""" An offer to provide a service. """ # Enthought library imports. from traits.api import Callable, Dict, Either, HasTraits, Str, Type class ServiceOffer(HasTraits): """ An offer to provide a service. """ #### 'ServiceOffer' interface ############################################# # The protocol that the service provides. # # This can be an actual class or interface, or a string that can be used to # import a class or interface. # # e.g. 'foo.bar.baz.Baz' is turned into 'from foo.bar.baz import Baz' protocol = Either(Str, Type) # A callable (or a string that can be used to import a callable) that is # the factory that creates the actual service object. # # e.g:: # # callable(**properties) -> Any # # e.g. 'foo.bar.baz.Baz' is turned into 'from foo.bar.baz import Baz' factory = Either(Str, Callable) # An optional set of properties to associate with the service offer. # # This dictionary is passed as keyword arguments to the factory. properties = Dict #### EOF ###################################################################### envisage-4.1.0/envisage/provider_extension_registry.py0000644000175100001440000002520711674464014024344 0ustar ischnellusers00000000000000""" An extension registry implementation with multiple providers. """ # Standard library imports. import logging # Enthought library imports. from traits.api import List, implements, on_trait_change # Local imports. from extension_registry import ExtensionRegistry from i_extension_provider import IExtensionProvider from i_provider_extension_registry import IProviderExtensionRegistry # Logging. logger = logging.getLogger(__name__) class ProviderExtensionRegistry(ExtensionRegistry): """ An extension registry implementation with multiple providers. """ implements(IProviderExtensionRegistry) #### Protected 'ProviderExtensionRegistry' interface ###################### # The extension providers that populate the registry. _providers = List(IExtensionProvider) ########################################################################### # 'IExtensionRegistry' interface. ########################################################################### def set_extensions(self, extension_point_id, extensions): """ Set the extensions to an extension point. """ raise SystemError('extension points cannot be set') ########################################################################### # 'ProviderExtensionRegistry' interface. ########################################################################### def add_provider(self, provider): """ Add an extension provider. """ events = self._add_provider(provider) for extension_point_id, (refs, added, index) in events.items(): self._call_listeners(refs, extension_point_id, added, [], index) return def get_providers(self): """ Return all of the providers in the registry. """ return self._providers[:] def remove_provider(self, provider): """ Remove an extension provider. Raise a 'ValueError' if the provider is not in the registry. """ events = self._remove_provider(provider) for extension_point_id, (refs, removed, index) in events.items(): self._call_listeners(refs, extension_point_id, [], removed, index) return ########################################################################### # Protected 'ExtensionRegistry' interface. ########################################################################### def _get_extensions(self, extension_point_id): """ Return the extensions for the given extension point. """ # If we don't know about the extension point then it sure ain't got # any extensions! if not extension_point_id in self._extension_points: logger.warn( 'getting extensions of unknown extension point <%s>' \ % extension_point_id ) extensions = [] # Has this extension point already been accessed? elif extension_point_id in self._extensions: extensions = self._extensions[extension_point_id] # If not, then ask each provider for its contributions to the extension # point. else: extensions = self._initialize_extensions(extension_point_id) self._extensions[extension_point_id] = extensions # We store the extensions as a list of lists, with each inner list # containing the contributions from a single provider. Here we just # concatenate them into a single list. # # You could use a list comprehension, here:- # # all = [x for y in extensions for x in y] # # But I'm sure sure that that makes it any clearer ;^) all = [] map(all.extend, extensions) return all ########################################################################### # Protected 'ProviderExtensionRegistry' interface. ########################################################################### def _add_provider(self, provider): """ Add a new provider. """ # Add the provider's extension points. self._add_provider_extension_points(provider) # Add the provider's extensions. events = self._add_provider_extensions(provider) # And finally, tag it into the list of providers. self._providers.append(provider) return events def _add_provider_extensions(self, provider): """ Add a provider's extensions to the registry. """ # Each provider can contribute to multiple extension points, so we # build up a dictionary of the 'ExtensionPointChanged' events that we # need to fire. events = {} # Does the provider contribute any extensions to an extension point # that has already been accessed? for extension_point_id, extensions in self._extensions.items(): new = provider.get_extensions(extension_point_id) # We only need fire an event for this extension point if the # provider contributes any extensions. if len(new) > 0: index = sum(map(len, extensions)) refs = self._get_listener_refs(extension_point_id) events[extension_point_id] = (refs, new[:], index) extensions.append(new) return events def _add_provider_extension_points(self, provider): """ Add a provider's extension points to the registry. """ for extension_point in provider.get_extension_points(): self._extension_points[extension_point.id] = extension_point return def _remove_provider(self, provider): """ Remove a provider. """ # Remove the provider's extensions. events = self._remove_provider_extensions(provider) # Remove the provider's extension points. self._remove_provider_extension_points(provider, events) # And finally take it out of the list of providers. self._providers.remove(provider) return events def _remove_provider_extensions(self, provider): """ Remove a provider's extensions from the registry. """ # Each provider can contribute to multiple extension points, so we # build up a dictionary of the 'ExtensionPointChanged' events that we # need to fire. events = {} # Find the index of the provider in the provider list. Its # contributions are at the same index in the extensions list of lists. index = self._providers.index(provider) # Does the provider contribute any extensions to an extension point # that has already been accessed? for extension_point_id, extensions in self._extensions.items(): old = extensions[index] # We only need fire an event for this extension point if the # provider contributed any extensions. if len(old) > 0: offset = sum(map(len, extensions[:index])) refs = self._get_listener_refs(extension_point_id) events[extension_point_id] = (refs, old[:], offset) del extensions[index] return events def _remove_provider_extension_points(self, provider, events): """ Remove a provider's extension points from the registry. """ for extension_point in provider.get_extension_points(): # Remove the extension point. del self._extension_points[extension_point.id] return ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ @on_trait_change('_providers:extension_point_changed') def _providers_extension_point_changed(self, obj, trait_name, old, event): """ Dynamic trait change handler. """ logger.debug('provider <%s> extension point changed', obj) extension_point_id = event.extension_point_id # If the extension point has not yet been accessed then we don't fire a # changed event. # # This is because we only access extension points lazily and so we # can't tell what has actually changed because we have nothing to # compare it to! if not extension_point_id in self._extensions: return # This is a list of lists where each inner list contains the # contributions made to the extension point by a single provider. # # fixme: This causes a problem if the extension point has not yet been # accessed! The tricky thing is that if it hasn't been accessed yet # how do we know what has changed?!? Maybe we should just return an # empty list instead of barfing! extensions = self._extensions[extension_point_id] # Find the index of the provider in the provider list. Its # contributions are at the same index in the extensions list of lists. provider_index = self._providers.index(obj) # Get the updated list from the provider. extensions[provider_index] = obj.get_extensions(extension_point_id) # Find where the provider's contributions are in the whole 'list'. offset = sum(map(len, extensions[:provider_index])) # Translate the event index from one that refers to the list of # contributions from the provider, to the list of contributions from # all providers. index = self._translate_index(event.index, offset) # Find out who is listening. refs = self._get_listener_refs(extension_point_id) # Let any listeners know that the extensions have been added. self._call_listeners( refs, extension_point_id, event.added, event.removed, index ) return #### Methods ############################################################## def _initialize_extensions(self, extension_point_id): """ Initialize the extensions to an extension point. """ # We store the extensions as a list of lists, with each inner list # containing the contributions from a single provider. extensions = [] for provider in self._providers: extensions.append(provider.get_extensions(extension_point_id)[:]) logger.debug('extensions to <%s> <%s>', extension_point_id, extensions) return extensions def _translate_index(self, index, offset): """ Translate an event index by the given offset. """ if isinstance(index, slice): index = slice(index.start+offset, index.stop+offset, index.step) else: index = index + offset return index #### EOF ###################################################################### envisage-4.1.0/envisage/plugin_extension_registry.py0000644000175100001440000000405611674464014024007 0ustar ischnellusers00000000000000""" An extension registry that uses plugins as extension providers. """ # Enthought library imports. from traits.api import Instance, on_trait_change # Local imports. from i_plugin_manager import IPluginManager from provider_extension_registry import ProviderExtensionRegistry class PluginExtensionRegistry(ProviderExtensionRegistry): """ 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. """ #### 'PluginExtensionRegistry' interface ################################## # The plugin manager that has the plugins we are after! plugin_manager = Instance(IPluginManager) ########################################################################### # 'PluginExtensionRegistry' interface. ########################################################################### #### Trait change handlers ################################################ def _plugin_manager_changed(self, trait_name, old, new): """ Static trait change handler. """ # In practise I can't see why you would ever want (or need) to change # the registry's plugin manager on the fly, but hey... Hence, 'old' # will probably always be 'None'! if old is not None: for plugin in old: self.remove_provider(plugin) if new is not None: for plugin in new: self.add_provider(plugin) return @on_trait_change('plugin_manager:plugin_added') def _on_plugin_added(self, obj, trait_name, old, event): """ Dynamic trait change handler. """ self.add_provider(event.plugin) return @on_trait_change('plugin_manager:plugin_removed') def _on_plugin_removed(self, obj, trait_name, old, event): """ Dynamic trait change handler. """ self.remove_provider(event.plugin) return #### EOF ###################################################################### envisage-4.1.0/envisage/i_extension_point.py0000644000175100001440000000210711674464014022215 0ustar ischnellusers00000000000000""" The interface for extension points. """ # Enthought library imports. from traits.api import Instance, Interface, Str, TraitType class IExtensionPoint(Interface): """ The interface for extension points. """ # A description of what the extension point is and does! (it is called # the slightly dubious, 'desc', instead of 'description', or, to be more # 'Pythonic', maybe 'doc' to match the 'desc' metadata used in traits). desc = Str # The extension point's unique identifier. # # Where 'unique' technically means 'unique within the extension registry', # but since the chances are that you will want to include extension points # from external sources, this really means 'globally unique'! Using the # Python package path might be useful here ;^) # # e.g. 'envisage.ui.workbench.views' id = Str # A trait type that describes what can be contributed to the extension # point. # # e.g. List(Str) trait_type = Instance(TraitType) #### EOF ###################################################################### envisage-4.1.0/envisage/extension_point_binding.py0000644000175100001440000001453211674464014023404 0ustar ischnellusers00000000000000""" A binding between a trait on an object and an extension point. """ # Standard library imports. import weakref # Enthought library imports. from traits.api import Any, HasTraits, Instance, Str, Undefined # Local imports. from i_extension_registry import IExtensionRegistry class ExtensionPointBinding(HasTraits): """ A binding between a trait on an object and an extension point. """ #### 'ExtensionPointBinding' *CLASS* interface ############################ # We keep a reference to each binding alive until its associated object # is garbage collected. _bindings = weakref.WeakKeyDictionary() #### 'ExtensionPointBinding' interface #################################### # The object that we are binding the extension point to. obj = Any # The Id of the extension point. extension_point_id = Str # The extension registry used by the binding. If this trait is not set then # the class-scope extension registry set on the 'ExtensionPoint' class is # used (and if that is not set then the binding won't work ;^) extension_registry = Instance(IExtensionRegistry) # The name of the trait that we are binding the extension point to. trait_name = Str #### Private interface #################################################### # A flag that prevents us from setting a trait twice. _event_handled = False ########################################################################### # 'object' interface. ########################################################################### def __init__(self, **traits): """ Constructor. """ super(ExtensionPointBinding, self).__init__(**traits) # Initialize the object's trait from the extension point. self._set_trait(notify=False) # Wire-up the trait change and extension point handlers. self._initialize() # We keep a reference to each binding alive until its associated # object is garbage collected. ExtensionPointBinding._bindings[self.obj] = self return ########################################################################### # 'ExtensionPointBinding' interface. ########################################################################### #### Trait initializers ################################################### def _extension_registry_default(self): """ Trait initializer. """ # fixme: Sneaky global!!!!! from extension_point import ExtensionPoint return ExtensionPoint.extension_registry ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ def _on_trait_changed(self, obj, trait_name, old, new): """ Dynamic trait change handler. """ if not self._event_handled: self._set_extensions(new) return def _on_trait_items_changed(self, obj, trait_name, old, event): """ Dynamic trait change handler. """ if not self._event_handled: self._set_extensions(getattr(obj, self.trait_name)) return #### Other observer pattern listeners ##################################### def _extension_point_listener(self, extension_registry, event): """ Listener called when an extension point is changed. """ self._event_handled = True if event.index is not None: self._update_trait(event) else: self._set_trait(notify=True) self._event_handled = False return #### Methods ############################################################## def _initialize(self): """ Wire-up trait change handlers etc. """ # Listen for the object's trait being changed. self.obj.on_trait_change( self._on_trait_changed, self.trait_name ) self.obj.on_trait_change( self._on_trait_items_changed, self.trait_name + '_items' ) # Listen for the extension point being changed. self.extension_registry.add_extension_point_listener( self._extension_point_listener, self.extension_point_id ) return def _set_trait(self, notify): """ Set the object's trait to the value of the extension point. """ value = self.extension_registry.get_extensions(self.extension_point_id) traits = {self.trait_name : value} self.obj.set(trait_change_notify=notify, **traits) return def _update_trait(self, event): """ Update the object's trait to the value of the extension point. """ self._set_trait(notify=False) self.obj.trait_property_changed( self.trait_name + '_items', Undefined, event ) return def _set_extensions(self, extensions): """ Set the extensions to an extension point. """ self.extension_registry.set_extensions( self.extension_point_id, extensions ) return # Factory function for creating bindings. def bind_extension_point( obj, trait_name, extension_point_id, extension_registry=None ): """ Create a binding to an extension point. """ # This may seem a bit wierd, but we manually build up a dictionary of # the traits that need to be set at the time the 'ExtensionPointBinding' # instance is created. # # This is because we only want to set the 'extension_registry' trait iff # one is explicitly specified. If we passed it in with the default argument # value of 'None' then it counts as 'setting' the trait which prevents # the binding instance from defaulting to the appropriate registry. # Also, if we try to set the 'extension_registry' trait *after* # construction time then it is too late as the binding initialization is # done in the constructor (we could of course split that out, which may be # the 'right' way to do it ;^). traits = { 'obj' : obj, 'trait_name' : trait_name, 'extension_point_id' : extension_point_id } if extension_registry is not None: traits['extension_registry'] = extension_registry return ExtensionPointBinding(**traits) #### EOF ###################################################################### envisage-4.1.0/envisage/application_event.py0000644000175100001440000000054411674464014022167 0ustar ischnellusers00000000000000""" An application event. """ # Enthought library imports. from traits.api import Instance, Vetoable class ApplicationEvent(Vetoable): """ An application event. """ # The application that the event is for. application = Instance('envisage.api.IApplication') #### EOF ###################################################################### envisage-4.1.0/envisage/extension_point.py0000644000175100001440000002211611674464014021707 0ustar ischnellusers00000000000000""" A trait type used to declare and access extension points. """ # Standard library imports. import inspect, weakref # Enthought library imports. from traits.api import List, TraitType, Undefined, implements # Local imports. from i_extension_point import IExtensionPoint def contributes_to(id): """ A factory for extension point decorators! As an alternative to making contributions via traits, you can use this decorator to mark any method on a 'Plugin' as contributing to an extension point (note this is *only* used on 'Plugin' instances!). e.g. Using a trait you might have something like:: class MyPlugin(Plugin): messages = List(contributes_to='acme.messages') def _messages_default(self): return ['Hello', 'Hola'] whereas, using the decorator, it would be:: class MyPlugin(Plugin): @contributes_to('acme.messages') def _get_messages(self): return ['Hello', 'Hola'] There is not much in it really, but the decorator version looks a little less like 'magic' since it doesn't require the developer to know about Traits default initializers. However, if you know that you will want to dynamically change your contributions then use the trait version because all you have to do is change the value of the trait and the framework will react accordingly. """ def decorator(fn): """ A decorator for marking methods as extension contributors. """ fn.__extension_point__ = id return fn return decorator # Exception message template. INVALID_TRAIT_TYPE = 'extension points must be "List"s e.g. List, List(Int)' \ ' but a value of %s was specified.' class ExtensionPoint(TraitType): """ A trait type used to declare and access extension points. Note that this is a trait *type* and hence does *NOT* have traits itself (i.e. it does *not* inherit from 'HasTraits'). """ # Even though trait types do not themselves have traits, we can still # declare that we implement an interface (since it is just PyProtocols # underneath the covers). implements(IExtensionPoint) ########################################################################### # 'ExtensionPoint' *CLASS* interface. ########################################################################### @staticmethod def bind(obj, trait_name, extension_point_id): """ Create a binding to an extension point. """ from extension_point_binding import bind_extension_point return bind_extension_point(obj, trait_name, extension_point_id) @staticmethod def connect_extension_point_traits(obj): """ Connect all of the 'ExtensionPoint' traits on an object. """ for trait_name, trait in obj.traits(__extension_point__=True).items(): trait.trait_type.connect(obj, trait_name) return @staticmethod def disconnect_extension_point_traits(obj): """ Disconnect all of the 'ExtensionPoint' traits on an object. """ for trait_name, trait in obj.traits(__extension_point__=True).items(): trait.trait_type.disconnect(obj, trait_name) return ########################################################################### # 'object' interface. ########################################################################### def __init__(self, trait_type=List, id=None, **metadata): """ Constructor. """ # We add '__extension_point__' to the metadata to make the extension # point traits easier to find with the 'traits' and 'trait_names' # methods on 'HasTraits'. metadata['__extension_point__'] = True super(ExtensionPoint, self).__init__(**metadata) # The trait type that describes the extension point. # # If we are handed a trait type *class* e.g. List, instead of a trait # type *instance* e.g. List() or List(Int) etc, then we instantiate it. if inspect.isclass(trait_type): trait_type = trait_type() # Currently, we only support list extension points (we may in the # future want to allow other collections e.g. dictionaries etc). if not isinstance(trait_type, List): raise TypeError(INVALID_TRAIT_TYPE % trait_type) self.trait_type = trait_type # The Id of the extension point. if id is None: raise ValueError('an extension point must have an Id') self.id = id # A dictionary that is used solely to keep a reference to all extension # point listeners alive until their associated objects are garbage # collected. # # Dict(weakref.ref(Any), Dict(Str, Callable)) self._obj_to_listeners_map = weakref.WeakKeyDictionary() return ########################################################################### # 'TraitType' interface. ########################################################################### def get(self, obj, trait_name): """ Trait type getter. """ extension_registry = self._get_extension_registry(obj) # Get the extensions to this extension point. extensions = extension_registry.get_extensions(self.id) # Make sure the contributions are of the appropriate type. return self.trait_type.validate(obj, trait_name, extensions) def set(self, obj, name, value): """ Trait type setter. """ extension_registry = self._get_extension_registry(obj) # Note that some extension registry implementations may not support the # setting of extension points (the default, plugin extension registry # for exxample ;^). extension_registry.set_extensions(self.id, value) return ########################################################################### # 'ExtensionPoint' interface. ########################################################################### def connect(self, obj, trait_name): """ Connect the extension point to a trait on an object. This allows the object to react when contributions are added or removed from the extension point. fixme: It would be nice to be able to make the connection automatically but we would need a slight tweak to traits to allow the trait type to be notified when a new instance that uses the trait type is created. """ def listener(extension_registry, event): """ Listener called when an extension point is changed. """ # If an index was specified then we fire an '_items' changed event. if event.index is not None: name = trait_name + '_items' old = Undefined new = event # Otherwise, we fire a normal trait changed event. else: name = trait_name old = event.removed new = event.added obj.trait_property_changed(name, old, new) return extension_registry = self._get_extension_registry(obj) # Add the listener to the extension registry. extension_registry.add_extension_point_listener(listener, self.id) # Save a reference to the listener so that it does not get garbage # collected until its associated object does. listeners = self._obj_to_listeners_map.setdefault(obj, {}) listeners[trait_name] = listener return def disconnect(self, obj, trait_name): """ Disconnect the extension point from a trait on an object. """ extension_registry = self._get_extension_registry(obj) listener = self._obj_to_listeners_map[obj].get(trait_name) if listener is not None: # Remove the listener from the extension registry. extension_registry.remove_extension_point_listener( listener, self.id ) # Clean up. del self._obj_to_listeners_map[obj][trait_name] return ########################################################################### # Private interface. ########################################################################### def _get_extension_registry(self, obj): """ Return the extension registry in effect for an object. """ extension_registry = getattr(obj, 'extension_registry', None) if extension_registry is None: # If the debug package is present then log the call stack to help # the developer see where the problem occurred. try: from etsdevtools.debug.api import log_called_from log_called_from(10) except: pass raise ValueError( 'The "ExtensionPoint" trait type can only be used in ' \ 'objects that have a reference to an extension registry ' \ 'via their "extension_registry" trait. ' \ 'Extension point Id <%s>' % self.id ) return extension_registry #### EOF ###################################################################### envisage-4.1.0/envisage/class_load_hook.py0000644000175100001440000000602511674464014021607 0ustar ischnellusers00000000000000""" A hook to allow code be executed when a class is loaded. """ # Standard library imports. import sys # Enthought library imports. from traits.api import Callable, HasTraits, MetaHasTraits, Str class ClassLoadHook(HasTraits): """ A hook to allow code to be executed when a class is loaded. If the class is *already* loaded when the 'connect' method is called then the code is executed immediately. """ #### 'ClassLoadHook' interface ############################################ # The name of the class. When this class is loaded the 'on_class_loaded' # method is called. class_name = Str # A callable that will be executed when the class is loaded. The callable # must take a single argument which will be the loaded class. # # This is used in the default implementation of 'on_class_loaded'. If you # override that, then you don't have to set to this trait. on_load = Callable ########################################################################### # 'ClassLoadHook' interface. ########################################################################### def connect(self): """ Connect the load hook to listen for the class being loaded. """ MetaHasTraits.add_listener(self.on_class_loaded, self.class_name) # If the class has already been loaded then run the code now! cls = self._get_class(self.class_name) if cls is not None: self.on_class_loaded(cls) return def disconnect(self): """ Disconnect the load hook. """ MetaHasTraits.remove_listener(self.on_class_loaded, self.class_name) return def on_class_loaded(self, cls): """ This method is called when the class is loaded. If 'self.on_load' is not None, it calls 'self.on_load(cls)'. """ if self.on_load is not None: self.on_load(cls) return ########################################################################### # Private interface. ########################################################################### def _get_class(self, class_path): """ Returns the class defined by *class_path*. Returns **None** if the class has not yet been loaded. """ # Only check if the class name has at least a partial hierarchy. # # fixme: Comment should say why! if '.' in class_path: components = class_path.split('.') module_name = '.'.join(components[:-1]) class_name = components[-1] # The class is loaded if its module has been imported and the class # is defined in the module dictionary. module = sys.modules.get(module_name, None) if module is not None and hasattr(module, class_name): klass = getattr(module, class_name) else: klass = None else: klass = None return klass #### EOF ###################################################################### envisage-4.1.0/envisage/i_application.py0000644000175100001440000000353411674464014021300 0ustar ischnellusers00000000000000""" The application interface. """ # Enthought library imports. from apptools.preferences.api import IPreferences from traits.api import Event, Instance, Str, VetoableEvent # Local imports. from i_extension_registry import IExtensionRegistry from i_import_manager import IImportManager from i_plugin_manager import IPluginManager from i_service_registry import IServiceRegistry from application_event import ApplicationEvent class IApplication( IExtensionRegistry, IImportManager, IPluginManager, IServiceRegistry ): """ The application interface. """ # The application's globally unique identifier. id = Str # The name of a directory (created for you) to which the application can # read and write non-user accessible data, i.e. configuration information, # preferences, etc. home = Str # The name of a directory (created for you upon access) to which the # application can read and write user-accessible data, e.g. projects created # by the user. user_data = Str # The root preferences node. preferences = Instance(IPreferences) #### Events #### # Fired when the application is starting. This is the first thing that # happens when the 'start' method is called. starting = VetoableEvent(ApplicationEvent) # Fired when all plugins have been started. started = Event(ApplicationEvent) # Fired when the plugin manager is stopping. This is the first thing that # happens when the 'stop' method is called. stopping = VetoableEvent(ApplicationEvent) # Fired when all plugins have been stopped. stopped = Event(ApplicationEvent) def run(self): """ Run the application. The same as:: if application.start(): application.stop() """ #### EOF ###################################################################### envisage-4.1.0/envisage/i_plugin_manager.py0000644000175100001440000000372611674464014021770 0ustar ischnellusers00000000000000""" The plugin manager interface. """ # Enthought library imports. from traits.api import Event, Interface # Local imports. from i_plugin import IPlugin from plugin_event import PluginEvent class IPluginManager(Interface): """ The plugin manager interface. """ #### Events #### # Fired when a plugin has been added to the manager. plugin_added = Event(PluginEvent) # Fired when a plugin has been removed from the manager. plugin_removed = Event(PluginEvent) def __iter__(self): """ Return an iterator over the manager's plugins. """ def add_plugin(self, plugin): """ Add a plugin to the manager. """ def get_plugin(self, plugin_id): """ Return the plugin with the specified Id. Return None if no such plugin exists. """ def remove_plugin(self, plugin): """ Remove a plugin from the manager. """ def start(self): """ Start the plugin manager. This starts all of the manager's plugins. """ def start_plugin(self, plugin=None, plugin_id=None): """ Start the specified plugin. If a plugin is specified then start it. If no plugin is specified then the Id is used to look up the plugin and then start it. If no such plugin exists then a 'SystemError' exception is raised. """ def stop(self): """ Stop the plugin manager. This stop's all of the plugin manager's plugins (in the reverse order that they were started). """ def stop_plugin(self, plugin=None, plugin_id=None): """ Stop the specified plugin. If a plugin is specified then stop it (the Id is ignored). If no plugin is specified then the Id is used to look up the plugin and then stop it. If no such plugin exists then a 'SystemError' exception is raised. """ #### EOF ###################################################################### envisage-4.1.0/envisage/egg_plugin_manager.py0000644000175100001440000001010011674464014022262 0ustar ischnellusers00000000000000""" A plugin manager that gets its plugins from Eggs. """ # Standard library imports. import logging, pkg_resources, re # Enthought library imports. from traits.api import Instance, List, Str # Local imports. from egg_utils import get_entry_points_in_egg_order from plugin_manager import PluginManager # Logging. logger = logging.getLogger(__name__) class EggPluginManager(PluginManager): """ A plugin manager that gets its plugins from Eggs. To declare a plugin (or plugins) in your egg use an entry point in your 'setup.py' file, e.g. [envisage.plugins] acme.foo = acme.foo.foo_plugin:FooPlugin The left hand side of the entry point declaration must be the same as the 'id' trait of the plugin (e.g. the 'FooPlugin' would have its 'id' trait set to 'acme.foo'). This allows the plugin manager to filter out plugins using the 'include' and 'exclude' lists (if specified) *without* having to import and instantiate them. """ # Entry point Id. PLUGINS = 'envisage.plugins' #### 'EggPluginManager' interface ######################################### # The working set that contains the eggs that contain the plugins that # live in the house that Jack built ;^) By default we use the global # working set. working_set = Instance(pkg_resources.WorkingSet, pkg_resources.working_set) # An optional list of the Ids of the plugins that are to be excluded by # the manager. # # Each item in the list is actually a regular expression as used by the # 're' module. exclude = List(Str) # An optional list of the Ids of the plugins that are to be included by # the manager (i.e. *only* plugins with Ids in this list will be added to # the manager). # # Each item in the list is actually a regular expression as used by the # 're' module. include = List(Str) ########################################################################### # Protected 'PluginManager' interface. ########################################################################### def __plugins_default(self): """ Trait initializer. """ plugins = [] for ep in get_entry_points_in_egg_order(self.working_set,self.PLUGINS): if self._is_included(ep.name) and not self._is_excluded(ep.name): plugin = self._create_plugin_from_ep(ep) plugins.append(plugin) logger.debug('egg plugin manager found plugins <%s>', plugins) return plugins ########################################################################### # Private interface. ########################################################################### def _create_plugin_from_ep(self, ep): """ Create a plugin from an extension point. """ klass = ep.load() plugin = klass(application=self.application) # Warn if the entry point is an old-style one where the LHS didn't have # to be the same as the plugin Id. if ep.name != plugin.id: logger.warn( 'entry point name <%s> should be the same as the ' 'plugin id <%s>' % (ep.name, plugin.id) ) return plugin def _is_excluded(self, plugin_id): """ Return True if the plugin Id is excluded. If no 'exclude' patterns are specified then this method returns False for all plugin Ids. """ if len(self.exclude) == 0: return False for pattern in self.exclude: if re.match(pattern, plugin_id) is not None: return True return False def _is_included(self, plugin_id): """ Return True if the plugin Id is included. If no 'include' patterns are specified then this method returns True for all plugin Ids. """ if len(self.include) == 0: return True for pattern in self.include: if re.match(pattern, plugin_id) is not None: return True return False #### EOF ###################################################################### envisage-4.1.0/envisage/i_extension_registry.py0000644000175100001440000000474411674464014022745 0ustar ischnellusers00000000000000""" The interface for extension registries. """ # Enthought library imports. from traits.api import Interface class IExtensionRegistry(Interface): """ The interface for extension registries. """ def add_extension_point_listener(self, listener, extension_point_id=None): """ Add a listener for extensions being added or removed. A listener is any Python callable with the following signature:: def listener(extension_registry, extension_point_changed_event): ... If an extension point is specified then the listener will only be called when extensions are added to or removed from that extension point (the extension point may or may not have been added to the registry at the time of this call). If *no* extension point is specified then the listener will be called when extensions are added to or removed from *any* extension point. When extensions are added or removed all specific listeners are called first (in arbitrary order), followed by all non-specific listeners (again, in arbitrary order). """ def add_extension_point(self, extension_point): """ Add an extension point. If an extension point already exists with this Id then it is simply replaced. """ def get_extensions(self, extension_point_id): """ Return the extensions contributed to an extension point. Return an empty list if the extension point does not exist. """ def get_extension_point(self, extension_point_id): """ Return the extension point with the specified Id. Return None if no such extension point exists. """ def get_extension_points(self): """ Return all extension points that have been added to the registry. """ def remove_extension_point_listener(self,listener,extension_point_id=None): """ Remove a listener for extensions being added or removed. Raise a 'ValueError' if the listener does not exist. """ def remove_extension_point(self, extension_point_id): """ Remove an extension point. Raise an 'UnknownExtensionPoint' exception if no extension point exists with the specified Id. """ def set_extensions(self, extension_point_id, extensions): """ Set the extensions contributed to an extension point. """ #### EOF ###################################################################### envisage-4.1.0/envisage/i_provider_extension_registry.py0000644000175100001440000000124111674464014024644 0ustar ischnellusers00000000000000""" The provider extension registry interface. """ # Local imports. from i_extension_registry import IExtensionRegistry class IProviderExtensionRegistry(IExtensionRegistry): """ The provider extension registry interface. """ def add_provider(self, provider): """ Add an extension provider. """ def get_providers(self): """ Return all of the providers in the registry. """ def remove_provider(self, provider): """ Remove an extension provider. Raise a 'ValueError' if the provider is not in the registry. """ #### EOF ###################################################################### envisage-4.1.0/envisage/service.py0000644000175100001440000000502611674464014020123 0ustar ischnellusers00000000000000""" A trait type used to access services. """ # Standard library imports. import logging # Enthought library imports. from traits.api import TraitType # Logging. logger = logging.getLogger(__name__) class Service(TraitType): """ A trait type used to access services. Note that this is a trait *type* and hence does *NOT* have traits itself (i.e. it does *not* inherit from 'HasTraits'). """ ########################################################################### # 'object' interface. ########################################################################### def __init__( self, protocol=None, query='', minimize='', maximize='', **metadata ): """ Constructor. """ super(Service, self).__init__(**metadata) # The protocol that the service must provide. self._protocol = protocol # The optional query. self._query = query # The optional name of the trait/property to minimize. self._minimize = minimize # The optional name of the trait/property to maximize. self._maximize = maximize return ########################################################################### # 'TraitType' interface. ########################################################################### def get(self, obj, trait_name): """ Trait type getter. """ service_registry = self._get_service_registry(obj) obj = service_registry.get_service( self._protocol, self._query, self._minimize, self._maximize ) return obj def set(self, obj, name, value): """ Trait type setter. """ raise SystemError('Service traits cannot be set') ########################################################################### # Private interface. ########################################################################### def _get_service_registry(self, obj): """ Return the service registry in effect for an object. """ service_registry = getattr(obj, 'service_registry', None) if service_registry is None: raise ValueError( 'The "Service" trait type can only be used within objects ' \ 'that have a reference to a service registry via their ' \ '"service_registry" trait. ' \ 'Object <%s> Service protocol <%s>' % (obj, self._protocol) ) return service_registry #### EOF ###################################################################### envisage-4.1.0/envisage/extension_registry.py0000644000175100001440000001342511674464014022431 0ustar ischnellusers00000000000000""" A base class for extension registry implementation. """ # Standard library imports. import logging # Enthought library imports. from traits.api import Dict, HasTraits, implements # Local imports. from extension_point_changed_event import ExtensionPointChangedEvent from i_extension_registry import IExtensionRegistry import safeweakref from unknown_extension_point import UnknownExtensionPoint # Logging. logger = logging.getLogger(__name__) class ExtensionRegistry(HasTraits): """ A base class for extension registry implementation. """ implements(IExtensionRegistry) ########################################################################### # Protected 'ExtensionRegistry' interface. ########################################################################### # A dictionary of extensions, keyed by extension point. _extensions = Dict # The extension points that have been added *explicitly*. _extension_points = Dict # Extension listeners. # # These are called when extensions are added to or removed from an # extension point. # # e.g. Dict(extension_point, [weakref.ref(callable)]) # # A listener is any Python callable with the following signature:- # # def listener(extension_registry, extension_point_changed_event): # ... _listeners = Dict ########################################################################### # 'IExtensionRegistry' interface. ########################################################################### def add_extension_point_listener(self, listener, extension_point_id=None): """ Add a listener for extensions being added or removed. """ listeners = self._listeners.setdefault(extension_point_id, []) listeners.append(safeweakref.ref(listener)) return def add_extension_point(self, extension_point): """ Add an extension point. """ self._extension_points[extension_point.id] = extension_point logger.debug('extension point <%s> added', extension_point.id) return def get_extensions(self, extension_point_id): """ Return the extensions contributed to an extension point. """ return self._get_extensions(extension_point_id)[:] def get_extension_point(self, extension_point_id): """ Return the extension point with the specified Id. """ return self._extension_points.get(extension_point_id) def get_extension_points(self): """ Return all extension points. """ return self._extension_points.values() def remove_extension_point_listener(self,listener,extension_point_id=None): """ Remove a listener for extensions being added or removed. """ listeners = self._listeners.setdefault(extension_point_id, []) listeners.remove(safeweakref.ref(listener)) return def remove_extension_point(self, extension_point_id): """ Remove an extension point. """ self._check_extension_point(extension_point_id) # Remove the extension point. del self._extension_points[extension_point_id] # Remove any extensions to the extension point. if extension_point_id in self._extensions: old = self._extensions[extension_point_id] del self._extensions[extension_point_id] else: old = [] refs = self._get_listener_refs(extension_point_id) self._call_listeners(refs, extension_point_id, [], old, 0) logger.debug('extension point <%s> removed', extension_point_id) return def set_extensions(self, extension_point_id, extensions): """ Set the extensions contributed to an extension point. """ self._check_extension_point(extension_point_id) old = self._get_extensions(extension_point_id) self._extensions[extension_point_id] = extensions refs = self._get_listener_refs(extension_point_id) self._call_listeners(refs, extension_point_id, extensions, old, None) return ########################################################################### # Protected 'ExtensionRegistry' interface. ########################################################################### def _call_listeners(self, refs, extension_point_id, added, removed, index): """ Call listeners that are listening to an extension point. """ event = ExtensionPointChangedEvent( extension_point_id = extension_point_id, added = added, removed = removed, index = index ) for ref in refs: listener = ref() if listener is not None: listener(self, event) return def _check_extension_point(self, extension_point_id): """ Check to see if the extension point exists. Raise an 'UnknownExtensionPoint' if it does not. """ if not extension_point_id in self._extension_points: raise UnknownExtensionPoint(extension_point_id) return def _get_extensions(self, extension_point_id): """ Return the extensions for the given extension point. """ return self._extensions.setdefault(extension_point_id, []) def _get_listener_refs(self, extension_point_id): """ Get weak references to all listeners to an extension point. Returns a list containing the weak references to those listeners that are listening to this extension point specifically first, followed by those that are listening to any extension point. """ refs = [] refs.extend(self._listeners.get(extension_point_id, [])) refs.extend(self._listeners.get(None, [])) return refs #### EOF ###################################################################### envisage-4.1.0/envisage/safeweakref.py0000644000175100001440000000561411674464014020751 0ustar ischnellusers00000000000000""" An implementation of weak references that works for bound methods. This code is based on the code in the Python Cookbook, but you can call `ref` for objects that are *not* bound methods too, in which case it just returns a standard `weakref.ref`. Weak references to bound methods are cached so that `ref(x) is ref(x)` as for standard weakrefs, and the `ref` class defined here is therefore intended to be used as a drop-in replacement for 'weakref.ref'. """ # Standard library imports. import new, weakref # Because this module is intended as a drop-in replacement for weakref, we # import everything from that module here (so the user can do things like # "import safeweakref as weakref" etc). from weakref import * class ref(object): """ An implementation of weak references that works for bound methods. """ # A cache containing the weak references we have already created. # # We cache the weak references by the object containing the associated # bound methods, hence this is a dictionary of dictionaries in the form:- # # { bound_method.im_self : { bound_method.im_func : ref } } # # This makes sure that when the object is garbage collected, any cached # weak references are garbage collected too. _cache = weakref.WeakKeyDictionary() def __new__(cls, obj, *args, **kw): """ Create a new instance of the class. """ # If the object is a bound method then either get from the cache, or # create an instance of *this* class. if hasattr(obj, 'im_self'): func_cache = ref._cache.setdefault(obj.im_self, {}) # If we haven't created a weakref to this bound method before, then # create one and cache it. self = func_cache.get(obj.im_func) if self is None: self = object.__new__(cls, obj, *args, **kw) func_cache[obj.im_func] = self # Otherwise, just return a regular weakref (because we aren't # returning an instance of *this* class our constructor does not get # called). else: self = weakref.ref(obj) return self def __init__(self, obj): """ Create a weak reference to a bound method object. 'obj' is *always* a bound method because in the '__new__' method we don't return an instance of this class if it is not, and hence this constructor doesn't get called. """ self._cls = obj.im_class self._fn = obj.im_func self._ref = weakref.ref(obj.im_self) return def __call__(self): """ Return a strong reference to the object. Return None if the object has been garbage collected. """ obj = self._ref() if obj is not None: obj = new.instancemethod(self._fn, obj, self._cls) return obj #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/0000755000175100001440000000000011674464014017567 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/debug/0000755000175100001440000000000011674464014020655 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/debug/fbi_plugin_definition.py0000644000175100001440000000243711674464014025563 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------- # # FBI (Frame Based Inspector) Plugin. # # Written by: David C. Morrill # # Date: 1/4/2006 # # (c) Copyright 2006 by Enthought, Inc. # #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- from envisage.core.core_plugin_definition \ import PluginDefinition #------------------------------------------------------------------------------- # The plugin definition: #------------------------------------------------------------------------------- PluginDefinition( # The plugin's globally unique identifier: id = "envisage.plugins.debug.fbi", # The name of the class that implements the plugin: class_name = "envisage.plugins.debug.fbi_plugin.FBIPlugin", # General information about the plugin: name = "FBI Plugin", version = "1.0.0", provider_name = "Enthought Inc", provider_url = "www.enthought.com", enabled = True, autostart = True, # The Id's of the plugins that this plugin requires: requires = [ "envisage.core", ] ) envisage-4.1.0/envisage/plugins/debug/__init__.py0000644000175100001440000000000011674464014022754 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/debug/fbi_plugin.py0000644000175100001440000000270311674464014023347 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------- # # wxPython Test Plugin. # # Written by: David C. Morrill # # Date: 10/18/2005 # # (c) Copyright 2005 by Enthought, Inc. # #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- import sys from traits.api import push_exception_handler from envisage.api import Plugin from etsdevtools.debug.fbi import enable_fbi, fbi #------------------------------------------------------------------------------- # 'FBIPlugin' class: #------------------------------------------------------------------------------- class FBIPlugin ( Plugin ): """ FBIPython plugin. """ #--------------------------------------------------------------------------- # 'Plugin' interface: #--------------------------------------------------------------------------- def start ( self, application ): """ Starts the plugin. """ # Tell the FBI to wiretap all unauthorized exceptions: enable_fbi() push_exception_handler( handler = lambda obj, name, old, new: fbi(), locked = False, main = True ) def stop ( self, application ): """ Stops the plugin. """ pass envisage-4.1.0/envisage/plugins/text_editor/0000755000175100001440000000000011674464014022121 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/text_editor/api.py0000644000175100001440000000014111674464014023240 0ustar ischnellusers00000000000000from text_editor_action_set import TextEditorActionSet from editor.text_editor import TextEditor envisage-4.1.0/envisage/plugins/text_editor/editor/0000755000175100001440000000000011674464014023407 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/text_editor/editor/text_editor.py0000644000175100001440000001446711674464014026327 0ustar ischnellusers00000000000000""" A text editor. """ # Standard library imports. from os.path import basename # Enthought library imports. from pyface.workbench.api import TraitsUIEditor from pyface.api import FileDialog, CANCEL from traits.api import Code, Instance from traitsui.api import CodeEditor, Group, Item, View from traitsui.key_bindings import KeyBinding, KeyBindings from traitsui.menu import NoButtons # Local imports. from text_editor_handler import TextEditorHandler def _id_generator(): """ A generator that returns the next number for untitled files. """ i = 1 while True: yield(i) i += 1 return _id_generator = _id_generator() class TextEditor(TraitsUIEditor): """ A text editor. """ #### 'TextEditor' interface ############################################### # The key bindings used by the editor. key_bindings = Instance(KeyBindings) # The text being edited. text = Code ########################################################################### # 'IEditor' interface. ########################################################################### def save(self): """ Saves the text to disk. """ # If the file has not yet been saved then prompt for the file name. if len(self.obj.path) == 0: self.save_as() else: f = file(self.obj.path, 'w') f.write(self.text) f.close() # We have just saved the file so we ain't dirty no more! self.dirty = False return def save_as(self): """ Saves the text to disk after prompting for the file name. """ dialog = FileDialog( parent = self.window.control, action = 'save as', default_filename = self.name, wildcard = FileDialog.WILDCARD_PY ) if dialog.open() != CANCEL: # Update the editor. self.id = dialog.path self.name = basename(dialog.path) # Update the resource. self.obj.path = dialog.path # Save it! self.save() return ########################################################################### # 'TraitsUIEditor' interface. ########################################################################### def create_ui(self, parent): """ Creates the traits UI that represents the editor. """ ui = self.edit_traits( parent=parent, view=self._create_traits_ui_view(), kind='subpanel' ) return ui ########################################################################### # 'TextEditor' interface. ########################################################################### def run(self): """ Runs the file as Python. """ # The file must be saved first! self.save() # Execute the code. if len(self.obj.path) > 0: view = self.window.get_view_by_id( 'envisage.plugins.python_shell_view' ) if view is not None: view.execute_command( 'execfile(r"%s")' % self.obj.path, hidden=False ) return def select_line(self, lineno): """ Selects the specified line. """ self.ui.info.text.selected_line = lineno return ########################################################################### # Private interface. ########################################################################### #### Trait initializers ################################################### def _key_bindings_default(self): """ Trait initializer. """ key_bindings = KeyBindings( KeyBinding( binding1 = 'Ctrl-s', description = 'Save the file', method_name = 'save' ), KeyBinding( binding1 = 'Ctrl-r', description = 'Run the file', method_name = 'run' ) ) return key_bindings #### Trait change handlers ################################################ def _obj_changed(self, new): """ Static trait change handler. """ # The path will be the empty string if we are editing a file that has # not yet been saved. if len(new.path) == 0: self.id = self._get_unique_id() self.name = self.id else: self.id = new.path self.name = basename(new.path) f = file(new.path, 'r') self.text = f.read() f.close() return def _text_changed(self, trait_name, old, new): """ Static trait change handler. """ if self.traits_inited(): self.dirty = True return def _dirty_changed(self, dirty): """ Static trait change handler. """ if len(self.obj.path) > 0: if dirty: self.name = basename(self.obj.path) + '*' else: self.name = basename(self.obj.path) return #### Methods ############################################################## def _create_traits_ui_view(self): """ Create the traits UI view used by the editor. fixme: We create the view dynamically to allow the key bindings to be created dynamically (we don't use this just yet, but obviously plugins need to be able to contribute new bindings). """ view = View( Group( Item( 'text', editor=CodeEditor(key_bindings=self.key_bindings) ), show_labels = False ), id = 'envisage.editor.text_editor', handler = TextEditorHandler(), kind = 'live', resizable = True, width = 1.0, height = 1.0, buttons = NoButtons, ) return view def _get_unique_id(self, prefix='Untitled '): """ Return a unique id for a new file. """ id = prefix + str(_id_generator.next()) while self.window.get_editor_by_id(id) is not None: id = prefix + str(_id_generator.next()) return id #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/text_editor/editor/text_editor_handler.py0000644000175100001440000000156211674464014030014 0ustar ischnellusers00000000000000""" The traits UI handler for the text editor. """ # Enthought library imports. from traitsui.api import Handler class TextEditorHandler(Handler): """ The traits UI handler for the text editor. """ ########################################################################### # 'TextEditorHandler' interface. ########################################################################### # fixme: We need to work out how to create these 'dispatch' methods # dynamically! Plugins will want to add bindings to the editor to bind # a key to an action. def run(self, info): """ Run the text as Python code. """ info.object.run() return def save(self, info): """ Save the text to disk. """ info.object.save() return #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/text_editor/editor/__init__.py0000644000175100001440000000000011674464014025506 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/text_editor/actions.py0000644000175100001440000000213111674464014024130 0ustar ischnellusers00000000000000import logging from apptools.io.api import File from pyface.api import FileDialog, OK from pyface.action.api import Action from traits.api import Any from editor.text_editor import TextEditor logger = logging.getLogger(__name__) class NewFileAction(Action): """ Open a new file in the text editor. """ tooltip = "Create a new file for editing" description = "Create a new file for editing" # The WorkbenchWindow the action is attached to. window = Any() def perform(self, event=None): logger.info('NewFileAction.perform()') self.window.workbench.edit(File(''), kind=TextEditor, use_existing=False) class OpenFileAction(Action): """ Open an existing file in the text editor. """ tooltip = "Open a file for editing" description = "Open a file for editing" def perform(self, event=None): logger.info('OpenFileAction.perform()') dialog = FileDialog(parent=self.window.control, title='Open File') if dialog.open() == OK: self.window.workbench.edit(File(dialog.path), kind=TextEditor) envisage-4.1.0/envisage/plugins/text_editor/text_editor_action_set.py0000644000175100001440000000147411674464014027243 0ustar ischnellusers00000000000000 from envisage.ui.action.api import Action, ActionSet, Group class TextEditorActionSet(ActionSet): """ The default action set for the Text Editor plugin. """ groups = [ Group( id = "TextFileGroup", path = "MenuBar/File", before = "ExitGroup", ) ] actions = [ Action( id = "NewFileAction", name = "New Text File", class_name='envisage.plugins.text_editor.actions.NewFileAction', group='TextFileGroup', path="MenuBar/File", ), Action( id = 'OpenFile', name = "Open Text File...", class_name='envisage.plugins.text_editor.actions.OpenFileAction', group='TextFileGroup', path="MenuBar/File", ), ] envisage-4.1.0/envisage/plugins/text_editor/__init__.py0000644000175100001440000000000011674464014024220 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/text_editor/text_editor_plugin.py0000644000175100001440000000142111674464014026401 0ustar ischnellusers00000000000000""" Text Editor plugin for the Workbench UI. """ # Enthought library imports. from traits.api import List from envisage.api import Plugin # The plugin's globally unique identifier (also used as the prefix for all # identifiers defined in this module). ID = "envisage.plugins.text_editor" class TextEditorPlugin(Plugin): """ Text Editor plugin for the Workbench UI. """ name = 'Text Editor plugin' #### Contributions made by this plugin ##################################### ACTION_SETS = 'envisage.ui.workbench.action_sets' action_sets = List(contributes_to=ACTION_SETS) def _action_sets_default(self): from envisage.plugins.text_editor.text_editor_action_set import \ TextEditorActionSet return [TextEditorActionSet] envisage-4.1.0/envisage/plugins/ipython_shell/0000755000175100001440000000000011674464014022450 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/ipython_shell/actions/0000755000175100001440000000000011674464014024110 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/ipython_shell/actions/ipython_shell_actions.py0000644000175100001440000000355511674464014031073 0ustar ischnellusers00000000000000from envisage.ui.action.api import Action, ActionSet, Group from pyface.action.api import Action as PyfaceAction from envisage.plugins.python_shell.api import IPythonShell def get_shell(window): """ Given an application window, retrieve the ipython shell. """ return window.application.get_service(IPythonShell) ################################################################################ # Groups ################################################################################ ipython_shell_group = Group( id='IPythonShellGroup', path='MenuBar/Tools', #before='ExitGroup' ) ################################################################################ # `ClearScreen` class. ################################################################################ class ClearScreen(PyfaceAction): """ An action that clears the IPython screen. """ tooltip = "Clear the IPython screen." description = "Clear the IPython screen." ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): """ Performs the action. """ shell = get_shell(self.window) if shell is not None: shell.control.clear_screen() clear_screen = Action( path = "MenuBar/Tools", class_name = __name__ + '.ClearScreen', name = "Clear IPython screen", group = "IPythonShellGroup", ) ################################################################################ # `IPythonShellActionSet` class. ################################################################################ class IPythonShellActionSet(ActionSet): """ The default action set for the IPython shell plugin. """ groups = [ipython_shell_group, ] actions = [clear_screen] envisage-4.1.0/envisage/plugins/ipython_shell/actions/__init__.py0000644000175100001440000000000011674464014026207 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/ipython_shell/ipython_shell_plugin.py0000644000175100001440000000563711674464014027274 0ustar ischnellusers00000000000000""" An IPython shell plugin. """ # Enthought library imports. from envisage.api import ExtensionPoint, Plugin from traits.api import Dict, List, Str class IPythonShellPlugin(Plugin): """ An IPython shell plugin. """ # Extension point Ids. BANNER = 'envisage.plugins.ipython_shell.banner' BINDINGS = 'envisage.plugins.python_shell.bindings' COMMANDS = 'envisage.plugins.python_shell.commands' VIEWS = 'envisage.ui.workbench.views' ACTION_SETS = 'envisage.ui.workbench.action_sets' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'envisage.plugins.python_shell' # The plugin's name (suitable for displaying to the user). name = 'Python Shell' #### Extension points offered by this plugin ############################## banner = ExtensionPoint( List(Str), id=BANNER, desc=""" This extension point allows you to contribute a string that is printed as a banner when the IPython shell is started. """ ) bindings = ExtensionPoint( List(Dict), id=BINDINGS, desc=""" This extension point allows you to contribute name/value pairs that will be bound when the interactive Python shell is started. e.g. Each item in the list is a dictionary of name/value pairs:: {'x' : 10, 'y' : ['a', 'b', 'c']} """ ) commands = ExtensionPoint( List(Str), id=COMMANDS, desc=""" This extension point allows you to contribute commands that are executed when the interactive Python shell is started. e.g. Each item in the list is a string of arbitrary Python code:: 'import os, sys' 'from traits.api import *' Yes, I know this is insecure but it follows the usual Python rule of 'we are all consenting adults'. """ ) #### Contributions to extension points made by this plugin ################ # Our action sets. action_sets = List(contributes_to=ACTION_SETS) def _action_sets_default(self): """ Trait initializer. """ from envisage.plugins.ipython_shell.actions.ipython_shell_actions \ import IPythonShellActionSet return [IPythonShellActionSet] # Bindings. contributed_bindings = List(contributes_to=BINDINGS) def _contributed_bindings_default(self): """ Trait initializer. """ return [{'application' : self.application}] # Views. contributed_views = List(contributes_to=VIEWS) def _contributed_views_default(self): """ Trait initializer. """ # Local imports. from view.ipython_shell_view import IPythonShellView from view.namespace_view \ import NamespaceView return [IPythonShellView, NamespaceView] #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/ipython_shell/api.py0000644000175100001440000000016211674464014023572 0ustar ischnellusers00000000000000from envisage.plugins.python_shell.i_python_shell import IPythonShell from i_namespace_view import INamespaceView envisage-4.1.0/envisage/plugins/ipython_shell/i_namespace_view.py0000644000175100001440000000062411674464014026322 0ustar ischnellusers00000000000000""" Interface definition for the Namespace view """ # Enthought library imports. from traits.api import Interface class INamespaceView(Interface): """ Interface definition for the Namespace view """ def _on_names_changed(self, new): """ Handler to track the changes in the namespace viewed. """ #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/ipython_shell/__init__.py0000644000175100001440000000000011674464014024547 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/ipython_shell/view/0000755000175100001440000000000011674464014023422 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/ipython_shell/view/namespace_view.py0000644000175100001440000002017711674464014026771 0ustar ischnellusers00000000000000""" A view containing the contents of a Python shell namespace. """ # Enthought library imports. from envisage.plugins.python_shell.api import IPythonShell from envisage.plugins.ipython_shell.api import INamespaceView from pyface.workbench.api import View from traits.api import Property, implements, Instance, \ Str, HasTraits from traitsui.api import Item, TreeEditor, Group from traitsui.api import View as TraitsView from traitsui.value_tree import DictNode, StringNode, \ value_tree_nodes from pyface.timer.api import Timer from pyface.api import GUI def search_namespace(namespace, string, depth=3): """ Iterator on a dictionnary-like object. Given a namespace, search recursively for a name containing the string in the enclosed modules and classes. """ if depth==0: raise StopIteration for child_name in namespace: child = namespace[child_name] if string in child_name: yield child_name, child if hasattr(child, '__dict__'): for suitable_child_name, suitable_child in \ search_namespace(child.__dict__, string, depth=depth-1): yield ('%s.%s' % (child_name, suitable_child_name), suitable_child) def filter_namespace(namespace, string, depth=3): """ Return a flattened dictionnary to the depth given, with only the keys matching the given name. """ out_dict = dict() for key, item in search_namespace(namespace, string, depth=depth): out_dict[key] = item return out_dict def explore(node): """ Small helper function to graphically edit an object. """ # FIXME: This is really very dumb. The view used should be made # better. The logics should probably be put in the nodes themselves, # subclassing them. name = node.name obj = node.value class MyClass(HasTraits): the_object = obj view = TraitsView(Item('the_object', style='custom', show_label=False), resizable=True, title=name, width=600, ) return MyClass().edit_traits() class NamespaceNode(DictNode): """ Subclass of the DictNode for the namespace purposes. """ def tno_get_icon ( self, node, is_expanded ): """ Returns the icon for a specified object. We overwrite this method because we don't have a default icon for this object. """ return ('@icons:dict_node') def tno_get_children ( self, node ): """ Gets the object's children. We overwrite this method for a nicer label on the objects. """ node_for = self.node_for items = self.value.items() items.sort( lambda l, r: cmp( l[0], r[0] ) ) if len( items ) > 500: return ([ self.node_for( k, v ) for k, v in items[: 250 ] ] + [ StringNode( value = '...', readonly = True ) ] + [ self.node_for( k, v ) for k, v in items[ -250: ] ]) return [ self.node_for( k, v ) for k, v in items ] ################################################################################ class NamespaceView(View): """ A view containing the contents of the Python shell namespace. """ implements(INamespaceView) #### 'IView' interface #################################################### # The part's globally unique identifier. id = 'envisage.plugins.ipython_shell.namespace_view' # The view's name. name = 'Namespace' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'left' #### 'NamespaceView' interface ############################################ # The different tree nodes tree_nodes = Property(depends_on='search_text') # Search text search_text = Str tree_editor = Property(depends_on="ui") # The timer used to refresh the ui _refresh_tree_nodes_timer = Instance(Timer) def __refresh_tree_nodes_timer_default(self): return Timer(100, self._refresh_tree_nodes) ########################################################################### # 'View' interface. ########################################################################### traits_view = TraitsView( Group(Item('search_text', label='Search')), Item( 'tree_nodes', id = 'table', editor = TreeEditor( auto_open=1, hide_root=True, editable=False, nodes=value_tree_nodes, on_dclick='object._explore', ), springy = True, resizable = True, show_label = False ), resizable = True, ) def create_control(self, parent): """ Creates the toolkit-specific control that represents the view. 'parent' is the toolkit-specific control that is the view's parent. """ self.ui = self.edit_traits(parent=parent, kind='subpanel') # Register the view as a service. self.window.application.register_service(INamespaceView, self) shell = self.window.application.get_service(IPythonShell) if shell is not None: shell.on_trait_change(self._on_names_changed, 'names') self._on_names_changed(shell.names) return self.ui.control def destroy_control(self): """ Destroys the toolkit-specific control that represents the view. """ super(NamespaceView, self).destroy_control() # Remove the namespace change handler shell= self.window.application.get_service(IPythonShell) if shell is not None: shell.on_trait_change( self._on_names_changed, 'names', remove=True ) ########################################################################### # 'NamespaceView' interface. ########################################################################### #### Properties ########################################################### def _get_tree_nodes(self): """ Property getter. """ shell = self.window.application.get_service(IPythonShell) # Cater for an un-initialized python shell view if shell is None: return NamespaceNode(value={}, readonly=True) filtered_namespace = dict() for name in shell.names: filtered_namespace[name] = shell.lookup(name) if not self.search_text == '': filtered_namespace = filter_namespace(filtered_namespace, self.search_text) return NamespaceNode(value=filtered_namespace, readonly=True) def _get_tree_editor(self): """ Walk the editor list to retrieve the instance of the tree editor currently used. """ for editor in self.ui._editors: print editor return self.ui._editors[-1] def _refresh_tree_nodes(self): """ Callback called by a timer to refresh the UI. The UI is refreshed by a timer to buffer the refreshes, in order not to slow down the execution engine. """ self.trait_property_changed('tree_nodes', None) self._refresh_tree_nodes_timer.Stop() ########################################################################### # Private interface. ########################################################################### #### Trait change handlers ################################################ def _on_names_changed(self, new): """ Dynamic trait change handler. """ if not self._refresh_tree_nodes_timer.IsRunning(): GUI.invoke_later(self._refresh_tree_nodes_timer.Start) def _explore(self, object): """ Displays a view of the object. """ explore(object) #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/ipython_shell/view/api.py0000644000175100001440000000006011674464014024541 0ustar ischnellusers00000000000000from ipython_shell_view import IPythonShellView envisage-4.1.0/envisage/plugins/ipython_shell/view/ipython_shell_view.py0000644000175100001440000001355411674464014027717 0ustar ischnellusers00000000000000""" A view containing an interactive Python shell. """ # Standard library imports. import logging import traceback # Major library imports from IPython.kernel.core.interpreter import Interpreter # Enthought library imports. from envisage.api import IExtensionRegistry from envisage.api import ExtensionPoint from envisage.plugins.python_shell.api import IPythonShell from envisage.plugins.ipython_shell.api import INamespaceView from pyface.workbench.api import View from pyface.ipython_widget import IPythonWidget from pyface.api import GUI from traits.api import Instance, Property, implements, Dict # Setup a logger for this module. logger = logging.getLogger(__name__) class IPythonShellView(View): """ A view containing an IPython shell. """ implements(IPythonShell) #### 'IView' interface #################################################### # The part's globally unique identifier. id = 'envisage.plugins.python_shell_view' # The part's name (displayed to the user). name = 'IPython' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### 'PythonShellView' interface ########################################## # The interpreter's namespace. namespace = Dict # The names bound in the interpreter's namespace. names = Property(depends_on="namespace") #### 'IPythonShellView' interface ######################################### # The interpreter interpreter = Instance(Interpreter) def _interpreter_default(self): # Create an interpreter that has a reference to our namespace. return Interpreter(user_ns=self.namespace) #### 'IExtensionPointUser' interface ###################################### # The extension registry that the object's extension points are stored in. extension_registry = Property(Instance(IExtensionRegistry)) #### Private interface #################################################### # Banner. _banner = ExtensionPoint(id='envisage.plugins.ipython_shell.banner') # Bindings. _bindings = ExtensionPoint(id='envisage.plugins.python_shell.bindings') # Commands. _commands = ExtensionPoint(id='envisage.plugins.python_shell.commands') ########################################################################### # 'IExtensionPointUser' interface. ########################################################################### def _get_extension_registry(self): """ Trait property getter. """ return self.window.application ########################################################################### # 'View' interface. ########################################################################### def create_control(self, parent): """ Creates the toolkit-specific control that represents the view. """ self.shell = IPythonWidget(parent, banner='\n'.join(self._banner), interp=self.interpreter) # Namespace contributions. for bindings in self._bindings: for name, value in bindings.items(): self.bind(name, value) for command in self._commands: try: self.execute_command(command) except Exception, e: logger.exception( "The command '%s' supplied to the Ipython shell " "plugin has raised an exception:\n%s" % (command, traceback.format_exc())) # Register the view as a service. self.window.application.register_service(IPythonShell, self) ns_view = self.window.application.get_service(INamespaceView) if ns_view is not None: self.on_trait_change(ns_view._on_names_changed, 'names') def try_set_focus(): try: self.shell.control.SetFocus() except: # The window may not have been created yet. pass def set_focus(): self.window.application.gui.invoke_later(try_set_focus) GUI.invoke_later(set_focus) return self.shell.control def destroy_control(self): """ Destroys the toolkit-specific control that represents the view. """ super(IPythonShellView, self).destroy_control() # Remove the namespace change handler ns_view = self.window.application.get_service(INamespaceView) if ns_view is not None: self.on_trait_change( ns_view._on_names_changed, 'names', remove=True ) ########################################################################### # 'PythonShellView' interface. ########################################################################### #### Properties ########################################################### def _get_names(self): """ Property getter. """ return self.control.ipython0.magic_who_ls() #### Methods ############################################################## def bind(self, name, value): """ Binds a name to a value in the interpreter's namespace. """ self.namespace[name] = value return def execute_command(self, command, hidden=True): """ Execute a command in the interpreter. """ self.shell.execute_command(command, hidden) self.trait_property_changed('namespace', [], self.namespace) def execute_file(self, path, hidden=True): """ Execute a command in the interpreter. """ self.shell.execute_file(path, hidden) self.trait_property_changed('namespace', [], self.namespace) def lookup(self, name): """ Returns the value bound to a name in the interpreter's namespace.""" return self.namespace[name] #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/ipython_shell/view/__init__.py0000644000175100001440000000000011674464014025521 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/event_manager/0000755000175100001440000000000011674464014022402 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/event_manager/plugin.py0000644000175100001440000000302311674464014024250 0ustar ischnellusers00000000000000# # # (C) Copyright 2011 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in LICENSE.txt # """ This module provides a plugin which adds an EventManager to application. If the application does not already have an evt_mgr attribute which is an instance of EventManager, the plugin creates a new EventManager instance, creates a service to offer the event manager and sets the evt_mgr instance of the application to the created event manager. """ # Enthought library imports. from envisage.api import Plugin, ServiceOffer from traits.api import List, Any # Local imports. from encore.events.event_manager import EventManager class EventManagerPlugin(Plugin): """ Plugin to add event manager to the application. """ id = 'envisage.event_manager' SERVICE_OFFERS = 'envisage.service_offers' service_offers = List(contributes_to=SERVICE_OFFERS) evt_mgr = Any def _service_offers_default(self): evt_mgr = self.evt_mgr # Ensure evt_mgr is created evt_mgr_service_offer = ServiceOffer( protocol = EventManager, factory = lambda: evt_mgr, ) return [evt_mgr_service_offer] def _evt_mgr_default(self): """ If application already has an EventManager, then that is returned. """ app = self.application evt_mgr = getattr(app, 'evt_mgr', None) if evt_mgr is None: evt_mgr = EventManager() app.evt_mgr = evt_mgr return evt_mgr envisage-4.1.0/envisage/plugins/event_manager/__init__.py0000644000175100001440000000000011674464014024501 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/python_shell/0000755000175100001440000000000011674464014022277 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/python_shell/api.py0000644000175100001440000000005011674464014023415 0ustar ischnellusers00000000000000from i_python_shell import IPythonShell envisage-4.1.0/envisage/plugins/python_shell/i_python_shell.py0000644000175100001440000000134411674464014025673 0ustar ischnellusers00000000000000""" A simple interface for the Python shell. """ # Enthought library imports. from traits.api import Interface class IPythonShell(Interface): """ A simple interface for the Python shell. """ def bind(self, name, value): """ Binds a name to a value in the interpreter's namespace. """ def execute_command(self, command, hidden=True): """ Execute a command in the interpreter. """ def execute_file(self, path, hidden=True): """ Execute a file in the interpreter. """ def lookup(self, name): """ Returns the value bound to a name in the interpreter's namespace. """ #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/python_shell/__init__.py0000644000175100001440000000000011674464014024376 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/python_shell/view/0000755000175100001440000000000011674464014023251 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/python_shell/view/namespace_view.py0000644000175100001440000001057511674464014026621 0ustar ischnellusers00000000000000""" A view containing the contents of a Python shell namespace. """ import types # Enthought library imports. from envisage.plugins.python_shell.api import IPythonShell from envisage.plugins.python_shell.view.python_shell_view import PythonShellView from pyface.workbench.api import View from traits.api import HasTraits, Str, Property, List, Instance, \ DelegatesTo, cached_property from traitsui.api import Item, TableEditor, VGroup from traitsui.api import View as TraitsView from traitsui.table_column import ObjectColumn from traitsui.table_filter import RuleTableFilter from traitsui.table_filter import MenuFilterTemplate from traitsui.table_filter import EvalFilterTemplate from traitsui.table_filter import RuleFilterTemplate # Table editor definition: filters = [EvalFilterTemplate, MenuFilterTemplate, RuleFilterTemplate] table_editor = TableEditor( columns = [ ObjectColumn(name='name'), ObjectColumn(name='type'), ObjectColumn(name='module'), ], editable = False, deletable = False, sortable = True, sort_model = False, filters = filters, search = RuleTableFilter(), ) def type_to_str(obj): """ Make a string out `obj`'s type robustly. """ typ = type(obj) if typ.__name__ == 'vtkobject' or typ is types.InstanceType: typ = obj.__class__ if type.__module__ == '__builtin__': # Make things like int and str easier to read. return typ.__name__ else: name = '%s.%s' % (typ.__module__, typ.__name__) return name def module_to_str(obj): """ Return the string representation of `obj`s __module__ attribute, or an empty string if there is no such attribute. """ if hasattr(obj, '__module__'): return str(obj.__module__) else: return '' class NamespaceView(View): """ A view containing the contents of the Python shell namespace. """ #### 'IView' interface #################################################### # The part's globally unique identifier. id = 'enthought.plugins.python_shell.view.namespace_view' # The view's name. name = 'Namespace' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'left' #### 'NamespaceView' interface ############################################ # The bindings in the namespace. This is a list of HasTraits objects with # 'name', 'type' and 'module' string attributes. bindings = Property(List, depends_on=['namespace']) shell_view = Instance(PythonShellView) namespace = DelegatesTo('shell_view') # The default traits UI view. traits_view = TraitsView( VGroup( Item( 'bindings', id = 'table', editor = table_editor, springy = True, resizable = True, ), show_border = True, show_labels = False ), resizable = True, ) ########################################################################### # 'View' interface. ########################################################################### def create_control(self, parent): """ Creates the toolkit-specific control that represents the view. 'parent' is the toolkit-specific control that is the view's parent. """ self.ui = self.edit_traits(parent=parent, kind='subpanel') self.shell_view = self.window.application.get_service(IPythonShell) # 'shell_view' is an instance of the class PythonShellView from the module # envisage.plugins.python_shell.view.python_shell_view. return self.ui.control ########################################################################### # 'NamespaceView' interface. ########################################################################### #### Properties ########################################################### @cached_property def _get_bindings(self): """ Property getter. """ if self.shell_view is None: return [] class item(HasTraits): name = Str type = Str module = Str data = [item(name=name, type=type_to_str(value), module=module_to_str(value)) for name, value in self.shell_view.namespace.items()] return data envisage-4.1.0/envisage/plugins/python_shell/view/api.py0000644000175100001440000000005611674464014024375 0ustar ischnellusers00000000000000from python_shell_view import PythonShellView envisage-4.1.0/envisage/plugins/python_shell/view/__init__.py0000644000175100001440000000005611674464014025363 0ustar ischnellusers00000000000000from python_shell_view import PythonShellView envisage-4.1.0/envisage/plugins/python_shell/view/python_shell_view.py0000644000175100001440000001723311674464014027373 0ustar ischnellusers00000000000000""" A view containing an interactive Python shell. """ # Standard library imports. import logging, sys # Enthought library imports. from envisage.api import IExtensionRegistry from envisage.api import ExtensionPoint from envisage.plugins.python_shell.api import IPythonShell from pyface.api import PythonShell from pyface.workbench.api import View from traits.api import Any, Event, Instance, Property, DictStrAny, implements # Setup a logger for this module. logger = logging.getLogger(__name__) class PseudoFile ( object ): """ Simulates a normal File object. """ def __init__(self, write): self.write = write def readline(self): pass def writelines(self, l): map(self.write, l) def flush(self): pass def isatty(self): return 1 class PythonShellView(View): """ A view containing an interactive Python shell. """ implements(IPythonShell) #### 'IView' interface #################################################### # The part's globally unique identifier. id = 'envisage.plugins.python_shell_view' # The part's name (displayed to the user). name = 'Python' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### 'PythonShellView' interface ########################################## # The interpreter's namespace. namespace = Property(DictStrAny) # The names bound in the interpreter's namespace. names = Property # Original value for 'sys.stdout': original_stdout = Any # Stdout text is posted to this event stdout_text = Event #### 'IExtensionPointUser' interface ###################################### # The extension registry that the object's extension points are stored in. extension_registry = Property(Instance(IExtensionRegistry)) #### Private interface #################################################### # Bindings. _bindings = ExtensionPoint(id='envisage.plugins.python_shell.bindings') # Commands. _commands = ExtensionPoint(id='envisage.plugins.python_shell.commands') ########################################################################### # 'IExtensionPointUser' interface. ########################################################################### def _get_extension_registry(self): """ Trait property getter. """ return self.window.application ########################################################################### # 'View' interface. ########################################################################### def create_control(self, parent): """ Creates the toolkit-specific control that represents the view. """ self.shell = shell = PythonShell(parent) shell.on_trait_change(self._on_key_pressed, 'key_pressed') shell.on_trait_change(self._on_command_executed, 'command_executed') # Write application standard out to this shell instead of to DOS window self.on_trait_change( self._on_write_stdout, 'stdout_text', dispatch='ui' ) self.original_stdout = sys.stdout sys.stdout = PseudoFile(self._write_stdout) # Namespace contributions. for bindings in self._bindings: for name, value in bindings.items(): self.bind(name, value) for command in self._commands: self.execute_command(command) # We take note of the starting set of names and types bound in the # interpreter's namespace so that we can show the user what they have # added or removed in the namespace view. self._namespace_types = set((name, type(value)) for name, value in \ self.namespace.items()) # Register the view as a service. app = self.window.application self._service_id = app.register_service(IPythonShell, self) return self.shell.control def destroy_control(self): """ Destroys the toolkit-specific control that represents the view. """ super(PythonShellView, self).destroy_control() # Unregister the view as a service. self.window.application.unregister_service(self._service_id) # Remove the sys.stdout handlers. self.on_trait_change( self._on_write_stdout, 'stdout_text', remove=True ) # Restore the original stdout. sys.stdout = self.original_stdout return ########################################################################### # 'PythonShellView' interface. ########################################################################### #### Properties ########################################################### def _get_namespace(self): """ Property getter. """ return self.shell.interpreter().locals def _get_names(self): """ Property getter. """ return self.shell.interpreter().locals.keys() #### Methods ############################################################## def bind(self, name, value): """ Binds a name to a value in the interpreter's namespace. """ self.shell.bind(name, value) return def execute_command(self, command, hidden=True): """ Execute a command in the interpreter. """ return self.shell.execute_command(command, hidden) def execute_file(self, path, hidden=True): """ Execute a command in the interpreter. """ return self.shell.execute_file(path, hidden) def lookup(self, name): """ Returns the value bound to a name in the interpreter's namespace. """ return self.shell.interpreter().locals[name] ########################################################################### # Private interface. ########################################################################### def _write_stdout(self, text): """ Handles text written to stdout. """ self.stdout_text = text return #### Trait change handlers ################################################ def _on_command_executed(self, shell): """ Dynamic trait change handler. """ if self.control is not None: # Get the set of tuples of names and types in the current namespace. namespace_types = set((name, type(value)) for name, value in \ self.namespace.items()) # Figure out the changes in the namespace, if any. added = namespace_types.difference(self._namespace_types) removed = self._namespace_types.difference(namespace_types) # Cache the new list, to use for comparison next time. self._namespace_types = namespace_types # Fire events if there are change. if len(added) > 0 or len(removed) > 0: self.trait_property_changed('namespace', {}, self.namespace) self.trait_property_changed('names', [], self.names) return def _on_key_pressed(self, event): """ Dynamic trait change handler. """ if event.alt_down and event.key_code == 317: zoom = self.shell.control.GetZoom() if zoom != 20: self.shell.control.SetZoom(zoom+1) elif event.alt_down and event.key_code == 319: zoom = self.shell.control.GetZoom() if zoom != -10: self.shell.control.SetZoom(zoom-1) return def _on_write_stdout(self, text): """ Dynamic trait change handler. """ self.shell.control.write(text) return #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/python_shell/python_shell_plugin.py0000644000175100001440000000440211674464014026737 0ustar ischnellusers00000000000000""" The interactive Python shell plugin. """ # Enthought library imports. from envisage.api import ExtensionPoint, Plugin from traits.api import Dict, List, Str class PythonShellPlugin(Plugin): """ The interactive Python shell plugin. """ # Extension point Ids. BINDINGS = 'envisage.plugins.python_shell.bindings' COMMANDS = 'envisage.plugins.python_shell.commands' VIEWS = 'envisage.ui.workbench.views' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'envisage.plugins.python_shell' # The plugin's name (suitable for displaying to the user). name = 'Python Shell' #### Extension points offered by this plugin ############################## bindings = ExtensionPoint( List(Dict), id=BINDINGS, desc=""" This extension point allows you to contribute name/value pairs that will be bound when the interactive Python shell is started. e.g. Each item in the list is a dictionary of name/value pairs:: {'x' : 10, 'y' : ['a', 'b', 'c']} """ ) commands = ExtensionPoint( List(Str), id=COMMANDS, desc=""" This extension point allows you to contribute commands that are executed when the interactive Python shell is started. e.g. Each item in the list is a string of arbitrary Python code:: 'import os, sys' 'from traits.api import *' Yes, I know this is insecure but it follows the usual Python rule of 'we are all consenting adults'. """ ) #### Contributions to extension points made by this plugin ################ # Bindings. contributed_bindings = List(contributes_to=BINDINGS) def _contributed_bindings_default(self): """ Trait initializer. """ return [{'application' : self.application}] # Views. contributed_views = List(contributes_to=VIEWS) def _contributed_views_default(self): """ Trait initializer. """ # Local imports. from view.python_shell_view import PythonShellView from view.namespace_view import NamespaceView return [PythonShellView, NamespaceView] #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/remote_editor/0000755000175100001440000000000011674464014022430 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/remote_editor_controller.py0000644000175100001440000000112411674464014030104 0ustar ischnellusers00000000000000""" A client controlling a remote editor. """ # Enthought library imports from traits.api import implements # Local imports from envisage.plugins.remote_editor.communication.client import Client from i_remote_editor import IRemoteEditor class RemoteEditorController(Client): """ A Client used to control a remote editor. """ implements(IRemoteEditor) # Client interface self_type = "python_shell" other_type = "python_editor" def new_file(self): self.send_command('new') def open_file(self, filename): self.send_command('open', filename) envisage-4.1.0/envisage/plugins/remote_editor/api.py0000644000175100001440000000021711674464014023553 0ustar ischnellusers00000000000000from i_remote_editor import IRemoteEditor from i_remote_shell import IRemoteShell from remote_editor_controller import RemoteEditorController envisage-4.1.0/envisage/plugins/remote_editor/preferences.ini0000644000175100001440000000034311674464014025432 0ustar ischnellusers00000000000000[enthought.remote_editor] python_shell = python -c "from enthought.epdlab.app.epdlab import main; main()" python_editor = python -c "from enthought.plugins.remote_editor.editor_plugins.editra.start_editra import main; main()" envisage-4.1.0/envisage/plugins/remote_editor/actions.py0000644000175100001440000000617211674464014024450 0ustar ischnellusers00000000000000from envisage.ui.action.api import Action, ActionSet, Group from pyface.api import FileDialog, OK from pyface.action.api import Action as PyfaceAction from envisage.plugins.remote_editor.api import IRemoteEditor def get_server(window): """ Given an application window, retrieve the communication server. """ return window.application.get_service(IRemoteEditor) ################################################################################ # Groups ################################################################################ file_group = Group( id='RemoteEditorFileGroup', path='MenuBar/File', before='ExitGroup' ) ################################################################################ # `OpenScript` class. ################################################################################ class OpenScript(PyfaceAction): """ An action that opens a Python file in a remote editor. """ tooltip = "Open a Python script in separate editor." description = "Open a Python script in separate editor." ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): """ Performs the action. """ server = get_server(self.window) wildcard = 'Python files (*.py)|*.py' parent = self.window.control dialog = FileDialog(parent=parent, title='Open Python script in separate editor', action='open', wildcard=wildcard ) if dialog.open() == OK: server.open_file(dialog.path) open_script = Action( path = "MenuBar/File", class_name = __name__ + '.OpenScript', name = "Open script in editor", group = "RemoteEditorFileGroup", ) ################################################################################ # `NewScript` class. ################################################################################ class NewScript(PyfaceAction): """ An action that opens a new file in a remote editor. """ tooltip = "Open a new file in separate editor." description = "Open a new file in separate editor." ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): """ Performs the action. """ server = get_server(self.window) server.new_file() new_script = Action( path = "MenuBar/File", class_name = __name__ + '.NewScript', name = "New script in editor", group = "RemoteEditorFileGroup", ) ################################################################################ # `RemoteEditorActionSet` class. ################################################################################ class RemoteEditorActionSet(ActionSet): """ The default action set for the remote editor plugin. """ groups = [file_group, ] actions = [open_script, new_script] envisage-4.1.0/envisage/plugins/remote_editor/communication/0000755000175100001440000000000011674464014025275 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/communication/util.py0000644000175100001440000001135011674464014026624 0ustar ischnellusers00000000000000# Standard library imports from errno import EINTR import os import select import socket from subprocess import Popen import sys import csv import StringIO # ETS imports from traits.etsconfig.api import ETSConfig # An obscure ASCII character that we used as separators in socket streams MESSAGE_SEP = chr(7) # 'bell' character # The location of the server lock file and the communication log LOCK_PATH = os.path.join(ETSConfig.application_data, 'remote_editor_server.lock') LOG_PATH = os.path.join(ETSConfig.application_data, 'remote_editor_server.log') def quoted_split(s): f = StringIO.StringIO(s) split = csv.reader(f, delimiter=' ', quotechar='"').next() return split def spawn_independent(command, shell=False): """ Given a command suitable for 'Popen', open the process such that if this process is killed, the spawned process survives. `command` is either a list of strings, with the first item in the list being the executable and the rest being its arguments, or a single string containing the executable and its arguments. In the latter case, any argument that contains spaces must be delimited with double-quotes. """ if sys.platform == 'win32': if isinstance(command, basestring): command = 'start /b ' + command else: command.insert(0, 'start') command.insert(1, '/b') Popen(command, shell=True) elif sys.platform == 'darwin': pid = os.fork() if pid: return else: os.setpgrp() if isinstance(command, basestring): tmp = quoted_split(command) else: tmp = command os.execv(tmp[0], tmp) else: pid = os.fork() if pid: return else: os.setpgrp() Popen(command, shell=shell) sys.exit(0) def get_server_port(): """ Reads the server port from the lock file. If the file does not exist returns -1. """ if os.path.exists(LOCK_PATH): f = open(LOCK_PATH, 'r') try: return int(f.read().strip()) finally: f.close() else: return -1 def accept_no_intr(sock): """ Call sock.accept such that if it is interrupted by an EINTR ("Interrupted system call") signal or a KeyboardInterrupt exception, it is re-called. """ while True: try: return sock.accept() except socket.error, err: if err[0] != EINTR: raise except KeyboardInterrupt: pass def send(sock, command, arguments=''): """ Send a command with arguments (both strings) through a socket. This information is encoded with length information to ensure that everything is received. """ sent, total = 0, 0 msg = command + MESSAGE_SEP + arguments msg = str(len(msg)) + MESSAGE_SEP + msg length = len(msg) while total < length: msg = msg[sent:] sent = sock.send(msg) if not sent: raise socket.error total += sent def send_port(port, command, arguments='', timeout=None): """ A send a command to a port. Convenience function that uses 'send'. """ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if timeout is not None: sock.settimeout(timeout) errno = sock.connect_ex(('localhost', port)) if errno: sock.close() return False try: send(sock, command, arguments) except socket.error: return False finally: try: sock.shutdown(socket.SHUT_WR) except: pass return True def receive(sock): """ Receive a command with arguments from a socket that was previously sent information with 'send'. """ index = -1 chunk, length = '', '' received = False while not received: # Use select to query the socket for activity before calling sock.recv. # Choose a timeout of 60 seconds for now. readers, writers, in_error = select.select([sock], [], [], 60) for rsock in readers: while index == -1: length += chunk chunk = rsock.recv(4096) if not chunk: raise socket.error index = chunk.find(MESSAGE_SEP) length = int(length + chunk[:index]) msg = chunk[index+1:] while len(msg) < length: chunk = rsock.recv(length - len(msg)) if not chunk: raise socket.error msg += chunk received = True command, sep, arguments = msg.partition(MESSAGE_SEP) return command, arguments envisage-4.1.0/envisage/plugins/remote_editor/communication/tests/0000755000175100001440000000000011674464014026437 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/communication/tests/test_communication.py0000644000175100001440000000662411674464014032725 0ustar ischnellusers00000000000000# Standard library imports import os import unittest from time import sleep from threading import Thread # ETS imports from traits.api import Int, Str # Local imports from envisage.plugins.remote_editor.communication.client import Client from envisage.plugins.remote_editor.communication.server import Server from envisage.plugins.remote_editor.communication.util import \ get_server_port, LOCK_PATH class TestClient(Client): command = Str arguments = Str error_count = Int(0) def handle_command(self, command, arguments): self.command = command self.arguments = arguments def _error_changed(self, error): if error: self.error_count += 1 class TestThread(Thread): def run(self): self.server = Server() self.server.init() self.server.main() class CommunicationTestCase(unittest.TestCase): def setUp(self): """ Make sure no old lock files exist prior to run. """ if os.path.exists(LOCK_PATH): os.remove(LOCK_PATH) def tearDown(self): """ Make sure no old lock files are left around. """ if os.path.exists(LOCK_PATH): os.remove(LOCK_PATH) def testCommunication(self): """ Can the Server communicate with Clients and handle errors appropriately? """ # Test server set up # Does the ping operation work when the Server is not running? self.assert_(not Server.ping(get_server_port())) # Set up server thread serverThread = TestThread() serverThread.setDaemon(True) serverThread.start() sleep(.5) self.assert_(os.path.exists(LOCK_PATH)) # Test normal operation self.assert_(Server.ping(get_server_port())) client1 = TestClient(self_type='client1', other_type='client2') client1.register() client2 = TestClient(self_type='client2', other_type='client1') client2.register() sleep(.5) self.assert_(not(client1.orphaned or client2.orphaned)) client1.send_command("foo", "bar") sleep(.1) self.assertEqual(client2.command, "foo") self.assertEqual(client2.arguments, "bar") client1.unregister() sleep(.1) self.assert_(client1.orphaned and client2.orphaned) client1.register() sleep(.1) self.assert_(not(client1.orphaned or client2.orphaned)) # Simulated breakage -- does the Server handle unexpected communication # failure? # Have client1 'die'. We send the dummy command to force its connection # loop to terminate after the call to 'stop'. (In Python we can't just # kill the thread, which is really what we want to do in this case.) client1._communication_thread.stop() sleep(.1) serverThread.server._send_to(client1._port, "dummy", "") sleep(.1) # The Server should inform client1 that it could not complete its # request client2.send_command("foo", "bar") sleep(.1) self.assert_(client2.orphaned) self.assertEqual(client2.error_count, 1) if __name__ == '__main__': """ Run the unittest, but redirect the log to stderr for convenience. """ import logging console = logging.StreamHandler() console.setLevel(logging.DEBUG) logging.getLogger("communication").addHandler(console) unittest.main() envisage-4.1.0/envisage/plugins/remote_editor/communication/tests/__init__.py0000644000175100001440000000000011674464014030536 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/communication/server.py0000644000175100001440000003055511674464014027165 0ustar ischnellusers00000000000000# Standard library imports import os, sys import logging import socket # ETS imports from apptools.preferences.api import Preferences from traits.api import HasTraits, HasStrictTraits, Int, Str, List, \ Dict, Tuple, Instance # Local imports from util import accept_no_intr, receive, send_port, spawn_independent, \ MESSAGE_SEP, LOCK_PATH, LOG_PATH logger = logging.getLogger("communication") logger.setLevel(logging.DEBUG) logging.basicConfig(filename=LOG_PATH) class PortInfo(HasStrictTraits): """ Object to store information on how a port is being used. """ port = Int type = Str other_type = Str def __str__(self): return "Port: %i, Type: %s, Other type: %s" % \ (self.port, self.type, self.other_type) class Server(HasTraits): """ A socket protocal that facilates two objects communicating with each other. The only instance methods that should be called in ordinary use are 'init' and 'main'. Communication should be done through the methods on 'Client' objects. """ spawn_commands = Dict(Str, Str) _port = Int _sock = Instance(socket.socket) _port_map = Dict(Int, Instance(PortInfo)) _orphans = List(Instance(PortInfo)) _pairs = Dict(Instance(PortInfo), Instance(PortInfo)) # Commands that have been queued for spawned process # desired_type -> list of (command, arguments) _queue = Dict(Str, List(Tuple(Str, Str))) def init(self, pref_path='', pref_node=''): """ Read a configuration file and attempt to bind the server to the specified port. """ # Bind to port and write port to lock file self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._sock.bind(('localhost', 0)) self._port = self._sock.getsockname()[1] f = open(LOCK_PATH, 'w') f.write(str(self._port)) f.close() # Read configuration file if not pref_path: return if os.path.exists(pref_path): prefs = Preferences(filename=pref_path) if prefs.node_exists(pref_node): spawn_node = prefs.node(pref_node) for key in spawn_node.keys(): cmd = spawn_node.get(key).strip() if cmd.startswith('python '): cmd = cmd.replace('python', sys.executable, 1) self.spawn_commands[key] = cmd else: msg = "Server could not locate preference node '%s.'" logger.error(msg % pref_node) else: msg = "Server given non-existent preference path '%s'." logger.error(msg % pref_path) def main(self, port=0): """ Starts the server mainloop. If 'port' is specified, the assumption is that this Server was spawned from an object on said port. The Server will inform the Client that it has been created, and if fails to contact the client, this function will return. """ try: # Start listening *before* we (potentially) inform the spawner that # we are working. This means that if the spawner tries to register, # we will be ready. logger.info("Server listening on port %i..." % self._port) self._sock.listen(5) self._sock.settimeout(300) # If necessary, inform the launcher that we have initialized # correctly by telling it our port if port: if not send_port(port, "__port__", str(self._port), timeout=5): msg = "Server could not contact spawner. Shutting down..." logger.warning(msg) return # Start the mainloop while True: try: client, address = accept_no_intr(self._sock) except socket.timeout: # Every 5 minutes of inactivity, we trigger a garbage # collection. We do this to make sure the server doesn't # stay on, with dead process as zombies. self._gc() continue try: if address[0] != '127.0.0.1': msg = "Server received connection from a non-local " \ "party (port %s). Ignoring..." logger.warning(msg, address[0]) continue command, arguments = receive(client) logger.debug("Server received: %s %s", command, arguments) if command == "send": port, command, arguments = arguments.split(MESSAGE_SEP) self._send_from(int(port), command, arguments) elif command == "register": port, type, other_type = arguments.split(MESSAGE_SEP) self._register(int(port), type, other_type) elif command == "unregister": self._unregister(int(arguments)) elif command == "ping": self._send_to(int(arguments), "__status__", "1") elif command == "spawn": self._spawn(arguments) else: logger.error("Server received unknown command: %s %s", command, arguments) finally: client.close() finally: self._sock.close() @staticmethod def ping(server_port, timeout=1, error_only=False): """ Returns whether the server is running on 'server_port'. If error_only, return False only if there was an error (ie the socket is closed). """ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(timeout) sock.bind(('localhost', 0)) sock.listen(1) try: port = str(sock.getsockname()[1]) send_port(server_port, "ping", port, timeout=timeout) try: server, address = accept_no_intr(sock) try: command, arguments = receive(server) return command == "__status__" and bool(int(arguments)) finally: try: server.shutdown(socket.SHUT_RD) except: pass except socket.error: # 'sock' may have timed out, so use try..except. try: sock.shutdown(socket.SHUT_RD) except: pass return False except: try: sock.shutdown(socket.SHUT_RD) except: pass def _spawn(self, object_type): """ Attempt to spawn an process according the specified type. Returns whether this was sucessful. """ try: command = self.spawn_commands[object_type] except KeyError: msg = "No spawn command is defined for object type '%s'." \ % object_type logger.warning(msg) return msg try: logging.info("Server spawning Client of type '%s.'" % object_type) spawn_independent(command, shell=True) except OSError: msg = "Error spawning process for '%s' with command '%s'." \ % (object_type, command) logger.error(msg) return msg return False def _match(self, port): """ Attempt to match a registered client on 'port' to another registered client of the same type. """ # Try to find a compatible orphan info = self._port_map[port] for orphan in self._orphans: if info.other_type == orphan.type: # Ping the orphan to see if its alive: if not self._send_to(orphan.port, '__keepalive__', ''): continue # Save information about the matching self._orphans.remove(orphan) self._pairs[info] = orphan self._pairs[orphan] = info # Dispatch orphaned status to clients self._send_to(port, "__orphaned__", "0") self._send_to(orphan.port, "__orphaned__", "0") # Check command queue and dispatch, if necessary for command, arguments in self._queue.pop(info.type, []): self._send_to(port, command, arguments) return orphan # Otherwise, the object becomes an orphan self._orphans.append(info) return None def _register(self, port, object_type, other_type): """ Register a port of 'object_type' that wants to be paired with another object of 'other_type'. These types are simply strings. Calling 'register' on an already registered port has no effect. """ # Only continue if this object is not already registered if port in self._port_map: return info = PortInfo(port=port, type=object_type, other_type=other_type) self._port_map[port] = info self._match(port) def _unregister(self, port): """ Unregister a port. Calling 'unregister' on a port that is not registered has no effect. """ try: info = self._port_map.pop(port) except KeyError: return if info in self._pairs: other = self._pairs.pop(info) if other in self._pairs: self._pairs.pop(other) self._orphans.append(other) self._send_to(other.port, "__orphaned__", "1") else: self._orphans.remove(info) # If we have nobody registered, terminate the server. if len(self._port_map) == 0: logger.info("No registered Clients left. Server shutting down...") sys.exit(0) def _gc(self): """ Garbage collection of the processes. Check that all the orphaned processes are still responsive, and if not, unregister them. """ for object_info in self._orphans: self._send_to(object_info.port, '__keepalive__', '') # _send_to will automatically unregister the port. def _send_from(self, port, command, arguments): """ Send a command from an object on the specified port. """ try: object_info = self._port_map[port] except KeyError: msg = "Server received a 'send' command from an unregistered " \ "object (port %s)." logger.warning(msg % port) return try_spawn = False if object_info in self._pairs: other = self._pairs[object_info] while not self._send_to(other.port, command, arguments): # The object will automatically be orphaned by _send_to in the # event of a communication failure. Try to find another match. if object_info in self._orphans: self._orphans.remove(object_info) other = self._match(port) if other is None: try_spawn = True break else: try_spawn = True if try_spawn: queue = self._queue.get(object_info.other_type) if queue: queue.append((command, arguments)) else: error_msg = self._spawn(object_info.other_type) if error_msg: self._send_to(port, '__error__', '1' + error_msg) else: self._queue[object_info.other_type] = [(command, arguments)] self._match(port) def _send_to(self, port, command, arguments): """ Send a command to an object on the specified port. Returns whether the command was sent sucessfully. """ status = send_port(port, command, arguments) if not status: msg = "Server failed to communicate with client on port %i. " \ "Unregistering..." logger.warning(msg % port) self._unregister(port) return status def main(pref_path, pref_node, *arg, **kw): server = Server() server.init(pref_path, pref_node) server.main(*arg, **kw) envisage-4.1.0/envisage/plugins/remote_editor/communication/__init__.py0000644000175100001440000000000011674464014027374 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/communication/client.py0000644000175100001440000002276611674464014027142 0ustar ischnellusers00000000000000# Standard library imports import logging import os import select import socket import sys from threading import Thread # ETS imports from traits.api import HasTraits, Int, Str, Bool, Instance, List, \ Tuple, Enum from envisage.plugins import remote_editor # Local imports from server import Server from util import accept_no_intr, get_server_port, receive, send_port, \ spawn_independent, MESSAGE_SEP logger = logging.getLogger(__name__) class ClientThread(Thread): """ A thread for listening for commands from the server. """ def __init__(self, client): Thread.__init__(self) self.client = client self._finished = False def run(self): # Get the server port, spawning it if necessary server_port = get_server_port() if server_port == -1 or not Server.ping(server_port, timeout=5): if len(self.client.server_prefs): # Spawn the server logger.info("Client spawning Server...") sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(5) sock.bind(('localhost', 0)) sock.listen(1) port = sock.getsockname()[1] args = self.client.server_prefs + ( port, ) code = "from envisage.plugins.remote_editor.communication." \ "server import main; main(r'%s', '%s', %i)" % args spawn_independent([sys.executable, '-c', code]) # Await a reponse from the server try: server, address = accept_no_intr(sock) try: command, arguments = receive(server) if command == "__port__": self.client._server_port = int(arguments) else: raise socket.error finally: # Use try...except to handle timeouts try: server.shutdown(socket.SHUT_RD) except: pass except socket.error, e: logger.error(repr(e)) logger.error("Client spawned a non-responsive Server! " \ "Unregistering...") self.client.error = True self.client.unregister() return finally: sock.close() else: logger.error("Client could not contact the Server and no " \ "spawn command is defined. Unregistering...") self.client.error = True self.client.unregister() return else: self.client._server_port = server_port # Create the socket that will receive commands from the server sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(('localhost', 0)) sock.listen(1) self.client._port = sock.getsockname()[1] # Register with the server port = str(self.client._port) arguments = MESSAGE_SEP.join((port, self.client.self_type, self.client.other_type)) self.client.error = not send_port(self.client._server_port, 'register', arguments) self.client.registered = True # Send queued commands (these can only exist if we spawned the server) for command, args in self.client._queue: arguments = MESSAGE_SEP.join((port, command, args)) self.client.error = not send_port(self.client._server_port, 'send', arguments) self.client._queue = [] # Start the loop to listen for commands from the Server logger.info("Client listening on port %i..." % self.client._port) try: while not self._finished: server, address = accept_no_intr(sock) # Reject non-local connections if address[0] != '127.0.0.1': msg = "Client on port %s received connection from a " \ "non-local party (port %s). Ignoring..." logger.warning(msg % (port, address[0])) continue # Receive the command from the server self.client.error = False command, arguments = receive(server) msg = r"Client on port %s received: %s %s" logger.debug(msg, port, command, arguments) # Handle special commands from the server if command == "__orphaned__": self.client.orphaned = bool(int(arguments)) elif command == "__error__": error_status = arguments[0] error_message = '' if len(arguments) > 0: error_message = arguments[1:] logger.warning("Error status received from the server: " \ "%s\n%s" % (error_status, error_message)) self.client.error = bool(int(error_status)) # Handle other commands through Client interface else: if self.client.ui_dispatch == 'off': self.client.handle_command(command, arguments) else: if self.client.ui_dispatch == 'auto': from pyface.gui import GUI else: exec('from pyface.ui.%s.gui import GUI' % self.client.ui_dispatch) GUI.invoke_later(self.client.handle_command, command, arguments) finally: self.client.unregister() def stop(self): self._finished = True class Client(HasTraits): """ An object that communicates with another object through a Server. """ # The preferences file path and node path to use for spawning a Server. If # this is not specified it will not be possible for this Client to spawn # the server. server_prefs = Tuple((os.path.join(remote_editor.__path__[0], "preferences.ini"), "enthought.remote_editor"), Str, Str) # The type of this object and the type of the desired object, respectively self_type = Str other_type = Str # Specifies how 'handle_command' should be called. If 'auto', use the # dispatch method appropriate for the toolkit Traits is using. Failure to # set this variable as appropriate will likely result in crashes. ui_dispatch = Enum('off', 'auto', 'wx', 'qt4') # Whether this client has been registered with the Server. Note that this is # *not* set after the 'register' method is called--it is set when the Server # actually receives the register command, which happens asynchronously. registered = Bool(False) # The client's orphaned status orphaned = Bool(True) # The client's error state. This is set to True after a failure to # communicate with the server or a failure by the server to communicate with # this object's counterpart. error = Bool(False) # Protected traits _port = Int _server_port = Int _communication_thread = Instance(ClientThread) _queue = List(Tuple(Str, Str)) def register(self): """ Inform the server that this Client is available to receive commands. """ if self._communication_thread is not None: raise RuntimeError, "'register' has already been called on Client!" self._communication_thread = ClientThread(self) self._communication_thread.setDaemon(True) self._communication_thread.start() def unregister(self): """ Inform the server that this Client is no longer available to receive commands. Note that it is poor etiquette not to communicate when a Client is becoming unavailable. Calling 'unregister' when a Client is not registered has no effect. """ if self._communication_thread is not None: self._communication_thread.stop() self._communication_thread = None send_port(self._server_port, 'unregister', str(self._port)) self._port = 0 self._server_port = 0 self.registered = False self.orphaned = True def send_command(self, command, arguments=''): """ Send a command to the server which is to be passed to an object of the appropriate type. """ if self._communication_thread is None: raise RuntimeError, "Client is not registered. Cannot send command." msg = r"Client on port %i sending: %s %s" logger.debug(msg, self._port, command, arguments) args = MESSAGE_SEP.join((str(self._port), command, arguments)) if self.registered: self.error = not send_port(self._server_port, 'send', args) else: self._queue.append((command, arguments)) def handle_command(self, command, arguments): """ This function should take a command string and an arguments string and do something with them. It should return True if the command given was understood; otherwise, False. """ raise NotImplementedError envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/0000755000175100001440000000000011674464014025457 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editor_plugin.py0000644000175100001440000000175111674464014030701 0ustar ischnellusers00000000000000# Standard library imports import os import logging # Local imports from envisage.plugins.remote_editor.communication.client import Client class EditorPlugin(Client): # EditorPlugin interface def new(self): raise NotImplementedError def open(self, filename): raise NotImplementedError def run_file(self, path): self.send_command('run_file', path) def run_text(self, text): self.send_command('run_text', text) # Client interface self_type = "python_editor" other_type = "python_shell" def handle_command(self, command, arguments): if command == "new": self.new() return True elif command == "open": if os.path.exists(arguments): self.open(arguments) else: logging.warning("EditorPlugin recieved invalid path '%s' for " "'open' command", arguments) return True return False envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/0000755000175100001440000000000011674464014026727 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/start_editra.py0000644000175100001440000000250411674464014031767 0ustar ischnellusers00000000000000""" Provides a platform indepedent way to launch Editra. Code mostly copied from Editra run file (/usr/bin/editra) in Ubuntu wx package. """ import sys import os try: import Editra as Editra_root sys.path.insert(0, os.path.join(os.path.dirname(Editra_root.__file__), 'src')) # Really ugly: we need to remove the Editra name from the list of # imported modules sys.modules.pop('Editra') except ImportError: import wx.tools # Editra needs its src package to be on the sys.path for plugins and # such to work right, so put it there before we do the first import of # any Editra package or module. sys.path.insert(0, os.path.join(os.path.dirname(wx.tools.__file__), 'Editra', 'src')) import Editra # XXX: Super ugly: monkey-patch the main Editra class to add our plugins old_MainLoop = Editra.Editra.MainLoop def my_MainLoop(self, *args, **kwargs): from envisage.plugins.remote_editor.editor_plugins.editra.editra_plugin \ import RemoteEditorPlugin plugin = RemoteEditorPlugin(Editra=self) try: plugin.do_PlugIt() old_MainLoop(self, *args, **kwargs) finally: plugin.client.unregister() Editra.Editra.MainLoop = my_MainLoop def main(): Editra.Main() if __name__ == '__main__': main() envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/0000755000175100001440000000000011674464014030174 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/python_runsel_24x24.png0000644000175100001440000000305111674464014034455 0ustar ischnellusers00000000000000PNG  IHDRw=sRGBbKGD pHYs  tIME (Э%IDATHǵU]lUnh)mVm&ڈ} >(G 11Ġ1.LL)[[+SJm?uwfg>G(/d*,dmįF[&;Fc,K@) %-k;r'~P1 @'@`e(@0r {Isf(n#akx;bTiwIpcE R*@v: -b 370EGQ\dm_?5F!9%q;K).YcB`ΑL\@@8tnG ODyPl*k5?*(S9I5-L"D")۽fa0p3S͍Tg 9@8ipCB8MNdU6ScQ!,ļ,Kt#4ێd;PJmx$1W, 0&-*X[QL5SNKȵ]cPljܵ~ u}ZL}6R|= T>HKi$ Q<)@_^fY;r;"}aEQ(!dᨡi333dvဦHȐӱfzD։SGG/kO/D'@WW<008Ό{ff\h4 #H $ ) ֬\¹_:&Fce? 6od~\l6ZRR-[|eeya<+t#|M`W/9Kǭ ݭ2;x<~$Id?q*vzic`!$IR{ZZZpQ,d R/ ʌ~z.;d9_  g4&vVTT BdrQWw=Y"ࣣciYe6Ziׯ_?[\0X0X5IENDB`envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/python_runsel_16x16.png0000644000175100001440000000156611674464014034470 0ustar ischnellusers00000000000000PNG  IHDRasRGBbKGD pHYs  tIME ,$IDAT8]_hU|i&$u%[MgqE Ba0 AZod2ti"Ѝpk Ɩlt_9^4Y=yx=Gc! |0==-,Ꙛ/J0tz>5w]NjѥCasqPg^zV~Σ@'B3 l]jEo}sGNɝLD 366h*:΃8mEVC>=y'/g_uڶ}[ P$oP %,;7,ro=yv©Ns$J.[}]G^+~H_Ӡ1=Qҗw#5H7O3GW3/v;{6wr%Jn4 Mip^bчPi?W(BһSn~L~:P@)Ryxʋ^%:jm슇B[Ca 4 BRSjYzheƚz\W+[дTK2:±ԉپKPö@/8?W|<29fWJu]u/dd ׏(g3NuX,-Z뗓ɤn۶m]\\tHoc\owIENDB`envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/python_run_32x32.png0000644000175100001440000000375711674464014033764 0ustar ischnellusers00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME "7 oIDATXŗ[]Uk_gg8LӁbZ7;g @SĀM6& ȃ1ƄFDR%S4JNtôv=s-bWNvvN}}k-$" в ɓ-.%͉`Zk Pz{չ/݀[Pc\o 7>R$Z1p?jsR ^_`];w /ɛnq6nZ/]K,wږ~8i$ ub2Ndٶ\z~̪(/Oyk1̅pT'v6.riVTJa Ğ3J2T ;Vjwb,7 7 #X03QdIk7;V);ywjyUd) x̍`E A ΠɝvWt/23@ydX-8:{FFNe~O(evј/\ SZEA1;il|W&}a?ەZFk8{ϖԽyƢ*\6GJ5q\ۺu+yё_ <Ѵg~'TjxP,,n*(=y\s 'Hp(T\@B?4|'okg5m9'CbC^ O^okT3xwr|/l߼m?vؾ}aX Ԗ^&<`,M]H *!6ME?hC{ tqp*OU:r`r|3sIkgnYv,$I:HQ龚Qvʐm]=dȲWO ,5bZ\<h@!?RIENDB`envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/python_runsel_32x32.png0000644000175100001440000000374611674464014034466 0ustar ischnellusers00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME )1t3fIDATXåklTs66Əp1hTUIZTR*i>TiU!R*UU&UM|p&4 5nR%^3zCҌtvvv?9?_`B!0- Hqf" bX׳Hcи8g9`L^`Jp8 \BQq$LKLlٱe?r{cn4P,^jOe^U̺UNֶI! bdy:8Y5@27 +s׮.=?,>?a992H+-2L1=ܳk/h*\VR{yh$,p%seT.ע9;7,)>pU?6_KWuedzDoޥq sT41.Ok(kxrς*_ji`S}v006VcS젝·`̐;w0.qw=,˷otq,&umn"vtR!]EfI2)\;?xA{-\m&_ti~v; AGZ )dzWǻz-zI#+yvEID[uLI\"ss;|;N5:}g6]k"Lm ry*c-Df($c!BX?z ?( o@N@!p(ROǔTHP2#JJJ.B !(!CXV~^?xJ#ߛ/2jA5 KHƴ"#BL)!0(PN_FweEd Aa&İ2;U$.*ȴ\PWuȤ/o)Lz5@>b:AVJ+T"N\@(3ϵ…_GR۶~qBgZL RiԳjN˷^c4iwu]MF3Mݘ3sW#ie}ŔH wje\w/:k] 7+ʉ9=gϴe aL5ͣn#;oE.][={g0GvN<ѓyXS`!cemTp4?ux,Yc3{k%@fG4w B qe692LiZIf2nttV/# _YUc"Gđp(2R(@EVbD \e`(EiޗXQaF'N>U'Jt-d+j@,*5kzfrBG`{ Y^v;>O#'F:/v m];YHa_hʦ@-gjQ$Rpi٭,"^x-JC M׊sbS7#%,nXјX$^jE4bĚw+M55>n6v,3d %Y{EE5Y4ǚibW͞YXp[gIK"΋YVHz 4ғ9B9MXm4ԭy} Rrȱv5>l77G-?it[N7bZ<=͢9Ztǧ+bMj;VjIENDB`envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/python_run_16x16.png0000644000175100001440000000132011674464014033750 0ustar ischnellusers00000000000000PNG  IHDRasRGBbKGD pHYs  tIME % #PIDAT8˕kQϛN8FIj[:55DPDh\pݩKn\  ڂUkAD I3M2x﹈ͦ]qϹ !ko@=?^Іm@{+&7DvGDc]s}ܭX@TSv *dz$4cXm,5!'R9l 4TR?8Jpp 0h5)5՟URF9e}5 Ep=GղrۀLLcY+#3@)8|w}M;-`o4q5Q!SJ|_7D@_K\e d!DY®iM kgQP- dKo &?x 1p }.5؀_*Kk#\(Mlm0AXĀB%BB3O( (5D$ za5/^tNǟ6z"K$+Hm K!wbkr6"y* A@UJ4sοWR44#=IENDB`envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/image_LICENSE.txt0000644000175100001440000000135411674464014033164 0ustar ischnellusers00000000000000The icons are mostly derived work from other icons. As such they are licensed accordingly to the original license: Enthought: BSD-like Unless stated in this file, icons are work of enthought, and are released under BSD-like license. Files and orginal authors: ---------------------------------------------------------------- python_run_16x16.png | Enthought python_run_24x24.png | Enthought python_run_32x32.png | Enthought python_run_48x48.png | Enthought python_runsel_16x16.png | Enthought python_runsel_24x24.png | Enthought python_runsel_32x32.png | Enthought python_runsel_48x48.png | Enthought envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/python_run_24x24.png0000644000175100001440000000244111674464014033753 0ustar ischnellusers00000000000000PNG  IHDRw=sRGBbKGD pHYs  tIME $.=9IDATHǵYlTewMN -FDmhQI ! 1ąF""P)B̽->x/sw(L~7HHwE.X(vKB_7qvdsFX"zPcT/)Y?Î$nkނIOy=k_^J,H PYW׈;-ZRaEfaߴT>d )d>q3ҁxxLL&!^cS2s:qr_@[eQ*[f=R!?N^aawVMOv{KN0\ }r=>u=(BݶWhE ų*rWi=gcK0E)3  $h0'q[Vӛg2}C 04@.(R5QJΖOF3D19Ŵ+cnY@Y8ݕƒ!J)aaؖE4ZapȤL뎖N'=%> OK̸8g@exj*9{<{~ًa,q@L"R xo[lc)J3 bX==d Zr}'pߚ.rrgܮR)5Jhl+@̹DݹΪ?mpٯk sHd D l6&11,>9|0X|m߽,}:Sa1{6NFvL1-MIs|bwP)cέ]?^fEG*ir7#`|@qNZWʏRbw |Dp(q=m8 {\tRٍK-ջRdtx%}j᫷7m*n?@puk} z4`\T H$7~hցP}?s. ה}uʳ-ڳB¶g?v8@KJdT"¡SCdwE*AjM)ܞ)ǽD(ʀdw tgG6zIENDB`envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/python_runsel_48x48.png0000644000175100001440000000553411674464014034501 0ustar ischnellusers00000000000000PNG  IHDR00WsRGBbKGD pHYs  tIME  IDATh՚{pT?ܻ{7nB$$Cx(j)(`jǶǴvq:m3N?l;JÛJAQy&$׽􏽛lB Y\;7s'gc=;:_PӀ Q(rn D#/ 0k8Zvk yďض-2x08VMhBhJ)8]Zl<āB~xݺu)+V4:ļ%s+ʫ+hx~M‚@|}Y\@$ ~=aÆ) IE4YVw_n/ls/MPg2c1pv3c]{#WO!vnޒwh{)K=^h<N+B_vm\xAF><{&-S̻i> ~lSW-玘X?~eYh^>}#o[?˅(+cj-?rJRhiе"4]6[)grY طG*{V:̵'v 3]1^JÉvX |4\B֊63S&4|?laq&|w74۸[y9JwSx^,cTJ1r_J~ym"L#sg1w-+y qi?)`;o>}KwDژT)zB=Fg!" X)DA)u8RghˡFgߜll5B^zh•^J 0ClL:PE9/茴u}T]C?9;^-5QBh6±(NqXHFDJ-'zJav?ޥa\=M[?0 gu)|*29oXE-}q¡8(`0.D bDqbQ TXm*,S rT#o܌ە;'C(ҹ# JS,B \cFـضRB Dsr,@3C3m㍆F"0 WW"@[#2}x"7Φ.P/@p3 MYb06V^r imV ?y{Q+L'>kjȔL"( ",!5R_@'~ VۙVMxͮv*P1W`̼P HT1)A  ?󮾑c+ՆBjSƒIK l?6ب'G"~7aq21w2) N̶Rݥ3|j-=w=m[Y=9ʺwzؘͭq+~n_tgw4BNTbmBR&gXdAKQ*fV#fwl4C^_̺csT&fs+ʌB2m -Or^ cY~=byWd:}RJCoj0@@BS4f l#ŌQZ0p4={B'<չ߬yө̖ѱIlDL;TD*4T It&Mjl oMmӎq9|*eI|HtCd"@@SeL;l2Rɿ5ju!t֌48Bа WD -`Yc Ѱ%Ǥp_nc8h"8fW/gkwnhmjݣKjժ,yƽH<rռ =qgqjK.أ>ze8)~cvoDCůݵIHb{0_#55.`VE{O+R[SSn^d?ŨB*Fe^t11w]M,T l.tɤ=쳮p `335k$^Qn.d:'#oIENDB`envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/images/python_run_48x48.png0000644000175100001440000000651311674464014033773 0ustar ischnellusers00000000000000PNG  IHDR00WsRGBbKGD pHYs  tIME !fF IDATh՚{pT}?޻{wWZ+ I $0 6cvRpffi&Si6zē鴓Ǵî8lc1!$X&PB/ =V8􏽻Z̙wse@@f $ B SXn}Qq`S #A|wFHܕj3MёPP{Mvt_ތ1Lת?L Uڴp7rk*:r->d87-O puvQ#)jZYyJ1#Cn/o )3u˳ ~E"\AKsX}e7q_ɪZ?9 NSCnsXپ֨\]G2"+<1( ߴ?.J@- #;'ڡ ;iGV%bs=: LJY dff9IȈv%[Թع˛[BtL߄?@vH|F>^v-75;].E恲sP" 䆧SYnQ8!v-É>-;K ( dؤ*M󛮌@nLq2'P(WjaJ^ՅE0_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VrOVC~~B3t&%!=3; RF@&NP2ǁع*vIENDB`envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/editra_plugin.py0000644000175100001440000001545011674464014032134 0ustar ischnellusers00000000000000""" Integrates Editra with the an envisage applciation with the remote editor plugin. """ __author__ = "Enthought" __version__ = "0.1" # Standard library imports import os # System library imports import wx # ETS imports from traits.api import Any, Bool from envisage.plugins.remote_editor.editor_plugins.editor_plugin \ import EditorPlugin # Editra namespace imports from wx.tools.Editra.src import ed_menu from profiler import Profile_Get # Constants _ = wx.GetTranslation ID_RUN_SCRIPT = wx.NewId() ID_RUN_TEXT = wx.NewId() class EditraEditorPlugin(EditorPlugin): # Client interface # Dispatch all command events in same thread as the wx event loop ui_dispatch = 'wx' # EditraEditorPlugin interface # A reference to the Editra mainWindow main_window = Any # Whether the window should be given focus when it recieves a command raise_on_command = Bool(True) #-------------------------------------------------------------------------- # 'EditorPlugin' interface #-------------------------------------------------------------------------- def new(self): """ Open a new file in the main window. """ notebook = self.main_window.GetNotebook() current = notebook.GetCurrentCtrl() if current.GetFileName() != "" or str(current.GetText()) != "": notebook.NewPage() notebook.GoCurrentPage() current.FindLexer('py') current.BackSpaceUnIndents = True if self.raise_on_command: self.main_window.Raise() def open(self, filename): """ Open the given filename in the main window. """ self.main_window.DoOpen(None, filename) if self.raise_on_command: self.main_window.Raise() class RemoteEditorPlugin(object): """ Editor plugin for communicating with shells programs, acting as a remote editor. """ def __init__(self, Editra=None): self.Editra = Editra def do_PlugIt(self): self.mainWindow = mainWindow = wx.GetApp().GetMainWindow() self.log = wx.GetApp().GetLog() self.log("[remote editor][info] Installing remote editor plugin") menuBar= mainWindow.GetMenuBar() # Register the EditorPlugin with the Enthought remote_editor server self.client = EditraEditorPlugin(main_window=self.mainWindow) self.client.register() # Set up a handler for keybindings. Ideally, we would do this through an # interface provided by Editra, but since this seems to change with # every single Editra release, we take the brute force approach. mainWindow.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) # Insert menu items toolsMenu = menuBar.GetMenuByName("tools") mnu_run_text = wx.MenuItem(toolsMenu, ID_RUN_TEXT, _('Execute selection\tShift+Enter'), _('Execute selected text in a python shell'), wx.ITEM_NORMAL) mnu_run_text.SetBitmap(wx.Bitmap(os.path.join( os.path.dirname(__file__), 'images', 'python_runsel_16x16.png'))) toolsMenu.AppendItem(mnu_run_text, use_bmp=False) mnu_run_script = wx.MenuItem(toolsMenu, ID_RUN_SCRIPT, _('Execute script\tCtrl+Enter'), _('Execute file in a python shell')) mnu_run_script.SetBitmap(wx.Bitmap(os.path.join( os.path.dirname(__file__), 'images', 'python_run_16x16.png'))) toolsMenu.AppendItem(mnu_run_script, use_bmp=False) # Bind the events. self.mainWindow._handlers['menu'].extend( [(ID_RUN_SCRIPT, self.OnRunScript), (ID_RUN_TEXT, self.OnRunText) ]) # The enable/disable callback for the toolbar button (we need to insert # this callback at the front of the stack). self.mainWindow._handlers['ui'].insert(0, (ID_RUN_TEXT, self.EnableSelection), ) # Insert toolbar items toolBar = mainWindow.GetToolBar() self.run_sel_tb = toolBar.AddLabelTool( ID_RUN_TEXT, 'Execute selection', wx.Bitmap(os.path.join(os.path.dirname(__file__), 'images', 'python_runsel_24x24.png')), shortHelp='Execute selection', longHelp='Execute selection in shell') self.run_file_tb = toolBar.AddLabelTool( ID_RUN_SCRIPT, 'Execute', wx.Bitmap(os.path.join(os.path.dirname(__file__), 'images', 'python_run_24x24.png')), shortHelp='Execute script', longHelp='Execute whole file in shell') # Just calling AddLabelTool is not displaying the new tools in the # toolbar (for Win XP and OS-X at least). Need to call Realize. toolBar.Realize() def OnRunScript(self, event): """ Run the script, prompting for a save if necessary. """ notebook = self.mainWindow.GetNotebook() currentTab = notebook.GetCurrentCtrl() filename = currentTab.GetFileName() if filename == "": if self.mainWindow.OnSaveAs(None, page=currentTab): filename = currentTab.GetFileName() else: return else: if currentTab.GetModify(): result = notebook.frame.ModifySave() if result == wx.ID_CANCEL: return self.client.send_command('run_file', filename) def OnRunText(self, event): """ Run the selected text. """ currentTab = self.mainWindow.GetNotebook().GetCurrentCtrl() text = str(currentTab.GetSelectedText()) # Convert from unicode if text == "": msg = _("Cannot execute. No text is selected.") self.mainWindow.PushStatusText(msg) else: self.client.send_command('run_text', text) def OnKeyDown(self, event): """ Handles key presses when the version of Editra is less than 0.3 (no KeyBindings support). """ if event.GetKeyCode() == wx.WXK_RETURN: if event.ShiftDown(): self.OnRunText(event) elif event.ControlDown(): self.OnRunScript(event) else: event.Skip() def EnableSelection(self, evt): if not self.mainWindow.IsActive(): return e_id = evt.GetId() evt.SetMode(wx.UPDATE_UI_PROCESS_SPECIFIED) # Slow the update interval to reduce overhead evt.SetUpdateInterval(200) ctrl = self.mainWindow.nb.GetCurrentCtrl() if e_id == ID_RUN_TEXT: evt.Enable(ctrl.GetSelectionStart() != ctrl.GetSelectionEnd()) else: evt.Skip() envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/editra/__init__.py0000644000175100001440000000000011674464014031026 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/__init__.py0000644000175100001440000000000011674464014027556 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/readme.txt0000644000175100001440000000031511674464014027454 0ustar ischnellusers00000000000000The root of this directory contains abstract base classes for plugins. The subdirectories contain implementations of one or more of these plugins for some specific tool which is external to this project. envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/emacs/0000755000175100001440000000000011674464014026547 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/emacs/enshell.el0000644000175100001440000000010511674464014030517 0ustar ischnellusers00000000000000(pymacs-load "enthought.plugins.remote_editor.communication.client") envisage-4.1.0/envisage/plugins/remote_editor/editor_plugins/emacs/enshell_plugin.py0000644000175100001440000000120511674464014032127 0ustar ischnellusers00000000000000""" """ # System library imports from Pymacs import lisp # ETS imports from envisage.plugins.remote_editor.plugins.editor_plugin import \ EditorPlugin client = EditorPlugin() client.register() def run_text(): start = lisp.point() end = lisp.mark(True) if start > end: start, end = end, start text = lisp.buffer_substring(start, end) if len(text): client.run_text(text) else: # TODO Complain in message bar pass def run_file(): path = lisp.buffer_file_name() if path is None: # TODO Complain in message bar pass else: client.run_file(path) envisage-4.1.0/envisage/plugins/remote_editor/enshell_client.py0000644000175100001440000000071411674464014025774 0ustar ischnellusers00000000000000# Standard library imports import os # Local imports from envisage.plugins import remote_editor from envisage.plugins.remote_editor.communication.client import Client class EnshellClient(Client): """ A Client that is configured to spawn servers using the config file for this application. """ server_prefs = (os.path.join(remote_editor.__path__[0], "preferences.ini"), "enthought.remote_editor") envisage-4.1.0/envisage/plugins/remote_editor/remote_shell_controller.py0000644000175100001440000000154511674464014027734 0ustar ischnellusers00000000000000""" A client controlling a remote shell. """ # Enthought library imports from traits.api import implements # Local imports from envisage.plugins.remote_editor.communication.client import Client from i_remote_shell import IRemoteShell class RemoteShellController(Client): """ A Client used to control a remote shell. """ implements(IRemoteShell) #------------------------------------------------------ # Client interface #------------------------------------------------------ self_type = "python_editor" other_type = "python_shell" #------------------------------------------------------ # RemoteShell interface #------------------------------------------------------ def run_file(self, path): self.send_command('run_file', path) def run_text(self, text): self.send_command('run_text', text) envisage-4.1.0/envisage/plugins/remote_editor/i_remote_shell.py0000644000175100001440000000071511674464014025777 0ustar ischnellusers00000000000000""" Interface definition for the Remote shell """ # Enthought library imports. from traits.api import Interface class IRemoteShell(Interface): """ Interface definition for the remote shell """ def run_file(self, path): """ Runs a file in the remote shell. """ def run_text(self, text): """ Runs a string in the remote shell. """ #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/remote_editor/__init__.py0000644000175100001440000000000011674464014024527 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/remote_editor/i_remote_editor.py0000644000175100001440000000073011674464014026153 0ustar ischnellusers00000000000000""" Interface definition for the Remote editor """ # Enthought library imports. from traits.api import Interface class IRemoteEditor(Interface): """ Interface definition for the Namespace view """ def new_file(self): """ Creates a new file in the remote editor. """ def open_file(self, filename): """ Opens a file in the remote editor. """ #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/remote_editor/envisage_remote_editor.py0000644000175100001440000000410511674464014027524 0ustar ischnellusers00000000000000""" An implementation of a client controlling a remote editor, but also using envisage to retrieve an execution engine, and run the commands from the editor. """ # Standard library imports import logging # Enthought library imports from traits.api import Instance from envisage.api import Application from envisage.plugins.python_shell.api import IPythonShell from pyface.api import GUI # Local imports from envisage.plugins.remote_editor.remote_editor_controller import \ RemoteEditorController logger = logging.getLogger(__name__) class EnvisageRemoteEditorController(RemoteEditorController): """ An implementation of a client controlling a remote editor, but also using envisage to retrieve an execution engine, and run the commands from the editor. """ # Tell the Client code to play well with the wx or Qt4 event loop ui_dispatch = 'auto' # A reference to the Envisage application. application = Instance(Application) ########################################################################### # EnvisageRemoteEditorController interface ########################################################################### def run_file(self, path): """ Called by the server to execute a file. """ shell = self.application.get_service(IPythonShell) shell.execute_file(path, hidden=False) def run_text(self, text): """ Called by the server to execute text. """ shell = self.application.get_service(IPythonShell) shell.execute_command(text, hidden=False) ########################################################################### # Enshell Client interface ########################################################################### def handle_command(self, command, arguments): """ Hande commands coming in from the server. """ if command == "run_file": self.run_file(arguments) return True elif command == "run_text": self.run_text(arguments) return True return False envisage-4.1.0/envisage/plugins/remote_editor/remote_editor_plugin.py0000644000175100001440000000643411674464014027230 0ustar ischnellusers00000000000000""" A plugin for controlling a remote editor. """ # Enthought library imports. from envisage.api import Plugin from envisage.plugins.remote_editor.api import IRemoteEditor from traits.api import List, Instance, Any, on_trait_change # Local imports from envisage_remote_editor import EnvisageRemoteEditorController \ as RemoteEditorController ID = 'envisage.plugins.remote_editor' class RemoteEditorPlugin(Plugin): """ A plugin for controlling a remote editor. """ # Extension point Ids. REMOTE_EDITOR = ID ACTION_SETS = 'envisage.ui.workbench.action_sets' PREFERENCES = 'envisage.preferences' PREFERENCES_PAGES = 'envisage.ui.workbench.preferences_pages' # Our remote controller for the editor remote_controller = Instance(RemoteEditorController) # The shell and editor commands server_prefs = Any #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'envisage.plugins.remote_editor' # The plugin's name (suitable for displaying to the user). name = 'Remote editor' #### Extension points offered by this plugin ############################## #### Contributions to extension points made by this plugin ################ # Our action sets. action_sets = List(contributes_to=ACTION_SETS) # Preferences pages. # FIXME: Create a UI for remote editor preferences #preferences_pages = List(contributes_to=PREFERENCES_PAGES) # Preferences. preferences = List(contributes_to=PREFERENCES) def _action_sets_default(self): """ Trait initializer. """ from envisage.plugins.remote_editor.actions import \ RemoteEditorActionSet return [ RemoteEditorActionSet ] def _preferences_default(self): """ Trait initializer. """ return [ 'pkgfile://%s/preferences.ini' % ID ] def _preferences_pages_default(self): """ Trait initializer. """ from envisage.plugins.remote_editor.preference_pages \ import RemoteEditorPreferencesPage return [ RemoteEditorPreferencesPage ] ########################################################################### # Private interface. ########################################################################### # Create the central server for spawning shells and editors. @on_trait_change('application:started') def _create_server(self): """ Create the central server for spawning shells and editors and register the controller as an envisage service. """ # Register our client to the server. If the server does not exist, this # will create it. self.remote_controller = RemoteEditorController( application=self.application) # XXX I don't like this at all if self.server_prefs: self.remote_controller.server_prefs = self.server_prefs self.remote_controller.register() self.application.register_service(IRemoteEditor, self.remote_controller) @on_trait_change('application:stopping') def _unregister_from_server(self): """ Unregister this client from the server. """ self.remote_controller.unregister() #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/update_checker/0000755000175100001440000000000011674464014022535 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/update_checker/tools.py0000644000175100001440000000142611674464014024252 0ustar ischnellusers00000000000000""" A collection of command-line tools for building encoded update.xml files. """ class InfoFile: update_file = "" version = None checksum = None # A multi-line HTML document describing the changes between # this version and the previous version description = "" @classmethod def from_info_file(filename): return def files2xml(filenames): """ Given a list of filenames, extracts the app version and log information from accompanying files produces an output xml file. There are no constraints or restrictions on the names or extensions of the input files. They just need to be accompanied by a sidecar file named similarly, but with a ".info" extension, that can be loaded by the InfoFile class. """ return envisage-4.1.0/envisage/plugins/update_checker/tests/0000755000175100001440000000000011674464014023677 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/update_checker/tests/bare_app.py0000644000175100001440000000155611674464014026031 0ustar ischnellusers00000000000000 # Standard library imports. import logging # Enthought library imports. from envisage.ui.workbench.api import WorkbenchApplication from envisage.core_plugin import CorePlugin from envisage.ui.workbench.workbench_plugin import WorkbenchPlugin from enthought.epdlab.plugins.code_editor.plugin import CodeEditorPlugin # Logging. logger = logging.getLogger() logger.addHandler(logging.StreamHandler(file('update_checker.log', 'w'))) logger.setLevel(logging.DEBUG) def main(): application = Application( id='Update Checker Tester', plugins=[UpdateChecker()] ) application = WorkbenchApplication( id='update_checker_tester', name='Update Checker', plugins=[ CorePlugin(), WorkbenchPlugin(), UpdateCheckerPlugin( ), ]) application.run() if __name__ == "__main__": main() envisage-4.1.0/envisage/plugins/update_checker/update_checker_plugin.py0000644000175100001440000000411211674464014027431 0ustar ischnellusers00000000000000 # Enthought library imports from envisage.api import Plugin from traits.api import Bool, Callable, Event, Int, Instance, Str, Trait # Local, relative imports from update_info import UpdateInfo # The globally unique ID of this plugin ID = "envisage.plugins.update_checker" class UpdateCheckerPlugin(Plugin): name = "Update Checker Plugin" # The URI to an updates.xml file. Although this can be a local path, # typically it will be a URL. location = Str("localhost") # Update # Should the plugin automatically check for updates? check_automatically = Bool(True) # The frequency with which to check for updates # Can be "startup", which means at application startup, or an integer number # of seconds # TODO: Contribute a preference for this! check_frequency = Trait("startup", "startup", Int) # Whether or not to display a dialog informing the user of available # updates display_dialog = Bool(True) # The UpdateInfo object that contains the actual update information. # Regardless of whether or not a dialog is displayed to the user, this # attribute will be populated with the appropriate information. update_info = Instance(UpdateInfo) # This event fires every time the UpdateCheckerPlugin is invoked and # determines that an application update is available. update_needed = Event() #Event(ApplicationEvent) #======================================================================== # Plugin interface #======================================================================== def start(self): """ Make the appropriate contributions """ self.application.on_trait_change("started", self._check_for_update) def stop(self): """ Clean up """ self.application.on_trait_change("started", self._check_for_update, remove=True) #======================================================================== # Public methods #======================================================================== def _check_for_update(self): pass envisage-4.1.0/envisage/plugins/update_checker/update_checker_dialog.py0000644000175100001440000000017011674464014027372 0ustar ischnellusers00000000000000 """ This module is a UI for informing the user that an update has been found, and prompting them to download it. """ envisage-4.1.0/envisage/plugins/update_checker/update_info.py0000644000175100001440000000332011674464014025402 0ustar ischnellusers00000000000000 from traits.api import Callable, HasTraits, List, Str class VersionInfo(HasTraits): """ Represents the information about a particular version of an application. """ # The version string that this version = Str() # Customer-facing notes about this version. Typically this is an # HTML document containing the changelog between this version and # the previous version notes = Str() # The location of where to obtain this version. Typically this will # be an HTTP URL, but this can be a URI for a local or LAN item, or # it can be a location = Str() # A function that takes a string (self.version) and returns something # that can be used to compare against the version-parsed version of # another VersionInfo object. version_parser = Callable() def __cmp__(self, other): """ Allows for comparing two VersionInfo objects so they can be presented in version-sorted order. This is where we parse and interpretation of the **version** string attribute. """ # TODO: Do something more intelligent here if self.version_parser is not None: self_ver = self.version_parser(self.version) else: self_ver = self.version if other.version_parser is not None: other_ver = other.version_parser(other.version) else: other_ver = other.version return self_ver < other_ver class UpdateInfo(HasTraits): """ Encapsulates the information about the available update or updates. An update can consist of multiple versions, with each version containing its own information and download URL. """ updates = List(VersionInfo) pass envisage-4.1.0/envisage/plugins/update_checker/__init__.py0000644000175100001440000000000011674464014024634 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/update_checker/update_info_view.py0000644000175100001440000000047511674464014026444 0ustar ischnellusers00000000000000 from traitsui.api import View class UpdateInfoView(View): """ A View for UpdateInfo objects that displays them in a nice HTML widget. Note that this view does NOT include any UI widgets for interacting with the user or prompting for a download; for that, use the UpdateCheckerDialog. """ pass envisage-4.1.0/envisage/plugins/tasks/0000755000175100001440000000000011674464014020714 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/tasks/__init__.py0000644000175100001440000000000011674464014023013 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/tasks/python_shell_plugin.py0000644000175100001440000000721111674464014025355 0ustar ischnellusers00000000000000""" Module defining a simple Python shell Envisage tasks plugin. This plugin provides a task with a simple Python shell. This shouldn't be confused with a more full-featured shell, such as those provided by IPython. """ # Standard library imports. import logging # Enthought library imports. from traits.api import Str, List, Dict, Instance, Property from pyface.tasks.contrib.python_shell import PythonShellTask from envisage.api import Plugin, ExtensionPoint, IExtensionRegistry from envisage.ui.tasks.api import TaskFactory logger = logging.getLogger() BINDINGS = 'envisage.plugins.python_shell.bindings' COMMANDS = 'envisage.plugins.python_shell.commands' class EnvisagePythonShellTask(PythonShellTask): """ Subclass of PythonShellTask that gets its bindings and commands from an Envisage ExtensionPoint """ id='envisage.plugins.tasks.python_shell_task' # ExtensionPointUser interface extension_registry = Property(Instance(IExtensionRegistry)) # The list of bindings for the shell bindings = ExtensionPoint(id=BINDINGS) # The list of commands to run on shell startup commands = ExtensionPoint(id=COMMANDS) # property getter/setters def _get_extension_registry(self): if self.window is not None: return self.window.application return None class PythonShellPlugin(Plugin): """ A tasks plugin to display a simple Python shell to the user. """ # Extension point IDs. BINDINGS = BINDINGS COMMANDS = COMMANDS TASKS = 'envisage.ui.tasks.tasks' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'envisage.plugins.tasks.python_shell_plugin' # The plugin's name (suitable for displaying to the user). name = 'Python Shell' #### Extension points exposed by this plugin ############################## bindings = ExtensionPoint( List(Dict), id=BINDINGS, desc=""" This extension point allows you to contribute name/value pairs that will be bound when the interactive Python shell is started. e.g. Each item in the list is a dictionary of name/value pairs:: {'x' : 10, 'y' : ['a', 'b', 'c']} """ ) commands = ExtensionPoint( List(Str), id=COMMANDS, desc=""" This extension point allows you to contribute commands that are executed when the interactive Python shell is started. e.g. Each item in the list is a string of arbitrary Python code:: 'import os, sys' 'from traits.api import *' Yes, I know this is insecure but it follows the usual Python rule of 'we are all consenting adults'. """ ) #### Contributions to extension points made by this plugin ################ # Bindings. contributed_bindings = List(contributes_to=BINDINGS) tasks = List(contributes_to=TASKS) ########################################################################### # Protected interface. ########################################################################### def start(self): logger.debug('started python shell plugin') def _contributed_bindings_default(self): """ By default we expose the Envisage application object to the namespace """ return [{'application' : self.application}] def _tasks_default(self): return [ TaskFactory( id='envisage.plugins.tasks.python_shell_task', name='Python Shell', factory=EnvisagePythonShellTask ), ] envisage-4.1.0/envisage/plugins/__init__.py0000644000175100001440000000000011674464014021666 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/refresh_code/0000755000175100001440000000000011674464014022217 5ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/refresh_code/actions.py0000644000175100001440000000120111674464014024223 0ustar ischnellusers00000000000000""" Actions for the refresh code plugin. """ # Enthought library imports. from pyface.action.api import Action class RefreshCode(Action): """ Invoke the 'refresh code' function. """ #### 'Action' interface ################################################### name = 'Refresh Code' description = 'Refresh application to reflect python code changes' accelerator = 'Ctrl+Shift+R' def perform(self, event): """ Perform the action. """ from traits.util.refresh import refresh refresh() return #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/refresh_code/refresh_code_plugin.py0000644000175100001440000000155511674464014026605 0ustar ischnellusers00000000000000""" A plugin that offers the 'refresh code' functionality. """ # Enthought library imports. from envisage.api import Plugin from traits.api import List class RefreshCodePlugin(Plugin): """ A plugin that offers the 'refresh code' functionality. """ # Extension point Ids. ACTION_SETS = 'envisage.ui.workbench.action_sets' #### Extension points offered by this plugin ############################## # None. #### Contributions to extension points made by this plugin ################ action_sets = List(contributes_to=ACTION_SETS) def _action_sets_default(self): """ Trait initializer. """ from envisage.plugins.refresh_code.refresh_code_action_set import ( RefreshCodeActionSet ) return [RefreshCodeActionSet] #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/refresh_code/refresh_code_action_set.py0000644000175100001440000000104011674464014027424 0ustar ischnellusers00000000000000""" The default action set for the refresh code plugin. """ # Enthought library imports. from envisage.ui.action.api import Action, ActionSet # This package PKG = '.'.join(__name__.split('.')[:-1]) refresh_code = Action( class_name = PKG + '.actions.RefreshCode', path = 'MenuBar/Tools', group='additions' ) class RefreshCodeActionSet(ActionSet): """ The default action set for the refresh code plugin. """ actions = [refresh_code] #### EOF ###################################################################### envisage-4.1.0/envisage/plugins/refresh_code/__init__.py0000644000175100001440000000000011674464014024316 0ustar ischnellusers00000000000000envisage-4.1.0/envisage/plugins/refresh_code/refresh_code_plugin_definition.py0000644000175100001440000000731411674464014031014 0ustar ischnellusers00000000000000""" Text Editor plugin definition. """ # Plugin extension-point imports. from envisage import PluginDefinition, get_using_workbench # Are we using the old UI plugin, or the shiny new Workbench plugin? USING_WORKBENCH = get_using_workbench() # Enthought plugin definition imports. if USING_WORKBENCH: from envisage.workbench.action.action_plugin_definition import \ Action, Group, Location, Menu, WorkbenchActionSet else: from envisage.ui.ui_plugin_definition import \ Action, Group, Menu, UIActions # The plugin's globally unique identifier (also used as the prefix for all # identifiers defined in this module). ID = "envisage.plugins.refresh_code" ############################################################################### # Extensions. ############################################################################### if USING_WORKBENCH: refresh_code = Action( name = "Refresh Code", description = "Refresh application to reflect python code changes", accelerator = "Ctrl+Shift+R", function_name = "traits.util.refresh.refresh", locations = [ Location(path="MenuBar/FileMenu/ExitGroup") ] ) actions = WorkbenchActionSet( id = ID + ".refresh_code_action_set", name = "Refresh Code", # fixme: This menus stuff should go away once we get ticket:312 # resolved. #groups = [ # Group( # id = "ToolsMenuGroup", # location = Location(path="MenuBar") # ), # Group( # id = "RefreshGroup", # location = Location(path="MenuBar/ToolsMenu") # ), #], #menus = [ # Menu( # id = "ToolMenu", # name = "&Tools", # location = Location(path="MenuBar/ToolsMenuGroup"), # groups = [] # ), #], actions = [refresh_code] ) requires = "envisage.workbench.action" else: refresh_code = Action( name = "Refresh Code", # fixme: this should change description = "Refresh application to reflect python code changes", menu_bar_path = "ToolsMenu/additions", # fixme: this should change accelerator = "Ctrl+Shift+R", function_name = "traits.util.refresh.refresh" ) actions = UIActions( # fixme: This menus stuff should go away once we get ticket:312 # resolved. menus = [ Menu( id = "ToolsMenu", name = "&Tools", path = "ToolsGroup", groups = [ Group(id = "Start"), Group(id = "End"), ] ), ], actions = [refresh_code] ) requires = "envisage.ui" ############################################################################### # The plugin definition! ############################################################################### class RefreshCodePluginDefinition(PluginDefinition): # The plugin's globally unique identifier. id = ID # General information about the plugin. name = "Refresh Code Plugin" version = "1.0.0" provider_name = "Enthought Inc" provider_url = "www.enthought.com" enabled = True # The Id's of the plugins that this plugin requires. requires = [requires] # The extension points offered by this plugin, extension_points = [] # The contributions that this plugin makes to extension points offered by # either itself or other plugins. extensions = [actions] #### EOF ###################################################################### envisage-4.1.0/envisage/__init__.py0000644000175100001440000000021511674464014020215 0ustar ischnellusers00000000000000# Copyright (c) 2007-2011 by Enthought, Inc. # All rights reserved. __version__ = '4.1.0' __requires__ = [ 'apptools', 'traits', ] envisage-4.1.0/envisage/unknown_extension.py0000644000175100001440000000040711674464014022254 0ustar ischnellusers00000000000000""" The exception raised when an unknown extension is referenced. """ class UnknownExtension(Exception): """ The exception raised when an unknown extension is referenced. """ #### EOF ###################################################################### envisage-4.1.0/envisage/unknown_extension_point.py0000644000175100001440000000043011674464014023461 0ustar ischnellusers00000000000000""" The exception raised when an unknown extension point is referenced. """ class UnknownExtensionPoint(Exception): """ The exception raised when an unknown extension point is referenced. """ #### EOF ###################################################################### envisage-4.1.0/envisage/plugin_activator.py0000644000175100001440000000247011674464014022035 0ustar ischnellusers00000000000000""" The default plugin activator. """ # Enthought library imports. from traits.api import HasTraits, implements # Local imports. from i_plugin_activator import IPluginActivator class PluginActivator(HasTraits): """ The default plugin activator. """ implements(IPluginActivator) ########################################################################### # 'IPluginActivator' interface. ########################################################################### def start_plugin(self, plugin): """ Start the specified plugin. """ # Connect all of the plugin's extension point traits so that the plugin # will be notified if and when contributions are added or removed. plugin.connect_extension_point_traits() # Register all services. plugin.register_services() # Plugin specific start. plugin.start() return def stop_plugin(self, plugin): """ Stop the specified plugin. """ # Plugin specific stop. plugin.stop() # Unregister all service. plugin.unregister_services() # Disconnect all of the plugin's extension point traits. plugin.disconnect_extension_point_traits() return #### EOF ###################################################################### envisage-4.1.0/envisage/i_import_manager.py0000644000175100001440000000244211674464014021776 0ustar ischnellusers00000000000000""" The interface for import managers. """ # Enthought library imports. from traits.api import Interface class IImportManager(Interface): """ The interface for import managers. """ def import_symbol(self, symbol_path): """ Import the symbol defined by the specified symbol path. 'symbol_path' is a string containing the path to a symbol through the Python package namespace. It can be in one of two forms: 1) 'foo.bar.baz' Which is turned into the equivalent of an import statement that looks like:: from foo.bar import baz With the value of 'baz' being returned. 2) 'foo.bar:baz' (i.e. a ':' separating the module from the symbol) Which is turned into the equivalent of:: from foo import bar eval('baz', bar.__dict__) With the result of the 'eval' being returned. The second form is recommended as it allows for nested symbols to be retreived, e.g. the symbol path 'foo.bar:baz.bling' becomes:: from foo import bar eval('baz.bling', bar.__dict__) The first form is retained for backwards compatability. """ #### EOF ###################################################################### envisage-4.1.0/README.rst0000644000175100001440000000242711674464014016001 0ustar ischnellusers00000000000000========================================== envisage: extensible application framework ========================================== http://github.enthought.com/envisage Envisage is a Python-based framework for building extensible applications, that is, applications whose functionality can be extended by adding "plug-ins". Envisage provides a standard mechanism for features to be added to an application, whether by the original developer or by someone else. In fact, when you build an application using Envisage, the entire application consists primarily of plug-ins. In this respect, it is similar to the Eclipse and Netbeans frameworks for Java applications. Each plug-in is able to: - Advertise where and how it can be extended (its "extension points"). - Contribute extensions to the extension points offered by other plug-ins. - Create and share the objects that perform the real work of the application ("services"). The Envisage project provides the basic machinery of the Envisage framework. This project contains no plug-ins. You are free to use: - plug-ins from the EnvisagePlugins project - plug-ins from other ETS projects that expose their functionality as plug-ins - plug-ins that you create yourself Prerequisites ------------- * `traits `_ envisage-4.1.0/image_LICENSE_CP.txt0000644000175100001440000004671611674464014017672 0ustar ischnellusers00000000000000License The Crystal Project are released under LGPL. GNU General Public License. 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a. The modified work must itself be a software library. b. You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c. You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d. If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a. Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) . b. Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c. Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d. If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e. Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a. Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b. Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. No Warranty 15. Because the library is licensed free of charge, there is no warranty for the library, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the library "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the library is with you. Should the library prove defective, you assume the cost of all necessary servicing, repair or correction. 16. In no event unless required by applicable law or agreed to in writing will any copyright holder, or any other party who may modify and/or redistribute the library as permitted above, be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use the library (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the library to operate with any other software), even if such holder or other party has been advised of the possibility of such damages. envisage-4.1.0/setup.py0000644000175100001440000000330711674464014016022 0ustar ischnellusers00000000000000# Copyright (c) 2008-2011 by Enthought, Inc. # All rights reserved. from os.path import join from setuptools import setup, find_packages info = {} execfile(join('envisage', '__init__.py'), info) setup( name = 'envisage', version = info['__version__'], author = "Martin Chilvers, et. al.", author_email = "info@enthought.com", maintainer = 'ETS Developers', maintainer_email = 'enthought-dev@enthought.com', url = "http://code.enthought.com/projects/envisage/", download_url = ('http://www.enthought.com/repo/ets/envisage-%s.tar.gz' % info['__version__']), classifiers = [c.strip() for c in """\ Development Status :: 5 - Production/Stable Intended Audience :: Developers Intended Audience :: Science/Research License :: OSI Approved :: BSD License Operating System :: MacOS Operating System :: Microsoft :: Windows Operating System :: OS Independent Operating System :: POSIX Operating System :: Unix Programming Language :: Python Topic :: Scientific/Engineering Topic :: Software Development Topic :: Software Development :: Libraries """.splitlines() if len(c.strip()) > 0], description = 'extensible application framework', long_description = open('README.rst').read(), entry_points = """ [envisage.plugins] envisage.core = envisage.core_plugin:CorePlugin """, ext_modules = [], install_requires = info['__requires__'], license = "BSD", packages = find_packages(), package_data = {'': ['images/*', '*.ini',]}, platforms = ["Windows", "Linux", "Mac OS-X", "Unix", "Solaris"], zip_safe = False, ) envisage-4.1.0/examples/0000755000175100001440000000000011674464014016123 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/0000755000175100001440000000000011674464014021000 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/dist/0000755000175100001440000000000011674464014021743 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/dist/run.py0000644000175100001440000000452411674464014023126 0ustar ischnellusers00000000000000""" Run the application. Usually, all you have to do in here is:- 1) Initialise the logging package as you see fit (or not at all ;^)! 2) Set the 'EGG_PATH' variable to be a list of the directories that contain your application's eggs. 3) Edit the 'run' function to do whatever you need to do to start your application. """ # Standard library imports. import logging # Create a log file. logger = logging.getLogger() logger.addHandler(logging.StreamHandler(file('acme_motd.log', 'w'))) logger.setLevel(logging.DEBUG) # A list of the directories that contain the application's eggs (any directory # not specified as an absolute path is treated as being relative to the current # working directory). EGG_PATH = ['eggs'] def run(): """ The function that starts your application. """ # Enthought library imports. # # We do the imports here in case the Enthought eggs are loaded dyanmically # via the 'EGG_PATH'. from envisage.api import Application, EggPluginManager # Create a plugin manager that ignores all eggs except the ones that we # need for this example. plugin_manager = EggPluginManager( include = [ 'envisage.core', 'acme.motd', 'acme.motd.software_quotes' ] ) # Create an application that uses the egg plugin manager to find its # plugins. application = Application(id='acme.motd', plugin_manager=plugin_manager) # Run it! return application.run() ############################################################################### # Usually, there is no need to edit anything below here! ############################################################################### # Standard library imports. from pkg_resources import Environment, working_set # Logging. logger = logging.getLogger(__name__) def main(): """ Run the application. """ # Find all additional eggs. environment = Environment(EGG_PATH) distributions, errors = working_set.find_plugins(environment) if len(errors) > 0: raise SystemError('cannot add eggs %s' % errors) logger.debug('added eggs %s' % distributions) # Add them to the working set. map(working_set.add, distributions) # Create and run the application. return run() if __name__ == '__main__': main() #### EOF ###################################################################### envisage-4.1.0/examples/MOTD_Using_Eggs/README.txt0000644000175100001440000000145711674464014022505 0ustar ischnellusers00000000000000Welcome to the "Message of the Day" (MOTD) example. This directory contains two subdirectories:: dist Which contains the actual runnable application as it might actually be distributed/deployed. src Which contains the source code for the eggs that make up the application. This directory is there to allow easy access to the example code, but would obviously not normally be deployed. To build the eggs required by the application:: (where, '...' refers to the directory that *this* file is in):: ``cd .../src/acme.motd`` ``python setup.py bdist_egg -d ../../dist/eggs`` ``cd .../src/acme.motd.software_quotes`` ``python setup.py bdist_egg -d ../../dist/eggs`` To run the application:: ``cd .../dist`` ``python run.py`` or equivalent, depending on your operating system and shell. envisage-4.1.0/examples/MOTD_Using_Eggs/src/0000755000175100001440000000000011674464014021567 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/0000755000175100001440000000000011674464014023436 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/0000755000175100001440000000000011674464014024343 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/motd/0000755000175100001440000000000011674464014025306 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/motd/i_motd.py0000644000175100001440000000063111674464014027133 0ustar ischnellusers00000000000000""" The 'Message of the Day' interface. """ # Enthought library imports. from traits.api import Interface class IMOTD(Interface): """ The 'Message of the Day' interface. """ def motd(self): """ Return the message of the day. Returns an object that implements the 'IMessage' interface. """ #### EOF ###################################################################### envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/motd/motd_plugin.py0000644000175100001440000000700311674464014030201 0ustar ischnellusers00000000000000""" The 'Message of the Day' plugin """ # In the interest of lazy loading you should only import from the following # packages at the module level of a plugin:: # # - envisage # - traits # # Eveything else should be imported when it is actually required. # Enthought library imports. from envisage.api import ExtensionPoint, Plugin, ServiceOffer from traits.api import Instance, List, on_trait_change class MOTDPlugin(Plugin): """ The 'Message of the Day' plugin. When this plugin is started it prints the 'Message of the Day' to stdout. """ # The Ids of the extension points that this plugin offers. MESSAGES = 'acme.motd.messages' # The Ids of the extension points that this plugin contributes to. SERVICE_OFFERS = 'envisage.service_offers' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.motd' # The plugin's name (suitable for displaying to the user). name = 'MOTD' #### Extension points offered by this plugin ############################## # The messages extension point. # # Notice that we use the string name of the 'IMessage' interface rather # than actually importing it. This makes sure that the import only happens # when somebody actually gets the contributions to the extension point. messages = ExtensionPoint( List(Instance('acme.motd.api.IMessage')), id=MESSAGES, desc=""" This extension point allows you to contribute messages to the 'Message Of The Day'. """ ) #### Contributions to extension points made by this plugin ################ service_offers = List(contributes_to=SERVICE_OFFERS) def _service_offers_default(self): """ Trait initializer. """ # When you register a service offer it is best to specify the protocol # a string name (rather than importing the protocol right now). This # allows the protocol to be lazily loaded. Also, don't specify the # protocol as coming from an 'api.py' file as this is not the actual # module name known to Python. motd_service_offer = ServiceOffer( protocol = 'acme.motd.i_motd.IMOTD', factory = self._create_motd_service ) return [motd_service_offer] ########################################################################### # Private interface. ########################################################################### def _create_motd_service(self): """ Factory method for the 'MOTD' service. """ # Only do imports when you need to! This makes sure that the import # only happens when somebody needs an 'IMOTD' service. from motd import MOTD return MOTD(messages=self.messages) # This plugin does all of its work in this method which gets called when # the application has started all of its plugins. @on_trait_change('application:started') def _print_motd(self): """ Print the 'Message of the Day' to stdout! """ # Note that we always offer the service via its name, but look it up # via the actual protocol. from acme.motd.api import IMOTD # Lookup the MOTD service. motd = self.application.get_service(IMOTD) # Get the message of the day... message = motd.motd() # ... and print it. print '\n"%s"\n\n- %s' % (message.text, message.author) return #### EOF ###################################################################### envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/motd/api.py0000644000175100001440000000015311674464014026430 0ustar ischnellusers00000000000000from i_message import IMessage from i_motd import IMOTD from message import Message from motd import MOTD envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/motd/i_message.py0000644000175100001440000000061311674464014027614 0ustar ischnellusers00000000000000""" The interface for 'Message of the Day' messages. """ # Enthought library imports. from traits.api import Interface, Str class IMessage(Interface): """ The interface for 'Message of the Day' messages. """ # The author of the message. author = Str # The text of the message. text = Str #### EOF ###################################################################### envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/motd/motd.py0000644000175100001440000000214111674464014026621 0ustar ischnellusers00000000000000""" The 'Message of the Day' implementation! """ # Standard library imports. from random import choice # Enthought library imports. from traits.api import HasTraits, List, implements # Local imports. from i_message import IMessage from i_motd import IMOTD from message import Message class MOTD(HasTraits): """ The 'Message of the Day' implementation! """ implements(IMOTD) # The default message is used when there are no other messages! DEFAULT_MESSAGE = Message( author='Anon', text='Work hard and be good to your Mother' ) # The list of possible messages. messages = List(IMessage) ########################################################################### # 'IMOTD' interface. ########################################################################### def motd(self): """ Prints a random message. """ if len(self.messages) > 0: message = choice(self.messages) else: message = self.DEFAULT_MESSAGE return message #### EOF ###################################################################### envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/motd/__init__.py0000644000175100001440000000034311674464014027417 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/motd/message.py0000644000175100001440000000075711674464014027315 0ustar ischnellusers00000000000000""" The default implementation of the 'IMessage' interface. """ # Enthought library imports. from traits.api import HasTraits, Str, implements # Local imports. from i_message import IMessage class Message(HasTraits): """ The default implementation of the 'IMessage' interface. """ implements(IMessage) # The author of the message. author = Str # The text of the message. text = Str #### EOF ###################################################################### envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/acme/__init__.py0000644000175100001440000000034311674464014026454 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd/setup.py0000644000175100001440000000120211674464014025143 0ustar ischnellusers00000000000000# Major package imports. from setuptools import setup, find_packages setup( name = 'acme.motd', version = '0.1a1', author = 'Enthought, Inc', author_email = 'info@enthought.com', license = 'BSD', zip_safe = True, packages = find_packages(), include_package_data = True, namespace_packages = [ 'acme', 'acme.motd' ], install_requires = [ 'EnvisageCore>=3.0.0a1', ], entry_points = """ [envisage.plugins] acme.motd = acme.motd.motd_plugin:MOTDPlugin """ ) envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/0000755000175100001440000000000011674464014026667 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/0000755000175100001440000000000011674464014027574 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/motd/0000755000175100001440000000000011674464014030537 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/motd/software_quotes/0000755000175100001440000000000011674464014033771 5ustar ischnellusers00000000000000././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/motd/software_quotes/messages.pyenvisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/motd/software_quotes/mess0000644000175100001440000000410411674464014034662 0ustar ischnellusers00000000000000""" Some messages! """ from acme.motd.api import Message messages = [ Message( author = "Bertrand Meyer", text = "You can have quality software, or you can have pointer" " arithmetic; but you cannot have both at the same time." ), Message( author = "Edsger W. Dijkstra", text = "The effective programmer is keenly aware of the limited size" " of his own head." ), Message( author = "Richard Buckminster-Fuller", text = "When I'm working on a problem, I never think about beauty. I" " think only how to solve the problem. But when I have finished, if" " the solution is not beautiful, I know it is wrong." ), Message( author = "Tom Gilb", text = "If you don't know what you're doing, don't do it on a large" " scale." ), Message( author = "Arthur Norman", text = "The best way to implement hard code is never to know you're" " implementing it." ), Message( author = "Albert Einstein", text = "Any intelligent fool can make things bigger, more complex," " and more violent. It takes a touch of genius - and a lot of courage" " - to move in the opposite direction." ), Message( author = "Martin Fowler", text = "Any fool can write code that a computer can understand. Good" " programmers write code that humans can understand." ), Message( author = "Chet Hendrickson", text = "The rule is, 'Do the simplest thing that could possibly" " work', not the most stupid." ), Message( author = "Ron Jeffries", text = "If you're working sixty hour weeks, you're too tired to be" " doing good software." ), Message( author = "Edward Tufte", text = "Clutter and confusion are failures of design, not attributes" " of information. There's no such thing as information overload." ) ] #### EOF ###################################################################### ././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/motd/software_quotes/__init__.pyenvisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/motd/software_quotes/__in0000644000175100001440000000034311674464014034620 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ ././@LongLink0000000000000000000000000000017200000000000011215 Lustar 00000000000000envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/motd/software_quotes/software_quotes_plugin.pyenvisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/motd/software_quotes/soft0000644000175100001440000000174111674464014034672 0ustar ischnellusers00000000000000""" The 'Software Quotes' plugin """ # Enthought library imports. from envisage.api import Plugin from traits.api import List class SoftwareQuotesPlugin(Plugin): """ The 'Software Quotes' plugin. """ #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.motd.software_quotes' # The plugin's name (suitable for displaying to the user). name = 'Software Quotes' #### Extension points offered by this plugin ############################## # None #### Contributions to extension points made by this plugin ################ # Messages for the 'Message Of The Day'. messages = List(contributes_to='acme.motd.messages') def _messages_default(self): """ Trait initializer. """ # Only do imports when you need to! from messages import messages return messages #### EOF ###################################################################### envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/motd/__init__.py0000644000175100001440000000034311674464014032650 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/acme/__init__.py0000644000175100001440000000034311674464014031705 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/MOTD_Using_Eggs/src/acme.motd.software_quotes/setup.py0000644000175100001440000000134211674464014030401 0ustar ischnellusers00000000000000# Major package imports. from setuptools import setup, find_packages setup( name = 'acme.motd.software_quotes', version = '0.1a1', author = 'Enthought, Inc', author_email = 'info@enthought.com', license = 'BSD', zip_safe = True, packages = find_packages(), include_package_data = True, namespace_packages = [ 'acme', 'acme.motd', 'acme.motd.software_quotes' ], install_requires = [ 'acme.motd', ], entry_points = """ [envisage.plugins] acme.motd.software_quotes = acme.motd.software_quotes.software_quotes_plugin:SoftwareQuotesPlugin """ ) envisage-4.1.0/examples/MOTD/0000755000175100001440000000000011674464014016666 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD/acme/0000755000175100001440000000000011674464014017573 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD/acme/motd/0000755000175100001440000000000011674464014020536 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD/acme/motd/i_motd.py0000644000175100001440000000063111674464014022363 0ustar ischnellusers00000000000000""" The 'Message of the Day' interface. """ # Enthought library imports. from traits.api import Interface class IMOTD(Interface): """ The 'Message of the Day' interface. """ def motd(self): """ Return the message of the day. Returns an object that implements the 'IMessage' interface. """ #### EOF ###################################################################### envisage-4.1.0/examples/MOTD/acme/motd/motd_plugin.py0000644000175100001440000000706211674464014023436 0ustar ischnellusers00000000000000""" The 'Message of the Day' plugin """ # In the interest of lazy loading you should only import from the following # packages at the module level of a plugin:: # # - envisage # - traits # # Eveything else should be imported when it is actually required. # Enthought library imports. from envisage.api import ExtensionPoint, Plugin, ServiceOffer from traits.api import Instance, List, on_trait_change class MOTDPlugin(Plugin): """ The 'Message of the Day' plugin. This plugin simply prints the 'Message of the Day' to stdout. """ # The Ids of the extension points that this plugin offers. MESSAGES = 'acme.motd.messages' # The Ids of the extension points that this plugin contributes to. SERVICE_OFFERS = 'envisage.service_offers' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.motd' # The plugin's name (suitable for displaying to the user). name = 'MOTD' #### Extension points offered by this plugin ############################## # The messages extension point. # # Notice that we use the string name of the 'IMessage' interface rather # than actually importing it. This makes sure that the import only happens # when somebody actually gets the contributions to the extension point. messages = ExtensionPoint( List(Instance('acme.motd.api.IMessage')), id=MESSAGES, desc=""" This extension point allows you to contribute messages to the 'Message Of The Day'. """ ) #### Contributions to extension points made by this plugin ################ service_offers = List(contributes_to=SERVICE_OFFERS) def _service_offers_default(self): """ Trait initializer. """ # Register the protocol as a string containing the actual module path # and *not* a module path that goes via an 'api.py' file as this does # not match what Python thinks the module is! This allows the service # to be looked up by passing either the exact same string, or the # actual protocol object itself (the latter is the preferred way of # doing it!). motd_service_offer = ServiceOffer( protocol = 'acme.motd.i_motd.IMOTD', factory = self._create_motd_service ) return [motd_service_offer] ########################################################################### # Private interface. ########################################################################### def _create_motd_service(self): """ Factory method for the 'MOTD' service. """ # Only do imports when you need to! This makes sure that the import # only happens when somebody needs an 'IMOTD' service. from motd import MOTD return MOTD(messages=self.messages) # This plugin does all of its work in this method which gets called when # the application has started all of its plugins. @on_trait_change('application:started') def _print_motd(self): """ Print the 'Message of the Day' to stdout! """ # Note that we always offer the service via its name, but look it up # via the actual protocol. from acme.motd.api import IMOTD # Lookup the MOTD service. motd = self.application.get_service(IMOTD) # Get the message of the day... message = motd.motd() # ... and print it. print '\n"%s"\n\n- %s' % (message.text, message.author) return #### EOF ###################################################################### envisage-4.1.0/examples/MOTD/acme/motd/api.py0000644000175100001440000000015311674464014021660 0ustar ischnellusers00000000000000from i_message import IMessage from i_motd import IMOTD from message import Message from motd import MOTD envisage-4.1.0/examples/MOTD/acme/motd/i_message.py0000644000175100001440000000061311674464014023044 0ustar ischnellusers00000000000000""" The interface for 'Message of the Day' messages. """ # Enthought library imports. from traits.api import Interface, Str class IMessage(Interface): """ The interface for 'Message of the Day' messages. """ # The author of the message. author = Str # The text of the message. text = Str #### EOF ###################################################################### envisage-4.1.0/examples/MOTD/acme/motd/motd.py0000644000175100001440000000214111674464014022051 0ustar ischnellusers00000000000000""" The 'Message of the Day' implementation! """ # Standard library imports. from random import choice # Enthought library imports. from traits.api import HasTraits, List, implements # Local imports. from i_message import IMessage from i_motd import IMOTD from message import Message class MOTD(HasTraits): """ The 'Message of the Day' implementation! """ implements(IMOTD) # The default message is used when there are no other messages! DEFAULT_MESSAGE = Message( author='Anon', text='Work hard and be good to your Mother' ) # The list of possible messages. messages = List(IMessage) ########################################################################### # 'IMOTD' interface. ########################################################################### def motd(self): """ Prints a random message. """ if len(self.messages) > 0: message = choice(self.messages) else: message = self.DEFAULT_MESSAGE return message #### EOF ###################################################################### envisage-4.1.0/examples/MOTD/acme/motd/software_quotes/0000755000175100001440000000000011674464014023770 5ustar ischnellusers00000000000000envisage-4.1.0/examples/MOTD/acme/motd/software_quotes/messages.py0000644000175100001440000000410411674464014026150 0ustar ischnellusers00000000000000""" Some messages! """ from acme.motd.api import Message messages = [ Message( author = "Bertrand Meyer", text = "You can have quality software, or you can have pointer" " arithmetic; but you cannot have both at the same time." ), Message( author = "Edsger W. Dijkstra", text = "The effective programmer is keenly aware of the limited size" " of his own head." ), Message( author = "Richard Buckminster-Fuller", text = "When I'm working on a problem, I never think about beauty. I" " think only how to solve the problem. But when I have finished, if" " the solution is not beautiful, I know it is wrong." ), Message( author = "Tom Gilb", text = "If you don't know what you're doing, don't do it on a large" " scale." ), Message( author = "Arthur Norman", text = "The best way to implement hard code is never to know you're" " implementing it." ), Message( author = "Albert Einstein", text = "Any intelligent fool can make things bigger, more complex," " and more violent. It takes a touch of genius - and a lot of courage" " - to move in the opposite direction." ), Message( author = "Martin Fowler", text = "Any fool can write code that a computer can understand. Good" " programmers write code that humans can understand." ), Message( author = "Chet Hendrickson", text = "The rule is, 'Do the simplest thing that could possibly" " work', not the most stupid." ), Message( author = "Ron Jeffries", text = "If you're working sixty hour weeks, you're too tired to be" " doing good software." ), Message( author = "Edward Tufte", text = "Clutter and confusion are failures of design, not attributes" " of information. There's no such thing as information overload." ) ] #### EOF ###################################################################### envisage-4.1.0/examples/MOTD/acme/motd/software_quotes/__init__.py0000644000175100001440000000034311674464014026101 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/MOTD/acme/motd/software_quotes/software_quotes_plugin.py0000644000175100001440000000174111674464014031155 0ustar ischnellusers00000000000000""" The 'Software Quotes' plugin """ # Enthought library imports. from envisage.api import Plugin from traits.api import List class SoftwareQuotesPlugin(Plugin): """ The 'Software Quotes' plugin. """ #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.motd.software_quotes' # The plugin's name (suitable for displaying to the user). name = 'Software Quotes' #### Extension points offered by this plugin ############################## # None #### Contributions to extension points made by this plugin ################ # Messages for the 'Message Of The Day'. messages = List(contributes_to='acme.motd.messages') def _messages_default(self): """ Trait initializer. """ # Only do imports when you need to! from messages import messages return messages #### EOF ###################################################################### envisage-4.1.0/examples/MOTD/acme/motd/__init__.py0000644000175100001440000000034311674464014022647 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/MOTD/acme/motd/message.py0000644000175100001440000000075711674464014022545 0ustar ischnellusers00000000000000""" The default implementation of the 'IMessage' interface. """ # Enthought library imports. from traits.api import HasTraits, Str, implements # Local imports. from i_message import IMessage class Message(HasTraits): """ The default implementation of the 'IMessage' interface. """ implements(IMessage) # The author of the message. author = Str # The text of the message. text = Str #### EOF ###################################################################### envisage-4.1.0/examples/MOTD/acme/__init__.py0000644000175100001440000000034311674464014021704 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/MOTD/run.py0000644000175100001440000000174611674464014020054 0ustar ischnellusers00000000000000""" Run the MOTD example application. """ # Standard library imports. import logging # Enthought library imports. from envisage.api import Application # Enthought plugins. from envisage.core_plugin import CorePlugin # Example plugins. from acme.motd.motd_plugin import MOTDPlugin from acme.motd.software_quotes.software_quotes_plugin import ( SoftwareQuotesPlugin ) # Do whatever you want to do with log messages! Here we create a log file. logger = logging.getLogger() logger.addHandler(logging.StreamHandler(file('acme_motd.log', 'w'))) logger.setLevel(logging.DEBUG) def main(): """ Run the application. """ # Create an application containing the appropriate plugins. application = Application( id = 'acme.motd', plugins = [CorePlugin(), MOTDPlugin(), SoftwareQuotesPlugin()] ) # Run it! return application.run() if __name__ == '__main__': main() #### EOF ###################################################################### envisage-4.1.0/examples/MOTD/README.txt0000644000175100001440000000024411674464014020364 0ustar ischnellusers00000000000000Welcome to the "Message of the Day" (MOTD) example. To run the application:: ``python run.py`` or equivalent, depending on your operating system and shell. envisage-4.1.0/examples/plugins/0000755000175100001440000000000011674464014017604 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/0000755000175100001440000000000011674464014022613 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/0000755000175100001440000000000011674464014025622 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/data/0000755000175100001440000000000011674464014026533 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/data/data.py0000644000175100001440000001553111674464014030023 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- # Enthought library imports. from chaco.chaco_plot_editor import ChacoPlotItem from blockcanvas.numerical_modeling.numeric_context.api import NumericContext from traits.api import adapts, Array, Enum, Float, HasTraits, \ Instance, Range, Property from traitsui.api import Group, Item, RangeEditor, ITreeNode, \ ITreeNodeAdapter, View from numpy import arange class DataView(HasTraits): volume = Array pressure = Property(Array, depends_on=['temperature','attraction','totVolume']) attraction = Range(low=-50.0,high=50.0,value=0.0) totVolume = Range(low=.01,high=100.0,value=0.01) temperature = Range(low=-50.0,high=50.0,value=50.0) r_constant= Float(8.314472) plot_type = Enum("line", "scatter") data_view = View(ChacoPlotItem("volume", "pressure", type_trait="plot_type", resizable=True, x_label="Volume", y_label="Pressure", x_bounds=(-10,120), x_auto=False, y_bounds=(-2000,4000), y_auto=False, color="blue", bgcolor="white", border_visible=True, border_width=1, title='Pressure vs. Volume', padding_bg_color="lightgray"), Item(name='attraction'), Item(name='totVolume'), Item(name='temperature'), Item(name='r_constant',style='readonly'), Item(name='plot_type'), resizable = True, buttons = ["OK"], title='Van der waal Equation', width=900, height=500) def _volume_default(self): return arange(.1, 100) # Pressure is calculated whenever one of the elements the property depends on changes. def _get_pressure(self): return ((self.r_constant*self.temperature)/(self.volume - self.totVolume)) - (self.attraction/(self.volume*self.volume)) class Data(NumericContext): name = Property(depends_on = ['context_name']) # data_parameters = Property data_parameters = Instance(DataView) ################################################################################### # Object Methods ################################################################################### """ Contains all of the data for a data """ def __init__(self, name="Unknown", **traits): super( Data, self ).__init__( **traits ) self.context_name = name self.data_parameters = DataView() # self.data_parameters = DataView() # self['data_parameters'] = DataParameters(self) # TODO cgalvan: Init other data def __getstate__(self): """ Return the state of this object for pickling. Extended to remove transient traits, and also store version information. """ # Obtain state from base class(es) state = super(Data, self).__getstate__() # Add in our current version number. Note use a different attribute # name from any base or derived class so that our numbers don't # override theirs. state['_data_version'] = 1 return state def __setstate__(self, state): """ Restore the state of this object during unpickling. Extended to handle version upgrades. """ # Get the version info out of the state dictionary. version = state.pop('_data_version', 0) # Upgrade to version 1. if version < 1: # Include dynamic bindings to all the numeric contexts in the # dictionary items_dict = {} if state.has_key('context_data'): context_data = state['context_data'] if isinstance(context_data, dict) and len(context_data) > 0: items_dict = context_data._dict if len(items_dict) > 0: self._add_all_items_as_dynamic_bindings_to_state(state, items_dict) # Restore the base class's state. super(Data, self).__setstate__(state) return ############################################################################ # Protected Methods ############################################################################ # def _get_data_parameters(self): # return self['data_parameters'] def _get_data_parameters(self): return self.data_parameters def _get_name(self): return self.context_name def _set_name(self, new_name): self.context_name = new_name return class DataAdapter(ITreeNodeAdapter): """ ITreeNodeAdapter for our custom Data object. """ adapts(Data, ITreeNode) #-- ITreeNodeAdapter Method Overrides -------------------------------------- def allows_children(self): """ Returns whether this object can have children. """ return False def get_label(self): """ Gets the label to display for a specified object. """ return self.adaptee.name def confirm_delete(self): """ Checks whether a specified object can be deleted. Returns ------- * **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). """ return None def when_label_changed(self, listener, remove): """ Sets up or removes a listener for the label being changed on a specified object. """ self.adaptee.on_trait_change(listener, 'list_items', remove=remove, dispatch='ui') def get_tooltip(self): """ Gets the tooltip to display for a specified object. """ return "Data" def get_icon(self, is_expanded): """ Returns the icon for a specified object. """ return '' def can_auto_close(self): """ Returns whether the object's children should be automatically closed. """ return True def can_rename_me(self): """ Returns whether the object can be renamed. """ return True def can_delete_me(self): """ Returns whether the object can be deleted. """ return True envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/0000755000175100001440000000000011674464014030031 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/services.py0000644000175100001440000000077411674464014032236 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ The identifiers for the services in this plugin. """ # The model service identifier IDATA_MODEL = 'data.plugin.IModelService' # The UI service identifier. IDATA_UI = 'data.plugin.IUiService' #### EOF ##################################################################### envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/data_action_set.py0000644000175100001440000000227511674464014033532 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ An action set for contributing actions to Data. """ # Enthought library imports. from envisage.action.action_plugin_definition import ActionSet ############################################################################## # Constants ############################################################################## # A commonly used string within our declarations. ROOT = 'data.plugin.resource_type' # The prefix used to identify menu-building resources, within an action set, # for the context menu applying to a Data. This string MUST MATCH the string # that the Data's node type is looking for! DATA_CONTEXT_MENU = '%s.data_node_type' % ROOT class DataActionSet(ActionSet): """ Action and menu definitions for the project view. """ # A mapping from human-readable root names to globally unique Ids. aliases = { 'DataContextMenu': DATA_CONTEXT_MENU } #### EOF ##################################################################### envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/ui_service.py0000644000175100001440000000734411674464014032550 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ The UI service for the Data plugin. """ # Standard library imports. import logging # Enthought library imports. from envisage.api import ApplicationObject, UOL from pyface.api import confirm, error, FileDialog, information, YES # Data library imports. # Local imports. from services import IDATA_MODEL # Setup a logger for this module logger = logging.getLogger(__name__) class UiService(ApplicationObject): """ The UI service for the Data plugin. """ ########################################################################## # Attributes ########################################################################## #### public 'UiService' interface ######################################## # A reference to the Data plugin's model service. model_service = UOL ########################################################################## # 'Object' interface ########################################################################## #### operator methods #################################################### def __init__(self, **kws): """ Constructor. Extended to ensure our UOL properties are set. """ super(UiService, self).__init__(**kws) # Ensure we have a default model-service if one wasn't specified. if self.model_service is None: self.model_service = 'service://%s' % IDATA_MODEL return ########################################################################## # 'UIService' interface ########################################################################## #### public methods ###################################################### #TODO cgalvan: to be implemented # def delete_data(self, context, data_name, parent_window): # """ # Delete a Data. # # """ # # # Open confirmation-dialog to confirm deletion # message = 'Are you sure you want to delete %s?' % data_name # if confirm(parent_window, message) == YES: # self.model_service.delete_context_item(context, data_name) # # return def edit_data(self, window, data): """ Edit the data parameters of the specified data. """ data_parameters = data.data_parameters edit_ui = data_parameters.edit_traits(view='data_view', kind = 'livemodal', # handler=handler, parent=window) return edit_ui.result def display_message(self, msg, title=None, is_error=False): """ Display the specified message to the user. """ # Ensure we record any reasons this method doesn't work. Especially # since it's critical in displaying errors to users! try: # Attempt to identify the current application window. parent_window = None workbench = self.application.get_service('envisage.' 'workbench.IWorkbench') if workbench is not None: parent_window = workbench.active_window.control # Display the requested message if is_error: error(parent_window, msg, title=title) else: information(parent_window, msg, title=title) except: logger.exception('Unable to display pop-up message') return #### EOF ##################################################################### envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/model_service.py0000644000175100001440000000350311674464014033224 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ The model service for the Data plugin. """ # Standard library imports. import logging import numpy # Enthought library imports. from envisage.api import ApplicationObject from apptools.naming.unique_name import make_unique_name from blockcanvas.numerical_modeling.numeric_context.api import NumericContext from blockcanvas.numerical_modeling.units.unit_array import UnitArray from scimath.units.api import convert,unit_manager from scimath.units.mass import gram from scimath.units.volume import cc from scimath.units.length import meter from scimath.units.geo_units import ppg, psi from pyface.wx.clipboard import clipboard # Data library imports. # Setup a logger for this module logger = logging.getLogger(__name__) class ModelService(ApplicationObject): """ The model service for the Dataplugin. """ ########################################################################## # 'ModelService' interface ########################################################################## #### public methods ###################################################### def delete_context_item(self, context, item_name): """ Deleting an item from a numeric context Parameters: ----------- context: NumericContext item_name: Str """ if isinstance(context, NumericContext) and context.has_key(item_name): context.pop(item_name) else: logger.error('Invalid context or data not found in context') return #### EOF ##################################################################### envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/action/0000755000175100001440000000000011674464014031306 5ustar ischnellusers00000000000000././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/action/rename_data_action.pyenvisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/action/rename_data_action.0000644000175100001440000000207011674464014035103 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ An action to rename a data. """ # Standard imports. import logging # Local imports from data_plugin_action import DataPluginAction # Create a logger for this module. logger = logging.getLogger(__name__) class RenameDataAction(DataPluginAction): """ An action to rename a data. """ ########################################################################### # 'Action' interface. ########################################################################### #### public interface ##################################################### def perform(self, event): """ Perform this action. """ logger.debug('Performing action [%s]', self) event.tree.edit_label(event.node) return #### EOF ##################################################################### ././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/action/data_plugin_action.pyenvisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/action/data_plugin_action.0000644000175100001440000001172311674464014035137 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ A base class for actions that use the data plugin's services. """ # Standard library imports. import logging # Enthought library imports. from envisage.api import UOL from envisage.single_project.api import ProjectAction # Data library imports. from data.data import Data # Application imports. from data.plugin.services import IDATA_MODEL, IDATA_UI # Create a logger for this module. logger = logging.getLogger(__name__) class DataPluginAction(ProjectAction): """ A base class for actions that use the data plugin's services. """ ########################################################################## # Attributes ########################################################################## #### public 'DataPluginAction' interface ################################# # A reference to the data plugin's model service. data_model_service = UOL # A reference to the data plugin's UI service. data_ui_service = UOL ########################################################################## # 'object' interface ########################################################################## #### operator methods #################################################### def __init__(self, **kws): """ Constructor. Extended to ensure that our UOL's have default identification strings. """ super(DataPluginAction, self).__init__(**kws) if self.data_model_service is None: self.data_model_service = 'service://%s' % IDATA_MODEL if self.data_ui_service is None: self.data_ui_service = 'service://%s' % IDATA_UI return ########################################################################## # 'DataPluginAction' interface. ########################################################################## #### protected methods ################################################### def _get_target_data(self, event, show_error=True): """ Return the data this action should import into. If the show_error parameter is True, then an error message will be displayed to the user if a data could not be located. """ data = None # If the event has a node, then try to find the data from that node. if hasattr(event, 'node'): data = self._get_target_data_from_node(event.node) # If we don't have a data yet, then try and find it from the current # project selection. if data is None: data = self._get_target_data_from_project_selection() # If we have not identified a data, and we're supposed to show an error, # then do so now. if data is None and show_error: self._display_error('Unable to identify a Data to perform this ' 'action with. Please select a target Data within the project ' 'tree and try again.') logger.debug('Target data: %s', data) return data def _get_target_data_from_node(self, node): """ Locate the data this action should import into from the specified node. """ # If the object itself is a data, then we're done obj = node.obj if isinstance(obj, Data): return obj # Otherwise, scan upward through the tree containing the node, looking # for the closest parent that is a data. data = None context = node.context while context is not None: if hasattr(context, 'adaptee'): obj = context.adaptee if isinstance(obj, Data): data = obj break if hasattr(context, 'context'): context = context.context else: context = None return data def _get_target_data_from_project_selection(self): """ Locate the data this action should import into from project selection. """ data = None # Find the first data in the project selection. for item in self.model_service.selection: if isinstance(item, Data): data = item break elif hasattr(item, 'obj') and isinstance(item.obj, Data): data = item.obj break return data def _get_node_name(self, event, show_error=True): """ Return the name of the selection """ if hasattr(event, 'node'): if hasattr(event.node, 'name'): return event.node.name if show_error: logger.error('Could not retrieve the name of the selected data') return None #### EOF ##################################################################### envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/action/edit_data_action.py0000644000175100001440000000255311674464014035140 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ An action to edit the data parameters of a Data. """ # Standard imports. import logging # Local imports from data_plugin_action import DataPluginAction # Create a logger for this module. logger = logging.getLogger(__name__) class EditDataAction(DataPluginAction): """ An action to edit the data parameters of a data. """ ########################################################################### # 'Action' interface. ########################################################################### #### public interface ##################################################### def perform(self, event): """ Perform this action. """ logger.debug('Performing EditDataAction [%s]', self) # Pull the parent for any displayed UI from the event. window = event.window.control # If we can find a target data, then perform the operation. data = self._get_target_data(event) if data is not None: self.data_ui_service.edit_data(window, data) return #### EOF ##################################################################### envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/action/__init__.py0000644000175100001440000000000011674464014033405 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/plugin_definition.py0000644000175100001440000001130611674464014034112 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ A Data resource type plugin. """ # Enthought library imports. from envisage import PluginDefinition from envisage.action.action_plugin_definition import \ Group, Location, Menu from envisage.action.default_action import DefaultAction from envisage.core.core_plugin_definition import ApplicationObject from envisage.resource.resource_plugin_definition \ import ResourceType, ResourceManager from envisage.plugins.python_shell.python_shell_plugin_definition import \ Namespace # Local imports. from data.plugin.services import IDATA_MODEL, IDATA_UI from data.plugin.data_action_set import DataActionSet ############################################################################## # Constants ############################################################################## # This plugin's globally unique identifier. Our usage's assume this is the # python path to the package containing the plugin definition module. ID = 'data.plugin' ############################################################################## # Extensions. ############################################################################## #### Actions and ActionSets ################################################## class RenameDataAction(DefaultAction): description = 'Rename this data.' name = '&Rename' class EditDataAction(DefaultAction): description = 'Edit data properties.' name = '&Edit Data Properties' data_action_set = DataActionSet( actions = [ # # Data action group # DeleteDataAction( # locations = [ # Location( # after='RenameData', # path='DataContextMenu/ActionGroup', # ), # ], # ), RenameDataAction( locations = [ Location(path='DataContextMenu/ActionGroup'), ], ), EditDataAction( locations = [ Location(path='DataContextMenu/ActionGroup'), ], ), ], groups = [ # Data groups Group( id = 'ActionGroup', location = Location( # after='PersistenceGroup', path='DataContextMenu', ), ), ], id = '%s.data_action_set.Default' % ID, name = 'DataPlugin', ) #### Application Objects ##################################################### model_service = ApplicationObject( class_name = '%s.model_service.ModelService' % ID, uol = 'service://' + IDATA_MODEL, ) ui_service = ApplicationObject( class_name = '%s.ui_service.UiService' % ID, kw = {'model_service' : model_service.uol}, uol = 'service://' + IDATA_UI, ) #### Resource Types ########################################################## # References to other plugin's resource types FOLDER = 'envisage.resource.folder_resource_type.FolderResourceType' INSTANCE = ('envisage.resource.instance_resource_type.' 'InstanceResourceType') # References to our resource types DATA_TYPE = ID + '.resource_type.data_resource_type.DataResourceType' resource_types = ResourceManager( resource_types = [ ResourceType( class_name = DATA_TYPE, #precedes = [FOLDER, INSTANCE], ), ], ) #### Shell Namespace ######################################################### # Import template code into the shell for scripting. #namespace = Namespace( # commands = [ # 'from cp.data.api import *', # ] # ) ############################################################################## # The plugin definition. ############################################################################## class DataPlugin(PluginDefinition): # The plugin's globally unique identifier. id = ID # General information about the plugin. name = 'Data Plugin' version = '0.0.1' provider_name = 'Enthought Inc' provider_url = 'www.enthought.com' autostart = True # The Id's of the plugins that this plugin requires. requires = [ ] # The extension points offered by this plugin. extension_points = [ DataActionSet, ] # The contributions that this plugin makes to extension points offered by # either itself or other plugins. extensions = [ model_service, # namespace, resource_types, ui_service, data_action_set, ] #### EOF ##################################################################### envisage-4.1.0/examples/plugins/single_project/sample_project/data/plugin/__init__.py0000644000175100001440000000000011674464014032130 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/data/__init__.py0000644000175100001440000000000011674464014030632 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/run.py0000644000175100001440000000403111674464014026776 0ustar ischnellusers00000000000000#!/usr/bin/env python #----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ The entry point for an Envisage application. """ # Standard library imports. import logging # Enthought plugins. from envisage.core_plugin import CorePlugin from envisage.developer.developer_plugin import DeveloperPlugin from envisage.developer.ui.developer_ui_plugin import DeveloperUIPlugin from envisage.ui.workbench.workbench_plugin import WorkbenchPlugin from envisage.ui.single_project.project_plugin import ProjectPlugin from envisage.ui.workbench.api import WorkbenchApplication from envisage.plugins.python_shell.python_shell_plugin import PythonShellPlugin # Local imports. from plugins.single_project.plugin_definition import EnvProjectPlugin # FIXME: This is uncommented for now until we have the new TreeEditor # implementation in place that can understand domain-objects that have # been abstracted to an INode interface. #from data.plugin.plugin_definition import DataPlugin # Configure a logger for this application logger = logging.getLogger() logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.DEBUG) def main(): """ Runs the application. """ # Create the application. application = WorkbenchApplication( id = 'testProject_extended', plugins=[ CorePlugin(), WorkbenchPlugin(), DeveloperPlugin(), DeveloperUIPlugin(), ProjectPlugin(), EnvProjectPlugin(), PythonShellPlugin(), # FIXME: This is uncommented for now until we have the new TreeEditor # implementation in place that can understand domain-objects that have # been abstracted to an INode interface. #DataPlugin(), ] ) # Run the application. application.run() return # Application entry point. if __name__ == '__main__': main() envisage-4.1.0/examples/plugins/single_project/sample_project/plugins/0000755000175100001440000000000011674464014027303 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/plugins/single_project/0000755000175100001440000000000011674464014032312 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/plugins/single_project/env_project.py0000644000175100001440000002115011674464014035201 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ Test envisage project. """ # System library imports. import logging # Enthought library imports. from envisage.ui.single_project.api import Project from apptools.naming.unique_name import make_unique_name from blockcanvas.numerical_modeling.numeric_context.numeric_context import \ NumericContext from traits.api import adapts, property_depends_on, Property, List from traitsui.api import Group, ITreeNode, ITreeNodeAdapter, View from traitsui.menu import Action, Menu # Data import from data.data import Data # Setup a logger for this module logger = logging.getLogger(__name__) class EnvProject(Project, NumericContext): """ Envisage project. """ ########################################################################## # Attributes ########################################################################## #### public 'Project' interface ########################################## # The location of this project on the filesystem. The default value # depends on the runtime environment so we use a traits default method to # set it. # # Overridden here to a File to use the File dialog since we're saving # projects as files. # Set up the naming environment. # klass_name = "apptools.naming.InitialContextFactory" # environment = {Context.INITIAL_CONTEXT_FACTORY : klass_name} # # # Create an initial context. # context = InitialContext(environment) # The list of names bound in this context: list_names = Property(List) # The list of items bound in this context: list_items = Property(List) # The UI view to use when creating a new project traits_view = View( Group('location'), title = 'New Env Project', id = 'plugins.single_project.env_project.EnvProject', buttons = [ 'OK', 'Cancel' ], # Ensure closing via the dialog close button is the same # as clicking cancel. close_result = False, # Ensure the user can resize the dialog. resizable = True, ) ########################################################################## # 'object' interface ########################################################################## #### operator methods #################################################### def __getstate__(self): """ Return the state of this object for pickling. Extended to remove transient traits, and also store version information. """ # Obtain state from base class(es) state = super(EnvProject, self).__getstate__() # Add in our current version number. Note use a different attribute # name from any base or derived class so that our numbers don't # override theirs. state['_env_project_version'] = 1 return state def __setstate__(self, state): """ Restore the state of this object during unpickling. Extended to handle version upgrades. """ # Get the version info out of the state dictionary. version = state.pop('_env_project_version', 0) # Upgrade to version 1. if version < 1: # Include dynamic bindings to all the numeric contexts in the # dictionary items_dict = {} if state.has_key('context_data'): context_data = state['context_data'] if isinstance(context_data, dict) and len(context_data) > 0: items_dict = state['context_data']._dict if len(items_dict) > 0: self._add_all_items_as_dynamic_bindings_to_state(state, items_dict) # Restore the base class's state. super(EnvProject, self).__setstate__(state) return ########################################################################## # 'EnvProject' interface ########################################################################## #### property implementaions ############################################# @property_depends_on('dict_modified') def _get_list_names(self): """ List the names bound in this context. """ result = [k for k, v in self.items() if isinstance(v, Data)] result.sort() return result @property_depends_on('dict_modified') def _get_list_items(self): """ List the items bound in this context. """ result = self.items() result.sort(lambda l, r: cmp(l[0], r[0])) return [v for n, v in result] def create_data(self, name='Data'): """ Create a new data within this project. The new data is initialized with the specified trait values and is automatically added to this project. """ # Ensure the name we associate with the data within this project is # unique. name = make_unique_name(name, self.keys()) # Create the new data data = Data(name) # Add it to ourself. self.bind_dynamic(data, 'context_name') logger.debug('Added new data (%s) to EnvProject (%s) with ' 'name (%s)', data, self, name) return data class EnvProjectAdapter(ITreeNodeAdapter): """ EnvProjectAdapter for our custom project. """ adapts(EnvProject, ITreeNode) #-- ITreeNodeAdapter Method Overrides -------------------------------------- def allows_children(self): """ Returns whether this object can have children. """ return True def has_children(self): """ Returns whether the object has children. """ return (len(self.adaptee.list_items) > 0) def get_children(self): """ Gets the object's children. """ return self.adaptee.list_items def get_children_id(self): """ Gets the object's children identifier. """ return 'list_items' def append_child(self, child=None): """ Appends a child to the object's children. """ data = self.adaptee.create_data() def confirm_delete(self): """ Checks whether a specified object can be deleted. Returns ------- * **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). """ return False def delete_child(self, index): """ Deletes a child at a specified index from the object's children. """ # Remove the child at the specified index. child = self.adaptee.list_items[index] self.adaptee._unbind_dynamic(child, 'context_name') def when_children_replaced(self, listener, remove): """ Sets up or removes a listener for children being replaced on a specified object. """ self.adaptee.on_trait_change(listener, 'list_items', remove=remove, dispatch='ui') def get_label(self): """ Gets the label to display for a specified object. """ return self.adaptee.name def get_menu(self): """ Returns the right-click context menu for an object. """ return Menu(*[ Action(name='Create Data', action='node.adapter.append_child', )] ) def get_tooltip(self): """ Gets the tooltip to display for a specified object. """ return "Project" def get_icon(self, is_expanded): """ Returns the icon for a specified object. """ return '' def can_rename(self): """ Returns whether the object's children can be renamed. """ return True def can_copy(self): """ Returns whether the object's children can be copied. """ return True def can_delete(self): """ Returns whether the object's children can be deleted. """ return True def can_auto_open(self): """ Returns whether the object's children should be automatically opened. """ return True def can_auto_close(self): """ Returns whether the object's children should be automatically closed. """ return False ### EOF ###################################################################### ././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/plugins/single_project/env_project_factory.pyenvisage-4.1.0/examples/plugins/single_project/sample_project/plugins/single_project/env_project_fac0000644000175100001440000000470711674464014035374 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ A customization of the single project factory to make EnvProjects. """ # Standard library imports import logging # Enthought library imports. from envisage.api import IApplication from traits.api import Instance from envisage.ui.single_project.api import ProjectFactory # Application imports. from plugins.single_project.env_project import EnvProject # Setup a logger for this module. logger = logging.getLogger(__name__) class EnvProjectFactory(ProjectFactory): """ A customization of the single project factory to make EnvProjects. """ ########################################################################## # Attributes ########################################################################## #### public 'ProjectFactory' interface ################################### # The class of the project created by this factory. # # This is provided so that the single_project services can call class # methods. # # This value is meant to be constant for the lifetime of this class! PROJECT_CLASS = EnvProject # Current envisage application. application = Instance(IApplication) #### public method ####################################################### def create(self): """ Create a new project from scratch. This must return an instance of a Project or 'None'. A return value of 'None' indicates that no project could be created. The plugin will display the default traits view to the user so that they can configure this new project. """ return self.PROJECT_CLASS(application=self.application) def open(self, location): """ Open a project from the specified location. This must return an instance of a Project or 'None'. A return value of 'None' indicates that no project could be opened from the specified location. """ try: project = self.PROJECT_CLASS.load(location, self.application) except: logger.exception('Unable to load Project from location %s', location) project = None return project ### EOF ######################################################################## ././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/plugins/single_project/env_project_action_set.pyenvisage-4.1.0/examples/plugins/single_project/sample_project/plugins/single_project/env_project_act0000644000175100001440000000214611674464014035405 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ An action set for contributing actions to components of a env project. """ # Enthought library imports. from envisage.single_project.plugin_definition import \ NO_SELECTION_MENU_ID, PROJECT_MENU_ID, SingleProjectActionSet ############################################################################## # Constants ############################################################################## # A commonly used string within our declarations. ROOT = 'plugins.single_project.resource_type' class EnvProjectActionSet(SingleProjectActionSet): """ Action and menu definitions for the project view. """ # A mapping from human-readable root names to globally unique Ids. aliases = { 'NoSelectionMenu' : NO_SELECTION_MENU_ID, 'ProjectMenu' : PROJECT_MENU_ID, } #### EOF ##################################################################### ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/plugins/single_project/plugin_definition.pyenvisage-4.1.0/examples/plugins/single_project/sample_project/plugins/single_project/plugin_definiti0000644000175100001440000000301411674464014035404 0ustar ischnellusers00000000000000#----------------------------------------------------------------------------- # # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ The env application's extension of the single project plugin. """ # Standard imports import os import sys # Enthought library imports. from envisage.api import Plugin, ServiceOffer from envisage.ui.single_project.api import FactoryDefinition from traits.api import List # This module's package. PKG = '.'.join(__name__.split('.')[:-1]) # Globally unique identifier. ID = 'plugins.single_project' ############################################################################### # `EnvProjectPlugin` class. ############################################################################### class EnvProjectPlugin(Plugin): # Extension point Ids. FACTORY_DEFINITIONS = 'envisage.ui.single_project.factory_definitions' # The plugin's name. name = 'Env Project Plugin' ###### Contributions to extension points made by this plugin ###### # Factory definition we contribute to. factory_definitions = List(contributes_to=FACTORY_DEFINITIONS) # Private methods. def _factory_definitions_default(self): """ Trait initializer. """ factory_definition = FactoryDefinition( class_name = '%s.env_project_factory.EnvProjectFactory' % ID, priority = 10, ) return [factory_definition] # TODO: Add contributions project action set. envisage-4.1.0/examples/plugins/single_project/sample_project/plugins/single_project/__init__.py0000644000175100001440000000000011674464014034411 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/single_project/sample_project/plugins/__init__.py0000644000175100001440000000000011674464014031402 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/0000755000175100001440000000000011674464014021566 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/0000755000175100001440000000000011674464014023052 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/0000755000175100001440000000000011674464014023757 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/acmelab/0000755000175100001440000000000011674464014025343 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/acmelab/acmelab.py0000644000175100001440000000306511674464014027305 0ustar ischnellusers00000000000000""" The Acme Lab application. """ # Standard library imports. from logging import DEBUG # Enthought library imports. from envisage.ui.workbench.api import WorkbenchApplication from pyface.api import AboutDialog, ImageResource, SplashScreen class Acmelab(WorkbenchApplication): """ The Acme Lab application. """ #### 'IApplication' interface ############################################# # The application's globally unique Id. id = 'acme.acmelab' #### 'WorkbenchApplication' interface ##################################### # Branding information. # # The icon used on window title bars etc. icon = ImageResource('acmelab.ico') # The name of the application (also used on window title bars etc). name = 'Acme Lab' ########################################################################### # 'WorkbenchApplication' interface. ########################################################################### def _about_dialog_default(self): """ Trait initializer. """ about_dialog = AboutDialog( parent = self.workbench.active_window.control, image = ImageResource('about') ) return about_dialog def _splash_screen_default(self): """ Trait initializer. """ splash_screen = SplashScreen( image = ImageResource('splash'), show_log_messages = True, log_level = DEBUG ) return splash_screen #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/acmelab/images/0000755000175100001440000000000011674464014026610 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/acmelab/images/splash.jpg0000644000175100001440000011120711674464014030606 0ustar ischnellusers00000000000000JFIFHH1ExifII* z(2i< CanonCanon PowerShot SD630HH2008:10:02 11:07:424<0220DXl t|  X |J 0100,    8 2006:08:31 06:38:042006:08:31 06:38:04? _ ." NZt(C   h J\E"F\@C_ Dm?;IMG:PowerShot SD630 JPEGFirmware Version 1.005)) 5^ sM|Y\]Nr;rYI[''`E uwxtwyx% @0111 '*: R980100 @  ( JFIFC    $.' ",#(7),01444'9=82<.342C  2!!22222222222222222222222222222222222222222222222222" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?XeUjp)D ?S0i*{T0RbZvړm&)C1I~LQpB*Mp"".)Qp)1RIw EJE4.+HEHE!DE4B(jZiZb*2T,qd"V sE:F*TҔ(8qڸΡW2ނ[ijK#t\QRzHLbLS31Iw &)1N#4n(M""w2T"4B),BE!))V!+QU)hU)1^hqjvs\rx0w|$t$_7t汿2;ylT y`*aTq^rĖ9>xk5X]Da)QM*Am}~d2qf!\U\V.!)1KINⰘ-!pN4MiqXB)S4p)S!)S%;yEc3@ jft$g'nTRTC~ƹѧ+5KѺ"gP>bin5IܖKΌlۈ>o8 wVq]D$TGLk+@%/B&@3Io=Veº-Oe:ari m?~t豚LA=S\??:P}꟝!z/LDf7E|_΁\ijOM2@\&j/5?:O0zb%&=EqK`XrNqVXH܌J9.A=H! $' A!?C\A,HI*ZͱH}U[2N隦]3҄KlduxJv=k7r{Տ:Gn3UK78}nVNιa BԒ] ?ZQGLXz\OB6uK2=93թ#7k?ޣ8.IO`D hTw$ |V94!ZW>>r>_žiES+zO1MX]: o!<)N|lyi^rO,?#` EO9|4I>) OEwM'9qҋ/'bqIj6'=8sSߝ\=? (6RŊc̒-':5[[ʥ?ZCm)-޸Σ8Kvyk0'*VU.<87} P!bNx7siЊ$?ZD#*,7˜zoг[_?;G?-DH: Zw`%$ǖބƅ^\–upPK9l/o!<Σ'<׆r\[r|O»a*c;z- ؾЙ*F$R@]+MXV0p5.!"P~U.(-XbpH2R6>e-y58ӄp0b3³m0"7?${w)R}:FLEo(`E۰3퉀(hkh'TpZV o3s7i\BdsjnRv.J)}h DR?M.Ĥ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ͪ&~ƿ𘂏 i:#gDو8[ ?1Am3 i;u:buZu1`Orlb،V͡1}UHYQ"M:`7m / '%ĦGuʪjA3KCzkZZ pyZpI (˴$iDU"zJ5-JyQ_D S1:mk, t)"Aħ([(j ֚b'f|V!XGMmKjtTC"^L7!'k IJ}zxW *#ᜦfw 8xt[cA@E3%cN&w= nU(q Mz(i(oY+q1ǬF`ہ5AXez DH V5JhAvma&¢Dzhɛ:V ~atDP;938N8u2LOztx--bvSSNu6g&n>aa =V +DBvE(\SEGCHi{ҁMύuE_ d - jq& #>֨ڠ*#bwd=AZ\a']`="o.ĸKKsf]o]況ʴ{Q^h5IZ͋\'}uX Bu$int vo$S yeB,.} 3B_8go$tA`CG:9qZ lq5^ZAc\V&_wom# Aj&GIF?¨*oy_jcWI9`9RaBs8iyGL#šE 7jmnL|}8V'P69*GJ8%ES S1RZ޳]V.?{dX'%H _VJ_KQ"'nOkr" i)}߁AYps8&gIZWu#xjW/O֣k֫漃ʈa4!M'N?&+T&F(%K^oOփl,%-7b=_XJ$<{aM+Z Hȧ|oQiig1y|XoR -.̖1)yY'% ~X7(U$$NJ튊֩\p΄5Mf=8b9^ E 㟤mCxΆuw7TED:X %y&߈uZWSm e06c.⧯NALoß~aݽWT|HM'į o0y9WJ0?(&_fxYg۝|^$Ϸh.$/\`MA< '?)gmB8{sq4}B~~理/-n{눏9*"6kpz|DiqcA3fʨ:s4elXPH\!s?|'<>ceI (g,^S$amE_}ǽcÂKHpfǿ~Ne$!{'Bc x{?~Ia{;'O\IvIENDB`envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/acmelab/images/acmelab.ico0000644000175100001440000004624611674464014030704 0ustar ischnellusers00000000000000hV V00%&(  U,O)1I%@C"s: t;P|?z>s:?s:e6b3mE3xU5tT%cDS,NJLKAt ~Cs: o=yH"Y3nYTGv>Dz>҇;΃6~l_ Z W)j'Y"[NJ~HyDs+]9o^ٚ[֗WѓR̎BÁd W4rQRZÏdÓc`Y$Yf۠e؞bԚ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ɓ`ʔdʗҩҬЩͧ˥~ɣ|ƠxÞvroczCs:!Xlՠxݪtۦmءl֠i՞gӜdљbϗ_͕\˒YɐVǍWǍpΞuΠo˜2es:s:s:BN M LYQŠ`ʔaȔyϣ԰ҮЫͩ˧Ȥ}ơzÞviR| x@s: DONJxܩxڨj֟[ѕWΒcљdЙaΖ[˒\ʓ^ʔpϟtϡ\ÎMs:s:s:cN- M LN9v_ɔ`ȓ^ő^ÑfĔwɠΩzǡoj[][*[r:s:s:+cmҟw٧wاwצnԡkҝnӟsӢuңtѢrΟuFzK~Fx r= p< o;pm:s:4s:s:s:s:s:s:t;s:s:s:s:s:s:s:W M L J I H G F E ~D |C zA x@ v? t> r=s:s:ls:s:s:s:s:s:s:s:s:- K JA I H G F E }D |B zA9 x@s: s:??envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/acmelab/images/image_LICENSE.txt0000644000175100001440000000053311674464014031576 0ustar ischnellusers00000000000000 filename source --------------------------------------------------- about.png Wikipedia: This image is in the public domain because it contains materials that originally came from the United States Central Intelligence Agency's World Factbook. acmelab.ico Gael Varoquaux splash.jpg Bryce Hendrix envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/acmelab/api.py0000644000175100001440000000003411674464014026463 0ustar ischnellusers00000000000000from acmelab import Acmelab envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/acmelab/__init__.py0000644000175100001440000000034311674464014027454 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/0000755000175100001440000000000011674464014025741 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/test_action_set.py0000644000175100001440000000503011674464014031500 0ustar ischnellusers00000000000000""" A test action set. """ # Enthought library imports. from envisage.ui.action.api import Action, Group, Menu, ToolBar from envisage.ui.workbench.api import WorkbenchActionSet class TestActionSet(WorkbenchActionSet): """ An action test useful for testing. """ #### 'ActionSet' interface ################################################ # The action set's globally unique identifier. id = 'envisage.ui.workbench.test' menus = [ Menu( name='&Test', path='MenuBar', before='Help', groups=['XGroup', 'YGroup'] ), Menu( name='Foo', path='MenuBar/Test', groups=['XGroup', 'YGroup'] ), Menu( name='Bar', path='MenuBar/Test', groups=['XGroup', 'YGroup'] ), ] groups = [ Group(id='Fred', path='MenuBar/Test') ] tool_bars = [ ToolBar(name='Fred', groups=['AToolBarGroup']), ToolBar(name='Wilma'), ToolBar(name='Barney') ] actions = [ Action( path='MenuBar/Test', group='Fred', class_name='envisage.ui.workbench.action.api:AboutAction' ), Action( path='MenuBar/Test', group='Fred', class_name='acme.workbench.action.new_view_action:NewViewAction' ), Action( path='ToolBar', class_name='envisage.ui.workbench.action.api:AboutAction' ), Action( path='ToolBar', class_name='envisage.ui.workbench.action.api:ExitAction' ), Action( path='ToolBar/Fred', group='AToolBarGroup', class_name='envisage.ui.workbench.action.api:AboutAction' ), Action( path='ToolBar/Wilma', class_name='envisage.ui.workbench.action.api:AboutAction' ), Action( path='ToolBar/Barney', class_name='envisage.ui.workbench.action.api:ExitAction' ) ] #### 'WorkbenchActionSet' interface ####################################### # The Ids of the perspectives that the action set is enabled in. enabled_for_perspectives = ['Foo'] # The Ids of the perspectives that the action set is visible in. visible_for_perspectives = ['Foo', 'Bar'] # The Ids of the views that the action set is enabled for. #enabled_for_views = ['Red'] # The Ids of the views that the action set is visible for. #visible_for_views = ['Red'] #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/acme_workbench_plugin.py0000644000175100001440000000406211674464014032642 0ustar ischnellusers00000000000000""" The AcmeLab Workbench plugin. """ # Enthought library imports. from envisage.api import Plugin from traits.api import List class AcmeWorkbenchPlugin(Plugin): """ The AcmeLab Workbench plugin. This plugin is part of the 'AcmeLab' example application. """ # Extension points Ids. ACTION_SETS = 'envisage.ui.workbench.action_sets' PERSPECTIVES = 'envisage.ui.workbench.perspectives' PREFERENCES_PAGES = 'envisage.ui.workbench.preferences_pages' VIEWS = 'envisage.ui.workbench.views' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.workbench' # The plugin's name (suitable for displaying to the user). name = 'Acme Workbench' #### Contributions to extension points made by this plugin ################ # Action sets. action_sets = List(contributes_to=ACTION_SETS) def _action_sets_default(self): """ Trait initializer. """ from test_action_set import TestActionSet return [TestActionSet] # Perspectives. perspectives = List(contributes_to=PERSPECTIVES) def _perspectives_default(self): """ Trait initializer. """ from acme.workbench.perspective.api import FooPerspective from acme.workbench.perspective.api import BarPerspective return [FooPerspective, BarPerspective] # Preferences pages. preferences_pages = List(contributes_to=PREFERENCES_PAGES) def _preferences_pages_default(self): """ Trait initializer. """ from acme_preferences_page import AcmePreferencesPage return [AcmePreferencesPage] # Views. views = List(contributes_to=VIEWS) def _views_default(self): """ Trait initializer. """ from acme.workbench.view.api import BlackView, BlueView, GreenView from acme.workbench.view.api import RedView, YellowView return [BlackView, BlueView, GreenView, RedView, YellowView] #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/acme_preferences_page.py0000644000175100001440000000262511674464014032602 0ustar ischnellusers00000000000000""" The preferences for the Acme workbench. """ # Enthought library imports. from apptools.preferences.ui.api import PreferencesPage from traits.api import Bool, Color, Int, Float, Font, Str from traitsui.api import View class AcmePreferencesPage(PreferencesPage): """ The preferences page for the Acme workbench. """ #### 'PreferencesPage' interface ########################################## # The page's category (e.g. 'General/Appearance'). The empty string means # that this is a top-level page. category = 'General' # The page's help identifier (optional). If a help Id *is* provided then # there will be a 'Help' button shown on the preference page. help_id = '' # The page name (this is what is shown in the preferences dialog. name = 'Acme' # The path to the preference node that contains the preferences. preferences_path = 'acme.workbench' #### Preferences ########################################################## # Width. width = Int(100) # Height. height = Int(200) # Ratio. ratio = Float(0.1) # Background color. bgcolor = Color('red') # Text font. font = Font('helvetica') #### Traits UI views ###################################################### trait_view = View('width', 'height', 'ratio', 'font', 'bgcolor') #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/action/0000755000175100001440000000000011674464014027216 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/action/new_view.py0000644000175100001440000000213311674464014031412 0ustar ischnellusers00000000000000""" An action that dynamically creates and adds a view. """ # Enthought library imports. from pyface.action.api import Action class NewViewAction(Action): """ An action that dynamically creates and adds a view. """ #### 'Action' interface ################################################### # A longer description of the action. description = 'Create and add a new view' # The action's name (displayed on menus/tool bar tools etc). name = 'New View' # A short description of the action used for tooltip text etc. tooltip = 'Create and add a new view' ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): """ Perform the action. """ # Create your view... view = View(id='my.view.fred', name='Fred', position='right') # ... add it to the window! self.window.add_view(view) return #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/action/new_view_action.py0000644000175100001440000000252211674464014032751 0ustar ischnellusers00000000000000""" An action that dynamically creates and adds a view. """ # Enthought library imports. from pyface.api import ImageResource from pyface.action.api import Action from pyface.workbench.api import View class NewViewAction(Action): """ An action that dynamically creates and adds a view. """ #### 'Action' interface ################################################### # A longer description of the action. description = 'Create and add a new view' # The action's name (displayed on menus/tool bar tools etc). name = 'New View' # A short description of the action used for tooltip text etc. tooltip = 'Create and add a new view' ########################################################################### # 'Action' interface. ########################################################################### def perform(self, event): """ Perform the action. """ # You can give the view a position... (it default to 'left')... view = View(id='my.view.fred', name='Fred', position='right') self.window.add_view(view) # or you can specify it on the call to 'add_view'... view = View(id='my.view.wilma', name='Wilma') self.window.add_view(view, position='top') return #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/action/__init__.py0000644000175100001440000000000011674464014031315 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/__init__.py0000644000175100001440000000034311674464014030052 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/perspective/0000755000175100001440000000000011674464014030272 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/perspective/api.py0000644000175100001440000000012611674464014031414 0ustar ischnellusers00000000000000from bar_perspective import BarPerspective from foo_perspective import FooPerspective envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/perspective/bar_perspective.py0000644000175100001440000000112011674464014034013 0ustar ischnellusers00000000000000""" An example perspective. """ # Enthought library imports. from pyface.workbench.api import Perspective, PerspectiveItem class BarPerspective(Perspective): """ An example perspective. """ # The perspective's name. name = 'Bar' # Should the editor area be shown in this perspective? show_editor_area = False # The contents of the perspective. contents = [ PerspectiveItem(id='Green'), PerspectiveItem(id='Black', position='bottom', relative_to='Green') ] #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/perspective/foo_perspective.py0000644000175100001440000000122211674464014034035 0ustar ischnellusers00000000000000""" An example perspective. """ # Enthought library imports. from pyface.workbench.api import Perspective, PerspectiveItem class FooPerspective(Perspective): """ An example perspective. """ # The perspective's name. name = 'Foo' # Should the editor area be shown in this perspective? show_editor_area = True # The contents of the perspective. contents = [ PerspectiveItem(id='Blue', position='left'), PerspectiveItem(id='Red', position='with', relative_to='Blue'), PerspectiveItem(id='Green', position='top') ] #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/perspective/__init__.py0000644000175100001440000000000011674464014032371 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/view/0000755000175100001440000000000011674464014026713 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/view/green_view.py0000644000175100001440000000076611674464014031430 0ustar ischnellusers00000000000000""" A view containing a green panel! """ # Local imports. from color_view import ColorView class GreenView(ColorView): """ A view containing a green panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Green' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/view/api.py0000644000175100001440000000024111674464014030033 0ustar ischnellusers00000000000000from black_view import BlackView from blue_view import BlueView from green_view import GreenView from red_view import RedView from yellow_view import YellowView envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/view/color_view.py0000644000175100001440000000475111674464014031444 0ustar ischnellusers00000000000000""" A view containing a colored panel! """ # Enthought library imports. from traits.etsconfig.api import ETSConfig from pyface.workbench.api import View class ColorView(View): """ A view containing a colored panel! This view is written so that it works with *both* wx and Qt4. Your own views obviously do not have to do this! """ #### 'IView' interface #################################################### # The category that the view belongs to. category = 'Color' ########################################################################### # 'IWorkbenchPart' interface. ########################################################################### #### Trait initializers ################################################### def _id_default(self): """ Trait initializer. """ # By making the Id the same as the name, we make it easy to specify # the views in the example perspectives. Note for larger applications # the Id should be globally unique, and by default we use the module # name and class name. return self.name #### Methods ############################################################## def create_control(self, parent): """ Creates the toolkit-specific control that represents the view. 'parent' is the toolkit-specific control that is the view's parent. """ method = getattr(self, '_%s_create_control' % ETSConfig.toolkit, None) if method is None: raise SystemError('Unknown toolkit %s', ETSConfig.toolkit) color = self.name.lower() return method(parent, color) ########################################################################### # Private interface. ########################################################################### def _wx_create_control(self, parent, color): """ Create a wx version of the control. """ import wx panel = wx.Panel(parent, -1) panel.SetBackgroundColour(color) return panel def _qt4_create_control(self, parent, color): """ Create a Qt4 version of the control. """ from PyQt4 import QtGui widget = QtGui.QWidget(parent) palette = widget.palette() palette.setColor(QtGui.QPalette.Window, QtGui.QColor(color)) widget.setPalette(palette) widget.setAutoFillBackground(True) return widget #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/view/red_view.py0000644000175100001440000000075611674464014031101 0ustar ischnellusers00000000000000""" A view containing a red panel! """ # Local imports. from color_view import ColorView class RedView(ColorView): """ A view containing a red panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Red' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/view/yellow_view.py0000644000175100001440000000077211674464014031640 0ustar ischnellusers00000000000000""" A view containing a yellow panel! """ # Local imports. from color_view import ColorView class YellowView(ColorView): """ A view containing a yellow panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Yellow' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/view/black_view.py0000644000175100001440000000076611674464014031404 0ustar ischnellusers00000000000000""" A view containing a black panel! """ # Local imports. from color_view import ColorView class BlackView(ColorView): """ A view containing a black panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Black' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/view/__init__.py0000644000175100001440000000000011674464014031012 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/workbench/view/blue_view.py0000644000175100001440000000076211674464014031253 0ustar ischnellusers00000000000000""" A view containing a blue panel! """ # Local imports. from color_view import ColorView class BlueView(ColorView): """ A view containing a blue panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Blue' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLab/acme/__init__.py0000644000175100001440000000034311674464014026070 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/plugins/workbench/AcmeLab/run.py0000644000175100001440000000250211674464014024227 0ustar ischnellusers00000000000000""" Run the AcmeLab example application. """ # Standard library imports. import logging # Example imports. from acme.acmelab.api import Acmelab # Enthought plugins. from envisage.core_plugin import CorePlugin from envisage.developer.developer_plugin import DeveloperPlugin from envisage.developer.ui.developer_ui_plugin import DeveloperUIPlugin from envisage.ui.workbench.workbench_plugin import WorkbenchPlugin # Example plugins. from acme.workbench.acme_workbench_plugin import AcmeWorkbenchPlugin # Do whatever you want to do with log messages! Here we create a log file. logger = logging.getLogger() #logger.addHandler(logging.StreamHandler(file('acmelab.log', 'w'))) logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.DEBUG) def main(): """ Run the application. """ # Create an application with the specified plugins. acmelab = Acmelab( plugins=[ CorePlugin(), WorkbenchPlugin(), AcmeWorkbenchPlugin(), DeveloperPlugin(), DeveloperUIPlugin() ] ) # Run it! This starts the application, starts the GUI event loop, and when # that terminates, stops the application. acmelab.run() return if __name__ == '__main__': main() #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/0000755000175100001440000000000011674464014024666 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/dist/0000755000175100001440000000000011674464014025631 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/dist/run.py0000644000175100001440000000434611674464014027016 0ustar ischnellusers00000000000000""" Run the application. Usually, all you have to do in here is:- 1) Initialise the logging package as you see fit (or not at all ;^)! 2) Set the 'EGG_PATH' variable to be a list of the directories that contain your application's eggs. 3) Edit the 'run' function to do whatever you need to do to start your application. """ # Standard library imports. import logging # Create a log file. logger = logging.getLogger() logger.addHandler(logging.StreamHandler(file('acmelab.log', 'w'))) logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.DEBUG) # A list of the directories that contain the application's eggs (any directory # not specified as an absolute path is treated as being relative to the current # working directory). EGG_PATH = ['eggs'] def run(): """ The function that starts your application. """ # We do the imports here because the modules may well be in eggs that get # added to the path in 'main'. from envisage.api import EggPluginManager from acme.acmelab.api import Acmelab # Create an application that uses the egg plugin manager to find its # plugins. acmelab = Acmelab(plugin_manager=EggPluginManager()) # Run it! This starts the application, starts the GUI event loop, and when # that terminates, stops the application. return acmelab.run() ############################################################################### # Usually, there is no need to edit anything below here! ############################################################################### # Standard library imports. import logging from pkg_resources import Environment, working_set # Logging. logger = logging.getLogger(__name__) def main(): """ Run the application. """ # Find all additional eggs. environment = Environment(EGG_PATH) distributions, errors = working_set.find_plugins(environment) if len(errors) > 0: raise SystemError('cannot add eggs %s' % errors) logger.debug('added eggs %s' % distributions) # Add them to the working set. map(working_set.add, distributions) # Create and run the application. return run() if __name__ == '__main__': main() #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/README.txt0000644000175100001440000000074011674464014026365 0ustar ischnellusers00000000000000To build the AcmeLab example:- cd .../src/acme.acmelab python setup.py sdist --dist-dir ../../dist/eggs cd .../src/acme.workbench python setup.py bdist_egg --dist-dir ../../dist/eggs cd ../../dist/eggs unzip the acmelab zip file add a '.egg' extension to each unzipped folder Surely there must be a better way to do this? I'm not an egg expert! To run the example:- cd .../envisage.ui.workbench_3.0/examples/AcmeLab/dist python run.py envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/0000755000175100001440000000000011674464014025455 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/0000755000175100001440000000000011674464014027745 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/0000755000175100001440000000000011674464014030652 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/0000755000175100001440000000000011674464014032236 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/acmelab.py0000644000175100001440000000306511674464014034200 0ustar ischnellusers00000000000000""" The Acme Lab application. """ # Standard library imports. from logging import DEBUG # Enthought library imports. from envisage.ui.workbench.api import WorkbenchApplication from pyface.api import AboutDialog, ImageResource, SplashScreen class Acmelab(WorkbenchApplication): """ The Acme Lab application. """ #### 'IApplication' interface ############################################# # The application's globally unique Id. id = 'acme.acmelab' #### 'WorkbenchApplication' interface ##################################### # Branding information. # # The icon used on window title bars etc. icon = ImageResource('acmelab.ico') # The name of the application (also used on window title bars etc). name = 'Acme Lab' ########################################################################### # 'WorkbenchApplication' interface. ########################################################################### def _about_dialog_default(self): """ Trait initializer. """ about_dialog = AboutDialog( parent = self.workbench.active_window.control, image = ImageResource('about') ) return about_dialog def _splash_screen_default(self): """ Trait initializer. """ splash_screen = SplashScreen( image = ImageResource('splash'), show_log_messages = True, log_level = DEBUG ) return splash_screen #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images/0000755000175100001440000000000011674464014033503 5ustar ischnellusers00000000000000././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images/splash.jpgenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images/spla0000644000175100001440000011120711674464014034367 0ustar ischnellusers00000000000000JFIFHH1ExifII* z(2i< CanonCanon PowerShot SD630HH2008:10:02 11:07:424<0220DXl t|  X |J 0100,    8 2006:08:31 06:38:042006:08:31 06:38:04? _ ." NZt(C   h J\E"F\@C_ Dm?;IMG:PowerShot SD630 JPEGFirmware Version 1.005)) 5^ sM|Y\]Nr;rYI[''`E uwxtwyx% @0111 '*: R980100 @  ( JFIFC    $.' ",#(7),01444'9=82<.342C  2!!22222222222222222222222222222222222222222222222222" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?XeUjp)D ?S0i*{T0RbZvړm&)C1I~LQpB*Mp"".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w-eF#ycj+ǽ1u($AMSJ{7OL1Z6M1JHI愵gM{?cVR][b6}2ݖhe#8qUte4avqi|yx"/86&n.oY9]|&PX2.&{V+Q! X:XQm J[frѢvGMWS <)`NbʣmjəR4Wӣ(Vl/=zE4##IFځ+WČ%}s]훲6.-).aE'8W$^lIvM͸Oo%R%1HG0o·m۴(L7 , ͗ p00r6\I F?i-혵H$dBAOA_Jmtȵ.LՇ6=j.lH*EZK-Bۑq? 1_g_gnjzVA[ﭴ[kx>drNIxd%~Zֵ7WKlݼF gШӥv -_ʨq@3p,rqjMæwPҢI3Y m,.WٮGoEwii1V HcĈ{"Y&p|@ MANsz75ln]fvcE6n1!f dҀ+\O " X&B̋>:#OCԔNUf|({&No:{+)Cq+R[}~ȒV;HGvsD,a\EiBI././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images/about.pngenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images/abou0000644000175100001440000002717011674464014034363 0ustar ischnellusers00000000000000PNG  IHDR,,SF0PLTEn:}~|CCClb;._ pHYs  tIME IDATx}{׹ 2&PjiuHp{bpALC2nrwʼn:B,qQ"3CQZ+6&R&EQ@]'q+$HsμΙɕ܁ ;|Lu;zӹvvwwwv}_7ݝ7v_'F$曺_߻KZ`?N^m껻gv/]ze$X:{wQ zg]BW;XXk?]z1vdXww_xi~vi v/|^$T(!Xv]5䔲{ ATE[[|^~~=LZK'h4%n)LAd% U]6|팳 )VUG"rH D]$?]yaA2RnZBOOi 1,2g<-X^8j1UBJlɍA؀7c8kS|~a\D7|6LC˻ o:̚C97e9\pbw HNmkEWO5-Vj°ڢF1ubHs'ú3xEIC~HZi\we9 8a o-McOڠ4ahGv8P߹ذ޻jhZWȬK4,yˬ:Iڬ׏ kd ,iXV&xz^aq[Xz??f_xzde;RjPIodXn JyK ||Lm*~M0w/<d[/x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fw 8xt[cA@E3%cN&w= nU(q Mz(i(oY+q1ǬF`ہ5AXez DH V5JhAvma&¢Dzhɛ:V ~atDP;938N8u2LOztx--bvSSNu6g&n>aa =V +DBvE(\SEGCHi{ҁMύuE_ d - jq& #>֨ڠ*#bwd=AZ\a']`="o.ĸKKsf]o]況ʴ{Q^h5IZ͋\'}uX Bu$int vo$S yeB,.} 3B_8go$tA`CG:9qZ lq5^ZAc\V&_wom# Aj&GIF?¨*oy_jcWI9`9RaBs8iyGL#šE 7jmnL|}8V'P69*GJ8%ES S1RZ޳]V.?{dX'%H _VJ_KQ"'nOkr" i)}߁AYps8&gIZWu#xjW/O֣k֫漃ʈa4!M'N?&+T&F(%K^oOփl,%-7b=_XJ$<{aM+Z Hȧ|oQiig1y|XoR -.̖1)yY'% ~X7(U$$NJ튊֩\p΄5Mf=8b9^ E 㟤mCxΆuw7TED:X %y&߈uZWSm e06c.⧯NALoß~aݽWT|HM'į o0y9WJ0?(&_fxYg۝|^$Ϸh.$/\`MA< '?)gmB8{sq4}B~~理/-n{눏9*"6kpz|DiqcA3fʨ:s4elXPH\!s?|'<>ceI (g,^S$amE_}ǽcÂKHpfǿ~Ne$!{'Bc x{?~Ia{;'O\IvIENDB`././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images/acmelab.icoenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images/acme0000644000175100001440000004624611674464014034347 0ustar ischnellusers00000000000000hV V00%&(  U,O)1I%@C"s: t;P|?z>s:?s:e6b3mE3xU5tT%cDS,NJLKAt ~Cs: o=yH"Y3nYTGv>Dz>҇;΃6~l_ Z W)j'Y"[NJ~HyDs+]9o^ٚ[֗WѓR̎BÁd W4rQRZÏdÓc`Y$Yf۠e؞bԚ[ϔUɎMÇ1rNz? OO:sr͟}̤yƟs?mNlڢk֠dљ]˓TŋS.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:gv=gЛqܥl٢kנg՝dҚ`ϖ]̔XɐTƌPÈYōq̞0ct:s: MSScʖ~ѧӮϫ̧ȣ{ğvqLFZĎuۧjנk֠hӜdЙ`͖[ʒVǍi˙oɚ/as:s:LO MM p< s:s:as:t;s:t;s:s:|s:C K I6 Gl F ~DV |B!s:(0` $s:s:js:s:s:s:s:s:ws:1V-T,cS+Q*O(M'K&I%G$E#\C"s:s:ls:s:s:s:s:s:s:s:s:s:s:s:s:\07Z/X.V-T,R+P)O(M'K&I%G$E#C"A ,s:Rs:s:s:v<']=rI}UL?s/c {Cs:s:s:s:vs:b3`2^1\0[0iB6|YDdMkRoLhC}_1nOW6G$E#D"e3s:s:FNrգwاwצvץvեuԤuӣuңsϡXPs:s:s:s:e5-c4a3_2$vMTuZzZyZxVtQoVsXsXrXqNg[:f3s:t:,ioעwۨpףN͍3z&ph!l-sC‚f̘tСrϟq<n:k8h7e5b3_2\0`1s:s:NĈx߫UՔlgfedca` _ ^ ] [ Z Y X9xs̞ax>s:s: r= p<tAT~[ U }B zA w? t=q<n:k8h6e5b3_1n8s:(eyiۢligfedca` _ ^ ] [ Z Y X WMs˞>ss:s:s: u? s> r==m]7h F D |B y@ w? s=p;m:j8g6d5g5s: {Alڢy+{jigfedca` _ ^ ] [ Z Y X W[jȘqɜPs:s: w@ u? S]RK G E D |B y@ v? s=p;m:j8g6o8s:G~yO֑kjigfedca` _ ^ ] [ Z Y X W U-msʝ]t;s:s: {B yA w@R^ [ J I G E D |B y@ v> s=p;m9j8s:u r<o;n9s:#XyUٖlkjigfedca` _ ^ ] [ Z Y X W UT3qrɝ=ms:s: ~D |C4g^-h O M L J H F E ~C {A x@ u> r<q:s:Bxy7҃lkjigfedca` _ ^ ] [ Z Y X W UT[rɝYs:s: E ~DGy^Y Q O M K J H F E ~C {A x@ u>s;s:Ny&xmp!s rnkfdca` _ ^ ] [ Z Y X W UTSkƘes:s: F EP]WWXYVSPK F D }C zA w?s;s:ZŏyMבM֐MԐMӏLҎKЌJϋF̈7~(td` _ ^ ] [ Z Y X W UTSaÑoĘs:s: G FYZ1m0l0j/i.f.e,c+a']TH }B zAt;s:\ȒzSؕRדPՒPԑPӐOюMύLΌJ̊IʉFȆ/vc ^ ] [ Z Y X W UTS_qŚt;s: H GXY:u9t9r9q7n7m5j4i3f1d/b$XGv=s:RyRؔUוT֔TԓRӒRґQЏPώN͍LˋJʉJȇDŃ%n ^ [ Z Y X W UTShŖis:s: I HP_Ðr=pl%Vs:/ey_ۜ\ٚ[ؙ[֘Z՗YԕWҔVВUϑS͏Q̍OʋMȉKƇHąD*o\ X W UT(irɝGws:s: K J2j`ȓOTTSRQPON}L{KyHvFt=ks: xAxުq`ڜ_ٛ_ך^֙]՗[ӖZѕWГVΑT͏RˍOɋNljKćH„F@}$j X UTHrɝ'Xs:s:^ L9 KT`ɔ\Ɛ]Đ]Ž[[[YXVUSR~O{My{Es:ZŎye۟cٝb؜`כ`֚^Ԙ]җ[ѕYϓW͑UˏRɍPNjNʼnKÆHƒFD:ydapɛkÖ v>s:s: M L JN`ɔ_ǓdǕdŔdÒdba`^\ZXU.]s:Pvvߩfڟfٟd؝c֛b՚aә^ї\ЕZΓX̑UʏSȍQƋMćKÅGFB~A|iȘsʝ-bs:s: M KY_˔aȔlʚnʛmȚlŘk×jifdba_W x@s:>|ynܤhڠh٠fםd֜cԛaҙ_З\ϔ[͓XˑUɎSnjPʼnMÇJGDYs˞Ut:s:s:8 N L K9v`ʕdʖv΢v͡u˟tȝsƜqĚo˜nkifd8fs:z@dԛx߫jڢkڡjؠg֞f՝dӛbљ_Ж]Δ[̒XʐTȍRƋOĈL†ILr˞nɚIs:s: M{ LMSċ`ʔl̛ѧ~Ϧ|ͥ{ˣyɠxǟvĝsšqnkfLs:Rvܩyݪmڣn٢kנi֞gԝeқbј_ϖ]͔ZʑWȏTƌQĉM‡^ǒr͟s̞3fs:s:s:N M L \^ɓ`ʔdʗҩҬЩͧ˥~ɣ|ƠxÞvroczCs:!Xlՠxݪtۦmءl֠i՞gӜdљbϗ_͕\˒YɐVǍWǍpΞuΠo˜2es:s:s:BN M LYQŠ`ʔaȔyϣ԰ҮЫͩ˧Ȥ}ơzÞviR| x@s: DONJxܩxڨj֟[ѕWΒcљdЙaΖ[˒\ʓ^ʔpϟtϡ\ÎMs:s:s:cN- M LN9v_ɔ`ȓ^ő^ÑfĔwɠΩzǡoj[][*[r:s:s:+cmҟw٧wاwצnԡkҝnӟsӢuңtѢrΟuFzK~Fx r= p< o;pm:s:4s:s:s:s:s:s:t;s:s:s:s:s:s:s:W M L J I H G F E ~D |C zA x@ v? t> r=s:s:ls:s:s:s:s:s:s:s:s:- K JA I H G F E }D |B zA9 x@s: s:??././@LongLink0000000000000000000000000000016200000000000011214 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images/image_LICENSE.txtenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images/imag0000644000175100001440000000053311674464014034344 0ustar ischnellusers00000000000000 filename source --------------------------------------------------- about.png Wikipedia: This image is in the public domain because it contains materials that originally came from the United States Central Intelligence Agency's World Factbook. acmelab.ico Gael Varoquaux splash.jpg Bryce Hendrix envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/api.py0000644000175100001440000000003411674464014033356 0ustar ischnellusers00000000000000from acmelab import Acmelab envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/__init__.py0000644000175100001440000000034311674464014034347 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/__init__.py0000644000175100001440000000034311674464014032763 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.acmelab/setup.py0000644000175100001440000000073111674464014031460 0ustar ischnellusers00000000000000# Major package imports. from setuptools import setup, find_packages setup( name = 'acme.acmelab', version = '0.1a1', author = 'Enthought, Inc', author_email = 'info@enthought.com', license = 'BSD', zip_safe = False, packages = find_packages(), include_package_data = True, namespace_packages = [ 'acme', 'acme.acmelab' ], ) envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/0000755000175100001440000000000011674464014030343 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/0000755000175100001440000000000011674464014031250 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/0000755000175100001440000000000011674464014033232 5ustar ischnellusers00000000000000././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/test_action_set.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/test_ac0000644000175100001440000000456111674464014034605 0ustar ischnellusers00000000000000""" A test action set. """ # Enthought library imports. from envisage.ui.action.api import Action, Group, Menu, ToolBar from envisage.ui.workbench.api import WorkbenchActionSet class TestActionSet(WorkbenchActionSet): """ An action test useful for testing. """ #### 'ActionSet' interface ################################################ # The action set's globally unique identifier. id = 'envisage.ui.workbench.test' menus = [ Menu( name='&Test', path='MenuBar', groups=['XGroup', 'YGroup'] ), Menu( name='Foo', path='MenuBar/Test', groups=['XGroup', 'YGroup'] ), Menu( name='Bar', path='MenuBar/Test', groups=['XGroup', 'YGroup'] ), ] groups = [ Group(id='Fred', path='MenuBar/Test') ] tool_bars = [ ToolBar(name='Fred', groups=['AToolBarGroup']), ToolBar(name='Wilma'), ToolBar(name='Barney') ] actions = [ Action( path='MenuBar/Test', group='Fred', class_name='envisage.ui.workbench.action.api:AboutAction' ), Action( path='ToolBar', class_name='envisage.ui.workbench.action.api:AboutAction' ), Action( path='ToolBar', class_name='envisage.ui.workbench.action.api:ExitAction' ), Action( path='ToolBar/Fred', group='AToolBarGroup', class_name='envisage.ui.workbench.action.api:AboutAction' ), Action( path='ToolBar/Wilma', class_name='envisage.ui.workbench.action.api:AboutAction' ), Action( path='ToolBar/Barney', class_name='envisage.ui.workbench.action.api:ExitAction' ) ] #### 'WorkbenchActionSet' interface ####################################### # The Ids of the perspectives that the action set is enabled in. enabled_for_perspectives = ['Foo'] # The Ids of the perspectives that the action set is visible in. visible_for_perspectives = ['Foo', 'Bar'] # The Ids of the views that the action set is enabled for. #enabled_for_views = ['Red'] # The Ids of the views that the action set is visible for. #visible_for_views = ['Red'] #### EOF ###################################################################### ././@LongLink0000000000000000000000000000016600000000000011220 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/acme_workbench_plugin.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/acme_wo0000644000175100001440000000406211674464014034571 0ustar ischnellusers00000000000000""" The AcmeLab Workbench plugin. """ # Enthought library imports. from envisage.api import Plugin from traits.api import List class AcmeWorkbenchPlugin(Plugin): """ The AcmeLab Workbench plugin. This plugin is part of the 'AcmeLab' example application. """ # Extension points Ids. ACTION_SETS = 'envisage.ui.workbench.action_sets' PERSPECTIVES = 'envisage.ui.workbench.perspectives' PREFERENCES_PAGES = 'envisage.ui.workbench.preferences_pages' VIEWS = 'envisage.ui.workbench.views' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.workbench' # The plugin's name (suitable for displaying to the user). name = 'Acme Workbench' #### Contributions to extension points made by this plugin ################ # Action sets. action_sets = List(contributes_to=ACTION_SETS) def _action_sets_default(self): """ Trait initializer. """ from test_action_set import TestActionSet return [TestActionSet] # Perspectives. perspectives = List(contributes_to=PERSPECTIVES) def _perspectives_default(self): """ Trait initializer. """ from acme.workbench.perspective.api import FooPerspective from acme.workbench.perspective.api import BarPerspective return [FooPerspective, BarPerspective] # Preferences pages. preferences_pages = List(contributes_to=PREFERENCES_PAGES) def _preferences_pages_default(self): """ Trait initializer. """ from acme_preferences_page import AcmePreferencesPage return [AcmePreferencesPage] # Views. views = List(contributes_to=VIEWS) def _views_default(self): """ Trait initializer. """ from acme.workbench.view.api import BlackView, BlueView, GreenView from acme.workbench.view.api import RedView, YellowView return [BlackView, BlueView, GreenView, RedView, YellowView] #### EOF ###################################################################### ././@LongLink0000000000000000000000000000016600000000000011220 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/acme_preferences_page.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/acme_pr0000644000175100001440000000262511674464014034570 0ustar ischnellusers00000000000000""" The preferences for the Acme workbench. """ # Enthought library imports. from apptools.preferences.ui.api import PreferencesPage from traits.api import Bool, Color, Int, Float, Font, Str from traitsui.api import View class AcmePreferencesPage(PreferencesPage): """ The preferences page for the Acme workbench. """ #### 'PreferencesPage' interface ########################################## # The page's category (e.g. 'General/Appearance'). The empty string means # that this is a top-level page. category = 'General' # The page's help identifier (optional). If a help Id *is* provided then # there will be a 'Help' button shown on the preference page. help_id = '' # The page name (this is what is shown in the preferences dialog. name = 'Acme' # The path to the preference node that contains the preferences. preferences_path = 'acme.workbench' #### Preferences ########################################################## # Width. width = Int(100) # Height. height = Int(200) # Ratio. ratio = Float(0.1) # Background color. bgcolor = Color('red') # Text font. font = Font('helvetica') #### Traits UI views ###################################################### trait_view = View('width', 'height', 'ratio', 'font', 'bgcolor') #### EOF ###################################################################### ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/__init__.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/__init_0000644000175100001440000000034311674464014034555 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspective/envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspec0000755000175100001440000000000011674464014034614 5ustar ischnellusers00000000000000././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspective/api.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspec0000644000175100001440000000012611674464014034615 0ustar ischnellusers00000000000000from bar_perspective import BarPerspective from foo_perspective import FooPerspective ././@LongLink0000000000000000000000000000017400000000000011217 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspective/bar_perspective.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspec0000644000175100001440000000112011674464014034610 0ustar ischnellusers00000000000000""" An example perspective. """ # Enthought library imports. from pyface.workbench.api import Perspective, PerspectiveItem class BarPerspective(Perspective): """ An example perspective. """ # The perspective's name. name = 'Bar' # Should the editor area be shown in this perspective? show_editor_area = False # The contents of the perspective. contents = [ PerspectiveItem(id='Green'), PerspectiveItem(id='Black', position='bottom', relative_to='Green') ] #### EOF ###################################################################### ././@LongLink0000000000000000000000000000017400000000000011217 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspective/foo_perspective.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspec0000644000175100001440000000122211674464014034613 0ustar ischnellusers00000000000000""" An example perspective. """ # Enthought library imports. from pyface.workbench.api import Perspective, PerspectiveItem class FooPerspective(Perspective): """ An example perspective. """ # The perspective's name. name = 'Foo' # Should the editor area be shown in this perspective? show_editor_area = True # The contents of the perspective. contents = [ PerspectiveItem(id='Blue', position='left'), PerspectiveItem(id='Red', position='with', relative_to='Blue'), PerspectiveItem(id='Green', position='top') ] #### EOF ###################################################################### ././@LongLink0000000000000000000000000000016500000000000011217 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspective/__init__.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/perspec0000644000175100001440000000000011674464014034604 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/0000755000175100001440000000000011674464014034204 5ustar ischnellusers00000000000000././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/green_view.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/gr0000644000175100001440000000076611674464014034550 0ustar ischnellusers00000000000000""" A view containing a green panel! """ # Local imports. from color_view import ColorView class GreenView(ColorView): """ A view containing a green panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Green' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/api.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/ap0000644000175100001440000000024111674464014034524 0ustar ischnellusers00000000000000from black_view import BlackView from blue_view import BlueView from green_view import GreenView from red_view import RedView from yellow_view import YellowView ././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/color_view.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/co0000644000175100001440000000475111674464014034537 0ustar ischnellusers00000000000000""" A view containing a colored panel! """ # Enthought library imports. from traits.etsconfig.api import ETSConfig from pyface.workbench.api import View class ColorView(View): """ A view containing a colored panel! This view is written so that it works with *both* wx and Qt4. Your own views obviously do not have to do this! """ #### 'IView' interface #################################################### # The category that the view belongs to. category = 'Color' ########################################################################### # 'IWorkbenchPart' interface. ########################################################################### #### Trait initializers ################################################### def _id_default(self): """ Trait initializer. """ # By making the Id the same as the name, we make it easy to specify # the views in the example perspectives. Note for larger applications # the Id should be globally unique, and by default we use the module # name and class name. return self.name #### Methods ############################################################## def create_control(self, parent): """ Creates the toolkit-specific control that represents the view. 'parent' is the toolkit-specific control that is the view's parent. """ method = getattr(self, '_%s_create_control' % ETSConfig.toolkit, None) if method is None: raise SystemError('Unknown toolkit %s', ETSConfig.toolkit) color = self.name.lower() return method(parent, color) ########################################################################### # Private interface. ########################################################################### def _wx_create_control(self, parent, color): """ Create a wx version of the control. """ import wx panel = wx.Panel(parent, -1) panel.SetBackgroundColour(color) return panel def _qt4_create_control(self, parent, color): """ Create a Qt4 version of the control. """ from PyQt4 import QtGui widget = QtGui.QWidget(parent) palette = widget.palette() palette.setColor(QtGui.QPalette.Window, QtGui.QColor(color)) widget.setPalette(palette) widget.setAutoFillBackground(True) return widget #### EOF ###################################################################### ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/red_view.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/re0000644000175100001440000000075611674464014034545 0ustar ischnellusers00000000000000""" A view containing a red panel! """ # Local imports. from color_view import ColorView class RedView(ColorView): """ A view containing a red panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Red' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### ././@LongLink0000000000000000000000000000016100000000000011213 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/yellow_view.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/ye0000644000175100001440000000077211674464014034552 0ustar ischnellusers00000000000000""" A view containing a yellow panel! """ # Local imports. from color_view import ColorView class YellowView(ColorView): """ A view containing a yellow panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Yellow' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### ././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/black_view.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/bl0000644000175100001440000000076611674464014034535 0ustar ischnellusers00000000000000""" A view containing a black panel! """ # Local imports. from color_view import ColorView class BlackView(ColorView): """ A view containing a black panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Black' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/__init__.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/__0000644000175100001440000000000011674464014034472 0ustar ischnellusers00000000000000././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/blue_view.pyenvisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/workbench/view/bl0000644000175100001440000000076211674464014034531 0ustar ischnellusers00000000000000""" A view containing a blue panel! """ # Local imports. from color_view import ColorView class BlueView(ColorView): """ A view containing a blue panel! """ #### 'IView' interface #################################################### # The view's name. name = 'Blue' # The default position of the view relative to the item specified in the # 'relative_to' trait. position = 'bottom' #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/acme/__init__.py0000644000175100001440000000034311674464014033361 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/plugins/workbench/AcmeLabUsingEggs/src/acme.workbench/setup.py0000644000175100001440000000115311674464014032055 0ustar ischnellusers00000000000000# Major package imports. from setuptools import setup, find_packages setup( name = 'acme.workbench', version = '0.1a1', author = 'Enthought, Inc', author_email = 'info@enthought.com', license = 'BSD', zip_safe = False, packages = find_packages(), include_package_data = True, namespace_packages = [ 'acme', 'acme.workbench' ], entry_points = """ [envisage.plugins] acme_workbench = acme.workbench.acme_workbench_plugin:AcmeWorkbenchPlugin """ ) envisage-4.1.0/examples/plugins/workbench/Lorenz/0000755000175100001440000000000011674464014023037 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/0000755000175100001440000000000011674464014023744 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/__init__.py0000644000175100001440000000034311674464014026055 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/0000755000175100001440000000000011674464014025255 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/lorenz_ui_plugin.py0000644000175100001440000000467511674464014031227 0ustar ischnellusers00000000000000""" The Lorenz UI plugin. """ # Enthought library imports. from envisage.api import Plugin from pyface.workbench.api import Perspective, PerspectiveItem from pyface.workbench.api import TraitsUIView from traits.api import List class LorenzPerspective(Perspective): """ A perspective containing the default Lorenz views. """ name = 'Lorenz' show_editor_area = False contents = [ PerspectiveItem(id='lorenz.data'), PerspectiveItem(id='lorenz.plot2d') ] class LorenzUIPlugin(Plugin): """ The Lorenz UI plugin. This plugin is part of the 'Lorenz' example application. """ # Extension points Ids. PERSPECTIVES = 'envisage.ui.workbench.perspectives' VIEWS = 'envisage.ui.workbench.views' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.lorenz.ui' # The plugin's name (suitable for displaying to the user). name = 'Lorenz UI' #### Contributions to extension points made by this plugin ################ # Perspectives. perspectives = List(contributes_to=PERSPECTIVES) def _perspectives_default(self): """ Trait initializer. """ return [LorenzPerspective] # Views. views = List(contributes_to=VIEWS) def _views_default(self): """ Trait initializer. """ return [self._create_data_view, self._create_plot2d_view] ########################################################################### # Private interface. ########################################################################### def _create_data_view(self, **traits): """ Factory method for the data view. """ from acme.lorenz.api import DataView, Lorenz data_view = TraitsUIView( id = 'lorenz.data', name = 'Data', obj = DataView(lorenz=self.application.get_service(Lorenz)), **traits ) return data_view def _create_plot2d_view(self, **traits): """ Factory method for the plot2D view. """ from acme.lorenz.api import Lorenz, Plot2DView plot2d_view = TraitsUIView( id = 'lorenz.plot2d', name = 'Plot 2D', obj = Plot2DView(lorenz=self.application.get_service(Lorenz)), **traits ) return plot2d_view #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/lorenz_application.py0000644000175100001440000000310711674464014031524 0ustar ischnellusers00000000000000""" The Lorenz example application. """ # Standard library imports. from logging import DEBUG # Enthought library imports. from envisage.ui.workbench.api import WorkbenchApplication from pyface.api import AboutDialog, ImageResource, SplashScreen class LorenzApplication(WorkbenchApplication): """ The Lorenz example application. """ #### 'IApplication' interface ############################################# # The application's globally unique Id. id = 'acme.lorenz' #### 'WorkbenchApplication' interface ##################################### # Branding information. # # The icon used on window title bars etc. icon = ImageResource('lorenz.ico') # The name of the application (also used on window title bars etc). name = 'Lorenz' ########################################################################### # 'WorkbenchApplication' interface. ########################################################################### def _about_dialog_default(self): """ Trait initializer. """ about_dialog = AboutDialog( parent = self.workbench.active_window.control, image = ImageResource('about') ) return about_dialog def _splash_screen_default(self): """ Trait initializer. """ splash_screen = SplashScreen( image = ImageResource('splash'), show_log_messages = True, log_level = DEBUG ) return splash_screen #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/images/0000755000175100001440000000000011674464014026522 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/images/splash.jpg0000644000175100001440000006303711674464014030527 0ustar ischnellusers00000000000000JFIFExifII* z(2ihCanonCanon PowerShot SD1102006:04:19 21:31:304<0220DXl t|   |v01002"*<d 2006:04:19 21:31:302006:04:19 21:31:30 ~ Z .n"*2j r  D $\@Z  ZD$ q*rrr000IMG:PowerShot SD110 JPEGFirmware Version 1.00QH @ /E\a@pR980100( JFIFC    $.' ",#(7),01444'9=82<.342C  2!!22222222222222222222222222222222222222222222222222" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?G~ T*xE>ax8*E:  _JoTpyހ*TJ@`*~ =)";zxC߈Bw$;e@[#*KdgD,@fJnFqKž>R,8$3CLc3=e@MC*=Ք8*c-I!`:ChqOY})mۂxb} =<8{I\*99N$}s H΢'}w.8S$Ij|aƕfI(=xK0T N)2U<*ɋ?1%jW07geOn )]6^D6#*z?3\֕{fWζ @Vb 7ZTA8@ 'XFϥQNU6m9\( R-^\$qZB~P998'.ȱ`Tw+QIހ'itɄvI@=:*H`S\_wu$aQ8{³%A)#1]HQz ij M W11I53:Qqf `hE)#֊1OC=`XT~*n!6`ҥ2BU@# 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{ğvqLFZĎuۧjנk֠hӜdЙ`͖[ʒVǍi˙oɚ/as:s:LO MM p< s:s:as:t;s:t;s:s:|s:C K I6 Gl F ~DV |B!s:(0` $s:s:js:s:s:s:s:s:ws:1V-T,cS+Q*O(M'K&I%G$E#\C"s:s:ls:s:s:s:s:s:s:s:s:s:s:s:s:\07Z/X.V-T,R+P)O(M'K&I%G$E#C"A ,s:Rs:s:s:v<']=rI}UL?s/c {Cs:s:s:s:vs:b3`2^1\0[0iB6|YDdMkRoLhC}_1nOW6G$E#D"e3s:s:FNrգwاwצvץvեuԤuӣuңsϡXPs:s:s:s:e5-c4a3_2$vMTuZzZyZxVtQoVsXsXrXqNg[:f3s:t:,ioעwۨpףN͍3z&ph!l-sC‚f̘tСrϟq<n:k8h7e5b3_2\0`1s:s:NĈx߫UՔlgfedca` _ ^ ] [ Z Y X9xs̞ax>s:s: r= p<tAT~[ U }B zA w? t=q<n:k8h6e5b3_1n8s:(eyiۢligfedca` _ ^ ] [ Z Y X WMs˞>ss:s:s: u? s> r==m]7h F D |B y@ w? s=p;m:j8g6d5g5s: {Alڢy+{jigfedca` _ ^ ] [ Z Y X W[jȘqɜPs:s: w@ u? S]RK G E D |B y@ v? s=p;m:j8g6o8s:G~yO֑kjigfedca` _ ^ ] [ Z Y X W U-msʝ]t;s:s: {B yA w@R^ [ J I G E D |B y@ v> s=p;m9j8s:u r<o;n9s:#XyUٖlkjigfedca` _ ^ ] [ Z Y X W UT3qrɝ=ms:s: ~D |C4g^-h O M L J H F E ~C {A x@ u> r<q:s:Bxy7҃lkjigfedca` _ ^ ] [ Z Y X W UT[rɝYs:s: E ~DGy^Y Q O M K J H F E ~C {A x@ u>s;s:Ny&xmp!s rnkfdca` _ ^ ] [ Z Y X W UTSkƘes:s: F EP]WWXYVSPK F D }C zA w?s;s:ZŏyMבM֐MԐMӏLҎKЌJϋF̈7~(td` _ ^ ] [ Z Y X W UTSaÑoĘs:s: G FYZ1m0l0j/i.f.e,c+a']TH }B zAt;s:\ȒzSؕRדPՒPԑPӐOюMύLΌJ̊IʉFȆ/vc ^ ] [ Z Y X W UTS_qŚt;s: H GXY:u9t9r9q7n7m5j4i3f1d/b$XGv=s:RyRؔUוT֔TԓRӒRґQЏPώN͍LˋJʉJȇDŃ%n ^ [ Z Y X W UTShŖis:s: I HP_Ðr=pl%Vs:/ey_ۜ\ٚ[ؙ[֘Z՗YԕWҔVВUϑS͏Q̍OʋMȉKƇHąD*o\ X W UT(irɝGws:s: K J2j`ȓOTTSRQPON}L{KyHvFt=ks: xAxުq`ڜ_ٛ_ך^֙]՗[ӖZѕWГVΑT͏RˍOɋNljKćH„F@}$j X UTHrɝ'Xs:s:^ L9 KT`ɔ\Ɛ]Đ]Ž[[[YXVUSR~O{My{Es:ZŎye۟cٝb؜`כ`֚^Ԙ]җ[ѕYϓW͑UˏRɍPNjNʼnKÆHƒFD:ydapɛkÖ v>s:s: M L JN`ɔ_ǓdǕdŔdÒdba`^\ZXU.]s:Pvvߩfڟfٟd؝c֛b՚aә^ї\ЕZΓX̑UʏSȍQƋMćKÅGFB~A|iȘsʝ-bs:s: M KY_˔aȔlʚnʛmȚlŘk×jifdba_W x@s:>|ynܤhڠh٠fםd֜cԛaҙ_З\ϔ[͓XˑUɎSnjPʼnMÇJGDYs˞Ut:s:s:8 N L K9v`ʕdʖv΢v͡u˟tȝsƜqĚo˜nkifd8fs:z@dԛx߫jڢkڡjؠg֞f՝dӛbљ_Ж]Δ[̒XʐTȍRƋOĈL†ILr˞nɚIs:s: M{ LMSċ`ʔl̛ѧ~Ϧ|ͥ{ˣyɠxǟvĝsšqnkfLs:Rvܩyݪmڣn٢kנi֞gԝeқbј_ϖ]͔ZʑWȏTƌQĉM‡^ǒr͟s̞3fs:s:s:N M L \^ɓ`ʔdʗҩҬЩͧ˥~ɣ|ƠxÞvroczCs:!Xlՠxݪtۦmءl֠i՞gӜdљbϗ_͕\˒YɐVǍWǍpΞuΠo˜2es:s:s:BN M LYQŠ`ʔaȔyϣ԰ҮЫͩ˧Ȥ}ơzÞviR| x@s: DONJxܩxڨj֟[ѕWΒcљdЙaΖ[˒\ʓ^ʔpϟtϡ\ÎMs:s:s:cN- M LN9v_ɔ`ȓ^ő^ÑfĔwɠΩzǡoj[][*[r:s:s:+cmҟw٧wاwצnԡkҝnӟsӢuңtѢrΟuFzK~Fx r= p< o;pm:s:4s:s:s:s:s:s:t;s:s:s:s:s:s:s:W M L J I H G F E ~D |C zA x@ v? t> r=s:s:ls:s:s:s:s:s:s:s:s:- K JA I H G F E }D |B zA9 x@s: s:??envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/images/image_LICENSE.txt0000644000175100001440000000072711674464014031515 0ustar ischnellusers00000000000000 filename source --------------------------------------------------- about.png Wikipedia: This image is in the public domain because it contains materials that originally came from the United States Central Intelligence Agency's World Factbook. acmelab.ico Gael Varoquaux splash.jpg Wikipedia: This file is licensed under the Creative Commons Attribution ShareAlike license versions 3.0, 2.5, 2.0, and 1.0 envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/api.py0000644000175100001440000000006011674464014026374 0ustar ischnellusers00000000000000from lorenz import DataView, Plot2DView, Lorenz envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/lorenz.py0000644000175100001440000000636511674464014027152 0ustar ischnellusers00000000000000""" Lorenz example. """ # Major package imports. from scipy import array, arange from scipy.integrate import odeint # Enthought library imports. from chaco.chaco_plot_editor import ChacoPlotItem from traits.api import Array, DelegatesTo, Float, HasTraits from traits.api import Instance, List, Trait from traitsui.api import Item, HGroup, VGroup, View class Lorenz(HasTraits): """ The Lorenz model. """ prandtl = Float(10.0, auto_set = False, enter_set = True) rayleigh = Float(28.0, auto_set = False, enter_set = True) beta = Float(8.0 / 3.0, auto_set = False, enter_set = True) # Give the dtype explicitly in the Array traits; this is a # work-around for trac ticket #1864. init = Array(value = array([0.0, 1.0, 0.0]), dtype=float) time = Array(value = array([0.0, 100.0, 0.01]), dtype=float) timePoints = Array() data3d = Array() output = Trait('x vs time', {'x vs time':0, 'y vs time':1, 'z vs time':2}) data2d = Array() def refresh(self): self.calculatePoints() self.data2d=self.data3d[:,self.output_] def __init__(self): self.refresh() def _output_changed(self): self.refresh() def _prandtl_changed(self): self.refresh() def _rayleigh_changed(self): self.refresh() def _beta_changed(self): self.refresh() def _init_changed(self): self.refresh() def _time_changed(self): self.refresh() def lorenz(self, w, t, prandtl, rayleigh, beta): x, y, z = w return array([prandtl * (y - x), x*(rayleigh - z) - y, x*y - beta*z]) def calculatePoints(self): init = self.init.copy() self.timePoints = arange(*self.time) self.data3d = odeint( self.lorenz, init, self.timePoints, args = (self.prandtl, self.rayleigh, self.beta) ) return class DataView(HasTraits): """ The data view. """ # The model that we are a view of. lorenz = Instance(Lorenz) # The view traits. prandtl = DelegatesTo('lorenz') rayleigh = DelegatesTo('lorenz') beta = DelegatesTo('lorenz') init = DelegatesTo('lorenz') time = DelegatesTo('lorenz') traits_ui_view = View( Item('prandtl'), Item('rayleigh'), Item('beta'), Item('init'), Item('time'), id='lorenz.data', resizable=True ) class Plot2DView(HasTraits): """ The Plot 2D view. """ # The model that we are a view of. lorenz = Instance(Lorenz) # The view traits. output = DelegatesTo('lorenz') timePoints = DelegatesTo('lorenz') data2d = DelegatesTo('lorenz') traits_ui_view = View( Item('output'), ChacoPlotItem( 'timePoints', 'data2d', show_label = False, resizable = True, orientation = 'h', title = 'Plot', x_label = 'time', y_label = 'x', color = 'red', bgcolor = 'white', border_visible = False , border_width = 1, padding_bg_color = 'lightgray' ), id = 'lorenz.plot2d', resizable = True ) #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/lorenz_plugin.py0000644000175100001440000000206611674464014030522 0ustar ischnellusers00000000000000""" The Lorenz plugin. """ # Enthought library imports. from envisage.api import Plugin, ServiceOffer from traits.api import List class LorenzPlugin(Plugin): """ The Lorenz plugin. This plugin is part of the 'Lorenz' example application. """ # Extension points Ids. SERVICE_OFFERS = 'envisage.service_offers' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.lorenz' # The plugin's name (suitable for displaying to the user). name = 'Lorenz' #### Contributions to extension points made by this plugin ################ # Service offers. service_offers = List(contributes_to=SERVICE_OFFERS) def _service_offers_default(self): """ Trait initializer. """ lorenz_service_offer = ServiceOffer( protocol = 'acme.lorenz.lorenz.Lorenz', factory = 'acme.lorenz.lorenz.Lorenz' ) return [lorenz_service_offer] #### EOF ###################################################################### envisage-4.1.0/examples/plugins/workbench/Lorenz/acme/lorenz/__init__.py0000644000175100001440000000034311674464014027366 0ustar ischnellusers00000000000000#------------------------------------------------------------------------------ # Copyright (c) 2007 by Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ envisage-4.1.0/examples/plugins/workbench/Lorenz/run.py0000644000175100001440000000226511674464014024222 0ustar ischnellusers00000000000000""" Run the Lorenz example application. """ # Standard library imports. import logging # Enthought plugins. from envisage.core_plugin import CorePlugin from envisage.ui.workbench.workbench_plugin import WorkbenchPlugin # Example imports. from acme.lorenz.lorenz_application import LorenzApplication from acme.lorenz.lorenz_plugin import LorenzPlugin from acme.lorenz.lorenz_ui_plugin import LorenzUIPlugin # Do whatever you want to do with log messages! Here we create a log file. logger = logging.getLogger() #logger.addHandler(logging.StreamHandler(file('lorenz.log', 'w'))) logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.DEBUG) def main(): """ Run the application. """ # Create an application with the specified plugins. lorenz_application = LorenzApplication( plugins=[ CorePlugin(), WorkbenchPlugin(), LorenzPlugin(), LorenzUIPlugin() ] ) # Run it! This starts the application, starts the GUI event loop, and when # that terminates, stops the application. lorenz_application.run() return if __name__ == '__main__': main() #### EOF ###################################################################### envisage-4.1.0/examples/plugins/tasks/0000755000175100001440000000000011674464014020731 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/tasks/attractors/0000755000175100001440000000000011674464014023117 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/tasks/attractors/visualize_2d_task.py0000644000175100001440000000525411674464014027121 0ustar ischnellusers00000000000000# Enthought library imports. from pyface.tasks.action.api import SGroup, SMenu, SMenuBar, \ TaskToggleGroup from pyface.tasks.api import Task, TaskLayout, Tabbed, PaneItem from traits.api import Any, List # Local imports. from model_config_pane import ModelConfigPane from model_help_pane import ModelHelpPane from plot_2d_pane import Plot2dPane class Visualize2dTask(Task): """ A task for visualizing attractors in 2D. """ #### 'Task' interface ##################################################### id = 'example.attractors.task_2d' name = '2D Visualization' menu_bar = SMenuBar(SMenu(id='File', name='&File'), SMenu(id='Edit', name='&Edit'), SMenu(TaskToggleGroup(), id='View', name='&View')) #### 'Visualize2dTask' interface ########################################## # The attractor model that is currently active (visible in the center pane). active_model = Any # The list of available attractor models. models = List ########################################################################### # 'Task' interface. ########################################################################### def create_central_pane(self): """ Create a plot pane with a list of models. Keep track of which model is active so that dock panes can introspect it. """ pane = Plot2dPane(models=self.models) self.active_model = pane.active_model pane.on_trait_change(self._update_active_model, 'active_model') return pane def create_dock_panes(self): return [ ModelConfigPane(model=self.active_model), ModelHelpPane(model=self.active_model) ] ########################################################################### # Protected interface. ########################################################################### #### Trait initializers ################################################### def _default_layout_default(self): return TaskLayout( left=Tabbed(PaneItem('example.attractors.model_config_pane'), PaneItem('example.attractors.model_help_pane'))) def _models_default(self): from model.henon import Henon from model.lorenz import Lorenz from model.rossler import Rossler return [ Henon(), Lorenz(), Rossler() ] #### Trait change handlers ################################################ def _update_active_model(self): self.active_model = self.window.central_pane.active_model for dock_pane in self.window.dock_panes: dock_pane.model = self.active_model envisage-4.1.0/examples/plugins/tasks/attractors/plot_3d_pane.py0000644000175100001440000000427011674464014026043 0ustar ischnellusers00000000000000# Enthought library imports. from mayavi.tools.mlab_scene_model import MlabSceneModel from mayavi.core.ui.mayavi_scene import MayaviScene from pyface.tasks.api import TraitsTaskPane from traits.api import Dict, Enum, Instance, List, Property, \ Unicode, on_trait_change from traitsui.api import EnumEditor, HGroup, Item, Label, View from tvtk.pyface.scene_editor import SceneEditor # Local imports. from model.i_model_3d import IModel3d class Plot3dPane(TraitsTaskPane): #### 'ITaskPane' interface ################################################ id = 'example.attractors.plot_3d_pane' name = 'Plot 3D Pane' #### 'Plot3dPane' interface ############################################### active_model = Instance(IModel3d) models = List(IModel3d) scene = Instance(MlabSceneModel, ()) view = View(HGroup(Label('Model: '), Item('active_model', editor = EnumEditor(name='_enum_map')), show_labels=False), Item('scene', editor = SceneEditor(scene_class=MayaviScene), show_label = False), resizable = True) #### Private traits ####################################################### _enum_map = Dict(IModel3d, Unicode) ########################################################################### # Protected interface. ########################################################################### #### Trait change handlers ################################################ @on_trait_change('active_model.points') def _update_scene(self): self.scene.mlab.clf() if self.active_model: x, y, z = self.active_model.points.swapaxes(0, 1) self.scene.mlab.plot3d(x, y, z, line_width=1.0, tube_radius=None) @on_trait_change('models[]') def _update_models(self): # Make sure that the active model is valid with the new model list. if self.active_model not in self.models: self.active_model = self.models[0] if self.models else None # Refresh the EnumEditor map. self._enum_map = dict((model, model.name) for model in self.models) envisage-4.1.0/examples/plugins/tasks/attractors/help/0000755000175100001440000000000011674464014024047 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/tasks/attractors/help/lorenz.html0000644000175100001440000000452311674464014026252 0ustar ischnellusers00000000000000

The Lorenz attractor itself, and the equations from which it is derived, were introduced by Edward Lorenz in 1963, who derived it from the simplified equations of convection rolls arising in the equations of the atmosphere.

In addition to its interest to the field of non-linear mathematics, the Lorenz model has important implications for climate and weather prediction. The model is an explicit statement that planetary and stellar atmospheres may exhibit a variety of quasi-periodic regimes that are, although fully deterministic, subject to abrupt and seemingly random change.

From a technical standpoint, the Lorenz oscillator is nonlinear, three-dimensional and deterministic. In 2001 it was proven by Warwick Tucker that for a certain set of parameters the system exhibits chaotic behavior and displays what is today called a strange attractor. The strange attractor in this case is a fractal of Hausdorff dimension between 2 and 3. Grassberger (1983) has estimated the Hausdorff dimension to be 2.06 ± 0.01 and the correlation dimension to be 2.05 ± 0.01.

The equations that govern the Lorenz oscillator are:

where σ is called the Prandtl number and ρ is called the Rayleigh number. All σ, ρ, β > 0, but usually σ = 10, β = 8/3 and ρ is varied. The system exhibits chaotic behavior for ρ = 28 but displays knotted periodic orbits for other values of ρ. For example, with ρ = 99.96 it becomes a T(3,2) torus knot.

When σ ≠ 0 and β (ρ-1) ≥ 0, the equations generate three critical points. The critical points at (0,0,0) correspond to no convection, and the critical points at (√(β(ρ-1)), √(β(ρ-1)), ρ-1) and (-√(β(ρ-1), -√(β(ρ-1)), ρ-1) correspond to steady convection. This pair is stable only if ρ= (σ(σ+β+3))/(σ-β-1), which can hold only for positive ρ if σ > β+1.

Text courtesy of Wikipedia under the CC Share-Alike License.

envisage-4.1.0/examples/plugins/tasks/attractors/help/images/0000755000175100001440000000000011674464014025314 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/tasks/attractors/help/images/rossler3.png0000644000175100001440000000144411674464014027601 0ustar ischnellusers00000000000000PNG  IHDR)Ú50PLTE@@@PPPtttbbb"""̶ 000LIDATH V=ha~&܏5J-$EN[F<&UbDpb""E): ]c\Ŀ޽w$'3D+L1:ldRJ&")eiԲm׻RbeZ jHe /Zx%(Hl ;M^+)h}i㢕'-l5|ǟ8W F>Em߇d1;6[)lEmy &t} %"ԺK]gƘ!1-#c>i ,s8Qb987sVU-rU"ny))O9q7FԥvK30qd*G̔( -yLTZ;? 18&5W=gY`TH!G >qژaiϮ,,jT@0cv~֙C.hEF`%Q9@3d#>`qqu)Z_HvNxȞ;&݋k:8:xK_-oioX>Q3hvuz>`_:*{ .$ug"Kaw Tc|Q_wgE/]A_V \;Qr%HUWdNRPe %| =N/szt/mkF60AɑэmSwGIENDB`envisage-4.1.0/examples/plugins/tasks/attractors/help/images/rossler1.png0000644000175100001440000000103111674464014027567 0ustar ischnellusers00000000000000PNG  IHDRm)0PLTE@@@PPPtttbbb"""̶ 000bIDATH ?H@ƿJ&ME.,88 8UK Xf-X h6Mnr2#/!w3lR(c T4N<><'Y6ku%Gh@s,% f %،UsQXةŎ^x W'snsqv Y-MFwV Zo_0ёI޽]ŖZiɱ1\$ '津'eoaΏd*^+o "b}`$~xIENDB`envisage-4.1.0/examples/plugins/tasks/attractors/help/images/lorenz3.png0000644000175100001440000000117311674464014027420 0ustar ischnellusers00000000000000PNG  IHDRt)=0PLTE@@@PPPtttbbb"""̶ 000LIDATH 1H#Ah1wC#UW{pW"jci,\ppJ;"ih#( 6hv¡Vfgј؝7ٙg3=խQGQ-j4.?P12ݓFV&c8GC |YIKXz*k5X)7-kAf7_yTXP<++E4 |QC iޠ :RKNǕd#ˏX/B^(TwZ p(b=K<+,EHbk\xilo8{fd^G@CKN+ȋ" 8PNut1h˵30D5'Bi O\B)xvMƮ h#v| 0 6Rϯ\;ƹ!?M_vf\1է\֢7Mך(hiG+ j{<ں1hYYrȑ{Nv.ԯ9$6s='.wpx=IENDB`envisage-4.1.0/examples/plugins/tasks/attractors/help/images/henon1.png0000644000175100001440000000165411674464014027220 0ustar ischnellusers00000000000000PNG  IHDR2#'0PLTEtttbbb@@@000"""PPP 9V7IDATX ?hQǿӗ%iS! Eq8-B-Tp`X %uE(VX:8V vppppPݽwrKӭo }Z3m Ù!'8_jd.ܔkr0Lq}RP =A %'GLX,3mە\|DITmjY|圗jE YZB!2r8P"UvF'Jn/*R},bw@+a)B&U~Å>` z)f% ~WJ^y shܒ)9t!2/z tu%7 cs-ZRc-hQdؘwA!d=' lыBF>gddY~q w-I##4t0ֱThh"kU_t]Ə\kI-sl_m| %7֒jQxP)ι"+xs+T huywҎ*:˨Q[mq{˹q؟s4GIaZk:J20iش<}/ɇa \4[9$S 7pcpp wgqhq}Y<90IENDB`envisage-4.1.0/examples/plugins/tasks/attractors/help/images/rossler2.png0000644000175100001440000000105711674464014027600 0ustar ischnellusers00000000000000PNG  IHDRh)+6q[0PLTE@@@PPPtttbbb"""̶ 000bIDATH ?O@ƟZ A$8A'#&tLN$u61,?Rrk{y w/$hmU6m24҃ y#@Z}+;Z1uB$( EKGbzc|0k/8SHKo%(-|0CRkYz8*CZy<&FHCƅ}[q?t)&!;(+CߖudY~8MCbOț`~h+zgb?cG ii\ в& )D?zƥ*5ODq-/n\y'aB2^+S eRse^F^.Q~ʝ1uPh~IENDB`envisage-4.1.0/examples/plugins/tasks/attractors/help/henon.html0000644000175100001440000000326011674464014026045 0ustar ischnellusers00000000000000

The Hénon map is a discrete-time dynamical system. It is one of the most studied examples of dynamical systems that exhibit chaotic behavior. The Hénon map takes a point (x_n, y_n) in the plane and maps it to a new point

The map depends on two parameters, a and b, which for the canonical Hénon map have values of a = 1.4 and b = 0.3. For the canonical values the Hénon map is chaotic. For other values of a and b the map may be chaotic, intermittent, or converge to a periodic orbit. An overview of the type of behavior of the map at different parameter values may be obtained from its orbit diagram.

The map was introduced by Michel Hénon as a simplified model of the Poincaré section of the Lorenz model. For the canonical map, an initial point of the plane will either approach a set of points known as the Hénon strange attractor, or diverge to infinity. The Hénon attractor is a fractal, smooth in one direction and a Cantor set in another. Numerical estimates yield a correlation dimension of 1.42 ± 0.02[1] and a Hausdorff dimension of 1.261 ± 0.003[2] for the attractor of the canonical map.

As a dynamical system, the canonical Hénon map is interesting because, unlike the logistic map, its orbits defy a simple description.

Text courtesy of Wikipedia under the CC Share-Alike License.

envisage-4.1.0/examples/plugins/tasks/attractors/help/rossler.html0000644000175100001440000000376211674464014026436 0ustar ischnellusers00000000000000

The Rössler attractor is the attractor for the Rössler system, a system of three non-linear ordinary differential equations. These differential equations define a continuous-time dynamical system that exhibits chaotic dynamics associated with the fractal properties of the attractor. Some properties of the Rössler system can be deduced via linear methods such as eigenvectors, but the main features of the system require non-linear methods such as Poincaré maps and bifurcation diagrams. The original Rössler paper says the Rössler attractor was intended to behave similarly to the Lorenz attractor, but also be easier to analyze qualitatively. An orbit within the attractor follows an outward spiral close to the x,y plane around an unstable fixed point. Once the graph spirals out enough, a second fixed point influences the graph, causing a rise and twist in the z-dimension. In the time domain, it becomes apparent that although each variable is oscillating within a fixed range of values, the oscillations are chaotic. This attractor has some similarities to the Lorenz attractor, but is simpler and has only one manifold. Otto Rössler designed the Rössler attractor in 1976, but the originally theoretical equations were later found to be useful in modeling equilibrium in chemical reactions. The defining equations are:

Rössler studied the chaotic attractor with a = 0.2, b = 0.2, and c = 5.7, though properties of a = 0.1, b = 0.1, and c = 14 have been more commonly used since.

Text courtesy of Wikipedia under the CC Share-Alike License.

envisage-4.1.0/examples/plugins/tasks/attractors/preferences.ini0000644000175100001440000000014111674464014026115 0ustar ischnellusers00000000000000[example.attractors] default_task = example.attractors.task_3d always_use_default_layout = False envisage-4.1.0/examples/plugins/tasks/attractors/visualize_3d_task.py0000644000175100001440000000517511674464014027124 0ustar ischnellusers00000000000000# Enthought library imports. from pyface.tasks.action.api import SGroup, SMenu, SMenuBar, \ TaskToggleGroup from pyface.tasks.api import Task, TaskLayout, Tabbed, PaneItem from traits.api import Any, List # Local imports. from model_config_pane import ModelConfigPane from model_help_pane import ModelHelpPane from plot_3d_pane import Plot3dPane class Visualize3dTask(Task): """ A task for visualizing attractors in 3D. """ #### 'Task' interface ##################################################### id = 'example.attractors.task_3d' name = '3D Visualization' menu_bar = SMenuBar(SMenu(id='File', name='&File'), SMenu(id='Edit', name='&Edit'), SMenu(TaskToggleGroup(), id='View', name='&View')) #### 'Visualize3dTask' interface ########################################## # The attractor model that is currently active (visible in the center pane). active_model = Any # The list of available attractor models. models = List ########################################################################### # 'Task' interface. ########################################################################### def create_central_pane(self): """ Create a plot pane with a list of models. Keep track of which model is active so that dock panes can introspect it. """ pane = Plot3dPane(models=self.models) self.active_model = pane.active_model pane.on_trait_change(self._update_active_model, 'active_model') return pane def create_dock_panes(self): return [ ModelConfigPane(model=self.active_model), ModelHelpPane(model=self.active_model) ] ########################################################################### # Protected interface. ########################################################################### #### Trait initializers ################################################### def _default_layout_default(self): return TaskLayout( left=Tabbed(PaneItem('example.attractors.model_config_pane'), PaneItem('example.attractors.model_help_pane'))) def _models_default(self): from model.lorenz import Lorenz from model.rossler import Rossler return [ Lorenz(), Rossler() ] #### Trait change handlers ################################################ def _update_active_model(self): self.active_model = self.window.central_pane.active_model for dock_pane in self.window.dock_panes: dock_pane.model = self.active_model envisage-4.1.0/examples/plugins/tasks/attractors/attractors_preferences.py0000644000175100001440000000431111674464014030237 0ustar ischnellusers00000000000000# Enthought library imports. from envisage.ui.tasks.api import PreferencesPane, TaskFactory from apptools.preferences.api import PreferencesHelper from traits.api import Bool, Dict, Enum, List, Str, Unicode from traitsui.api import EnumEditor, HGroup, VGroup, Item, Label, \ View class AttractorsPreferences(PreferencesHelper): """ The preferences helper for the Attractors application. """ #### 'PreferencesHelper' interface ######################################## # The path to the preference node that contains the preferences. preferences_path = 'example.attractors' #### Preferences ########################################################## # The task to activate on app startup if not restoring an old layout. default_task = Str # Whether to always apply the default application-level layout. # See TasksApplication for more information. always_use_default_layout = Bool class AttractorsPreferencesPane(PreferencesPane): """ The preferences pane for the Attractors application. """ #### 'PreferencesPane' interface ########################################## # The factory to use for creating the preferences model object. model_factory = AttractorsPreferences #### 'AttractorsPreferencesPane' interface ################################ task_map = Dict(Str, Unicode) view = View( VGroup(HGroup(Item('always_use_default_layout'), Label('Always use the default active task on startup'), show_labels = False), HGroup(Label('Default active task:'), Item('default_task', editor=EnumEditor(name='handler.task_map')), enabled_when = 'always_use_default_layout', show_labels = False), label='Application startup'), resizable=True) ########################################################################### # Private interface. ########################################################################### def _task_map_default(self): return dict((factory.id, factory.name) for factory in self.dialog.application.task_factories) envisage-4.1.0/examples/plugins/tasks/attractors/attractors_plugin.py0000644000175100001440000000357411674464014027246 0ustar ischnellusers00000000000000# Standard library imports. import os.path # Enthought library imports. from envisage.api import Plugin from envisage.ui.tasks.api import TaskFactory from traits.api import List class AttractorsPlugin(Plugin): """ The chaotic attractors plugin. """ # Extension point IDs. PREFERENCES = 'envisage.preferences' PREFERENCES_PANES = 'envisage.ui.tasks.preferences_panes' TASKS = 'envisage.ui.tasks.tasks' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'example.attractors' # The plugin's name (suitable for displaying to the user). name = 'Attractors' #### Contributions to extension points made by this plugin ################ preferences = List(contributes_to=PREFERENCES) preferences_panes = List(contributes_to=PREFERENCES_PANES) tasks = List(contributes_to=TASKS) ########################################################################### # Protected interface. ########################################################################### def _preferences_default(self): filename = os.path.join(os.path.dirname(__file__), 'preferences.ini') return [ 'file://' + filename ] def _preferences_panes_default(self): from attractors_preferences import AttractorsPreferencesPane return [ AttractorsPreferencesPane ] def _tasks_default(self): from visualize_2d_task import Visualize2dTask from visualize_3d_task import Visualize3dTask return [ TaskFactory(id = 'example.attractors.task_2d', name = '2D Visualization', factory = Visualize2dTask), TaskFactory(id = 'example.attractors.task_3d', name = '3D Visualization', factory = Visualize3dTask) ] envisage-4.1.0/examples/plugins/tasks/attractors/attractors_application.py0000644000175100001440000000371411674464014030247 0ustar ischnellusers00000000000000# Enthought library imports. from envisage.ui.tasks.api import TasksApplication from pyface.tasks.api import TaskWindowLayout from traits.api import Bool, Instance, List, Property # Local imports. from attractors_preferences import AttractorsPreferences, \ AttractorsPreferencesPane class AttractorsApplication(TasksApplication): """ The chaotic attractors Tasks application. """ #### 'IApplication' interface ############################################# # The application's globally unique identifier. id = 'example.attractors' # The application's user-visible name. name = 'Attractors' #### 'TasksApplication' interface ######################################### # The default window-level layout for the application. default_layout = List(TaskWindowLayout) # Whether to restore the previous application-level layout when the # applicaton is started. always_use_default_layout = Property(Bool) #### 'AttractorsApplication' interface #################################### preferences_helper = Instance(AttractorsPreferences) ########################################################################### # Private interface. ########################################################################### #### Trait initializers ################################################### def _default_layout_default(self): active_task = self.preferences_helper.default_task tasks = [ factory.id for factory in self.task_factories ] return [ TaskWindowLayout(*tasks, active_task = active_task, size = (800, 600)) ] def _preferences_helper_default(self): return AttractorsPreferences(preferences = self.preferences) #### Trait property getter/setters ######################################## def _get_always_use_default_layout(self): return self.preferences_helper.always_use_default_layout envisage-4.1.0/examples/plugins/tasks/attractors/model/0000755000175100001440000000000011674464014024217 5ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/tasks/attractors/model/rossler.py0000644000175100001440000000467011674464014026271 0ustar ischnellusers00000000000000# System library imports. from scipy import arange, array from scipy.integrate import odeint # Enthought libary imports. from traits.api import Adapter, Array, Float, HasTraits, Instance, \ Property, Str, Unicode, adapts, cached_property, implements from traitsui.api import View, Item # Local imports from i_model_3d import IModel3d, IModel3dIPlottable2dMixin from i_plottable_2d import IPlottable2d class Rossler(HasTraits): """ The model object for the Rossler attractor. """ implements(IModel3d) #### 'IModel3d' interface ################################################# name = Unicode('Rossler Attractor') points = Property(Array, depends_on=['a, b, c, initial_point, times']) #### 'Rossler' interface ################################################## # Equation parameters. a = Float(0.2, auto_set=False, enter_set=True) b = Float(0.2, auto_set=False, enter_set=True) c = Float(5.7, auto_set=False, enter_set=True) # Integration parameters. initial_point = Array(value=[0.0, 1.0, 0.0]) time_start = Float(0.0) time_stop = Float(100.0) time_step = Float(0.01) times = Property(Array, depends_on='time_start, time_stop, time_step') # Configuration view. view = View(Item('a'), Item('b'), Item('c'), Item('initial_point'), Item('time_start'), Item('time_stop'), Item('time_step'), resizable=True) ########################################################################### # 'Rossler' interface. ########################################################################### def compute_step(self, point, time): x, y, z = point return array([ -y - z, x + self.a * y, self.b + z * (x - self.c) ]) ########################################################################### # Protected interface. ########################################################################### @cached_property def _get_points(self): return odeint(self.compute_step, self.initial_point, self.times) @cached_property def _get_times(self): return arange(self.time_start, self.time_stop, self.time_step) class RosslerIPlottable2dAdapter(Adapter, IModel3dIPlottable2dMixin): implements(IPlottable2d) adaptee = Instance(Rossler) plot_type = Str('line') adapts(RosslerIPlottable2dAdapter, Rossler, IPlottable2d) envisage-4.1.0/examples/plugins/tasks/attractors/model/i_plottable_2d.py0000644000175100001440000000035211674464014027454 0ustar ischnellusers00000000000000# Enthought library imports. from traits.api import Enum, Unicode # Local imports. from i_model_2d import IModel2d class IPlottable2d(IModel2d): plot_type = Enum('line', 'scatter') x_label = Unicode y_label = Unicode envisage-4.1.0/examples/plugins/tasks/attractors/model/henon.py0000644000175100001440000000357711674464014025714 0ustar ischnellusers00000000000000# System library imports. from scipy import array, zeros # Enthought library imports. from traits.api import Array, Float, HasTraits, Int, Property, Str, \ Unicode, cached_property, implements from traitsui.api import Item, View # Local imports. from i_plottable_2d import IPlottable2d class Henon(HasTraits): """ The model object for the Henon map. """ implements(IPlottable2d) #### 'Henon' interface #################################################### # Equation parameters. a = Float(1.4, auto_set=False, enter_set=True) b = Float(0.3, auto_set=False, enter_set=True) # Iteration parameters. initial_point = Array(value=[0.1, 0.1]) steps = Int(10000) # Iteration results. points = Property(Array, depends_on='a, b, initial_point, steps') # Configuration view. view = View(Item('a'), Item('b'), Item('initial_point'), Item('steps'), resizable=True) #### 'IPlottable2D' interface ############################################# name = Unicode('Henon Map') plot_type = Str('scatter') x_data = Property(Array, depends_on='points') y_data = Property(Array, depends_on='points') x_label = Unicode('x') y_label = Unicode('y') ########################################################################### # Protected interface. ########################################################################### @cached_property def _get_points(self): point = self.initial_point points = zeros((self.steps, 2)) for i in xrange(self.steps): x, y = points[i] = point point = array([y + 1 - self.a * x**2, self.b * x]) return points @cached_property def _get_x_data(self): return self.points[:,0] @cached_property def _get_y_data(self): return self.points[:,1] envisage-4.1.0/examples/plugins/tasks/attractors/model/lorenz.py0000644000175100001440000000514011674464014026102 0ustar ischnellusers00000000000000# System library imports. from scipy import arange, array from scipy.integrate import odeint # Enthought libary imports. from traits.api import Adapter, Array, Float, HasTraits, Instance, \ Property, Str, Unicode, adapts, cached_property, implements from traitsui.api import View, Item # Local imports from i_model_3d import IModel3d, IModel3dIPlottable2dMixin from i_plottable_2d import IPlottable2d class Lorenz(HasTraits): """ The model object for the Lorenz attractor. """ implements(IModel3d) #### 'IModel3d' interface ################################################# name = Unicode('Lorenz Attractor') points = Property(Array, depends_on=['prandtl', 'rayleigh', 'beta', 'initial_point', 'times']) #### 'Lorenz' interface ################################################### # Equation parameters. prandtl = Float(10.0, auto_set=False, enter_set=True) rayleigh = Float(28.0, auto_set=False, enter_set=True) beta = Float(8.0 / 3.0, auto_set=False, enter_set=True) # Integration parameters. initial_point = Array(value=[0.0, 1.0, 0.0]) time_start = Float(0.0) time_stop = Float(100.0) time_step = Float(0.01) times = Property(Array, depends_on='time_start, time_stop, time_step') # Configuration view. view = View(Item('prandtl'), Item('rayleigh'), Item('beta'), Item('initial_point'), Item('time_start'), Item('time_stop'), Item('time_step'), resizable=True) ########################################################################### # 'Lorenz' interface. ########################################################################### def compute_step(self, point, time): x, y, z = point return array([ self.prandtl * (y - x), x * (self.rayleigh - z) - y, x * y - self.beta * z ]) ########################################################################### # Protected interface. ########################################################################### @cached_property def _get_points(self): return odeint(self.compute_step, self.initial_point, self.times) @cached_property def _get_times(self): return arange(self.time_start, self.time_stop, self.time_step) class LorenzIPlottable2dAdapter(Adapter, IModel3dIPlottable2dMixin): implements(IPlottable2d) adaptee = Instance(Lorenz) plot_type = Str('line') adapts(LorenzIPlottable2dAdapter, Lorenz, IPlottable2d) envisage-4.1.0/examples/plugins/tasks/attractors/model/i_model_2d.py0000644000175100001440000000032011674464014026561 0ustar ischnellusers00000000000000# Enthought library imports. from traits.api import Array, Interface, Unicode class IModel2d(Interface): # The user-visible name of the model. name = Unicode x_data = Array y_data = Array envisage-4.1.0/examples/plugins/tasks/attractors/model/__init__.py0000644000175100001440000000000011674464014026316 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/tasks/attractors/model/i_model_3d.py0000644000175100001440000000343711674464014026576 0ustar ischnellusers00000000000000# Enthought library imports. from traits.api import Array, DelegatesTo, HasTraits, Interface, \ Instance, Property, Trait, Unicode, cached_property from traitsui.api import Group, Item, View class IModel3d(Interface): """ A model object that produces an array of 3D points. """ # The user-visible name of the model. name = Unicode # An n-by-3 array. points = Array class IModel3dIPlottable2dMixin(HasTraits): """ A mixin class to facilliate defining a IModel3d -> IPlottable2D adapter. """ #### 'Adapter' interface ################################################## adaptee = Instance(IModel3d) #### 'IPlottable2D' interface ############################################# name = DelegatesTo('adaptee') x_data = Property(Array, depends_on='adaptee.points, x_label') y_data = Property(Array, depends_on='adaptee.points, y_label') x_label = Trait('x', { 'x':0, 'y':1, 'z':2 }) y_label = Trait('y', { 'x':0, 'y':1, 'z':2 }) view = View(Group(Group(Item('adaptee', style = 'custom', show_label = False), label = 'Model'), Group(Item('x_label', label = 'X axis'), Item('y_label', label = 'Y axis'), label = 'Plot'))) ########################################################################### # Protected interface. ########################################################################### @cached_property def _get_x_data(self): return self.adaptee.points[:,self.x_label_] @cached_property def _get_y_data(self): return self.adaptee.points[:,self.y_label_] envisage-4.1.0/examples/plugins/tasks/attractors/run.py0000644000175100001440000000113211674464014024272 0ustar ischnellusers00000000000000# Standard library imports. import logging # Plugin imports. from envisage.core_plugin import CorePlugin from envisage.ui.tasks.tasks_plugin import TasksPlugin from attractors_plugin import AttractorsPlugin # Local imports. from attractors_application import AttractorsApplication def main(argv): """ Run the application. """ logging.basicConfig(level=logging.WARNING) plugins = [ CorePlugin(), TasksPlugin(), AttractorsPlugin() ] app = AttractorsApplication(plugins=plugins) app.run() logging.shutdown() if __name__ == '__main__': import sys main(sys.argv) envisage-4.1.0/examples/plugins/tasks/attractors/model_help_pane.py0000644000175100001440000000354611674464014026614 0ustar ischnellusers00000000000000# Standard library imports. import codecs import os.path # Enthought library imports. from pyface.tasks.api import TraitsDockPane from traits.api import HasTraits, Instance, Property, Unicode, \ cached_property from traitsui.api import HTMLEditor, Item, View # Constants. HELP_PATH = os.path.join(os.path.dirname(__file__), 'help') class ModelHelpPane(TraitsDockPane): """ A dock pane for viewing any help associated with a model. """ #### 'ITaskPane' interface ################################################ id = 'example.attractors.model_help_pane' name = 'Model Information' #### 'ModelConfigPane' interface ########################################## model = Instance(HasTraits) html = Property(Unicode, depends_on='model') view = View(Item('pane.html', editor = HTMLEditor(base_url=HELP_PATH, open_externally=True), show_label = False), width = 300, resizable = True) ########################################################################### # Protected interface. ########################################################################### @cached_property def _get_html(self): """ Fetch the help HTML for the current model. """ if self.model is None: return 'No model selected.' # Determine the name of the model. model = self.model while hasattr(model, 'adaptee'): model = model.adaptee name = model.__class__.__name__.lower() # Load HTML file, if possible. path = os.path.join(HELP_PATH, name + '.html') if os.path.isfile(path): with codecs.open(path, 'r', 'utf-8') as f: return f.read() else: return 'No information available for model.' envisage-4.1.0/examples/plugins/tasks/attractors/__init__.py0000644000175100001440000000000011674464014025216 0ustar ischnellusers00000000000000envisage-4.1.0/examples/plugins/tasks/attractors/model_config_pane.py0000644000175100001440000000132011674464014027115 0ustar ischnellusers00000000000000# Enthought library imports. from pyface.tasks.api import TraitsDockPane from traits.api import HasTraits, Instance from traitsui.api import Item, View class ModelConfigPane(TraitsDockPane): """ A simple dock pane for editing an attractor model's configuration options. """ #### 'ITaskPane' interface ################################################ id = 'example.attractors.model_config_pane' name = 'Model Configuration' #### 'ModelConfigPane' interface ########################################## model = Instance(HasTraits) view = View(Item('pane.model', style = 'custom', show_label = False), resizable = True) envisage-4.1.0/examples/plugins/tasks/attractors/plot_2d_pane.py0000644000175100001440000000667211674464014026052 0ustar ischnellusers00000000000000# Enthought library imports. from chaco.chaco_plot_editor import ChacoPlotItem from pyface.tasks.api import TraitsTaskPane from traits.api import Dict, Enum, Instance, List, Property, \ Unicode, on_trait_change from traitsui.api import EnumEditor, HGroup, Item, Label, View # Local imports. from model.i_plottable_2d import IPlottable2d class Plot2dPane(TraitsTaskPane): #### 'ITaskPane' interface ################################################ id = 'example.attractors.plot_2d_pane' name = 'Plot 2D Pane' #### 'Plot2dPane' interface ############################################### active_model = Instance(IPlottable2d) models = List(IPlottable2d) plot_type = Property(Unicode, depends_on='active_model.plot_type') title = Property(Unicode, depends_on='active_model.name') x_data = Property(depends_on='active_model.x_data') y_data = Property(depends_on='active_model.y_data') x_label = Property(Unicode, depends_on='active_model.x_label') y_label = Property(Unicode, depends_on='active_model.y_label') view = View(HGroup(Label('Model: '), Item('active_model', editor = EnumEditor(name='_enum_map')), show_labels=False), ChacoPlotItem('x_data', 'y_data', show_label = False, resizable = True, orientation = 'h', marker = 'pixel', marker_size = 1, type_trait = 'plot_type', title = '', x_label_trait = 'x_label', y_label_trait = 'y_label', color = 'blue', bgcolor = 'white', border_visible = False , border_width = 1), resizable = True) #### Private traits ####################################################### _enum_map = Dict(IPlottable2d, Unicode) ########################################################################### # Protected interface. ########################################################################### #### Trait property getters/setters ####################################### def _get_plot_type(self): return self.active_model.plot_type if self.active_model else 'line' def _get_title(self): return self.active_model.name if self.active_model else '' def _get_x_data(self): return self.active_model.x_data if self.active_model else [] def _get_y_data(self): return self.active_model.y_data if self.active_model else [] def _get_x_label(self): return self.active_model.x_label if self.active_model else '' def _get_y_label(self): return self.active_model.y_label if self.active_model else '' #### Trait change handlers ################################################ @on_trait_change('models[]') def _update_models(self): # Make sure that the active model is valid with the new model list. if self.active_model not in self.models: self.active_model = self.models[0] if self.models else None # Refresh the EnumEditor map. self._enum_map = dict((model, model.name) for model in self.models) envisage-4.1.0/examples/Hello_World/0000755000175100001440000000000011674464014020335 5ustar ischnellusers00000000000000envisage-4.1.0/examples/Hello_World/hello_world.py0000644000175100001440000000550511674464014023226 0ustar ischnellusers00000000000000""" The Envisage version of the old chestnut. """ # Standard library imports. import logging # Enthought library imports. from envisage.api import Application, ExtensionPoint, Plugin from traits.api import List, Str # Create a log file. logger = logging.getLogger() logger.addHandler(logging.StreamHandler(file('hello_world.log', 'w'))) logger.setLevel(logging.DEBUG) class HelloWorld(Plugin): """ The 'Hello World' plugin. This plugin offers a single extension point 'greetings' which is a list of greetings, one of which is used to produce the ' World' message when the plugin is started. """ # This tells us that the plugin offers the 'greetings' extension point, # and that plugins that want to contribute to it must each provide a list # of strings (Str). greetings = ExtensionPoint( List(Str), id='greetings', desc='Greetings for "Hello World"' ) # Plugin's have two important lifecyle methods, 'start' and 'stop'. These # methods are called automatically by Envisage when the application is # started and stopped respectively. def start(self): """ Start the plugin. """ # Standard library imports. # # We put this import here just to emphasize that it is only used in # this specific plugin. import random print random.choice(self.greetings), 'World!' return class Greetings(Plugin): """ A plugin that contributes to the 'greetings' extension point. """ # This tells us that the plugin contributes the value of this trait to the # 'greetings' extension point. greetings = List(["Hello", "G'day"], contributes_to='greetings') class MoreGreetings(Plugin): """ Another plugin that contributes to the 'greetings' extension point. """ # This tells us that the plugin contributes the value of this trait to the # 'greetings' extension point. greetings = List(contributes_to='greetings') # This shows how you can use a standard trait initializer to populate the # list dynamically. def _greetings_default(self): """ Trait initializer. """ extensions = [ 'The %s application says %s' % (self.application.id, greeting) for greeting in ['Bonjour', 'Hola'] ] return extensions # Application entry point. if __name__ == '__main__': # Create the application. # # An application is simply a collection of plugins. In this case we # specify the plugins explicitly, but the mechanism for finding plugins # is configurable by setting the application's 'plugin_manager' trait. application = Application( id='hello.world', plugins=[HelloWorld(), Greetings(), MoreGreetings()] ) # Run it! application.run() #### EOF ###################################################################### envisage-4.1.0/examples/Hello_World/.gitignore0000644000175100001440000000002011674464014022315 0ustar ischnellusers00000000000000hello_world.log envisage-4.1.0/image_LICENSE.txt0000644000175100001440000000302011674464014017265 0ustar ischnellusers00000000000000The icons are mostly derived work from other icons. As such they are licensed accordingly to the original license: Project License File ---------------------------------------------------------------------------- CP (Crystal Project) LGPL image_LICENSE_CP.txt GV (Gael Varoquaux) BSD-like LICENSE.txt PSF Python Software Fo. see 1) CCL Creative Commons see 2) Unless stated in this file, icons are the work of Enthought, and are released under a 3 clause BSD license. 1) The Python logo is a trademark of the Python Software Foundation. Please refer to: http://www.python.org/psf/trademarks/ 2) Creative Commons Attribution ShareAlike license versions 3.0, 2.5, 2.0, and 1.0 Files and orginal authors: ---------------------------------------------------------------------------- envisage/ui/workbench/images: about.png | PSF application.ico | GV envisage/ui/workbench/action/images: exit.png | CP preferences.png | CP examples/workbench/AcmeLab/acme/acmelab/images: about.png | Public domain acmelab.ico | GV splash.jpg | CCL examples/workbench/AcmeLabUsingEggs/src/acme.acmelab/acme/acmelab/images: about.png | Public domain acmelab.ico | GV splash.jpg | CCL envisage-4.1.0/docs/0000755000175100001440000000000011674464014015235 5ustar ischnellusers00000000000000envisage-4.1.0/docs/source/0000755000175100001440000000000011674464014016535 5ustar ischnellusers00000000000000envisage-4.1.0/docs/source/_static/0000755000175100001440000000000011674464014020163 5ustar ischnellusers00000000000000envisage-4.1.0/docs/source/_static/e-logo-rev.png0000644000175100001440000000751111674464014022651 0ustar ischnellusers00000000000000PNG  IHDRoi*sRGB pHYs  tIMELIDATx]ktT>z\$m ȥ!TD jV|_CWph PT\"B$$6aIf9qfB%= By}; vo`!4ChVv[12 !HGiyg):QVd8SmsQAj2~~AH3qU:?!4[a6SRu ǎ7H'1"_Qq!JbBwx$I-S^QO>AO~( HAPU)=Ojjm+ v$~ئ"33zviJn[*.\v(/E1U`Ycֿ&y3g>=x$;GS@]d1YÓo"۾X6n8o2 ,c_܊U?y" "cdL5HfFj~}Q]H錩/Oxcq'~lӕ_ ţeW\| &cLMhdȶ9-՗ $ Θڳ9i˗>xa6>#E _h2$}앿"a\l߰0/"ޑҦ.*:UQyٕ~`:oYfxu? b)<̜>җ'rYgԾ6ngeSMkm>uv" Snhj ̌ry_ݚLM01@$(]vƏ{_{#&>4l|c.8~rK05bjԈm;14*:Ο3yK|ީT\> 8nd٤B]j맻]8#&[5TEUlu#u\/kk^6t=Zo`Ӌ-,R'*EP1#EQ DfsnlOYYYҨ!${G2yZ~\pN|olӋnϯBu-\$5˘TYgNR^\8gF{@|4Ņ0ov2֊^:j)D"zM En1]WfN@wǛ뿨k B|c!>8T'JԉaZxubOW~;c%dLynظedNSt~WX\f-pO',9UI21`xĥd  ,{ER"Z G 4PLq@$#15! G}\.-2kEfV=G15Q&ph!9Ce Cvj(# 5#GX:InHJZmڞU__(h݆' H7cHκ})"Db-&`i\eU?*YJ05 D S[GabDěrqEʪ9կm"4LwtGTدr{OPۿhj?:}"i b:/7yA@eK#$t13mj51K &^w !%PSSSֆlr{s^#w4DmQI S#3a@57Q; S#:į v4yR+A&P0j/))-&Z4S.[Z2d^!j8J01-j(T!05Q)"jԌ+@vpd"'4LuyC͉cv,@A1i_qLq|s4bvGz!U !KIQD1E3[1vI $00h6FL̙dnu˞?SScw\LGaʃcf-N]y/4u: c c PM18_h>4~h޽f l%&N^>?2=iC)9v!˜j>hN'N~(aİ}Wx+' u0?1sL _/>_nH ! x9zq@bzlLؘO_6Ac6~t=F&מc2\汋rh3.婓Jx`x^_>_mqKkj+-++Y.zw3TU+qܹ~M\_:pBI" D5 JcTubd!P%+~fz*EP]6R2;/uz] g,'Nd=C^n188D,dZ}W/)~ǎ/z~*0P]g*ݐ[{s]b76 $?`[퍘JTDDKŽ t "((}qqwZΦO11fZ XSXk71E~;{GbN#"k" r@4˗mrN"srLڀ?Vh?݁nw'?0l۶`bF4]2UU ;llgL bkx'ۄ&%QU#c*B{awE|DǶBhZ-f/wIENDB`envisage-4.1.0/docs/source/_static/default.css0000644000175100001440000003231311674464014022323 0ustar ischnellusers00000000000000/** * Sphinx Doc Design */ body { font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; font-size: 100%; background-color: #333333; color: #000; margin: 0; padding: 0; } /* :::: LAYOUT :::: */ div.document { background-color: #24326e; } div.documentwrapper { float: left; width: 100%; } div.bodywrapper { margin: 0 0 0 230px; } div.body { background-color: white; padding: 0 20px 30px 20px; } div.sphinxsidebarwrapper { padding: 10px 5px 0 10px; } div.sphinxsidebar { float: left; width: 230px; margin-left: -100%; font-size: 90%; } p.logo { text-align: center; } div.clearer { clear: both; } div.footer { color: #fff; width: 100%; padding: 9px 0 9px 0; text-align: center; font-size: 75%; } div.footer a { color: #fff; text-decoration: underline; } div.related { background-color: #24326e; color: #fff; width: 100%; height: 30px; line-height: 30px; font-size: 90%; } div.related h3 { display: none; } div.related ul { margin: 0; padding: 0 0 0 10px; list-style: none; } div.related li { display: inline; } div.related li.right { float: right; margin-right: 5px; } div.related a { color: white; } /* ::: TOC :::: */ div.sphinxsidebar h3 { font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; color: #acafb3; font-size: 1.4em; font-weight: normal; margin: 0; padding: 0; } div.sphinxsidebar h4 { font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; color: #acafb3; font-size: 1.3em; font-weight: normal; margin: 5px 0 0 0; padding: 0; } div.sphinxsidebar p { color: white; } div.sphinxsidebar p.topless { margin: 5px 10px 10px 10px; } div.sphinxsidebar ul { margin: 10px; padding: 0; list-style: none; color: white; } div.sphinxsidebar ul ul, div.sphinxsidebar ul.want-points { margin-left: 20px; list-style: square; } div.sphinxsidebar ul ul { margin-top: 0; margin-bottom: 0; } div.sphinxsidebar a { color: #fff; } div.sphinxsidebar form { margin-top: 10px; } div.sphinxsidebar input { border: 1px solid #9bbde2; font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; font-size: 1em; } /* :::: MODULE CLOUD :::: */ div.modulecloud { margin: -5px 10px 5px 10px; padding: 10px; line-height: 160%; border: 1px solid #666666; background-color: #dddddd; } div.modulecloud a { padding: 0 5px 0 5px; } /* :::: SEARCH :::: */ ul.search { margin: 10px 0 0 20px; padding: 0; } ul.search li { padding: 5px 0 5px 20px; background-image: url(file.png); background-repeat: no-repeat; background-position: 0 7px; } ul.search li a { font-weight: bold; } ul.search li div.context { color: #666; margin: 2px 0 0 30px; text-align: left; } ul.keywordmatches li.goodmatch a { font-weight: bold; } /* :::: COMMON FORM STYLES :::: */ div.actions { padding: 5px 10px 5px 10px; border-top: 1px solid #598ec0; border-bottom: 1px solid #598ec0; background-color: #9bbde2; } form dl { color: #333; } form dt { clear: both; float: left; min-width: 110px; margin-right: 10px; padding-top: 2px; } input#homepage { display: none; } div.error { margin: 5px 20px 0 0; padding: 5px; border: 1px solid #db7d46; font-weight: bold; } /* :::: INLINE COMMENTS :::: */ div.inlinecomments { position: absolute; right: 20px; } div.inlinecomments a.bubble { display: block; float: right; background-image: url(style/comment.png); background-repeat: no-repeat; width: 25px; height: 25px; text-align: center; padding-top: 3px; font-size: 0.9em; line-height: 14px; font-weight: bold; color: black; } div.inlinecomments a.bubble span { display: none; } div.inlinecomments a.emptybubble { background-image: url(style/nocomment.png); } div.inlinecomments a.bubble:hover { background-image: url(style/hovercomment.png); text-decoration: none; color: #598ec0; } div.inlinecomments div.comments { float: right; margin: 25px 5px 0 0; max-width: 50em; min-width: 30em; border: 1px solid #598ec0; background-color: #9bbde2; z-index: 150; } div#comments { border: 1px solid #598ec0; margin-top: 20px; } div#comments div.nocomments { padding: 10px; font-weight: bold; } div.inlinecomments div.comments h3, div#comments h3 { margin: 0; padding: 0; background-color: #598ec0; color: white; border: none; padding: 3px; } div.inlinecomments div.comments div.actions { padding: 4px; margin: 0; border-top: none; } div#comments div.comment { margin: 10px; border: 1px solid #598ec0; } div.inlinecomments div.comment h4, div.commentwindow div.comment h4, div#comments div.comment h4 { margin: 10px 0 0 0; background-color: #2eabb0; color: white; border: none; padding: 1px 4px 1px 4px; } div#comments div.comment h4 { margin: 0; } div#comments div.comment h4 a { color: #9bbde2; } div.inlinecomments div.comment div.text, div.commentwindow div.comment div.text, div#comments div.comment div.text { margin: -5px 0 -5px 0; padding: 0 10px 0 10px; } div.inlinecomments div.comment div.meta, div.commentwindow div.comment div.meta, div#comments div.comment div.meta { text-align: right; padding: 2px 10px 2px 0; font-size: 95%; color: #598ec0; border-top: 1px solid #598ec0; background-color: #9bbde2; } div.commentwindow { position: absolute; width: 500px; border: 1px solid #598ec0; background-color: #9bbde2; display: none; z-index: 130; } div.commentwindow h3 { margin: 0; background-color: #598ec0; color: white; border: none; padding: 5px; font-size: 1.5em; cursor: pointer; } div.commentwindow div.actions { margin: 10px -10px 0 -10px; padding: 4px 10px 4px 10px; color: #598ec0; } div.commentwindow div.actions input { border: 1px solid #598ec0; background-color: white; color: #073d61; cursor: pointer; } div.commentwindow div.form { padding: 0 10px 0 10px; } div.commentwindow div.form input, div.commentwindow div.form textarea { border: 1px solid #598ec0; background-color: white; color: black; } div.commentwindow div.error { margin: 10px 5px 10px 5px; background-color: #fff2b0; display: none; } div.commentwindow div.form textarea { width: 99%; } div.commentwindow div.preview { margin: 10px 0 10px 0; background-color: ##9bbde2; padding: 0 1px 1px 25px; } div.commentwindow div.preview h4 { margin: 0 0 -5px -20px; padding: 4px 0 0 4px; color: white; font-size: 1.3em; } div.commentwindow div.preview div.comment { background-color: #f2fbfd; } div.commentwindow div.preview div.comment h4 { margin: 10px 0 0 0!important; padding: 1px 4px 1px 4px!important; font-size: 1.2em; } /* :::: SUGGEST CHANGES :::: */ div#suggest-changes-box input, div#suggest-changes-box textarea { border: 1px solid #666; background-color: white; color: black; } div#suggest-changes-box textarea { width: 99%; height: 400px; } /* :::: PREVIEW :::: */ div.preview { background-image: url(style/preview.png); padding: 0 20px 20px 20px; margin-bottom: 30px; } /* :::: INDEX PAGE :::: */ table.contentstable { width: 90%; } table.contentstable p.biglink { line-height: 150%; } a.biglink { font-size: 1.3em; } span.linkdescr { font-style: italic; padding-top: 5px; font-size: 90%; } /* :::: INDEX STYLES :::: */ table.indextable td { text-align: left; vertical-align: top; } table.indextable dl, table.indextable dd { margin-top: 0; margin-bottom: 0; } table.indextable tr.pcap { height: 10px; } table.indextable tr.cap { margin-top: 10px; background-color: #dddddd; } img.toggler { margin-right: 3px; margin-top: 3px; cursor: pointer; } form.pfform { margin: 10px 0 20px 0; } /* :::: GLOBAL STYLES :::: */ .docwarning { background-color: #fff2b0; padding: 10px; margin: 0 -20px 0 -20px; border-bottom: 1px solid #db7d46; } p.subhead { font-weight: bold; margin-top: 20px; } a { color: #24326e; text-decoration: none; } a:hover { text-decoration: underline; } div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 { font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; background-color: #dddddd; font-weight: normal; color: #073d61; border-bottom: 1px solid #666; margin: 20px -20px 10px -20px; padding: 3px 0 3px 10px; } div.body h1 { margin-top: 0; font-size: 200%; } div.body h2 { font-size: 160%; } div.body h3 { font-size: 140%; } div.body h4 { font-size: 120%; } div.body h5 { font-size: 110%; } div.body h6 { font-size: 100%; } a.headerlink { color: #edaa1e; font-size: 0.8em; padding: 0 4px 0 4px; text-decoration: none; visibility: hidden; } h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, h4:hover > a.headerlink, h5:hover > a.headerlink, h6:hover > a.headerlink, dt:hover > a.headerlink { visibility: visible; } a.headerlink:hover { background-color: #edaa1e; color: white; } div.body p, div.body dd, div.body li { text-align: left; line-height: 130%; } div.body p.caption { text-align: inherit; } div.body td { text-align: left; } ul.fakelist { list-style: none; margin: 10px 0 10px 20px; padding: 0; } .field-list ul { padding-left: 1em; } .first { margin-top: 0 !important; } /* "Footnotes" heading */ p.rubric { margin-top: 30px; font-weight: bold; } /* "Topics" */ div.topic { background-color: #ddd; border: 1px solid #666; padding: 0 7px 0 7px; margin: 10px 0 10px 0; } p.topic-title { font-size: 1.1em; font-weight: bold; margin-top: 10px; } /* Admonitions */ div.admonition { margin-top: 10px; margin-bottom: 10px; padding: 7px; } div.admonition dt { font-weight: bold; } div.admonition dl { margin-bottom: 0; } div.admonition p { display: inline; } div.seealso { background-color: #fff2b0; border: 1px solid #edaa1e; } div.warning { background-color: #fff2b0; border: 1px solid ##db7d46; } div.note { background-color: #eee; border: 1px solid #666; } p.admonition-title { margin: 0px 10px 5px 0px; font-weight: bold; display: inline; } p.admonition-title:after { content: ":"; } div.body p.centered { text-align: center; margin-top: 25px; } table.docutils { border: 0; } table.docutils td, table.docutils th { padding: 1px 8px 1px 0; border-top: 0; border-left: 0; border-right: 0; border-bottom: 1px solid #a9a6a2; } table.field-list td, table.field-list th { border: 0 !important; } table.footnote td, table.footnote th { border: 0 !important; } .field-list ul { margin: 0; padding-left: 1em; } .field-list p { margin: 0; } dl { margin-bottom: 15px; clear: both; } dd p { margin-top: 0px; } dd ul, dd table { margin-bottom: 10px; } dd { margin-top: 3px; margin-bottom: 10px; margin-left: 30px; } .refcount { color: #24326e; } dt:target, .highlight { background-color: #edaa1e1; } dl.glossary dt { font-weight: bold; font-size: 1.1em; } th { text-align: left; padding-right: 5px; } pre { padding: 5px; background-color: #e6f3ff; color: #333; border: 1px solid #24326e; border-left: none; border-right: none; overflow: auto; } td.linenos pre { padding: 5px 0px; border: 0; background-color: transparent; color: #aaa; } table.highlighttable { margin-left: 0.5em; } table.highlighttable td { padding: 0 0.5em 0 0.5em; } tt { background-color: #ddd; padding: 0 1px 0 1px; font-size: 0.95em; } tt.descname { background-color: transparent; font-weight: bold; font-size: 1.2em; } tt.descclassname { background-color: transparent; } tt.xref, a tt { background-color: transparent; font-weight: bold; } .footnote:target { background-color: #fff2b0 } h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { background-color: transparent; } .optional { font-size: 1.3em; } .versionmodified { font-style: italic; } form.comment { margin: 0; padding: 10px 30px 10px 30px; background-color: #ddd; } form.comment h3 { background-color: #598ec0; color: white; margin: -10px -30px 10px -30px; padding: 5px; font-size: 1.4em; } form.comment input, form.comment textarea { border: 1px solid #ddd; padding: 2px; font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; font-size: 100%; } form.comment input[type="text"] { width: 240px; } form.comment textarea { width: 100%; height: 200px; margin-bottom: 10px; } .system-message { background-color: #edaa1e; padding: 5px; border: 3px solid red; } /* :::: PRINT :::: */ @media print { div.document, div.documentwrapper, div.bodywrapper { margin: 0; width : 100%; } div.sphinxsidebar, div.related, div.footer, div#comments div.new-comment-box, #top-link { display: none; } } envisage-4.1.0/docs/source/_static/et.ico0000644000175100001440000002362611674464014021300 0ustar ischnellusers00000000000000(f 00hvh F00( r5(H73iKD]ZZzols$jV4{H5Fg@Hg @' 9c]sE{c@Ec{bFQEPkG\ 1}m( @_-!p3%7)&[B<]VU~okWU#XW$iU$zu5{j6Yv1GWw"X f$I qJ QJ[JډJc4jJ5{J 1FJ qGI Q#W6 Q$j#XA${#h1IQ$j1< s4{A a5S Q}A\1J7|xp``?`8(0`W,"4(%p3%v>1IGF~QFja_~wtdFwG܆ h즋" ij""!zi"""!g""""ۆ"""""F얋""""""Gzޥ""""""Hi """"" ih s"""""  c"""""! R""""!|2"""!|{2""!|2"1"!5 y@y`"!""" 2""""G s"""""H b"""" i R""""!yR""""!qh2""""0i2""""GR"!z"""""hr"""r"""" """""FB""""#93"""""GB"""""62"""""hp"""""%""""" ht"""""#|"""""!"""""k """""""""""Y s"""""""""8 b"""""""&R"""""%2"""#|2"#k"Y?????( f-t1!j/#i1$n3$j2&r4&s4&s5&u5&]0'`1'^2'u5'v5'v6'x6';+(X2(_2(r4(u6(w7(x7(z7(y8(z8({8(P0)s7)z8){8)|9):*c5,i9-A1.R4.E3/W7/u=1x?2A97>;:{F:F?>{I>mH?DBAMDB~ODJHHOMLhSOQPPPQQSRRUTTaW\YXx_[c[]]]^^^b_^___dddpghhhmhkjijjjrksmnnnrpopppsssuttwwwyyy~{}}}t@4LhO\b$8PraKx_ *?VNdcpI 0M}Wfm:1n{|wFvu2!5yziAUSyxj?]GRryxj>E-BYyzk7l`, %3Jg~Z+DaT)9hzC&6Ooe" [q. *>;'#QX( <H/s=^( @m,6#>%D&K'O(R)P) Y+ q0!2%"`."8'#g1#4($l2%p3%q3%q4%0'&a0&r4&t5&u5&v5&e2'p4't4't5'u5'u6'v6'w6'x6'/)(r6(v6(x7(Y3)z8)v8*l6+2--m:-v;-w>1543Q93v@3lA7vC8;:9wF:><;N?<VA=?>>@??zK@AAAoJAFFF~SHbNIKKKnQKLLLrTMONNPNNZPQQQSRRVVUdXVXWWaWaX[ZZwa\d_^e^i_```iabbbedceedhhhphqh}mipijjjlkkplrlwmoooqpopppxqwrsssyvuwwwyyy{{}}}~~~ŻjjybO =iٙWa"HuihZ!.SWZ% 9bݫXxaBmnczq2 !*NwܐVr-% 3]wt\#%XzF' Dz:  EIv- N}I`')uHYH޾Hn65S|HJ' 9dH<%"DpHs0!.SDe(! ;g9pQ("GuM8b> .Uo0@m~1% KL  *Nwג7%%?4%% 3XжP& +_l,$ =g^/#AT($ ! 1>  )[4 #Ck,1{R(%+_f|xp``?`8(0`<5"=$H&/"S)m-*" -# X+ s0!b."o1"+%#h0#+%$l2$u3$p3%q3%q4%r4%+&&8)&V.&g2&r4&t4&t5&u5&.('O/'t5'u5'v5'u6'v6'q6(v7(y7(o7)}9),+*V2*g4*x9*:.,x;,/..70.C2.z=/211u=1l=2z@3666X?9:::}E:><<PB>~I>AAALAlKCODEEERFIIIUIUJKKK`OKMMMZPRRR\TS^TUUU_WaWYYYs_Zt`[`^^__^g_a``bbaccceeeofhggiiillksknmmpppxptsruuuxvxxxyyy}{y}z{{{|}}}~}~¿ȏՎV)IzEl~zEzEtgzE{=?bzEM+$0LqzE9!$ 8YzE5$CdzEc/$0LtzEW$$ :ZzEG$!Ce|?>$$0Ovo*R}u7$:Zc5 ?ac&!CeD $*JmN$$0R\%$ 4Rxf,! .eF <]v=)6u7!$EeږM'#(Tc-#0Ot׽a+ !AQ$# 8Yvh=$$6jB$ 1!!%Ty7!!!"A`&$6jQ&"%T@$Ay7!$6j`&!%SQ'$A?????envisage-4.1.0/docs/source/tasks_user_manual/0000755000175100001440000000000011674464014022255 5ustar ischnellusers00000000000000envisage-4.1.0/docs/source/tasks_user_manual/layout.rst0000644000175100001440000002324611674464014024333 0ustar ischnellusers00000000000000.. _layout: ======================= Window Layout ======================= First and foremost, the Tasks plugin is designed to facilitate the layout of modern, customizable user interfaces. Accordingly, we shall begin by learning how to use Tasks to perform basic window layout. .. index:: task; lifecycle Lifecycle of a Task ------------------- .. index:: model-view-controller pattern, MVC The Tasks plugin adheres to the model-view-controller (MVC) design pattern [1]_, for which the ``Task`` class functions as the controller and the ``TaskWindow`` class as the view, with the model being application-specific [2]_. Insofar as a ``Task`` is a controller, it does not itself instantiate or contain any GUI controls, although it does provide factories and a default layout for the controls that it manages. Controls are instantiated when a ``Task`` is assigned to a ``TaskWindow``. Specifically, the following actions are taken at this time: 1. The task's central pane is constructed and attached to the window 2. All of the task's dock panes are constructed, even if they are not by default visible 3. The visible dock panes are laid out around the central pane according to the task's default layout or persisted UI state information While the ``Task`` remains connected to the ``TaskWindow``, neither its central pane nor its dock panes will be destroyed. If the user "closes" a dock pane, the pane will be merely hidden, and can be re-activated via the application's View menu. Only when the ``Task`` itself is closed---that is, when it is removed from the ``TaskWindow``---will its panes be destroyed. This marks the end of the ``Task``'s lifecycle. If the task is to be re-used, a new instance should be constructed. .. index:: task; defining Defining a Task --------------- Minimally, a task is defined by subclassing ``Task`` and providing a central pane. For example, we define a task for editing Python scripts [3]_:: from pyface.tasks.api import Task class ExampleTask(Task): id = 'example.example_task' name = 'Python Script Editor' def create_central_pane(self): return PythonEditorPane() .. index:: ID, name The ``id`` attribute is a unique internal identifier for the task, whereas ``name`` is a user-visible descriptor for the task. We shall see that this is a common pattern in the Tasks framework. .. index:: central pane; defining All tasks must implement ``create_central_pane()`` and return a TaskPane instance. We might define the ``PythonEditorPane`` pane above as follows, making use of the ``PythonEditor`` available in PyFace:: from pyface.api import PythonEditor from pyface.tasks.api import TaskPane from traits.api import Instance class PythonEditorPane(TaskPane): id = 'example.python_editor_pane' name = 'Python Editor' editor = Instance(PythonEditor) def create(self, parent): self.editor = PythonEditor(parent) self.control = self.editor.control def destroy(self): self.editor.destroy() self.control = self.editor = None Besides providing an ID and a name for the pane, we implement the two basic methods of ``TaskPane``, namely ``create(parent)`` and ``destroy()``. The former constructs a toolkit-specific control for the pane and assigns its to the pane's ``control`` attribute. The latter performs the inverse operation, destroying the control and clearing ``control`` attribute. These methods give one full control over how a pane is constructed, but as we shall see below there are other, more convenient methods for defining a pane. .. index:: dock pane; defining Defining a Dock Pane -------------------- Now we imagine that we are building a very primitive Python IDE and that we would like to add a dock pane for browsing the local filesystem. We could create a ``DockPane`` subclass similarly to the ``TaskPane`` above, implementing the ``create_contents(parent)`` method of ``DockPane`` to provide the toolkit-specific control for the file browser. But if we are familiar with Traits UI we see that it would be more convenient to use the Traits UI ``FileEditor`` for this purpose. The Tasks framework provides the ``TraitsDockPane`` class to facilitate this. We define the pane as follows:: from pyface.tasks.api import TraitsDockPane from traits.api import Event, File, List, Str from traitsui.api import View, Item, FileEditor class FileBrowserPane(TraitsDockPane): #### TaskPane interface ############################################### id = 'example.file_browser_pane' name = 'File Browser' #### FileBrowserPane interface ######################################## # Fired when a file is double-clicked. activated = Event # The list of wildcard filters for filenames. filters = List(Str) # The currently selected file. selected_file = File # The view used to construct the dock pane's widget. view = View(Item('selected_file', editor=FileEditor(dclick_name='activated', filter_name='filters'), style='custom', show_label=False), resizable=True) When a control is needed for the pane, it will be constructed using the standard Traits UI mechanisms. There exist additional options, not described here, for specifying a model object, which is often important when building a complex application. There is also a ``TraitsTaskPane`` class that provides similar functionality for defining Traits-based central panes. As always, the reader is referred to the Tasks API documentation for more information. Now let us amend the example task defined above with a ``create_dock_panes()`` method. This method returns the list of dock pane instances associated with the task. We also define a method on our task for opening a file in the editor, which we connect to the dock pane's ``activated`` event:: class ExampleTask(Task): [ ... ] def create_dock_panes(self): """ Create the file browser and connect to its double click event. """ browser = PythonScriptBrowserPane() handler = lambda: self.open_file(browser.selected_file) browser.on_trait_change(handler, 'activated') return [ browser ] def open_file(self, filename): """ Open the file with the specified path in the central pane. """ self.window.central_pane.editor.path = filename .. index:: task; layout, PaneItem, TaskLayout, Tabbed, Splitter Providing a Default Layout -------------------------- Although dock panes are designed to be moved around and otherwise manipulated by the user, we often have a particular default layout in mind when designing an application. The Tasks framework provides the ``TaskLayout`` class to make the specification of this layout possible. Usually, we are only concerned with four attributes of this class, namely ``left``, ``right``, ``bottom``, and ``top``. Each of these attributes may be assigned a layout item, which is either a ``PaneItem``, for specifying a particular dock pane; a ``Tabbed`` item, containing other ``PaneItem`` instances; or a ``Splitter``, containing arbitrary subitems. A few examples should suffice to make this clear. To stack the dock pane with ID 'dock_pane_1' on top of that with ID 'dock_pane_2', with both to the left of the central pane, one specifies:: left = Splitter(PaneItem('dock_pane_1'), PaneItem('dock_pane_2'), orientation='vertical') .. index:: HSplitter, VSplitter We could also have used ``VSplitter``, which is a convenient abbreviation for a splitter with vertical orientation. Similarly, ``HSplitter`` is an abbrevation for a splitter with horizontal orientation. To put these dock panes in tab group below the central pane, we might write:: bottom_panes = Tabbed(PaneItem('dock_pane_1', height=400), PaneItem('dock_pane_2')) Observe that we have explicitly provided a height for the first dock pane. Provided that the dock pane's underlying control does not have a conflicting minimum or maximum size constraint, Tasks guarantees that it will honor this height exactly. Of course, if ``width`` or ``height`` are not provided, Tasks will use the dock pane's toolkit-specific size hint to determine its size. Now we will provide our example task with a simple layout using the ``default_layout`` attribute of ``Task``:: class ExampleTask(Task): [ ... ] default_layout = TaskLayout( left=PaneItem('example.python_script_browser_pane')) Note that dock panes that do not appear in the layout will not be visible by default. A task without a default layout is equivalent to a task with an empty layout; in both cases, only the central pane will be visible by default. Finally, note that the layout behavior is undefined if a dock pane appears multiple times in a layout. .. rubric:: Footnotes .. [1] For more information about the MVC pattern as used in ETS, the reader is referred to the `Introduction `_ of the Traits UI User Guide. .. [2] Throughout this document, "``Task``" will refer to the class of that name in the Tasks API, while "task" will be reserved for the general UI concept, and similarly for other terms. .. [3] In this and the subsequent section, we will be referencing (often in abbreviated form) the Tasks example code in the TraitsGUI package, available `online `_ and in the ETS distribution. envisage-4.1.0/docs/source/tasks_user_manual/extensibility.rst0000644000175100001440000004262311674464014025712 0ustar ischnellusers00000000000000.. _extensibility: =============== Extensibility =============== .. index:: Envisage The foregoing sections have described those elements of the Tasks framework that belong to the PyFace project; as such, our imports have been from the ``pyface.tasks`` package. We now discuss how Tasks can be used in conjunction with Envisage to build extensible applications. Accordingly, our imports in this section will be from the ``envisage.ui.tasks`` package. As remarked in the :ref:`introduction`, some familiarity with the Envisage plugin framework is assumed. For more information about Envisage, the reader is referred to the :doc:`../envisage_core_documentation/index`. .. _tasks-plugin: The Tasks Plugin ================ In creating an extensible Tasks application, we imagine two primary extensibility use cases: 1. **Contributing to an existing task:** In this case, the user wishes to add some combination of dock panes, menu items, and tool bar buttons to an existing task. In other words, the user would like to extend a task's functionality without changing its fundamental purpose. 2. **Contributing a new task:** Alternatively, the user may find that the none of the existing tasks are suitable for the functonality that he or she wishes to implement. Thus the user decides to contribute an entirely new task. The Tasks plugin has an extension point corresponding to each of these two use cases. These extensions points are: .. index:: TaskFactory 1. ``envisage.ui.tasks.tasks``: A list of ``TaskFactory`` instances. ``TaskFactory`` is a lightweight class for associating a task factory with a name and an ID. We shall see an example of its use in the following subsection. .. index:: TaskExtension 2. ``envisage.ui.tasks.task_extensions``: A list of ``TaskExtension`` instances. A ``TaskExtension`` is a bundle of menu bar, tool bar, and dock pane additions to an existing task. This class is discussed in detail in the subsection on :ref:`extending-a-task`. The Tasks plugin also provides two extensions points that permit the creation of extensible preferences dialogs. We defer discussion of this functionality to the subsection on :ref:`creating-a-preferences-dialog`. .. _tasks-applications: .. index:: application, TasksApplication Creating a Tasks Application ============================ Let us imagine that we are building a (slightly whimsical) application for visualizing `strange attractors `_, in two and three dimensions [1]_. We take for granted the existence of tasks for performing each of these two kinds of visualization. Like any Envisage application, our application will contain a ``Plugin`` instance to expose functionality to other plugins. In this case, we will contribute our two tasks to the Tasks plugin. Because the Tasks plugin is responsible for creating tasks and the windows that contain them, it expects to receive *factories* for creating ``Task`` instances rather than the instances themselves. The ``TaskFactory`` class fulfills this role. With this in mind, we can define a ``Plugin`` for our application:: class AttractorsPlugin(Plugin): #### 'IPlugin' interface ############################################## # The plugin's unique identifier. id = 'example.attractors' # The plugin's name (suitable for displaying to the user). name = 'Attractors' #### Contributions to extension points made by this plugin ############ tasks = List(contributes_to='envisage.ui.tasks.tasks') def _tasks_default(self): return [ TaskFactory(id = 'example.attractors.task_2d', name = '2D Visualization', factory = Visualize2dTask), TaskFactory(id = 'example.attractors.task_3d', name = '3D Visualization', factory = Visualize3dTask) ] .. index:: application; layout, TaskWindowLayout Having contributed tasks to the Tasks plugin, we must now specify how the tasks shall be added to windows to constitute our application. We call this specification the *application-level layout* to distinguish it from the lower-level layout attached to a task. Concretely, an application-level layout consists of a set of ``TaskWindowLayout`` objects, each of which indicates which tasks are attached to the window, which task is active in the window, and, optionally, the size and position of the window. The default application-level layout is defined inside our application class, which must inherit ``TasksApplication``:: class AttractorsApplication(TasksApplication): #### 'IApplication' interface ######################################### # The application's globally unique identifier. id = 'example.attractors' # The application's user-visible name. name = 'Attractors' #### 'TasksApplication' interface ##################################### # The default application-level layout for the application. default_layout = [ TaskWindowLayout('example.attractors.task_2d', 'example.attractors.task_3d', size=(800, 600)) ] Observe that each of the IDs specified in the layout must correspond to the ID of a ``TaskFactory`` that has been contributed to the Tasks plugin. Also note that the ``TaskWindowLayout`` class has an ``active_task`` attribute; by omitting it, we indicate that the first task in the task list is to be active by default. .. index:: application; state restoration By default, the Tasks framework will restore application-level layout when the application is restarted. That is, the set of windows and tasks attached to those windows that is extant when application exits will be restored when application is started again. If, however, the ``always_use_default_layout`` attribute of the application is set, the default application-layout will be applied when the application is restarted. Tasks will still attempt to restore as much user interface state as possible, including window positions and task layouts. This setting is partcularly useful for multi-window applications. Apart from this functionality, the Tasks plugin provides no additional *default* behavior for managing tasks and their windows, permitting users to switch tasks within a window, etc. This is to be expected, as these behaviors are fundamentally application-specific. That said, we shall see in :ref:`global-task-extensions` that the Tasks plugins provides a few built-in extensions for implementing common behaviors. .. _creating-a-preferences-dialog: Creating a Preferences Dialog ============================= .. index:: preferences There are three extensions points associated with preferences. One of these extension points is built into the Envisage core plugin, while the other two belong to the Tasks plugin. Let us survey each of them in turn. 1. ``envisage.preferences``: A list of locators for default preferences files (INI files). This extension point is at the model level in the preferences system. .. index:: preferences; category 2. ``envisage.ui.tasks.preferences_categories``: A list of ``PreferencesCategory`` instances. Preference categories have name and ID attributes. To each category with a given name corresponds a tab with that name in the preferences dialog, unless there is only a single category, in which the case the tab bar will not be shown. .. index:: preferences; pane 3. ``envisage.ui.tasks.preferences_panes``: A list of ``PreferencesPane`` instances. A preferences pane defines a set of user interface elements for changing application preferences via a model object called a ``PreferencesHelper``. A preferences pane has a name and an ID, as well as a ``category`` attribute for specifying the ID of the category to which it belongs. Preferences panes are stacked vertically among the other panes in their category. By default, the category of a pane is "General". As a convenience, if a category with the specified ID does not exist, it will be created automatically. Note that both preference panes and categories have ``before`` and ``after`` attributes for specifying their order, if this is necessary. See the next subsection for more information about this idiom. We shall now expand the example from the previous subsection by adding a preferences dialog for changing the default task and the application-level state restoration behavior. By doing so, we shall see concretely how to use the preferences system in Tasks, as well as reinforce our knowledge about application-level layout. We begin by defining "preferences.ini", our default preferences file:: [example.attractors] default_task = example.attractors.task_2d always_use_default_layout = False and contributing it to the Envisage core plugin:: class AttractorsPlugin(Plugin): [ ... ] preferences = List(contributes_to='envisage.preferences') def _preferences_default(self): return [ 'pkgfile://example.attractors/preferences.ini' ] This construction assumes that the attractors example is in Python's path (in the ``example.attractors`` package). Alternatively, we could have used the "file://" prefix in conjunction with an absolute path on the local filesystem. We can now define two classes: a preferences helper and preferences pane. The preferences helper is a model-level class that makes accessing the keys in the preferences file convenient and type safe. The preferences pane, introduced above, exposes a Traits UI view for this helper object:: from envisage.ui.tasks.api import PreferencesPane, TaskFactory from apptools.preferences.api import PreferencesHelper class AttractorsPreferences(PreferencesHelper): #### 'PreferencesHelper' interface #################################### # The path to the preference node that contains the preferences. # Notice that this corresponds to the section header in our preferences # file above. preferences_path = 'example.attractors' #### Preferences ###################################################### default_task = Str always_use_default_layout = Bool class AttractorsPreferencesPane(PreferencesPane): #### 'PreferencesPane' interface ###################################### # The factory to use for creating the preferences model object. model_factory = AttractorsPreferences #### 'AttractorsPreferencesPane' interface ############################ task_map = Dict(Str, Unicode) # Notice that the default context for trait names is that of the model # object, and that we must prefix names for this object with 'handler.'. view = View(Group(Item('always_use_default_layout'), Item('default_task', editor = EnumEditor(name='handler.task_map'), enabled_when = 'always_use_default_layout'), label='Application startup'), resizable=True) def _task_map_default(self): return dict((factory.id, factory.name) for factory in self.dialog.application.task_factories) Finally, we modify our application to make use of this new functionality:: class AttractorsApplication(TasksApplication): [ ... ] #### 'TasksApplication' interface ##################################### default_layout = List(TaskWindowLayout) always_use_default_layout = Property(Bool) #### 'AttractorsApplication' interface ################################ preferences_helper = Instance(AttractorsPreferences) def _default_layout_default(self): active_task = self.preferences_helper.default_task tasks = [ factory.id for factory in self.task_factories ] return [ TaskWindowLayout(*tasks, active_task = active_task, size = (800, 600)) ] def _get_always_use_default_layout(self): return self.preferences_helper.always_use_default_layout def _preferences_helper_default(self): return AttractorsPreferences(preferences = self.preferences) and contribute the preferences pane to the Tasks plugin:: class AttractorsPlugin(Plugin): [ ... ] preferences_panes = List( contributes_to='envisage.ui.tasks.preferences_panes') def _preferences_panes_default(self): return [ AttractorsPreferencesPane ] .. _extending-a-task: Extending an Existing Task ========================== Contributions are made to an existing task via the ``TaskExtension`` class, which was briefly introduced above. ``TaskExtension`` is a simple class with three attributes: 1. ``task_id``: The ID of the task to extend. 2. ``actions``: A list of ``SchemaAddition`` objects. 3. ``dock_pane_factories``: A list of callables for creating dock panes. .. index:: SchemaAddition The second attributes requires further discussion. In the previous section, we remarked that a task's menu and tool bars are defined using schemas; the ``SchemaAddition`` class provides a mechanism for inserting new items into these schemas. .. index:: path A schema implicitly defines a *path* for each of its elements. For example, in the schema:: SMenuBar(SMenu(SGroup([ ... ], id = 'SaveGroup'), [ ... ], id = 'File', name = '&File), SMenu([ ... ], id = 'Edit', name = '&Edit')) the edit menu has the path "MenuBar/Edit". Likewise, the save group in the file menu has the path "MenuBar/File/SaveGroup". We might define an addition for this menu as follows:: SchemaAddition(factory = MyContributedGroup, path = 'MenuBar/File') where ``factory`` is a callable that produces either a schema or an object from the PyFace action API [2]_. A schema addition that produces a schema can in turn be extended by another schema addition. If it produces a PyFace object, it cannot be further extended. In this case we have opted for latter, using a custom subclass of ``Group``. .. index:: before, after The group created from the schema addition above would be inserted at the bottom of the file menu. The ``SchemaAddition`` class provides two further attributes for specifying with greater precision the location of the insertion: ``before`` and ``after``. Setting one of these attributes to the ID of a schema with the same path ensures that the insertion will be made before or after, respectively, that schema. For example, in the expanded addition:: SchemaAddition(factory = MyContributedGroup, before = 'SaveGroup', path = 'MenuBar/File') the created group would be inserted before the save group. If both ``before`` and ``after`` are set, Tasks will attempt to honor both of them [3]_. In the event that Tasks cannot, the menu order is undefined (although the insertions are guaranteed to made) and an error is logged. .. _global-task-extensions: Global Task Extensions ======================= .. index:: TaskExtension; global When creating an application with several tasks it is frequently the case that certain menu bar or tool bar actions should be present in all tasks. Such actions might include an "Exit" item in the "File" menu or an "About" item in the "Help" menu. One can, of course, include these items in the schemas of each task; indeed, if the actions require task-specific behavior, this is the only reasonable approach to take. But for actions that are truly global in nature Tasks provides an alternative that may be more convenient. To create a ``TaskExtension`` that applies to all tasks, simply omit the ``task_id`` attribute. Tasks itself contributes a global task extension with the following menu items: - A group of actions in the menu with ID "View" for toggling the visibility of dock panes (see ``pyface.tasks.action.api.DockPaneToggleGroup``) - A "Preferences" action in the menu with ID "Edit", if the application has any preferences panes - An "Exit" action in the menu with ID "File" The user is free to supplement these items by contributing additional global task extensions. For example, to provide a simple mechanism for changing tasks, one might add include the built-in task switching group in the "View" menu, either at the toplevel or as a sub-menu (see ``pyface.tasks.action.api.TaskToggleGroup``). For switching between windows, Tasks includes the ``TaskWindowToggleGroup``. This class, as well as several other menu-related conveniences, can be found in ``envisage.ui.tasks.action.api``. .. rubric:: Footnotes .. [1] In this section, we shall be referencing--often with considerable simplification--the Attractors example code in the EnvisagePlugins package, available `online `_ and in the ETS distribution. .. [2] Although they are expanded into PyFace action items, schemas belong to a distinct API. It is beyond the scope of this document to describe the PyFace action API. For lack of more complete documentation, the reader is referred to the `source code `_. .. [3] Tasks differs from the Workbench in this regard. envisage-4.1.0/docs/source/tasks_user_manual/intro.rst0000644000175100001440000001023611674464014024144 0ustar ischnellusers00000000000000.. _introduction: ============== Introduction ============== Tasks is an extensible, toolkit-independent framework for building scriptable, task-oriented user interfaces. This document describes its concepts and design principles, surveys the classes in its API, and provides a brief tutorial illustrating its use. We assume that the reader has a basic familiarity with the concepts of Traits and Traits UI. These packages are well documented in their respective user manuals. In the :ref:`extensibility` section of this document, some additional knowledge of the Envisage plugin framework is assumed. For more detailed information concerning the Tasks API, the reader is referred to the Tasks API Reference. What is a Task? --------------- .. index:: task, pane .. _what-is-a-task: For the purposes of this document, a *task* is a collection of user interface elements, called *panes*, which are present in a single window, unified by a specific purpose, and possessed of a certain structure. In addition, a task may provide menus, toolbars, and configuration options appropriate for these elements. .. index:: central pane At the heart of every task is its *central pane*, which exposes its core functionality. The central pane is always visible and occupies the center of the window. For example, in an IDE there will be at least one task concerned with writing code. A code editing widget would constitute the central pane for this task. If the IDE also provided a GUI construction task (i.e., a WYSIWYG user interface builder ala Glade or Qt Designer), the central pane would consist of the "canvas" upon which the user arranges UI elements. .. index:: dock pane In addition to the central pane, a task may include any number of subsidiary panes. These panes are arranged around the central pane in various *dock areas*, for which reason they are called *dock panes*. Dock panes provide functionality that is relevant but unessential to the task at hand. For example, in the code editing task described above, the list of dock panes might include a file browser, a context-sensitive documentation window, a compilation log, and a debugger. In general, dock panes can be moved from one dock area to another, can be made visible or hidden, and can be detached from the main window. Historical Background --------------------- .. index:: background, Workbench .. _historical-background: Many of the ideas behind the Tasks plugin originate in another Envisage plugin, called the Workbench (which, in turn, took considerable inspiration from Eclipse). While the Workbench is useful for creating IDE-style applications---it was designed for this purpose---there is a large class of applications for which it is too inflexible. Significant issues include: - **A lack of distinction between the semantics of UI elements and the layout of those elements.** A perspective (the Workbench analogue of a task) has very little responsibility besides saving the state the user interface. Views (the analogues of dock panes) are added directly to the Workbench, which means that they cannot be restricted to certain perspectives, nor can a perspective exercise meaningful control over the layout of its views. Furthermore, since there is no structure imposed on views by the active perspective, there is no mechanism for coupling UI components, if this becomes necessary. Finally, since the application menus are not connected to perspectives, it is very difficult to maintain multiple sets of menus over the application lifecycle. - **A non-customizable central pane.** The notion of editors is inextricably connected to the Workbench; the central pane must be a notebook-style collection of editors. The above are design considerations that could not be remedied without a vast degree of backwards-incompatible change. Less systemic deficiencies of the Workbench include: - **A lack of robust support for multi-window applications.** The Workbench does not correctly persist layout state for multiple windows. - **An inflexible API for exposing user-configurable preferences.** The preferences dialog does not permit fine-grained layout of UI elements. Tasks has been designed specifically to address these issues. envisage-4.1.0/docs/source/tasks_user_manual/menus.rst0000644000175100001440000001171211674464014024140 0ustar ischnellusers00000000000000.. _menus: ==================== Menus and Tool Bars ==================== In addition to specifying a layout of panes, a task can include a menu bar, a status bar, and any number of tool bars. In this section, we shall see how the Tasks framework supports these important user interface elements. It is important to recall that a task is a kind of *blueprint* for a user interface. As such, a task can provide blueprints, or *schemas* as we shall henceforth call them, for menus and tool bars, but does not itself contain menu or tool bar controls. This distinction, though perhaps not very useful in the present section, will take on considerable importance in the subsequent section on :ref:`extensibility`. .. index:: menu bar Defining a Menu Bar ------------------- .. index:: Action Resuming our example of the script editing task from the previous section, we shall define some menu items for opening and saving files. As in Traits UI and PyFace, individual menu items are instances of the ``Action`` class [1]_. We might define the 'Open' action as follows:: from pyface.action.api import Action class OpenAction(Action): name = 'Open' accelerator = 'Ctrl+O' def perform(self, event): event.task.open() Of course, we must also implement the ``open()`` method on our task:: from pyface.api import FileDialog, OK class ExampleTask(Task): [ ... ] def open(self): """ Shows a dialog to open a file. """ dialog = FileDialog(parent=self.window.control, wildcard='*.py') if dialog.open() == OK: # Recall that 'open_file' was defined in the previous section. self.open_file(dialog.path) .. index:: MenuBarSchema, MenuSchema, GroupSchema, SMenuBar, SMenu, SGroup Now let us suppose that we have similarly implemented a ``SaveAction`` and a ``save()`` method on our task. We would like to add these actions to a menu bar. Tasks provides several ``Schema`` classes for this purpose: :``MenuBarSchema``: The root of a menu hierarchy. Contains some number of menu schemas. :``MenuSchema``: A menu or sub-menu in the menu hierarchy. :``GroupSchema``: A group of menu items that are logically related and that may or may not require separators from other groups. For convenience, these classes also have the abbreviated names ``SMenuBar``, ``SMenu``, and ``SGroup``, respectively. We can implement the menu bar for our task using these abbreviations:: from pyface.tasks.action.api import SMenu, SMenuBar class ExampleTask(Task): [ ... ] menu_bar = SMenuBar(SMenu(OpenAction(), SaveAction(), id='File', name='&File')) .. index:: TaskAction The pattern of having an ``Action`` instance call back to its task is so common that there is a predefined class for this purpose. We can use this ``TaskAction`` class to implement the above menu more simply, without having to define separately the ``OpenAction`` and ``SaveAction`` classes:: from pyface.tasks.action.api import SMenu, SMenuBar, TaskAction class ExampleTask(Task): [ ... ] menu_bar = SMenuBar(SMenu(TaskAction(name='Open...', method='open', accelerator='Ctrl+O'), TaskAction(name='Save', method='save', accelerator='Ctrl+S'), id='File', name='&File')) .. index:: tool bar Defining a Tool Bar ------------------- .. index:: ToolBarSchema, SToolBar Like a menu bar, a tool bar uses the ``Action`` class to represent individual items. A tool bar, however, is defined with a different set of schemas: :``ToolBarSchema``: The root of a tool bar hierarchy. Contains some number of group schemas and actions. :``GroupSchema``: A group of tool bar buttons that are logically related and that may or may not require separators from other groups. As above, these classes are often abbreviated as ``SToolBar`` and ``SGroup``, respectively. Let us now add a tool bar with buttons for opening and saving files to our script editing task:: from pyface.api import ImageResource from pyface.tasks.action.api import SToolBar, TaskAction class ExampleTask(Task): [ ... ] tool_bars = [ SToolBar(TaskAction(method='open', tooltip='Open a file', image=ImageResource('document_open')), TaskAction(method='save', tooltip='Save the current file', image=ImageResource('document_save'))) ] .. rubric:: Footnotes .. [1] The most convenient reference in this case is the `source code `_ itself. envisage-4.1.0/docs/source/tasks_user_manual/index.rst0000644000175100001440000000033611674464014024120 0ustar ischnellusers00000000000000Tasks User Manual ================= .. toctree:: :maxdepth: 3 front.rst intro.rst layout.rst menus.rst extensibility.rst Indices and tables ================== * :ref:`genindex` * :ref:`search` envisage-4.1.0/docs/source/tasks_user_manual/front.rst0000644000175100001440000000331511674464014024141 0ustar ischnellusers00000000000000==================== Front Matter ==================== :Authors: Evan Patterson :Version: Document Version 1 :Copyright: 2011 Enthought, Inc. All Rights Reserved. Redistribution and use of this document in source and derived forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source or derived format (for example, Portable Document Format or Hypertext Markup Language) must retain the above copyright notice, this list of conditions and the following disclaimer. * Neither the name of Enthought, Inc., nor the names of contributors may be used to endorse or promote products derived from this document without specific prior written permission. THIS DOCUMENT IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. All trademarks and registered trademarks are the property of their respective owners. | Enthought, Inc. | 515 Congress Avenue | Suite 2100 | Austin TX 78701 | 1.512.536.1057 (voice) | 1.512.536.1059 (fax) | http://www.enthought.com | info@enthought.com envisage-4.1.0/docs/source/conf.py0000644000175100001440000001300111674464014020027 0ustar ischnellusers00000000000000# -*- coding: utf-8 -*- # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default value; values that are commented out # serve to show the default value. import sys, os # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. #sys.path.append(os.path.abspath('some/directory')) # General configuration # --------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General substitutions. project = 'envisage' copyright = '2008-2011, Enthought' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. d = {} execfile(os.path.join('..', '..', 'envisage', '__init__.py'), d) version = release = d['__version__'] # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directories, that shouldn't be searched # for source files. #exclude_dirs = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'default.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". html_title = "Envisage Documentation" # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (within the static path) to place at the top of # the sidebar. html_logo = "e-logo-rev.png" # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. html_favicon = "et.ico" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. html_use_modindex = False # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, the reST sources are included in the HTML build as _sources/. #html_copy_source = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'Envisagedoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'Envisage.tex', 'Envisage Documentation', 'Enthought, Inc.', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. # latex_logo = "enthought_logo.jpg" latex_logo = "e-logo-rev.png" # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True envisage-4.1.0/docs/source/index.rst0000644000175100001440000000025411674464014020377 0ustar ischnellusers00000000000000Envisage Documentation ====================== .. toctree:: :maxdepth: 2 :glob: envisage_core_documentation/index tasks_user_manual/index * :ref:`search` envisage-4.1.0/docs/source/envisage_core_documentation/0000755000175100001440000000000011674464014024277 5ustar ischnellusers00000000000000envisage-4.1.0/docs/source/envisage_core_documentation/glossary.rst0000644000175100001440000000207711674464014026702 0ustar ischnellusers00000000000000Glossary ======== Application The thing that plugins plugin to! Extension Point A well defined place where new functionality and/or data can be contributed to an application. Extension (aka Contribution) An *actual* piece of functionality or data that is contributed (this is why extensions are often known as contributions). Think of 'extension points' as the 'where' and 'extensions' as the 'what'. Extension Registry The place where (by default) all of the extension points and their associated extensions are stored. Service In Envisage, a service is *any* object that a developer thinks is sufficiently useful to want to share it. Service Registry The 'yellow pages' style mechanism that is used to publish and look up services. Plugin The mechanism for delivering new functionality to an application. A plugin can do 3 simple things: 1) offer extension points 2) make contributions to extension points (including its own) 3) create and publish services Plugin Manager Finds, starts, and manages the plugins that make up an application. envisage-4.1.0/docs/source/envisage_core_documentation/services.rst0000644000175100001440000002610211674464014026655 0ustar ischnellusers00000000000000Services ======== Services are the real "guts" of an Envisage application -- they are the objects that do the actual work! To get the job done, services obviously need to interact, and so Envisage provides a way for them to find each other. This is where the *service registry* comes in. Don't be fazed by the term *service*. In Envisage it just means any objects in your application that you want to share between plugins. Services can be any Python object and do not have to inherit from any Envisage class or even implement any particular interface! Service Registry ================ The service registry provides a "Yellow Pages" style mechanism, in that services are published and looked up by *protocol* meaning *interface*, or *type*. It is called a "Yellow Pages" mechanism because it is just like looking up a telephone number in the "Yellow Pages" phone book. You use the "Yellow Pages" instead of the "White Pages" when you don't know the *name* of the person you want to call but you do know what *kind* of service you require. For example, if you have a leaking pipe, you know you need a plumber, so you pick up your "Yellow Pages", go to the "Plumbers" section and choose one that seems to fit the bill based on price, location, certification, etc. The service registry does exactly the same thing as the "Yellow Pages", only with objects, and it even allows you to publish your own entries for free (unlike the "real" one)! In an Envisage application, the service registry is accessed through the following methods on the IApplication_ interface:: def get_service(self, protocol, query='', minimimize='', maximize=''): """ Return at most one service that matches the specified query. """ def get_service_properties(self, service_id): """ Return the dictionary of properties associated with a service. """ def get_services(self, protocol, query='', minimimize='', maximize=''): """ Return all services that match the specified query. """ def register_service(self, protocol, obj, properties=None): """ Register a service. Returns a service ID that can be used to retrieve any service properties, and to unregister the service. """ def unregister_service(self, service_id): """ Unregister a service. """ The easiest way to explain the workings of these methods is to take a look at some examples, and so to continue our plumber theme, let's assume we have the following interface and implementation:: class IPlumber(Interface): """ What plumbers do! """ # The plumber's name. name = Str # The plumber's location. location = Str # The price per hour (in say, Estonian Krooni ;^) price = Int def fix_leaking_pipe(self, pipe): """ Fix a leaking pipe! """ class Plumber(HasTraits): """ An actual plumber implementation! """ implements(IPlumber) # The plumber's name. name = Str # The plumber's location. location = Str # The price per hour (in say, Estonian Krooni ;^) price = Int def fix_leaking_pipe(self, pipe): """ Fix a leaking pipe! """ ... code that actually fixes it! ... Registering a service --------------------- To register a service, create an object and call the register_service() method, passing it the protocol (interface or type) to publish the object under (for "protocol" think "Yellow Pages" section), and the object to publish. Note that the object to publish does *not* have to inherit from any particular base class or implement any special interface -- any arbitrary Python object will do:: fred = Plumber(name='fred', location='BH1', price=90) fred_id = application.register_service(IPlumber, fred) Note that each registered service gets assigned an ID that is unique within the current process. This can be used later to access its properties, or to unregister it, etc. You can also associate an arbitrary dictionary of properties with an object when you register it. These properties, along with the actual attributes of the service itself, can be used later to lookup the service using the query mechanism as shown in Section 4. :: wilma = Plumber(name='wilma', location='BH6') wilma_id = application.register_service(IPlumber, wilma, {'price' : 125}) Note that the symbol name of the protocol can be specified instead of the actual type or class. Say, for example, that the *IPlumber* interface can be imported via 'from acme.plumber.api import IPlumber', then the registration can be written as:: wilma_id = application.register_service('acme.plumber.api.IPlumber', wilma, {'price' : 125}) This comes in handy when using service factories (see later) to make sure that implementation classes are imported only when necessary. Looking up a service -------------------- Looking up a service is just as easy -- call get_service() specifiying the protocol of the service required:: plumber = application.get_service(IPlumber) Assuming that we have registered both *fred* and *wilma* as in Section 1, then there is no way of knowing which of those objects would be returned. The choice of the object returned does *not* necessarily reflect the order in which they were added, so don't depend on it. Note that the symbol name of the protocol can be specified instead of the actual type or class. Say, for example, that the *IPlumber* interface can be imported via 'from acme.plumber.api import IPlumber', then the service lookup can be written as:: plumber = application.get_service('acme.plumber.api.IPlumber') This comes in handy when using service factories (see later) to make sure that implementation classes are imported only when necessary. Looking up a list of services ----------------------------- You can also look up *all* services of a particular protocol:: plumbers = application.get_services(IPlumber) Assuming the registrations in Section 1, this returns a list containing both *fred* and *wilma*, again in arbitrary order. Using queries ------------- The get_service() and get_services() methods both take optional arguments that allow more control over the selection of an appropriate service. The first of these is the *query* argument, which is a string containing an arbitrary Python expression that is evaluated for each service, with the service only being returned if the expression evaluates to True. The namespace that the expression is evaluated in is created by first adding each of the service's attributes, followed by any additional properties that were specified when the service was registered (i.e., properties take precedence over attributes). Once again, assuming that we have registered *fred* and *wilma* as in Section 1, let's look at how to use the query mechanism to be more selective about the plumber(s) we look up. Find all plumbers whose price is less than 100 Krooni/Hour:: plumbers = application.get_services(IPlumber, "price < 100") This query would return a list containing one plumber, *fred*. Find plumbers named *fred*:: plumbers = application.get_services(IPlumber, "name == 'fred'") This query, again (and unsurprisingly), would return a list containing just *fred*. Queries can be used with the singular form of the get_service() method too, in which case only one of the services that matches the query is returned:: plumber = application.get_service(IPlumber, "price < 200") This query would return *either* *fred* or *wilma*. Using *minimize* and *maximize* ------------------------------- The *minimize* and *maximize* (optional) arguments to the get_service() and get_services() methods allow the services returned to be sorted by an attribute or property in either ascending or descending order respectively. To find the cheapest plumber:: cheapest = application.get_service(IPlumber, minimize='price') Or, if you believe that you get what you pay for, the most expensive:: most_expensive = application.get_service(IPlumber, maximize='price') The *minimize* and *maximize* arguments can also be used in conjunction with a query. For example to find the cheapest plumber in my area:: cheap_and_local = application.get_service(IPlumber, "location='BH6'", minimize='price') This query would definitely give the job to *wilma*! Unregistering a service ----------------------- When you register a service, Envisage returns a value that uniquely identifies the service within the current process (i.e., it is not suitable for persisting to use next time the application is run). To unregister a service, call the unregister_service() method, passing in the appropriate identifier:: fred = Plumber(name='fred', location='BH1', price=90) fred_id = application.register_service(IPlumber, fred) ... application.unregister_service(fred_id) Getting any additional service properties ----------------------------------------- If you associate an arbitrary dictionary of properties with an object when you register it, you can retrieve those properties by calling the get_service_properties() method with the appropriate service identifier:: wilma = Plumber(name='wilma', location='BH6') wilma_id = application.register_service(IPlumber, wilma, {'price':125}) ... properties = application.get_service_properties(wilma_id) This call would return a dictionary containing the following:: {'price' : 125} To set the properties for a service that has already been registered, use:: wilma = Plumber(name='wilma', location='BH6') wilma_id = application.register_service(IPlumber, wilma, {'price':125}) ... application.set_service_properties(wilma_id, {'price' : 150}) Not however, that in practise, it is more common to use the actual attributes of a service object for the purposes of querying, but this is useful if you want additional properties that aren't part of the object's type. Service Factories ----------------- Last, but not least, we will look at an important feature of the service registry, namely, service factories. Service factories allow a Python callable to be registered in place of an actual service object. The callable is invoked the first time anybody asks for a service with the same type that the factory was registered against, and the object returned by the callable replaces the factory in the registry (so that the next time it is asked for it is simply returned as normal). To register a service factory, just register any callable that takes two arguments. The first is the protocol (type) of the service being requested, and the second is the (possibly empty) dictionary of properties that were registered along with the factory, e.g.:: def wilma_factory(protocol, properties): """ A service factory that creates wilma the plumber! """ return Plumber(name='wilma', location='BH6') To register the factory, we just use 'application.register_service' as usual:: wilma_id = application.register_service(IPlumber, wilma_factory, {'price':125}) Now, the first time somebody tries to get any 'IPlumber' service, the factory is called and the returned plumber object replaces the factory in the registry. .. _IApplication: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/enthought/envisage/i_application.py envisage-4.1.0/docs/source/envisage_core_documentation/message_of_the_day.rst0000644000175100001440000002516111674464014030643 0ustar ischnellusers00000000000000The "Message of the Day" (MOTD) Example ======================================= Only marginally more complicated than the traditional "Hello World" example, this is a simple application that prints a witty, educational, or inspiring "Message of the Day". Obviously, if we actually had to write this application, we might not choose to use a framework like Envisage (it is one of the rare applications that is so simple that why would you bother), but it does serve to illustrate all of the fundamental aspects of building an Envisage application. All of the code for this example can be found in the `examples/MOTD`_ directory of the Envisage distribution, and to run it simply type:: cd .../examples/MOTD python run.py (or equivalent, depending on your operating system and shell) Before we dive right in to building our extensible application, let's take a small, but important, step back. Envisage is designed to be an integration platform -- a place where you can bring existing code and with a (hopefully) minimal amount of effort, make it work with the rest of the application. Because of this, we will start the MOTD example by designing the application without any knowledge of Envisage whatsoever. This is obviously a good idea in general, as it allows our code to be reused outside of Envisage applications. Plain Ol' MOTD -------------- So lets take a look at our non-Envisage aware MOTD application, the code for which is in the acme.motd_ package. A good place to start as a developer *using* any package in Envisage (and, for that matter, the entire Enthought tool-suite) is to look at any interfaces and classes exposed via its 'api.py' module. In this case, there are 2 interfaces 1) IMOTD_ The interface for simple "Message of the Day" functionality. 2) IMessage_ The interface supported by each message returned by the motd() method on the IMOTD_ interface. We also (*not* coincidentally!) have 2 corresponding implementation classes: 1) MOTD_ 2) Message_ As you can see, the MOTD_ class simply contains a list of messages and when its motd() method is called, it returns a random choice from that list. An example of using our MOTD_ class at the Python prompt might be:: >>> from acme.motd.api import Message, MOTD >>> motd = MOTD(messages=[Message(author='Anon', text='Hello World!')]) >>> message = motd.motd() >>> print '"%s" - %s' % (message.text, message.author) "Hello World!" - Anon >>> Well, we had to get "Hello World" in there somewhere! The important point here is that this code is written without any knowledge of Envisage or extensibility whatsoever. It is just a small, reusable piece of code (albeit a very simple one). Not So Plain Ol' MOTD --------------------- Now lets look at the steps that we have to go through to use this code and turn it into an extensible, pluggable Envisage application. Create the main Application class ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ First of all, we need to create an object that represents the application itself. In Envisage, this can be any object that implements the IApplication_ interface, but is usually either an instance of the default Application_ class, or one derived from it. In the MOTD_ example, we create the class in the run.py_ module as follows:: application = Application( id = 'acme.motd', plugins = [CorePlugin(), MOTDPlugin(), SoftwareQuotesPlugin()] ) application.run() In this case, we use the simplest way to tell Envisage which plugins make up the application by passing them in explicitly. Envisage applications allow you to completely configure how plugins are located by setting the plugin manager. Envisage ships with two plugin managers by default, one that simply takes a list of plugins as in the above example, and one that finds all plugins offered via the 'envisage.plugins' entry point in Python Eggs. The 'acme.motd' plugin ~~~~~~~~~~~~~~~~~~~~~~ As shown above, the corresponding plugin implementation is in the MOTDPlugin_ class:: class MOTDPlugin(Plugin): """ The 'Message of the Day' plugin. This plugin simply prints the 'Message of the Day' to stdout. """ # The IDs of the extension points that this plugin offers. MESSAGES = 'acme.motd.messages' # The IDs of the extension points that this plugin contributes to. SERVICE_OFFERS = 'envisage.service_offers' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.motd' # The plugin's name (suitable for displaying to the user). name = 'MOTD' #### Extension points offered by this plugin ############################## # The messages extension point. # # Notice that we use the string name of the 'IMessage' interface rather # than actually importing it. This makes sure that the import only happens # when somebody actually gets the contributions to the extension point. messages = ExtensionPoint( List(Instance('acme.motd.api.IMessage')), id=MESSAGES, desc=""" This extension point allows you to contribute messages to the 'Message Of The Day'. """ ) #### Contributions to extension points made by this plugin ################ service_offers = List(contributes_to=SERVICE_OFFERS) def _service_offers_default(self): """ Trait initializer. """ # Register the protocol as a string containing the actual module path # (do not use a module path that goes via an 'api.py' file as this does # not match what Python thinks the module is!). This allows the service # to be looked up by passing either the exact same string, or the # actual protocol object itself. motd_service_offer = ServiceOffer( protocol = 'acme.motd.i_motd.IMOTD', factory = self._create_motd_service ) return [motd_service_offer] ########################################################################### # Private interface. ########################################################################### def _create_motd_service(self): """ Factory method for the 'MOTD' service. """ # Only do imports when you need to! This makes sure that the import # only happens when somebody needs an 'IMOTD' service. from motd import MOTD return MOTD(messages=self.messages) # This plugin does all of its work in this method which gets called when # the application has started all of its plugins. @on_trait_change('application:started') def _print_motd(self): """ Print the 'Message of the Day' to stdout! """ # Note that we always offer the service via its name, but look it up # via the actual protocol. from acme.motd.api import IMOTD # Lookup the MOTD service. motd = self.application.get_service(IMOTD) # Get the message of the day... message = motd.motd() # ... and print it. print '\n"%s"\n\n- %s' % (message.text, message.author) return Although it is obviously a bit of overkill, the example shows how we would take a MOTD_ object and register it a service for other parts of the application to use. Sadly, in this example, there are no other parts of the application, so we just lookup and use the service ourselves! The 'acme.motd.software_quotes' plugin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ First of all, we have to create the messages that we want to add. Remember that when the acme.motd_ plugin advertised the extension point, it told us that every contribution had to implement the IMessage_ interface. Happily, there is a class that does just that already defined for us (Message_) and so we create a simple module ('messages.py'_) and add our Message_ instances to it:: messages = [ ... Message( author = "Martin Fowler", text = "Any fool can write code that a computer can understand. Good" " programmers write code that humans can understand." ) Message( author = "Chet Hendrickson", text = "The rule is, 'Do the simplest thing that could possibly" " work', not the most stupid." ) ... ] Now we create a plugin for the acme.motd.software_quotes_ package and tell Envisage about the messages that we have just created:: class SoftwareQuotesPlugin(Plugin): """ The 'Software Quotes' plugin. """ #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.motd.software_quotes' # The plugin's name (suitable for displaying to the user). name = 'Software Quotes' #### Contributions to extension points made by this plugin ################ # Messages for the 'Message Of The Day'. messages = List(contributes_to='acme.motd.messages') ########################################################################### # 'SoftwareQuotesPlugin' interface. ########################################################################### def _messages_default(self): """ Trait initializer. """ # Only do imports when you need to! from messages import messages return messages .. _`Python Eggs`: http://peak.telecommunity.com/DevCenter/PythonEggs .. _acme.motd: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/api.py .. _acme.motd.software_quotes: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/software_quotes/setup.py .. _Application: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/enthought/envisage/application.py .. _`examples/MOTD`: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD .. _IApplication: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/enthought/envisage/i_application.py .. _IMessage: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/i_message.py .. _Message: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/message.py .. _MOTD: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/motd.py .. _IMOTD: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/i_motd.py .. _MOTDPlugin: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/motd_plugin.py .. _run.py: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/run.py envisage-4.1.0/docs/source/envisage_core_documentation/images/0000755000175100001440000000000011674464014025544 5ustar ischnellusers00000000000000envisage-4.1.0/docs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-OӷtGP53DakT-0xhU^iE p6'@T-O&FGwUt%jUO J#@,*%@cE ! PJ37(Uk ۳U2 ZI"@iZi#@Z0h rcSi) Zٞ% @Z5D j'yFD PJ33"NU64@ET@zTl@RT-@4@AHU64@YC=vFD P=K@J P(s@՞2?\OU64@0 76>]J#@,*%@¬!jUU+-4(U43mhU2 ZI"@iZٞ% @Z0h R$ U43mhU {WUO'@,*%@բEdyV~Rh PVig   àkTZh> p=@g  P)f Q>> from acme.motd.api import Message, MOTD >>> motd = MOTD(messages=[Message(author='Anon', text='Hello World!')]) >>> message = motd.motd() >>> print '"%s" - %s' % (message.text, message.author) "Hello World!" - Anon >>> Well, we had to get "Hello World" in there somewhere! The important point here is that this code is written without any knowledge of Envisage or extensibility whatsoever. It is just a small, reusable piece of code (albeit a very simple one). Not So Plain Ol' MOTD --------------------- Now lets look at the steps that we have to go through to use this code and turn it into an extensible, pluggable Envisage application. Create the main Application class ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ First of all, we need to create an object that represents the application itself. In Envisage, this can be any object that implements the IApplication_ interface, but is usually either an instance of the default Application_ class, or one derived from it. In the MOTD_ example, we create the class in the run.py_ module as follows:: def run(): """ The function that starts your application. """ # Create and run the application. from envisage.api import Application return Application(id='acme.motd').run() Note that the run.py_ file also contains some boilerplate code to add the application's `Python Eggs`_ to the ``sys.path``, but this is not specific to Envisage - that code would be required for any egg-based application. Create the 'acme.motd' plugin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is the plugin that will deliver the "Message of the Day" functionality into the application. It will do this by declaring an extension point to allow other plugins to contribute messages, and by using contributions to create an instance of the MOTD_ class and to publish it as a service. By default, Envisage finds plugins via Python eggs, so all we have to do is to declare the existence of our plugin using the "envisage.plugins" entry point in our 'setup.py' module:: setup( ... entry_points = """ ... [envisage.plugins] acme.motd = acme.motd.motd_plugin:MOTDPlugin ... """ ) The left-hand-side of the 'acme.motd = acme.motd.motd_plugin:MOTDPlugin' line *must* be the same as the 'id' trait as specified in the 'MOTDPlugin' class - in this case 'acme.motd'. While this smacks of duplication, it allows plugin managers such as the 'EggPluginManager' to filter unwanted plugins by id without the need to import and instantiate them. Notice that we don't import the plugin from an 'api.py' module. This is to delay importing implementation code until it is actually needed. As showm above, the corresponding plugin implementation is in the MOTDPlugin_ class:: class MOTDPlugin(Plugin): """ The 'Message of the Day' plugin. This plugin simply prints the 'Message of the Day' to stdout. """ # The IDs of the extension points that this plugin offers. MESSAGES = 'acme.motd.messages' # The IDs of the extension points that this plugin contributes to. SERVICE_OFFERS = 'envisage.service_offers' #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.motd' # The plugin's name (suitable for displaying to the user). name = 'MOTD' #### Extension points offered by this plugin ############################## # The messages extension point. # # Notice that we use the string name of the 'IMessage' interface rather # than actually importing it. This makes sure that the import only happens # when somebody actually gets the contributions to the extension point. messages = ExtensionPoint( List(Instance('acme.motd.api.IMessage')), id=MESSAGES, desc=""" This extension point allows you to contribute messages to the 'Message Of The Day'. """ ) #### Contributions to extension points made by this plugin ################ service_offers = List(contributes_to=SERVICE_OFFERS) def _service_offers_default(self): """ Trait initializer. """ # Register the protocol as a string containing the actual module path # (do not use a module path that goes via an 'api.py' file as this does # not match what Python thinks the module is!). This allows the service # to be looked up by passing either the exact same string, or the # actual protocol object itself. motd_service_offer = ServiceOffer( protocol = 'acme.motd.i_motd.IMOTD', factory = self._create_motd_service ) return [motd_service_offer] ########################################################################### # Private interface. ########################################################################### def _create_motd_service(self): """ Factory method for the 'MOTD' service. """ # Only do imports when you need to! This makes sure that the import # only happens when somebody needs an 'IMOTD' service. from motd import MOTD return MOTD(messages=self.messages) # This plugin does all of its work in this method which gets called when # the application has started all of its plugins. @on_trait_change('application:started') def _print_motd(self): """ Print the 'Message of the Day' to stdout! """ # Note that we always offer the service via its name, but look it up # via the actual protocol. from acme.motd.api import IMOTD # Lookup the MOTD service. motd = self.application.get_service(IMOTD) # Get the message of the day... message = motd.motd() # ... and print it. print '\n"%s"\n\n- %s' % (message.text, message.author) return Although it is obviously a bit of overkill, the example shows how we would take a MOTD_ object and register it a service for other parts of the application to use. Sadly, in this example, there are no other parts of the application, so we just lookup and use the service ourselves! Build the 'acme.motd' egg ~~~~~~~~~~~~~~~~~~~~~~~~~ To deploy the plugin into an application, we have to build it as an egg (this is only because we are using eggs as our deployment mechanism, if you do not want to use eggs then obviously you don't have to do any of this!):: cd .../examples/MOTD/src/acme.motd python setup.py bdist_egg --dist-dir ../../dist/eggs If we run the application now , we will be told to work hard and be good to our Mothers. Good advice indeed, but what it really shows is that we haven't yet contributed any messages to the application. Lets do this next. Create the 'acme.motd.software_quotes' plugin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ First of all, we have to create the messages that we want to add. Remember that when the acme.motd_ plugin advertised the extension point, it told us that every contribution had to implement the IMessage_ interface. Happily, there is a class that does just that already defined for us (Message_) and so we create a simple module ('messages.py'_) and add our Message_ instances to it:: messages = [ ... Message( author = "Martin Fowler", text = "Any fool can write code that a computer can understand. Good" " programmers write code that humans can understand." ) Message( author = "Chet Hendrickson", text = "The rule is, 'Do the simplest thing that could possibly" " work', not the most stupid." ) ... ] Now we create a plugin for the acme.motd.software_quotes_ package and tell Envisage about the messages that we have just created:: class SoftwareQuotesPlugin(Plugin): """ The 'Software Quotes' plugin. """ #### 'IPlugin' interface ################################################## # The plugin's unique identifier. id = 'acme.motd.software_quotes' # The plugin's name (suitable for displaying to the user). name = 'Software Quotes' #### Extension point contributions ######################################## # Messages for the 'Message Of The Day'. messages = List(contributes_to='acme.motd.messages') ########################################################################### # 'SoftwareQuotesPlugin' interface. ########################################################################### def _messages_default(self): """ Trait initializer. """ # Only do imports when you need to! from messages import messages return messages And finally we go to the 'setup.py' file for the acme.motd.software_quotes_ egg and tell Envisage about the plugin:: setup( entry_points = """ [envisage.plugins] acme.motd.software_quotes = acme.motd.software_quotes.software_quotes_plugin:SoftwareQuotesPlugin ... """ ) Build the 'acme.motd.software_quotes' egg ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To deploy the plugin into an application, we have to build it as an egg:: cd .../examples/MOTD/src/acme.motd.software_quotes python setup.py bdist_egg --dist-dir ../../dist/eggs If we run the application now , we will (if all is well!) get a random, pithy quote about software development! To add more messages to the application in future, all we have to do is to create other plugins similar to the 'acme.motd.software_quotes' egg and drop them into the '.../examples/MOTD/dist/eggs' directory. We have successfully built our first extensible, pluggable application! .. _`Python Eggs`: http://peak.telecommunity.com/DevCenter/PythonEggs .. _acme.motd: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/api.py .. _acme.motd.software_quotes: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/software_quotes/setup.py .. _Application: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/enthought/envisage/application.py .. _`examples/MOTD`: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD .. _IApplication: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/enthought/envisage/i_application.py .. _IMessage: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/i_message.py .. _Message: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/message.py .. _MOTD: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/motd.py .. _IMOTD: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/i_motd.py .. _MOTDPlugin: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme/motd/motd_plugin.py .. _run.py: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/run.py envisage-4.1.0/docs/source/envisage_core_documentation/preferences.rst0000644000175100001440000000277411674464014027344 0ustar ischnellusers00000000000000 Preferences with Envisage ========================= Envisage presents preferences with two different extension points: * PREFERENCES = 'envisage.preferences' * PREFERENCES_PAGES = 'envisage.ui.workbench.preferences_pages' The first one is only model-related and is for programmatic access to preferences, whereas the second one is for displaying UIs to the user in the workbench plugin. Preferences ------------ The contribution point is simply a list of URLs to the preference file, e.g.:: preferences_pages = List( ['pkgfile://acme.acmelab/preferences.ini'], contributes_to=PREFERENCES_PAGES) where acme.acmelab is the python-module-like path to the package in which the default preferences.ini is stored. A plugin usually needs only one preferences file, regardless of how many preference pages or settings it has. Preferences pages ------------------ The preference pages are a Traits UI view to wrap the preferences and allow the user to modify them. A preference page is defined as in the preference_manager example in the AppTools examples. It can than be contributed to the workbench, as in:: preferences_pages = List(contributes_to=PREFERENCES_PAGES) def _preferences_pages_default(self): """ Trait initializer. """ from acme.preference_pages \ import ACMEPreferencePages return [ACMEPreferencePages, ] A plugin needs to contribute a preferences pages class for each category of preferences it contributes. envisage-4.1.0/docs/source/envisage_core_documentation/howto_create_a_plugin.rst0000644000175100001440000002537011674464014031401 0ustar ischnellusers00000000000000How To Create a Plugin for an Envisage Application ================================================== This document describes the process of creating an Envisage plugin that works with a Workbench-based application. There are several questions to consider when designing a plugin: * What does it do? * What functionality does it offer to other plugins? * What does it add to what other plugins already do? * What does it need from other plugins? What Does Your Plugin Do? ------------------------- "What your plugin does" refers to the basic functionality that your plugin adds to the application. Very often, you want to take some pre-existing chunk of functionality (module, library, etc.) and make it available within the Envisage application. Assuming the library has a well-defined API, you do not need to alter it in any way. You only create the plugin code to wrap it for Envisage. Sometimes, however, you are designing a new chunk of functionality just for the Envisage application. In this case, step back and think about how you would design the core functionality of the plugin, independent of Envisage. It is important to keep this separate from the plugin machinery that make that functionality work within Envisage. In either case, we will refer to the code that does this core functionality as "the library". Example Library ~~~~~~~~~~~~~~~ Suppose you have a library that implements a game of Tetris. You want to add this game to an Envisage application that lets users pick a game to play from a catalog of available games. You have a Tetris class that looks something like this:: class Tetris(HasTraits): # Basic colors background_color = Color foreground_color = Color # Shapes to use in the game shapes = List(IShape) ... In the following sections, we'll look at ways that this library can be integrated into the application by a plugin. What Does Your Plugin Offer to Other Plugins? --------------------------------------------- There are two ways that a plugin can provide functionality to other plugins. * **Offering services:** Your plugin may provide an API, the core functionality of your library, as a service. Yours might be the only provider of that type of service in an application, or it might be one of many. * **Defining extension points:** Your plugin may offer one or more extension points, which means that your plugin will do something specific with contributions to that extension point. Contributions to an extension point must be instances of a type or interface that you specify. An extension point is a trait attribute whose type is ExtensionPoint, which consists of a List of some other type, plus an ID. In other words, an extension point is a list, used by your plugin, that is populated by plugins. Examples of Offering Functionality to Other Plugins ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppose that the games application defines an "IGame" interface that it uses to control games, with methods for starting, stopping, displaying scores, and so on. In this case, you offer the Tetris library as a service that implements the "IGame" interface used by the application. (You might need to create an adapter for your Tetris class to the IGame interface, but we'll ignore that.) You can manually register a service, but a simple way to do it is to contribute to the 'envisage.services_offers' extension point of the Core plugin. This ensures that the plugin is registered, and is created when it is needed. You also want to allow users to contribute their own Tetris shapes, so you define an extension point for shapes. We'll leave aside the question of how users actually define their shapes. The point is that the catalog of shapes is extensible. (You would probably also contribute some basic shapes from your plugin, so that users don't *need* to contribute any.) What Does Your Plugin Add to Other Plugins? ------------------------------------------- Other plugins may provide extension points that are useful to your plugin. If so, you can contribute to those extension points. Essentially, your plugin passes one or more objects to the plugin whose extension point you are contributing to, and that plugin "does the right thing" with those items. Examples of Contributing to Extension Points ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Continuing the example of the Tetris game, the application might keep a list of available games, and present the list for the user to select from. Thus, it might have a 'games' extension point, to which you can contribute an object containing information about your Tetris game, such as name, description, icon, and entry point. More concretely, you want to specify default colors for the foreground and background colors of the game, but allow users to change them and save their changes across sessions. For specifying default preference values and saving changed values, you can contribute to the 'envisage.preferences' extension point offered by the Envisage core plugin; for a UI to change preferences, you can contribute to the 'envisage.ui.workbench.preferences_pages' extension point offered by the Workbench plugin. (A game application probably wouldn't use the Workbench plugin, but we'll assume it does to avoid using a fictional plugin.) A contribution to the preferences extension point must be a URL of a preferences file (readable by ConfigObj). A plugin typically has only one preferences file, even if it has many categories of preferences. A contribution to the preference_pages extension point must be a callable that returns an object that implements the `apptools.preferences.ui.api.IPreferencesPage` interface. Such an object typically has a Traits UI view that can be used in the Preferences dialog box to set the values of the preference attributes. A plugin may have multiple preferences pages, depending on how it groups the items to be configured. There are two strategies for defining a callable that returns an object: * Subclass from a class that implements the interface, in this case `apptools.preferences.ui.api.PreferencesPage`. * Define a factory function that returns an appropriate object. This strategy is not needed for preferences pages, but can be helpful when the object being returned contains a reference to a service. In either case, the contribution is a trait attribute on the plugin object. What Does Your Plugin Need from Other Plugins? ---------------------------------------------- Your plugin may need to use the API of some other plugin. In Envisage, you use the other plugin's API via a service, rather than directly. This allows for the plugin offering the service to be replaced with another one, transparently to your plugin. There may be multiple plugins offering a particular type of service, but a client plugin uses only one instance of a service at any given time. Example of Using a Service ~~~~~~~~~~~~~~~~~~~~~~~~~~ The service you use may be your own. For the Tetris game, the object that you contribute to the application's 'games' extension point needs to be able to start the game. However, to reduce memory overhead, you don't want the Tetris library to be imported until the user actually chooses to play Tetris. Using the service offered by the Tetris plugin is a way to accomplish that. Complete Example ---------------- The complete plugin for the Tetris game might look like this:: class TetrisPlugin(Plugin): """ Plugin to make the Tetris library available in Envisage. """ ##### IPlugin Interface ################################################ ### Extension points offered by the plugin # Shapes to be used in the game shape = ExtensionPoint(List(IShape), id='acme.tetris.shapes') ### Contributions to extension points my_shapes = List(contributes_to='acme.tetris.shapes') def _my_shapes_default(self): """ Trait initializer for 'my_shapes' contribution to this plugin's own 'shapes' extension point. """ return [ Shape1(), Shape2(), Shape3() ] games = List(contributes_to='acme.game_player.game_infos' def _games_default(self): """ Trait initializer for 'games' contribution to the application plugin's 'games' extension point. """ return [ GameInfo(name='Tetris', icon='tetris.png', description='Classic shape-fitting puzzle game', entry_point=self._start_game) ] preferences = List(contributes_to='envisage.preferences') def _preferences_default(self): """ Trait initializer for 'preferences' contribution. """ return ['pkgfile://acme.tetris.plugin/preferences.ini'] preferences_pages = List(contributes_to= 'envisage.ui.workbench.preferences_pages') def _preferences_pages_default(self): """ Trait initializer for 'preferences_pages' contribution. """ from acme.tetris.plugin.preferences_pages import \ TetrisPreferencesPages return [ TetrisPreferencesPages ] services_offers = List(contributes_to='envisages.service_offers') def _service_offers_default(self): """ Trait initializer for 'service_offers' contribution. """ return [ ServiceOffer(protocol=IGame, factory=self._create_tetris_service, properties={'name':'tetris'}) ] #### Private interface ################################################# def _create_tetris_service(self, **properties): """ Factory method for the Tetris service. """ tetris = Tetris() # This creates the non-Envisage library object. # Hook up the extension point contributions to the library object trait. bind_extension_point(tetris, 'shapes', 'acme.tetris.shapes') # Hook up the preferences to the library object traits. bind_preference(tetris, 'background_color', 'acme.tetris.background_color') bind_preference(tetris, 'foreground_color', 'acme.tetris.foreground_color') return tetris def _start_game(self): """ Starts a Tetris game. """ game = self.application.get_service(IGame, "name == 'tetris'") game.start() envisage-4.1.0/docs/source/envisage_core_documentation/index.rst0000644000175100001440000000050311674464014026136 0ustar ischnellusers00000000000000Envisage Core Documentation ============================================== .. toctree:: :maxdepth: 2 front.rst introduction.rst core.rst extension_points.rst services.rst plugins.rst howto_create_a_plugin.rst message_of_the_day.rst workbench.rst glossary.rst * :ref:`search` envisage-4.1.0/docs/source/envisage_core_documentation/plugins.rst0000644000175100001440000000765011674464014026522 0ustar ischnellusers00000000000000Plugins ======= *Plugins* are used to "deliver" `Extension Points`_, contributions to extension points, and Services_ into an Envisage application. In fact, plugins can be thought of as simply being "delivery trucks" -- they rarely (if ever) do any *real* work themselves. In other words, plugins can do 3 things: 1) Declare extension points 2) Make contributions to extension points (including its own) 3) Create and publish services Plugins are located and managed by the *plugin manager*, and, whilst Envisage is designed such that you can write your own plugin manager, by default, it uses an implementation based on `Python Eggs`_. Creating a Plugin ----------------- All plugins must implement the IPlugin_ interface (an easy way to achieve this is to subclass the base Plugin_ class), and should provide the following "housekeeping" information: - a globally unique identifier (e.g., "acme.motd") This obviously allows Envisage to identify a particular plugin in a sea of other plugins. Technically, this identifier only need be unique within your application, but since the intent is for applications to be able to include plugins from (potentially) all over the world, using the common reverse domain name notation is probably a good idea! - a name This name should be suitable for display to the user. - a doc string! A nice description of the intent and features of your plugin. Here is a snippet from the `acme.motd`_ plugin that is part of the `Message of the Day`_ example:: class MOTDPlugin(Plugin): """ The 'Message of the Day' plugin. When this plugin is started it prints the 'Message of the Day' to stdout. """ #### 'IPlugin' interface ############################################## # The plugin's unique identifier. id = 'acme.motd' # The plugin's name (suitable for displaying to the user). name = 'MOTD' Plugin Lifecycle ---------------- Plugins have a lifecycle in the context of an application. There are currently two key lifecycle methods on the IPlugin_ interface:: def start(self): """ Start the plugin. This method is called by the framework when the application is starting up. If you want to start a plugin manually use:: application.start_plugin(plugin) """ def stop(self): """ Stop the plugin. This method is called by the framework when the application is stopping. If you want to stop a plugin manually use:: application.stop_plugin(plugin) """ When Envisage starts up it calls the start() method of every plugin in the the same order that its iterator returns them in. This depends on the plugin manager being used, but by default this will be either a) the order of the list of plugins that was passed into the application or b) the order of the plugins based on egg dependencies. When the application stops, it calls the stop() method of each plugin in the reverse order that they were started in. .. _`Extension Points`: extension_points.html .. _`Python Eggs`: http://peak.telecommunity.com/DevCenter/PythonEggs .. _Services: services.html .. _acme.motd: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/src/acme.motd/setup.py .. _acme.motd.software_quotes: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/src/acme.motd.software_quotes/setup.py .. _IPlugin: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/enthought/envisage/i_plugin.py .. _`Message of the Day`: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD .. _MOTD: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/src/acme.motd/acme/motd/motd.py .. _MOTDPlugin: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/examples/MOTD/acme.motd/acme/motd/motd_plugin.py .. _Plugin: https://svn.enthought.com/enthought/browser/EnvisageCore/trunk/enthought/envisage/plugin.py envisage-4.1.0/docs/source/envisage_core_documentation/front.rst0000644000175100001440000000331711674464014026165 0ustar ischnellusers00000000000000==================== Front Matter ==================== :Authors: Martin Chilvers :Version: Document Version 1 :Copyright: 2008 Martin Chilvers. All Rights Reserved. Redistribution and use of this document in source and derived forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source or derived format (for example, Portable Document Format or Hypertext Markup Language) must retain the above copyright notice, this list of conditions and the following disclaimer. * Neither the name of Enthought, Inc., nor the names of contributors may be used to endorse or promote products derived from this document without specific prior written permission. THIS DOCUMENT IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. All trademarks and registered trademarks are the property of their respective owners. | Enthought, Inc. | 515 Congress Avenue | Suite 2100 | Austin TX 78701 | 1.512.536.1057 (voice) | 1.512.536.1059 (fax) | http://www.enthought.com | info@enthought.com envisage-4.1.0/docs/source/envisage_core_documentation/workbench.rst0000644000175100001440000000425211674464014027016 0ustar ischnellusers00000000000000Workbench ========= The workbench plugin, found in the envisage.ui.workbench_ package, provides a style of user interface that is often (but not exclusively) found in integrated development environments (IDEs). Note that this does not mean that all of your user interfaces must fit this pattern -- just that if they do, then we have done a lot of the work for you. Workbench user interfaces are based on 3 simple concepts: 1) Views Views are primarily used to present information to the user to help them perform their current task. In an IDE application, views might be: - file tree - class outlines 2) Editors Editors allow the user to manipulate data and objects to perform their current task. Editors are really the focus of users attention with the views used to provide supporting information. Editors are grouped together geographically in what is known as the *editor area*. In an IDE application, editors would contain the source code that a developer is currently working on. 3) Perspectives A perspective is a particular grouping of views (usually around the editor area) that correspond to a user task. For example, in an IDE, I might have the following perspectives: - Coding perspective This is the perspective that the user (in this case a developer) would be in when they are actually writing the code. It might contain views that show the files in the current project, the outline of the current class etc, and the editors would contain the source code that they are actually working on. - Debugging perspective In this perspective, the user would still see the source code in the editors, but the views might show things like breakpoints, variable watches, stack information etc. In keeping with the Envisage philosophy of making code as reuseable as possible, the workbench plugin is just a thin layer over the PyFace Workbench widget to allow views, editors and perspectives to be contributed via plugins. .. toctree:: :maxdepth: 2 preferences.rst .. _envisage.ui.workbench: https://svn.enthought.com/enthought/browser/EnvisagePlugins/trunk/enthought/envisage/ui/workbench/api.py envisage-4.1.0/docs/Makefile0000644000175100001440000000607411674464014016704 0ustar ischnellusers00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/metasci.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/metasci.qhc" latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt."