Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
##########################################################################
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]
##########################################################################
# 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.
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
##########################################################################
# 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)
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.
###########################################################################
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.
###########################################################################
""" 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. """
def is_node_for(self, obj):
""" Return whether this is the node that handles a specified object.
"""
return IApplication(obj, Undefined) is obj
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,