
    g
fb                     v    d Z dZdZdZdZdZddlmZ ddlm	Z	 dd	l
mZ dd
lmZ  G d dej                        Zy)zCommonly-required utility methods needed by -- and potentially
   customized by -- application and toolkit scripts. They have
   been pulled out from the scripts because certain scripts had
   gotten way too large as a result of including these methods.z$Id$z
$Revision$z$Date$z#Copyright (c) 2010 Joanmarie Diggs.LGPL    N)AXComponent)AXObject)AXUtilitiesc                   $    e Zd Zd Z	 	 ddZd Zy)	Utilitiesc                 D    t         j                  j                  | |       y)zCreates an instance of the Utilities class.

        Arguments:
        - script: the script with which this instance is associated.
        N)script_utilitiesr   __init__)selfscripts     [/usr/lib/python3/dist-packages/orca/scripts/toolkits/J2SE-access-bridge/script_utilities.pyr   zUtilities.__init__,   s     	""++D&9    c                    ||k(  ry||y|s,t        j                  |      t        j                  |      k7  ryt        j                  |      t        j                  |      k7  ryt        j                  |      r,t        j                  |      rt        j                  ||      ry|}|}t        j                  |      rt        j                  |      rt        j                  |      t        j                  |      k7  ryt        j                  |      }t        j                  |      }t        j                  |      rt        j                  |      r|r|r||k(  ryt        j                  j                  | |||||      S )zCompares two objects to determine if they are functionally
        the same object. This is needed because some applications and
        toolkits kill and replace accessibles.TF)r   get_nameget_child_countr   is_labelr   objects_have_same_rectget_index_in_parent
get_parentr
   r   isSameObject)r   obj1obj2comparePathsignoreNamesignoreDescriptionsparent1parent2s           r   r   zUtilities.isSameObject;   sN    4<<4<x006(:K:KD:QQ##D)X-E-Ed-KK %+*>*>t*D11$=
 ""7+0D0DW0M++G48T8TU\8]]))'2G))'2G	 ""7+0D0DW0M
 w7g#5))66$lK9KM 	Mr   c                    |}|r;t        j                  |      s&| j                  | j                  j                  |      }|s t
        j                  j                  | |      S d}|rct        j                  |      st        j                  |      r0t        j                  |      r|dz  }t        j                  |      }n	 |dz
  S |rc|dz
  S )zDetermines the node level of this object if it is in a tree
        relation, with 0 being the top level node.  If this object is
        not in a tree relation, then -1 will be returned.

        Arguments:
        -obj: the Accessible object
        r      )r   is_validfindReplicant_scriptlastDescendantChangedSourcer
   r   	nodeLevelr   is_expandableis_collapsed
is_visibler   )r   objnewObjcounts       r   r%   zUtilities.nodeLevelb   s     (++F3''(P(PRUVF#--77cBB((0K4L4LV4T))&1QJE!,,V4qy  qyr   N)FFT)__name__
__module____qualname__r   r   r%    r   r   r   r   *   s    : HM(,%MNr   r   )__doc____id____version____date____copyright____license__orca.script_utilitiesr
   orca.ax_componentr   orca.ax_objectr   orca.ax_utilitiesr   r   r/   r   r   <module>r:      sG   (C
 
5 0 ) # )Q ** Qr   