<commit_before>""" The 'View' menu """


# Standard library imports.
import logging

# Enthought library imports.
from enthought.pyface.action.api import Group, MenuManager
from enthought.traits.api import Any, Bool, Instance, List, Str, Unicode
from enthought.traits.api import on_trait_change

# Local imports.
from perspective_menu_manager import PerspectiveMenuManager
from show_view_action import ShowViewAction
from toggle_view_visibility_action import ToggleViewVisibilityAction


# Logging.
logger = logging.getLogger(__name__)


class ViewMenuManager(MenuManager):
    """ The 'View' menu.

    By default, this menu is displayed on the main menu bar.

    """

    #### 'ActionManager' interface ############################################

    # All of the groups in the manager.
    groups = List(Group)

    # The manager's unique identifier (if it has one).
    id = Str('View')

    #### 'MenuManager' interface ##############################################

    # The menu manager's name (if the manager is a sub-menu, this is what its
    # label will be).
    name = Unicode('&View')

    #### 'ViewMenuManager' interface ##########################################

    # Should the perspective menu be shown?
    show_perspective_menu = Bool(True)
    
    # The workbench window that the menu is part of.
    window = Instance('enthought.pyface.workbench.api.WorkbenchWindow')

    #### 'Private' interface ##################################################

    # The group containing the view hide/show actions.
    _view_group = Any
    
    ###########################################################################
    # 'ActionManager' interface.
    ###########################################################################

    def _groups_default(self):
        """ Trait initializer. """

        groups = []
        
        # Add a group containing the perspective menu (if requested).
        if self.show_perspective_menu and len(self.window.perspectives) > 0:
            groups.append(Group(PerspectiveMenuManager(window=self.window)))
            
        # 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 an 'Other...' item that will launch a dialog
        # to allow the user to choose a view to show.
        groups.append(self._create_other_group(self.window))

        return groups
    
    ###########################################################################
    # 'ViewMenuManager' interface.
    ###########################################################################

    @on_trait_change('window.active_perspective,window.active_part')
    def refresh(self):
        """ Refreshes the checked state of the actions in the menu. """
<commit_msg>- refresh the view menu when views are added to the window dynamically<commit_after>""" The 'View' menu """


# Standard library imports.
import logging

# Enthought library imports.
from enthought.pyface.action.api import Group, MenuManager
from enthought.traits.api import Any, Bool, Instance, List, Str, Unicode
from enthought.traits.api import on_trait_change

# Local imports.
from perspective_menu_manager import PerspectiveMenuManager
from show_view_action import ShowViewAction
from toggle_view_visibility_action import ToggleViewVisibilityAction


# Logging.
logger = logging.getLogger(__name__)


class ViewMenuManager(MenuManager):
    """ The 'View' menu.

    By default, this menu is displayed on the main menu bar.

    """

    #### 'ActionManager' interface ############################################

    # All of the groups in the manager.
    groups = List(Group)

    # The manager's unique identifier (if it has one).
    id = Str('View')

    #### 'MenuManager' interface ##############################################

    # The menu manager's name (if the manager is a sub-menu, this is what its
    # label will be).
    name = Unicode('&View')

    #### 'ViewMenuManager' interface ##########################################

    # Should the perspective menu be shown?
    show_perspective_menu = Bool(True)
    
    # The workbench window that the menu is part of.
    window = Instance('enthought.pyface.workbench.api.WorkbenchWindow')

    #### 'Private' interface ##################################################

    # The group containing the view hide/show actions.
    _view_group = Any
    
    ###########################################################################
    # 'ActionManager' interface.
    ###########################################################################

    def _groups_default(self):
        """ Trait initializer. """

        groups = []
        
        # Add a group containing the perspective menu (if requested).
        if self.show_perspective_menu and len(self.window.perspectives) > 0:
            groups.append(Group(PerspectiveMenuManager(window=self.window)))
            
        # 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 an 'Other...' item that will launch a dialog
        # to allow the user to choose a view to show.
        groups.append(self._create_other_group(self.window))

        return groups
    
    ###########################################################################
    # 'ViewMenuManager' interface.
    ###########################################################################

    @on_trait_change(
        'window.active_perspective,window.active_part,'
        'window.views,window.views_items'
    )
    def refresh(self):
        """ Refreshes the checked state of the actions in the menu. """

{'fraction_non_alphanumeric': 0.23910058359079986, 'fraction_numerical': 0.00034328870580157915, 'mean_word_length': 3.7489812550937245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '412045', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1386, 'n_words': 438}