junit.extensions.jfcunit.eventdata
Class JComboBoxMouseEventData

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

public class JComboBoxMouseEventData
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 JComboBox.

Author:
Vijay Aravamudhan : ThoughtWorks Inc.

Field Summary
private  javax.swing.JComboBox m_comboBox
          The JComboBox on which to trigger the event.
private  int m_elementIndex
          The zero-based index of the specific element on which to trigger the event.
private  javax.swing.JList m_listView
          The list view associated with the JComboBox.
 
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
JComboBoxMouseEventData()
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, int elementIndex, int numberOfClicks)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, int elementIndex, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, int elementIndex, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, int elementIndex, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position, java.awt.Point referencePoint)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, int elementIndex, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, java.awt.Point referencePoint)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, int elementIndex, int numberOfClicks, long sleepTime)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, java.lang.Object element, int numberOfClicks)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, java.lang.Object element, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, java.lang.Object element, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, java.lang.Object element, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, int position, java.awt.Point referencePoint)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, java.lang.Object element, int numberOfClicks, int modifiers, boolean isPopupTrigger, long sleepTime, java.awt.Point referencePoint)
          Constructor.
JComboBoxMouseEventData(JFCTestCase testCase, javax.swing.JComboBox comboBox, java.lang.Object element, int numberOfClicks, long sleepTime)
          Constructor.
 
Method Summary
private  java.awt.Rectangle calcButtonArea(java.awt.Rectangle comboBox, java.awt.Rectangle editor)
          Calculate the difference between the two rectangles.
 boolean canConsume(java.awt.AWTEvent ae)
          Returns true if the event can be consumed by this instance of event data.
 boolean consume(java.awt.AWTEvent ae)
          Consume the event.
 boolean equals(java.lang.Object o)
          Compare to event datas and determine if they are equal.
 java.awt.Component getComponent()
          The component on which the event has to be fired.
 int getElementIndex()
          Get the attribute value.
private static int getIndexOf(javax.swing.JComboBox comboBox, java.lang.Object element)
          Finds the index of the element passed in from the JComboBox.
private  javax.swing.JComboBox getParentComboBox(javax.swing.JList list)
          Get the parent combo box of the list.
 javax.swing.JComboBox getSource()
          Get the attribute value.
 int hashCode()
          Return a hashCode for this object.
private  boolean isComboBox(javax.swing.JList list)
          Get the parent combo box of the list.
 void populate(org.w3c.dom.Element e)
          Populate the JComboBoxMouseEventData XML element.
 boolean prepareComponent()
          Prepare the Component to receive the event.
 void setElementIndex(int elementIndex)
          Set the attribute value.
 void setSource(javax.swing.JComboBox comboBox)
          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_comboBox

private javax.swing.JComboBox m_comboBox
The JComboBox on which to trigger the event.


m_listView

private javax.swing.JList m_listView
The list view associated with the JComboBox.


m_elementIndex

private int m_elementIndex
The zero-based index of the specific element on which to trigger the event.

Constructor Detail

JComboBoxMouseEventData

public JComboBoxMouseEventData()
Constructor.


JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               java.lang.Object element,
                               int numberOfClicks)
Constructor.

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

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               java.lang.Object element,
                               int numberOfClicks,
                               long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comboBox - The JComboBox on which to trigger the event.
element - The specific element 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.

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               java.lang.Object element,
                               int numberOfClicks,
                               int modifiers,
                               boolean isPopupTrigger,
                               long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comboBox - The JComboBox on which to trigger the event.
element - The specific element 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.

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               java.lang.Object element,
                               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.
comboBox - The JComboBox on which to trigger the event.
element - The specific element 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.

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               java.lang.Object element,
                               int numberOfClicks,
                               int modifiers,
                               boolean isPopupTrigger,
                               long sleepTime,
                               int position)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comboBox - The JComboBox on which to trigger the event.
element - The specific element 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.

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               java.lang.Object element,
                               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.
comboBox - The JComboBox on which to trigger the event.
element - The specific element 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.

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               int elementIndex,
                               int numberOfClicks)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comboBox - The JComboBox on which to trigger the event.
elementIndex - The zero-based index of the specific element on which to trigger the event.
numberOfClicks - Number of clicks in the MouseEvent (1 for single-click, 2 for double clicks)

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               int elementIndex,
                               int numberOfClicks,
                               long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comboBox - The JComboBox on which to trigger the event.
elementIndex - The zero-based index of the specific element 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.

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               int elementIndex,
                               int numberOfClicks,
                               int modifiers,
                               boolean isPopupTrigger,
                               long sleepTime)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comboBox - The JComboBox on which to trigger the event.
elementIndex - The zero-based index of the specific element 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.

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               int elementIndex,
                               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.
comboBox - The JComboBox on which to trigger the event.
elementIndex - The zero-based index of the specific element 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.

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               int elementIndex,
                               int numberOfClicks,
                               int modifiers,
                               boolean isPopupTrigger,
                               long sleepTime,
                               int position)
Constructor.

Parameters:
testCase - The JFCTestCase on whose thread awtSleep() has to be invoked.
comboBox - The JComboBox on which to trigger the event.
elementIndex - The zero-based index of the specific element 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.

JComboBoxMouseEventData

public JComboBoxMouseEventData(JFCTestCase testCase,
                               javax.swing.JComboBox comboBox,
                               int elementIndex,
                               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.
comboBox - The JComboBox on which to trigger the event.
elementIndex - The zero-based index of the specific element 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

setSource

public final void setSource(javax.swing.JComboBox comboBox)
Set the attribute value.

Parameters:
comboBox - The new value of the attribute.

getSource

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

Returns:
JComboBox 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.

setElementIndex

public final void setElementIndex(int elementIndex)
Set the attribute value.

Parameters:
elementIndex - The new value of the attribute.

getElementIndex

public int getElementIndex()
Get the attribute value.

Returns:
int The value of the attribute.

canConsume

public boolean canConsume(java.awt.AWTEvent ae)
Returns true if the event can be consumed by this instance 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 determine 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()
Return a hashCode for this object.

Overrides:
hashCode in class AbstractMouseEventData
Returns:
int hashCode.

populate

public void populate(org.w3c.dom.Element e)
Populate the JComboBoxMouseEventData XML element.

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.

calcButtonArea

private java.awt.Rectangle calcButtonArea(java.awt.Rectangle comboBox,
                                          java.awt.Rectangle editor)
Calculate the difference between the two rectangles. And use this as the button location.

Parameters:
comboBox - Rectangle from combo box.
editor - Rectangle from editor.
Returns:
Rectangle Remaining rectangle.

toString

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

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

isComboBox

private boolean isComboBox(javax.swing.JList list)
Get the parent combo box of the list.

Parameters:
list - List to check.
Returns:
true if combo box.

getIndexOf

private static int getIndexOf(javax.swing.JComboBox comboBox,
                              java.lang.Object element)
Finds the index of the element passed in from the JComboBox.

Parameters:
comboBox - The JComboBox which holds the elements.
element - The element whose index has to be found out.
Returns:
int The zero-based index where the element occurs (-1 is returned if not found).

getParentComboBox

private javax.swing.JComboBox getParentComboBox(javax.swing.JList list)
Get the parent combo box of the list. This is difficult since the JList is normally a inner class, and there is not a linkage to traverse outside the class. Here we will traverse the Listener list to get to the JComboBox as it should be listening to the list as well.

Parameters:
list - List to check
Returns:
JComboBox of parent.


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