def get_action_sets(**traits): workbench_action_set = WorkbenchActionSet( id=ID + '.tools.workbench_action_set', name='Enthought developer tools plugins workbench actions', menus=[ Menu( groups=[Group(id='enthought_developer_ToolsGroup')], id='enthought_developer_ToolsMenu', path='MenuBar', name='Developer Tools', before='Help', ), Menu(groups=[Group(id='enthought_developer_DebugGroup')], id='enthought_developer_DebugMenu', path='MenuBar/enthought_developer_ToolsMenu', name='Debug'), ], actions=[ Action(name='Invoke FBI', tooltip='Invoke the FBI debugger', class_name=ID + '.action.actions.InvokeFBIAction', id='etsdevtools.developer.helper.fbi.fbi_invoker', path='MenuBar/enthought_developer_ToolsMenu/' 'enthought_developer_DebugMenu'), Action(name='Restore break points', tooltip='Restores all previously saved break points', class_name=ID + '.action.actions.RestoreBPAction', id='etsdevtools.developer.helper.fbi.break_points.restore', path='MenuBar/enthought_developer_ToolsMenu/' 'enthought_developer_DebugMenu'), ]) return workbench_action_set
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)
def test_duplicate_menu(self): """ duplicate menu """ action_sets = [ ActionSet(menus=[ Menu( name="&File", path="MenuBar", groups=[ Group(id="NewGroup", path="MenuBar/File"), Group(id="ExitGroup", path="MenuBar/File"), ], ), ], ), ActionSet(menus=[ Menu( name="&File", path="MenuBar", groups=[ Group(id="ExtraGroup", 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 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)
def _help_action_sets_default(self): """ Returns a list containing an action set class whose **actions** correspond to the help docs in the help_docs extension point. """ extension_point_mapping = { DOCS_MENU: self.help_docs, EXAMPLES_MENU: self.help_examples, DEMOS_MENU: self.help_demos, DOWNLOADS_MENU: self.help_downloads } # Construct traits for the action set ns = { 'id': 'apptools.help.help_plugin.help_action_set', 'name': 'Help Plugin ActionSet', 'groups': [Group(id=DOCS_GROUP, before='AboutGroup', path=HELP_MENU)] } for (menu_name, items) in extension_point_mapping.items(): if len(items) > 0: menu = Menu(name=menu_name, class_name=PKG + '.help_submenu_manager:%sMenuManager' % menu_name) if menu_name in self.menus: menu.path = 'MenuBar' menu.before = 'Help' else: menu.path = HELP_MENU menu.group = DOCS_GROUP # Append the menu. ns.setdefault('menus', []).append(menu) return [new.classobj('SPLHelpActionSet', (ActionSet, ), ns)]
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", ), ]
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)
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"]
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']
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'. with self.assertRaises(ValueError): builder.create_menu_bar_manager("MenuBar")
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)
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." ###########################################################################
# Partly added actions from mayavi_ui_action_set.py # Author: Prabhu Ramachandran <prabhu [at] aero . iitb . ac . in> # Copyright (c) 2008, Enthought, Inc. # License: BSD Style. # Enthought library imports. from envisage.ui.action.api import Action, Group, Menu, ToolBar from envisage.ui.workbench.api import WorkbenchActionSet from mayavi.core.registry import registry ######################################## # Groups file_group = Group(id='ConnectomeFileGroup', path='MenuBar/File', before='ExitGroup') visualize_group = Group( id='VisualizeGroup', path='MenuBar/VisualizeMenu', ) modules_group = Group( id='ModulesGroup', path='MenuBar/VisualizeMenu/ModulesMenu', ) filters_group = Group( id='FiltersGroup', path='MenuBar/VisualizeMenu/FiltersMenu',
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.
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"]
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']
# Copyright (c) 2006, Enthought, Inc. # License: BSD Style. # Enthought library imports. from envisage.ui.action.api import Action, ActionSet, Group, Menu # This package PKG = '.'.join(__name__.split('.')[:-1]) #### Groups ################################################################### scene_group = Group( id='TVTKSceneGroup', path='MenuBar/File', before='ExitGroup' ) view_group = Group( id='TVTKViewGroup', path='MenuBar/Tools', before='PreferencesGroup' ) #### Menus #################################################################### new_menu = Menu( name='&New', path='MenuBar/File', group='TVTKSceneGroup' ) save_scene_as_menu = Menu(
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)