def _create_other_group(self, window): """ Creates a group containing the 'Other...' action. """ group = Group() group.append(ShowViewAction(name='Other...', window=window)) return group
def _create_perspective_group(self, window): """ Create the actions that switch to specific perspectives. """ # fixme: Not sure if alphabetic sorting is appropriate in all cases, # but it will do for now! perspectives = window.perspectives[:] perspectives.sort(lambda x, y: cmp(x.name, y.name)) # For each perspective, create an action that sets the active # perspective to it. group = Group() for perspective in perspectives: group.append(SetActivePerspectiveAction(perspective=perspective, window=window)) return group
def _create_perspective_group(self, window): """ Create the actions that switch to specific perspectives. """ # fixme: Not sure if alphabetic sorting is appropriate in all cases, # but it will do for now! perspectives = window.perspectives[:] perspectives.sort(lambda x, y: cmp(x.name, y.name)) # For each perspective, create an action that sets the active # perspective to it. group = Group() for perspective in perspectives: group.append( SetActivePerspectiveAction(perspective=perspective, window=window)) return group
def get_context_menu(self, node): """ Returns the context menu for a node. """ sat = Group(id='SystemActionsTop') nsa = Group(id='NodeSpecificActions') sab = Group(id='SystemActionsBottom') # The 'New' menu. new_actions = self.get_new_actions(node) if new_actions is not None and len(new_actions) > 0: sat.append( MenuManager( name = 'New', *new_actions ), ) # Node-specific actions. actions = self.get_actions(node) if actions is not None and len(actions) > 0: for item in actions: nsa.append(item) # System actions (actions available on ALL nodes). system_actions = self.node_manager.system_actions if len(system_actions) > 0: for item in system_actions: sab.append(item) context_menu = MenuManager(sat, nsa, sab) context_menu.dump() return context_menu
def get_context_menu(self, node): """ Returns the context menu for a node. """ sat = Group(id='SystemActionsTop') nsa = Group(id='NodeSpecificActions') sab = Group(id='SystemActionsBottom') # The 'New' menu. new_actions = self.get_new_actions(node) if new_actions is not None and len(new_actions) > 0: sat.append(MenuManager(name='New', *new_actions), ) # Node-specific actions. actions = self.get_actions(node) if actions is not None and len(actions) > 0: for item in actions: nsa.append(item) # System actions (actions available on ALL nodes). system_actions = self.node_manager.system_actions if len(system_actions) > 0: for item in system_actions: sab.append(item) context_menu = MenuManager(sat, nsa, sab) context_menu.dump() return context_menu
def __init__(self, **traits): """Initialise the object.""" pm = get_permissions_manager() # Put them in a group so we can optionally append (because the PyFace # API doesn't do what you expect with append()). group = Group() group.append(LoginAction()) for act in pm.user_manager.user_actions: group.append(act) group.append(LogoutAction()) for act in pm.user_manager.management_actions: group.append(act) for act in pm.policy_manager.management_actions: group.append(act) super(UserMenuManager, self).__init__(group, **traits)
def _groups_default(self): """ Trait initialiser. """ # groups = super(PylonViewMenuManager, self)._groups_default() groups = [] new_group = Group(id="NewGroup") new_group.append(NewWindowAction(window=self.window)) # FIXME: Changing the enabled trait of the NewEditorAction causes barf # new_group.append(NewEditorAction(window=self.window)) # Insert a group for new part actions groups.append(new_group) # Add a group for view and perspective sub menus submenu_group = Group(id="SubMenuGroup") # Add the perspective menu (if requested). if self.show_perspective_menu and len(self.window.perspectives) > 0: perspective_menu = PerspectiveMenuManager(window=self.window) submenu_group.append(perspective_menu) # TODO: Create a ViewMenuManager with a selection of views view_submenu = MenuManager(self._create_other_group(self.window), name="Show View") submenu_group.append(view_submenu) groups.append(submenu_group) # Add a group containing a 'toggler' for all visible views. self._view_group = self._create_view_group(self.window) groups.append(self._view_group) # Add a group containing the preferences action groups.append( Group(PreferencesAction(window=self.window)) ) return groups