<s> """<STR_LIT>""" <EOL> from envisage . ui . action . api import ActionSet <EOL> from traits . api import Instance , List , Str <EOL> class WorkbenchActionSet ( ActionSet ) : <EOL> """<STR_LIT>""" <EOL> enabled_for_perspectives = List ( Str ) <EOL> visible_for_perspectives = List ( Str ) <EOL> enabled_for_views = List ( Str ) <EOL> visible_for_views = List ( Str ) <EOL> window = Instance ( '<STR_LIT>' ) <EOL> def _enabled_changed ( self , trait_name , old , new ) : <EOL> """<STR_LIT>""" <EOL> if self . window is not None : <EOL> self . _update_tool_bars ( self . window , '<STR_LIT>' , new ) <EOL> self . _update_actions ( self . window , '<STR_LIT>' , new ) <EOL> return <EOL> def _visible_changed ( self , trait_name , old , new ) : <EOL> """<STR_LIT>""" <EOL> if self . window is not None : <EOL> self . _update_tool_bars ( self . window , '<STR_LIT>' , new ) <EOL> self . _update_actions ( self . window , '<STR_LIT>' , new ) <EOL> return <EOL> def initialize ( self ) : <EOL> """<STR_LIT>""" <EOL> self . window . on_trait_change ( self . _refresh , '<STR_LIT>' ) <EOL> self . window . on_trait_change ( self . _refresh , '<STR_LIT>' ) <EOL> self . window . on_trait_change ( self . _refresh , '<STR_LIT>' ) <EOL> return <EOL> def _window_changed ( self ) : <EOL> """<STR_LIT>""" <EOL> self . initialize ( ) <EOL> return <EOL> def _refresh ( self ) : <EOL> """<STR_LIT>""" <EOL> window = self . window <EOL> if len ( self . enabled_for_perspectives ) > <NUM_LIT:0> : <EOL> self . enabled = window is not None and window . active_perspective is not None and window . active_perspective . id in self . enabled_for_perspectives <EOL> if len ( self . visible_for_perspectives ) > <NUM_LIT:0> : <EOL> self . visible = window is not None and window . active_perspective is not None and window . active_perspective . id in self . visible_for_perspectives <EOL> if len ( self . enabled_for_views ) > <NUM_LIT:0> : <EOL> self . enabled = window is not None and window . active_part is not None and window . active_part . id in self . enabled_for_views <EOL> if len ( self . visible_for_views ) > <NUM_LIT:0> : <EOL> self . visible = window is not None and window . active_part is not None and window . active_part . id in self . visible_for_views <EOL> return <EOL> def _update_actions ( self , window , trait_name , value ) : <EOL> """<STR_LIT>""" <EOL> def visitor ( item ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( item , '<STR_LIT>' ) : <EOL> if item . _action_set_ is self : <EOL> setattr ( item , trait_name , value ) <EOL> return <EOL> window . menu_bar_manager . walk ( visitor ) <EOL> for tool_bar_manager in window . tool_bar_managers : <EOL> tool_bar_manager . walk ( visitor ) <EOL> return <EOL> def _update_tool_bars ( self , window , trait_name , value ) : <EOL> """<STR_LIT>""" <EOL> for tool_bar_manager in window . tool_bar_managers : <EOL> if tool_bar_manager . _action_set_ is self : <EOL> setattr ( tool_bar_manager , trait_name , value ) <EOL> return </s>
