コード例 #1
0
    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)]
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
ファイル: actions.py プロジェクト: fagan2888/etsdevtools
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
コード例 #6
0
    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)
コード例 #7
0
    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)
コード例 #8
0
    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)
コード例 #9
0
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",
        ),
    ]
コード例 #10
0
ファイル: test_action_set.py プロジェクト: enthought/envisage
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"]
コード例 #11
0
ファイル: test_action_set.py プロジェクト: skailasa/envisage
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']
コード例 #12
0
    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
コード例 #13
0
    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)
コード例 #14
0
    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)
コード例 #15
0
    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
コード例 #16
0
    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)]
コード例 #17
0
    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)
コード例 #18
0
    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'.
        with self.assertRaises(ValueError):
            builder.create_menu_bar_manager("MenuBar")
コード例 #19
0
    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'.
        with self.assertRaises(ValueError):
            builder.create_menu_bar_manager("MenuBar")
コード例 #20
0
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'),
    ]
コード例 #21
0
)

modules_group = Group(
    id='ModulesGroup',
    path='MenuBar/VisualizeMenu/ModulesMenu',
)

filters_group = Group(
    id='FiltersGroup',
    path='MenuBar/VisualizeMenu/FiltersMenu',
)
########################################
# Menus

open_menu = Menu(id="LoadDataMenu",
                 name="&Load data",
                 path='MenuBar/File',
                 group='MayaviFileGroup')

visualize_menu = Menu(id="VisualizeMenu",
                      name="Visuali&ze",
                      path="MenuBar",
                      before="View")

modules_menu = Menu(
    id="ModulesMenu",
    name="&Modules",
    path="MenuBar/VisualizeMenu",
)

filters_menu = Menu(
    id="FiltersMenu",
コード例 #22
0
modules_group = Group(
    id='ModulesGroup',
    path='MenuBar/VisualizeMenu/ModulesMenu',
)

filters_group = Group(
    id='FiltersGroup',
    path='MenuBar/VisualizeMenu/FiltersMenu',
)

########################################
# Menus

open_menu = Menu(id="LoadDataMenu",
                 name="&Load data",
                 path='MenuBar/File',
                 group='ConnectomeFileGroup')

visualize_menu = Menu(id="VisualizeMenu",
                      name="Visuali&ze",
                      path="MenuBar",
                      before="View")

modules_menu = Menu(
    id="ModulesMenu",
    name="&Modules",
    path="MenuBar/VisualizeMenu",
)

filters_menu = Menu(
    id="FiltersMenu",
コード例 #23
0
#### 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(
    id='SaveSceneAs', name="Sa&ve Scene As",
    path='MenuBar/File', group='TVTKSceneGroup', after='New'
)

#### Actions ##################################################################

new_scene = Action(
    class_name = PKG + '.actions.NewScene',
    path       = 'MenuBar/File/New', group='additions'
)

#### Save actions ####
コード例 #24
0
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"]
コード例 #25
0
    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)
コード例 #26
0
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']