com.rational.test.ft.domain.java.jfc

Class JTreeProxy

  • All Implemented Interfaces:
    com.rational.test.ft.domain.IChannelObject, com.rational.test.ft.domain.IDataDriven, com.rational.test.ft.domain.IProxyBase, IPropertyFilter, ISetParent, com.rational.test.ft.object.interfaces.IGraphical, com.rational.test.ft.object.interfaces.IGraphicalSubitem, com.rational.test.ft.object.interfaces.ISubitem


    public class JTreeProxy
    extends JScrollPaneProxy
    implements com.rational.test.ft.object.interfaces.ISubitem
    Proxy for the javax.swing.JTree class.
    • TestObject interface:
      GuiSubitemTestObject
    • Supported Test Data Types:
      TypeDesciptionData Class
      tree tree Hierarchy ITestDataTree
      selected selected tree Hierarchy ITestDataTree


    • Default Recognition Properties:
      PropertyUsage
      .classThe Java full class name of the test object.
      .classIndexThe zero-based index of the class relative to the immediate parent in the object map.
      .priorLabelThe text of a preceding label. Suppressed if there is no preceding label.
      accessibleContext.accessibleNameA programmatically defined name for the component.
      nameThe name property, suppressed if default formatted (default form = className+count).
      toolTipTextThe text from the associated tool tip, omitted if there is no associated tool tip.

    • Supported Subitems:
      SubitemUsage
      List The ordered set of Text, Index and PLUS_MINUS subitems that define a path to a child tree node. Most commonly appears in scripts as atPath specifications.
      Row Defines the tree node via Row specification. The row must be defined by Text or Index subitems.
      Text Defines the element with the specified visible text.
      Index Defines the element at the specified zero-based index.

    • Constructor Detail

      • JTreeProxy

        public JTreeProxy(java.lang.Object theObjectInTheSUT)
        This sole constructor for all proxy objects sets the SUT object as a member variable for the proxy. All interactions with the supplied object are performed through this class.
    • Method Detail

      • getRole

        public java.lang.String getRole()
        Returns TestObjectRole.ROLE_TREE.
        Overrides:
        getRole in class JScrollPaneProxy
        Returns:
        A brief type name that describes the role this object plays in the UI.
        Since:
        RFT1.0
      • getSubitem

        public java.lang.Object getSubitem(com.rational.test.ft.script.Subitem subitem)
        Returns an object that represents the specified subitem in the associated test object. SubitemNotFoundException will be thrown if the specified subitem is invalid relative to the associated test object. null may be returned if the subitem does not have an object association that can be returned.
        Specified by:
        getSubitem in interface com.rational.test.ft.object.interfaces.IGraphicalSubitem
        Overrides:
        getSubitem in class JScrollPaneProxy
        Parameters:
        subitem - The subitem to fetch an object for.
        Returns:
        An object representation of the subitem.
      • scrollPathToVisible

        protected void scrollPathToVisible(javax.swing.tree.TreePath path)
        Makes sure all the path components in path are expanded (except for the last path component) and scrolls so that the node identified by the path is displayed. Only works when this JTree is contained in a JScrollPane.
        Parameters:
        path - the TreePath identifying the node to bring into view
      • getTreePath

        protected javax.swing.tree.TreePath getTreePath(java.awt.Point pt)
        Returns the closest path for the node at the specified point.
        Parameters:
        pt - the screen point relative to the JTree
        Returns:
        the TreePath for the node near that location
      • getTreePath

        protected javax.swing.tree.TreePath getTreePath(java.lang.Object node)
      • getTreePath

        protected javax.swing.tree.TreePath getTreePath(com.rational.test.ft.script.Subitem subitem)
      • getPathBounds

        protected java.awt.Rectangle getPathBounds(javax.swing.tree.TreePath path)
        Returns the Rectangle that the specified node will be drawn into. Returns null if any component in the path is hidden (under a collapsed parent).
        Parameters:
        path - - the TreePath identifying the node
        Returns:
        the Rectangle the node is drawn in, or null
      • getRowBounds

        protected java.awt.Rectangle getRowBounds(int row)
        Returns the Rectangle that the specified node will be drawn into. Returns null if any component in the path is hidden (under a collapsed parent).
        Parameters:
        path - - the TreePath identifying the node
        Returns:
        the Rectangle the node is drawn in, or null
      • getPointToRow

        protected java.awt.Point getPointToRow(javax.swing.tree.TreePath treePath,
                                               java.awt.Point pt)
      • isPointInNode

        protected boolean isPointInNode(java.awt.Point pt,
                                        javax.swing.tree.TreePath path)
        Returns true if the specified point is inside the node identified by the paticular path.
        Parameters:
        pt - - the Point
        path - - the TreePath identifying the node
        Returns:
        true if the point is inside the node or false
      • isPointInRow

        protected boolean isPointInRow(java.awt.Point pt,
                                       javax.swing.tree.TreePath path)
        Returns true if the specified point is inside the row identified by the paticular path.
        Parameters:
        pt - - the Point
        path - - the TreePath identifying the row
        Returns:
        true if the point is inside the node or false
      • getState

        protected com.rational.test.ft.script.Action getState(java.lang.Object node)
        Returns action state (expanded/selected/collapsed) of given node.
        Parameters:
        node - - the node
        Returns:
        action state of the node
      • getModel

        protected javax.swing.tree.TreeModel getModel()
        Returns the TreeModel that is providing the data.
        Returns:
        the TreeModel that is providing the data
      • getRoot

        protected java.lang.Object getRoot()
        This method is used to access the root nodes of the Tree component being queried. The "Object" returned will be passed to other methods to determine state information relative to the root node in the tree.
        Returns:
        The root node in the tree structure, or null if no root is available for this component.
      • getLastPathComponent

        protected java.lang.Object getLastPathComponent(java.lang.Object node)
        Returns the last component of this path.
        Returns:
        the Object at the end of the path
      • getChildCount

        protected int getChildCount(java.lang.Object node)
        This method is used to compute the number of child nodes available relative to the supplied node.
        Parameters:
        node - The node for which the child count is to be computed relative to.
        Returns:
        The number of child nodes available relative to the supplied node.
      • getIndexOfChild

        protected int getIndexOfChild(java.lang.Object child)
        This method is used to compute the index of child in parent
        Parameters:
        node - The node for which the child count is to be computed relative to.
        Returns:
        The number of child nodes available relative to the supplied node.
      • getChild

        protected java.lang.Object getChild(java.lang.Object parentNode,
                                            int nChildIndex)
        Returns the child of parent at index nChildIndex in the parent's child array.
        Parameters:
        parentNode - The parent node for which the Nth child should be computed and returned.
        nChildIndex - The zero based child index.
        Returns:
        The Nth child of the supplied parentNode object or null if there are not nChildIndex child nodes available relative to the parentNode.
      • isExpanded

        protected boolean isExpanded(java.lang.Object node)
        true is returned if the child nodes of the supplied node are visible. false is returned if the child nodes are not visible or the node does not have any child nodes.
        Parameters:
        node - The node to check to see if the child nodes are visible.
        Returns:
        true if child node(s) are visible.
      • isCollapsed

        protected boolean isCollapsed(java.lang.Object node)
        true is returned if the child nodes of the supplied node are not visible. false is returned if the child nodes are visible
        Parameters:
        node - The node to check to see if the child nodes are visible.
        Returns:
        true if this node is visible and the child nodes are nonvisible.
      • isSelected

        protected boolean isSelected(java.lang.Object node)
        true is returned if the supplied node is selected and false if it is not selected.
        Parameters:
        node - The node to check to see if the node is selected.
        Returns:
        true if the node is selected.
      • isVisible

        protected boolean isVisible(java.lang.Object node)
        Returns true if the supplied node is visible and false if it is not visible. This method is used in the VisibleNodes Object Data Verification Point test. As the nodes that make up the tree are traversed this method is called to determine if a particular node should be added to the verification point display.
        Parameters:
        node - The node to check to see if the node is visible.
        Returns:
        true if the node is visible.
      • isRootVisible

        protected boolean isRootVisible()
        Returns true<\b> if the root node of the tree is displayed.
        Returns:
        true<\b> if the root node of the tree is displayed
      • isEditable

        protected boolean isEditable()
        true is returned if the tree component being evaluated is directly editable. Node relative coordinates need to be saved in the action paramter of the JavaTree command if they are directly editable.
        Returns:
        true if the tree is editable.
      • allowsMultipleSelections

        protected boolean allowsMultipleSelections()
        true is returned if the tree component being evaluated allows multiple nodes to be selected at the same time. false is returned if only one node may be selected at any time.
        Returns:
        true if the tree allows multiple nodes to be selected at the same time.
      • expandNode

        protected void expandNode(java.lang.Object node)
        Set the state of the specified node to be expanded (such that the child nodes are visible). This command will be used during playback of a script that expanded the same node when the script was recorded. If the specified node is already expanded this command is a no-op.
        Parameters:
        node - The node that is to be expanded.
      • collapseNode

        protected void collapseNode(java.lang.Object node)
        Set the state of the specified node to be collapsed (such that the child nodes are not visible).
        Parameters:
        node - The node that is to be collapsed.
      • selectNode

        protected void selectNode(java.lang.Object node)
        Set the state of the specified node to be selected. If the specified node is already selected this call should be treated as a no-op.
        Parameters:
        node - The node that is to be selected.
      • deselectNode

        protected void deselectNode(java.lang.Object node)
        Set the state of the specified node to not be selected. If the specified node is not selected this call should be treated as a no-op.
        Parameters:
        node - The node that is to be deselected.
      • clearSelection

        protected void clearSelection()
        Clears all selections in the treeview component being evaluated.
      • getSelectedNodes

        protected java.lang.Object[] getSelectedNodes()
        Returns the list of currently selected nodes in the tree being evaluated. If no node is selected then a null object or a zero lengthed array of objects should be returned.
        Returns:
        The list of selected nodes in the tree or null.
      • getTextForNode

        protected java.lang.String getTextForNode(javax.swing.tree.TreePath treePath,
                                                  java.lang.Object node)
        Returns the text of the given node.
        Parameters:
        treePath - the TreePath of the node
        node - the node to get text for
        Returns:
        text of the node or null.
      • getPath

        protected com.rational.test.ft.script.Subitem[] getPath(java.awt.Point pt)
        Returns an array of Subitem representing the treepath at the given point.
        Parameters:
        pt - the screen point relative to the JTree
        Returns:
        array of subitems or null.
      • getRowForPath

        protected int getRowForPath(javax.swing.tree.TreePath treePath)
        Returns the row that displays the node identified by the specified path.
        Parameters:
        treePath - the TreePath identifying a node
        Returns:
        an integer specifying the display row, where 0 is the first row in the display, or -1 if any of the elements in path are hidden under a collapsed parent.
      • getFirstSelectionPath

        protected javax.swing.tree.TreePath getFirstSelectionPath()
        Returns the path to the first selected node.
        Returns:
        the TreePath for the first selected node, or null if nothing is currently selected
      • getPath

        protected com.rational.test.ft.script.Subitem[] getPath(javax.swing.tree.TreePath treePath,
                                                                boolean isDP)
        Returns an array of Subitem representing the treepath.
        Parameters:
        treePath -
        isDP - true if this array will be used by getDataDrivableCommand.
        Returns:
        array of subitems or null.
      • getDataDrivableCommand

        public com.rational.test.ft.sys.MethodSpecification getDataDrivableCommand()
        This method must be implemented by any proxy that wishes to support data driving. By default a null value is returned.
        Specified by:
        getDataDrivableCommand in interface com.rational.test.ft.domain.IDataDriven
        Overrides:
        getDataDrivableCommand in class com.rational.test.ft.domain.ProxyTestObject
        Since:
        RFT2.0
        See Also:
        ProxyTestObject.getDataDrivableCommands(int)
      • processSingleMouseEvent

        public void processSingleMouseEvent(com.rational.test.ft.domain.IMouseActionInfo action)
        Return a MethodSpecification for the specified mouse event. This is the primary record interface for mouse events against a particular control.
        Overrides:
        processSingleMouseEvent in class JavaGuiProxy
        Parameters:
        action - The event cache and other mouse state information for this mouse action.
      • setState

        public void setState(com.rational.test.ft.script.Action action,
                             com.rational.test.ft.script.Subitem item)
        This method performs a specific action against the subitem.
        Specified by:
        setState in interface com.rational.test.ft.object.interfaces.ISubitem
        Overrides:
        setState in class JScrollPaneProxy
        Parameters:
        item - The item to act upon.
        action - The action that should be performed.
      • getMethodSpecForPoint

        public com.rational.test.ft.sys.MethodSpecification getMethodSpecForPoint(java.awt.Point pt)
        Return a MethodSpecification for a method that returns a java.awt.Point for the specified coordinates. By default a method specification for IGraphical.getScreenPoint will be returned. However, if a proxy can find
        Overrides:
        getMethodSpecForPoint in class JavaGuiProxy
        Parameters:
        x - The screen relative x coordinate.
        y - The screen relative y coordinate.
        See Also:
        MethodSpecification
      • getScreenRectangle

        public java.awt.Rectangle getScreenRectangle(com.rational.test.ft.script.Subitem subitem)
        Returns the rectangle that contains the component being evaluated relative to the top left corner of the screen. This will commonly be two operations (getScreenRectangle for the parent object and then adjusting for the specified subitem) combined into a single operation. The rectangle is exposed so that actions may be directly scripted against a visible subitem. null is returned if the subitem is not showing.
        Specified by:
        getScreenRectangle in interface com.rational.test.ft.object.interfaces.IGraphicalSubitem
        Overrides:
        getScreenRectangle in class JScrollPaneProxy
        Returns:
        The adjusted rectangle surrounding subitem relative to the screen. null is returned if the subitem is not showing.
      • getTreePathClass

        protected java.lang.Class getTreePathClass()
      • constructPath

        protected java.lang.Object constructPath(java.lang.Object[] path)
      • constructPath

        protected java.lang.Object constructPath(java.lang.Object item)
      • hasDuplicateChildren

        protected boolean hasDuplicateChildren(javax.swing.tree.TreePath path,
                                               java.lang.String node)
      • getTestDataTypes

        public java.util.Hashtable getTestDataTypes()
        Returns a hashtable of data type descriptions of the verification point data available with the associated object in the SUT. The hashtable keys are String objects that are used as the VP type in the associated test data. The type is a simple value that is defferent then other type values associated with this object under test. The type keys map to a verbose description of the test data, reasonable for presentation to a user.
        Overrides:
        getTestDataTypes in class JavaProxy
        Returns:
        An hashtable of type/description pairs used to describe the verification data available from this proxy.
        See Also:
        getTestData(String), ITestData
      • getTestData

        public com.rational.test.ft.vp.ITestData getTestData(java.lang.String testDataType)
        This method constructs the specified verification data object. The testDataType parameter is one of the hashtable keys returned by getTestDataTypes.
        Overrides:
        getTestData in class com.rational.test.ft.domain.ProxyTestObject
        Parameters:
        testDataType - A test data type supplied by getTestDataTypes.
        Returns:
        The verification data for the supplied type.
        See Also:
        getTestDataTypes(), ITestData
      • updateTestData

        public com.rational.test.ft.vp.ITestData updateTestData(java.lang.String testDataType,
                                                                com.rational.test.ft.vp.ITestData testData)
        This method updates the supplied test data object and returns it. The testDataType parameter is one of the hashtable keys returned by getTestDataTypes. The testData is a previously supplied ITestData object that needs to be updated to reflect the current state of the associated test object.
        Overrides:
        updateTestData in class com.rational.test.ft.domain.ProxyTestObject
        Parameters:
        testDataType - A test data type supplied by getTestDataTypes.
        testData - The test data base object that requires updating.
        Returns:
        The testData passed in with appropriate updates.
        See Also:
        getTestDataTypes(), ITestData
      • canBeScrolled

        public boolean canBeScrolled()
        Returns true if the object is associated with scrollbar(s). By default, it returns false<\b>.
        Overrides:
        canBeScrolled in class ComponentProxy
        Returns:
        true if the object is associated with scrollbar(s).