<commit_before>#------------------------------------------------------------------------------
#
#  Copyright (c) 2005, Enthought, Inc.
#  All rights reserved.
#  
#  This software is provided without warranty under the terms of the BSD
#  license included in enthought/LICENSE.txt and may be redistributed only
#  under the conditions described in the aforementioned license.  The license
#  is also available online at http://www.enthought.com/licenses/BSD.txt
#  Thanks for using Enthought open source!
#  
#  Author: <NAME>
#  Date:   12/03/2004
#
#------------------------------------------------------------------------------

""" Defines the tree node descriptor used by the tree editor and tree editor 
factory classes.
"""

#-------------------------------------------------------------------------------
#  Imports:
#-------------------------------------------------------------------------------

import copy

from inspect \
    import stack

from enthought.traits.api \
    import HasTraits, HasPrivateTraits, Str, List, Callable, Instance, Any, \
           true, false
           
from enthought.traits.trait_base \
    import SequenceTypes, get_resource_path
    
from enthought.traits.ui.view \
    import View

#-------------------------------------------------------------------------------
#  'TreeNode' class:
#-------------------------------------------------------------------------------

class TreeNode ( HasPrivateTraits ):
    """ Represents a tree node. Used by the tree editor and tree editor factory
    classes.
    """
    
    #---------------------------------------------------------------------------
    #  Trait definitions:
    #---------------------------------------------------------------------------
    
    # Name of trait containing children ('' = Leaf)
    children = Str
    
    # Name of trait containing label ('=label' = constant)
    label = Str
    
    # Name to use for a new instance
    name = Str  
    
    # Can the object's children be renamed?
    rename = true
    
    # Can the object be renamed?
    rename_me = true
    
    # Can the object's children be copied?
    copy = true
    
    # Can the object's children be deleted?
    delete = true
    
    # Can the object be deleted (if its parent allows it)?
    delete_me = true
    
    # Can children be inserted (vs. appended)?
    insert = true
    
    # Should tree nodes be automatically opened (expanded)?
    auto_open = false
    
    # Automatically close sibling tree nodes?
    auto_close = false
    
    # List of object classes than can be added or copied
    add = List( Any )
    
    # List of object classes that can be moved
    move = List( Any )
    
    # List of object classes that the node applies to
    node_for = List( Any )
    
    # Function for formatting the label
    formatter = Callable
    
    # Function for handling selecting an object
    on_select = Callable
    
    # Function for handling double-clicking an object
    on_dclick = Callable
    
    # View to use for editing the object
    view = Instance( View )
    
    # Right-click context menu
    menu = Any
    
    # Name of leaf item icon
    icon_item = Str( '<item>' )
    
    # Name of group item icon
    icon_group = Str( '<group>' )
    
    # Name of opened group item icon
    icon_open = Str( '<open>' )
    
    # Resource path used to locate the node icon
    icon_path = Str   
    
    # fixme: The 'menu' trait should really be defined as:
    #        Instance( 'enthought.traits.ui.menu.MenuBar' ), but it doesn't work
    #        right currently.
    
    #---------------------------------------------------------------------------
    #  Initializes the object:  <commit_msg>[Qt] Extended the TreeNode 'menu' trait to support disabling the node's right-click context menu by specifying False as the value of the trait.<commit_after>#------------------------------------------------------------------------------
#
#  Copyright (c) 2005, Enthought, Inc.
#  All rights reserved.
#  
#  This software is provided without warranty under the terms of the BSD
#  license included in enthought/LICENSE.txt and may be redistributed only
#  under the conditions described in the aforementioned license.  The license
#  is also available online at http://www.enthought.com/licenses/BSD.txt
#  Thanks for using Enthought open source!
#  
#  Author: <NAME>
#  Date:   12/03/2004
#
#------------------------------------------------------------------------------

""" Defines the tree node descriptor used by the tree editor and tree editor 
factory classes.
"""

#-------------------------------------------------------------------------------
#  Imports:
#-------------------------------------------------------------------------------

import copy

from inspect \
    import stack

from enthought.traits.api \
    import HasTraits, HasPrivateTraits, Str, List, Callable, Instance, Any, \
           true, false
           
from enthought.traits.trait_base \
    import SequenceTypes, get_resource_path
    
from enthought.traits.ui.view \
    import View

#-------------------------------------------------------------------------------
#  'TreeNode' class:
#-------------------------------------------------------------------------------

class TreeNode ( HasPrivateTraits ):
    """ Represents a tree node. Used by the tree editor and tree editor factory
    classes.
    """
    
    #---------------------------------------------------------------------------
    #  Trait definitions:
    #---------------------------------------------------------------------------
    
    # Name of trait containing children ('' = Leaf)
    children = Str
    
    # Name of trait containing label ('=label' = constant)
    label = Str
    
    # Name to use for a new instance
    name = Str  
    
    # Can the object's children be renamed?
    rename = true
    
    # Can the object be renamed?
    rename_me = true
    
    # Can the object's children be copied?
    copy = true
    
    # Can the object's children be deleted?
    delete = true
    
    # Can the object be deleted (if its parent allows it)?
    delete_me = true
    
    # Can children be inserted (vs. appended)?
    insert = true
    
    # Should tree nodes be automatically opened (expanded)?
    auto_open = false
    
    # Automatically close sibling tree nodes?
    auto_close = false
    
    # List of object classes than can be added or copied
    add = List( Any )
    
    # List of object classes that can be moved
    move = List( Any )
    
    # List of object classes that the node applies to
    node_for = List( Any )
    
    # Function for formatting the label
    formatter = Callable
    
    # Function for handling selecting an object
    on_select = Callable
    
    # Function for handling double-clicking an object
    on_dclick = Callable
    
    # View to use for editing the object
    view = Instance( View )
    
    # Right-click context menu. The value can either be:
    # - Instance( Menu ): Use this menu as the context menu
    # - None: Use the default context menu
    # - False: Do not display a context menu
    menu = Any
    
    # Name of leaf item icon
    icon_item = Str( '<item>' )
    
    # Name of group item icon
    icon_group = Str( '<group>' )
    
    # Name of opened group item icon
    icon_open = Str( '<open>' )
    
    # Resource path used to locate the node icon
    icon_path = Str   
    
    # fixme: The 'menu' trait should really be defined as:
    #        Instance( 'enthought.traits.ui.menu.MenuBar' ), but it doesn't work
    #        right currently.
    
    #---------------------------------------------------------------------------
    #  Initializes the object:  
{'fraction_non_alphanumeric': 0.23890608875129, 'fraction_numerical': 0.0030959752321981426, 'mean_word_length': 1.3359445616149443, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1663818', 'n_tokens_mistral': 1902, 'n_tokens_neox': 1845, 'n_words': 733}