junit.extensions.jfcunit.eventdata
Class JTreeMouseEventData

java.lang.Object
  extended byjunit.extensions.jfcunit.eventdata.AbstractEventData
      extended byjunit.extensions.jfcunit.eventdata.AbstractMouseEventData
          extended byjunit.extensions.jfcunit.eventdata.JTreeMouseEventData
All Implemented Interfaces:
EventDataConstants

public class JTreeMouseEventData
extends AbstractMouseEventData

Data container class that holds all the data necessary for jfcUnit to fire mouse events. This class is specific to events on a JTree.

Author:
Vijay Aravamudhan : ThoughtWorks Inc.

Field Summary
private  java.lang.String m_nodeValue
          The String value of the specific node on which to trigger the event.
private  javax.swing.JTree m_tree
          The JTree on which to trigger the event.
private  javax.swing.tree.TreePath m_treePath
          The path of the specific node on which to trigger the event.
 
Fields inherited from class junit.extensions.jfcunit.eventdata.AbstractMouseEventData
 
Fields inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
 
Fields inherited from interface junit.extensions.jfcunit.eventdata.EventDataConstants
CENTER, CUSTOM, DEFAULT_HOLDTIME, DEFAULT_ISPOPUPTRIGGER, DEFAULT_KEY_MODIFIERS, DEFAULT_MOUSE_MODIFIERS, DEFAULT_NUMBEROFCLICKS, DEFAULT_POPUP_MODIFIERS, DEFAULT_POSITION, DEFAULT_SCROLL_AMOUNT, DEFAULT_SLEEPTIME, DEFAULT_WHEEL_ROTATION, DOWN_ARROW_SUBCOMPONENT, EAST, EDITOR_SUBCOMPONENT, INVALID_SUBCOMPONENT, INVALID_TEXT_OFFSET, NORTH, NORTH_EAST, NORTH_WEST, OFFSET, PERCENT, POSITIONSTRINGS, SOUTH, SOUTH_EAST, SOUTH_WEST, UP_ARROW_SUBCOMPONENT, WEST
 
Constructor Summary
JTreeMouseEventData()
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, java.lang.String nodeValue, int numberOfClicks)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, java.lang.String nodeValue, int numberOfClicks, boolean isPopupTrigger)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, java.lang.String nodeValue, int numberOfClicks, boolean isPopupTrigger, long sleepTime)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, java.lang.String nodeValue, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, java.lang.String nodeValue, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, java.lang.String nodeValue, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position, java.awt.Point referencePoint)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, java.lang.String nodeValue, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, java.awt.Point referencePoint)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, java.lang.String nodeValue, int numberOfClicks, long sleepTime)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, javax.swing.tree.TreePath treePath, int numberOfClicks)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, javax.swing.tree.TreePath treePath, int numberOfClicks, boolean isPopupTrigger)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, javax.swing.tree.TreePath treePath, int numberOfClicks, boolean isPopupTrigger, long sleepTime)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, javax.swing.tree.TreePath treePath, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, javax.swing.tree.TreePath treePath, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, javax.swing.tree.TreePath treePath, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position, java.awt.Point referencePoint)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, javax.swing.tree.TreePath treePath, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, java.awt.Point referencePoint)
          Constructor.
JTreeMouseEventData(JFCTestCase testCase, javax.swing.JTree tree, javax.swing.tree.TreePath treePath, int numberOfClicks, long sleepTime)
          Constructor.
 
Method Summary
private  java.lang.Object[] buildPath(javax.swing.tree.TreeNode node)
          Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.
 boolean canConsume(java.awt.AWTEvent ae)
          Returns true if the event can be consumed by this instnace of event data.
private  boolean checkNodesUserObject(javax.swing.tree.TreeNode node, java.lang.String userObj)
          Checks to see if the node is not null and its userObject is equal to the value passed in.
 boolean consume(java.awt.AWTEvent ae)
          Consume the event.
 boolean equals(java.lang.Object o)
          Compare to event datas and deterime if they are equal.
private  java.util.List findNodeList(javax.swing.tree.TreeNode parent, java.util.List outList)
          Calls itself recursively to build a list of all the child nodes in the parent.
 java.awt.Component getComponent()
          The component on which the event has to be fired.
private  javax.swing.tree.TreeNode getNode(javax.swing.JTree tree, java.lang.String userObj)
          Finds the node in the specified tree by comparing with the value passed in.
 java.lang.String getNodeValue()
          Get the attribute value.
 javax.swing.JTree getSource()
          Get the attribute value.
 javax.swing.tree.TreePath getTreePath()
          Get the attribute value.
 int hashCode()
          Get the hashCode.
 void populate(org.w3c.dom.Element e)
          Populate the XML Element with this nodes attributes.
 boolean prepareComponent()
          Prepare the component to receive the event.
 void setNodeValue(java.lang.String nodeValue)
          Set the attribute value.
 void setSource(javax.swing.JTree tree)
          Set the attribute value.
 void setTreePath(javax.swing.tree.TreePath treePath)
          Set the attribute value.
 java.lang.String toString()
          Get string description of event.
 
Methods inherited from class junit.extensions.jfcunit.eventdata.AbstractMouseEventData
getDefaultModifiers, getDefaultModifiers, getDefaultNumberOfClicks, getDefaultPopupTrigger, getModifierText, getNumberOfClicks, getPopupTrigger, sameSource, setNumberOfClicks, setPopupTrigger
 
Methods inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
calculatePoint, getDefaultPosition, getDefaultSleepTime, getLocationOnScreen, getModifiers, getPosition, getReferencePoint, getRoot, getRoot, getSleepTime, getTestCase, isMetaChar, isValid, isValidForProcessing, setLocationOnScreen, setModifiers, setPosition, setReferencePoint, setSleepTime, setTestCase, setValid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_tree

private javax.swing.JTree m_tree
The JTree on which to trigger the event.


m_nodeValue

private java.lang.String m_nodeValue
The String value of the specific node on which to trigger the event.


m_treePath

private javax.swing.tree.TreePath m_treePath
The path of the specific node on which to trigger the event.

Constructor Detail

JTreeMouseEventData

public JTreeMouseEventData()
Constructor.


JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           javax.swing.tree.TreePath treePath,
                           int numberOfClicks)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
treePath - The path of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           java.lang.String nodeValue,
                           int numberOfClicks)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
nodeValue - The String value of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           javax.swing.tree.TreePath treePath,
                           int numberOfClicks,
                           long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
treePath - The path of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
sleepTime - The wait time in ms between each event.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           java.lang.String nodeValue,
                           int numberOfClicks,
                           long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
nodeValue - The String value of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
sleepTime - The wait time in ms between each event.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           javax.swing.tree.TreePath treePath,
                           int numberOfClicks,
                           boolean isPopupTrigger)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
treePath - The path of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
isPopupTrigger - boolean specifying whether this event will show a popup.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           java.lang.String nodeValue,
                           int numberOfClicks,
                           boolean isPopupTrigger)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
nodeValue - The String value of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
isPopupTrigger - boolean specifying whether this event will show a popup.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           javax.swing.tree.TreePath treePath,
                           int numberOfClicks,
                           boolean isPopupTrigger,
                           long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
treePath - The path of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           java.lang.String nodeValue,
                           int numberOfClicks,
                           boolean isPopupTrigger,
                           long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
nodeValue - The String value of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           javax.swing.tree.TreePath treePath,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
treePath - The path of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           java.lang.String nodeValue,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
nodeValue - The String value of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           javax.swing.tree.TreePath treePath,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime,
                           int position)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
treePath - The path of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.
position - The relative mouse position within the cell.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           java.lang.String nodeValue,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime,
                           int position)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
nodeValue - The String value of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.
position - The relative mouse position within the cell.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           javax.swing.tree.TreePath treePath,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime,
                           java.awt.Point referencePoint)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
treePath - The path of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.
referencePoint - The custom mouse position within the cell.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           java.lang.String nodeValue,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime,
                           java.awt.Point referencePoint)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
nodeValue - The String value of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.
referencePoint - The CUSTOM mouse position within the cell.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           javax.swing.tree.TreePath treePath,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime,
                           int position,
                           java.awt.Point referencePoint)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
treePath - The path of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.
position - The relative mouse position within the cell.
referencePoint - If position is CUSTOM then the point is a offset from the location of the component. If the position is PERCENT then the location is a percentage offset of the hight and width. Otherwise, the referencePoint is unused.

JTreeMouseEventData

public JTreeMouseEventData(JFCTestCase testCase,
                           javax.swing.JTree tree,
                           java.lang.String nodeValue,
                           int numberOfClicks,
                           int modifiers,
                           boolean isPopupTrigger,
                           long sleepTime,
                           int position,
                           java.awt.Point referencePoint)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
tree - The component on which to trigger the event.
nodeValue - The String value of the specific node on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)
modifiers - The modifier key values that need to be passed onto the event.
isPopupTrigger - boolean specifying whether this event will show a popup.
sleepTime - The wait time in ms between each event.
position - The relative mouse position within the cell.
referencePoint - If position is CUSTOM then the point is a offset from the location of the component. If the position is PERCENT then the location is a percentage offset of the hight and width. Otherwise, the referencePoint is unused.
Method Detail

setNodeValue

public final void setNodeValue(java.lang.String nodeValue)
Set the attribute value.

Parameters:
nodeValue - The new value of the attribute.

getNodeValue

public final java.lang.String getNodeValue()
Get the attribute value.

Returns:
String The value of the attribute.

setSource

public final void setSource(javax.swing.JTree tree)
Set the attribute value.

Parameters:
tree - The new value of the attribute.

getSource

public final javax.swing.JTree getSource()
Get the attribute value.

Returns:
JTree The value of the attribute.

getComponent

public java.awt.Component getComponent()
The component on which the event has to be fired.

Specified by:
getComponent in class AbstractEventData
Returns:
The component.

setTreePath

public final void setTreePath(javax.swing.tree.TreePath treePath)
Set the attribute value.

Parameters:
treePath - The new value of the attribute.

getTreePath

public final javax.swing.tree.TreePath getTreePath()
Get the attribute value.

Returns:
TreePath The value of the attribute.

canConsume

public boolean canConsume(java.awt.AWTEvent ae)
Returns true if the event can be consumed by this instnace of event data.

Overrides:
canConsume in class AbstractMouseEventData
Parameters:
ae - Event to be consumed.
Returns:
true if the event was consumed.

consume

public boolean consume(java.awt.AWTEvent ae)
Consume the event.

Overrides:
consume in class AbstractMouseEventData
Parameters:
ae - AWTEvent to be consumed.
Returns:
boolean true if the event was consumed.

equals

public boolean equals(java.lang.Object o)
Compare to event datas and deterime if they are equal.

Overrides:
equals in class AbstractMouseEventData
Parameters:
o - Object to be compared.
Returns:
true if the events are the same.

hashCode

public int hashCode()
Get the hashCode.

Overrides:
hashCode in class AbstractMouseEventData
Returns:
int hashCode.

populate

public void populate(org.w3c.dom.Element e)
Populate the XML Element with this nodes attributes.

Overrides:
populate in class AbstractMouseEventData
Parameters:
e - element to be populated.

prepareComponent

public boolean prepareComponent()
Prepare the component to receive the event.

Overrides:
prepareComponent in class AbstractEventData
Returns:
true if the component is ready to receive the event.

toString

public java.lang.String toString()
Get string description of event.

Overrides:
toString in class AbstractMouseEventData
Returns:
String description of event.

getNode

private javax.swing.tree.TreeNode getNode(javax.swing.JTree tree,
                                          java.lang.String userObj)
Finds the node in the specified tree by comparing with the value passed in.

Parameters:
tree - The tree containing the node
userObj - The value of the node (usually the node label)
Returns:
The node whose value matched the value passed in

buildPath

private java.lang.Object[] buildPath(javax.swing.tree.TreeNode node)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. The length of the returned array gives the node's depth in the tree.

Parameters:
node - The TreeNode whose path has to be built.
Returns:
The array of nodes in the tree above the specified node.

checkNodesUserObject

private boolean checkNodesUserObject(javax.swing.tree.TreeNode node,
                                     java.lang.String userObj)
Checks to see if the node is not null and its userObject is equal to the value passed in.

Parameters:
node - Node
userObj - Expected value
Returns:
true if the values are the same

findNodeList

private java.util.List findNodeList(javax.swing.tree.TreeNode parent,
                                    java.util.List outList)
Calls itself recursively to build a list of all the child nodes in the parent.

Parameters:
parent - Node whose children have to be added to the list
outList - List of all the nodes in the tree
Returns:
List of all nodes


Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999