|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| JPopupMenuFinder.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
package junit.extensions.jfcunit.finder;
|
|
| 2 |
|
|
| 3 |
import java.awt.Component;
|
|
| 4 |
|
|
| 5 |
import javax.swing.JPopupMenu;
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
/**
|
|
| 9 |
* <p>Title: Find a popup menu given the invoker.</p>
|
|
| 10 |
* <p>Description: Locate the popup menu associated
|
|
| 11 |
* with the invoker. </p>
|
|
| 12 |
* <p>Copyright: Copyright (c) 2003</p>
|
|
| 13 |
* <p>Company: JFCUnit OpenSource Project</p>
|
|
| 14 |
* @author Kevin Wilson
|
|
| 15 |
* @version 1.0
|
|
| 16 |
*/
|
|
| 17 |
public class JPopupMenuFinder extends Finder { |
|
| 18 |
/**
|
|
| 19 |
* The Invoker of the Popup Menu.
|
|
| 20 |
*/
|
|
| 21 |
private Component m_invoker;
|
|
| 22 |
|
|
| 23 |
/**
|
|
| 24 |
* Constructor.
|
|
| 25 |
* @param invoker Component which is used to determine
|
|
| 26 |
* which menu to return.
|
|
| 27 |
*/
|
|
| 28 | 0 |
public JPopupMenuFinder(final Component invoker) {
|
| 29 | 0 |
setInvoker(invoker); |
| 30 | 0 |
setWait(2); |
| 31 |
} |
|
| 32 |
|
|
| 33 |
/**
|
|
| 34 |
* Set the invoker to be matched.
|
|
| 35 |
* @param invoker Component invoker to be matched.
|
|
| 36 |
*/
|
|
| 37 | 0 |
public final void setInvoker(final Component invoker) { |
| 38 | 0 |
m_invoker = invoker; |
| 39 |
} |
|
| 40 |
|
|
| 41 |
/**
|
|
| 42 |
* Get the invoker to be matched.
|
|
| 43 |
* @return Component invoker to be matched.
|
|
| 44 |
*/
|
|
| 45 | 0 |
public final Component getInvoker() {
|
| 46 | 0 |
return m_invoker;
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
/**
|
|
| 50 |
* For JPopupMenu components validate return all
|
|
| 51 |
* Components with the invoker.
|
|
| 52 |
* @param comp Component to be tested.
|
|
| 53 |
* @return boolean true if the invokers of the JPopupMenu
|
|
| 54 |
* matches the invoker passed in the constructor.
|
|
| 55 |
*/
|
|
| 56 | 0 |
public boolean testComponent(final Component comp) { |
| 57 | 0 |
if (isValidForProcessing(comp, JPopupMenu.class)) { |
| 58 | 0 |
return m_invoker.equals(((JPopupMenu) (comp)).getInvoker());
|
| 59 |
} |
|
| 60 |
|
|
| 61 | 0 |
return false; |
| 62 |
} |
|
| 63 |
} |
|
| 64 |
|
|
||||||||||