|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| JInternalFrameFinder.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
package junit.extensions.jfcunit.finder;
|
|
| 2 |
|
|
| 3 |
import junit.extensions.jfcunit.WindowMonitor;
|
|
| 4 |
|
|
| 5 |
import java.awt.Component;
|
|
| 6 |
import java.awt.Container;
|
|
| 7 |
|
|
| 8 |
import java.util.Iterator;
|
|
| 9 |
|
|
| 10 |
import javax.swing.JDesktopPane;
|
|
| 11 |
import javax.swing.JInternalFrame;
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
/**
|
|
| 15 |
* <p>Title: class JInternalFrameFinder.</p>
|
|
| 16 |
* <p>Description: </p>
|
|
| 17 |
* <p>Copyright: Copyright (c) 2003</p>
|
|
| 18 |
* <p>Company: </p>
|
|
| 19 |
* @author not attributable
|
|
| 20 |
* @version 1.0
|
|
| 21 |
*/
|
|
| 22 |
public class JInternalFrameFinder extends ComponentFinder { |
|
| 23 |
/**
|
|
| 24 |
* Title of the frame.
|
|
| 25 |
*/
|
|
| 26 |
private String m_title = null; |
|
| 27 |
|
|
| 28 |
/**
|
|
| 29 |
* Constructor for the internal frame finder.
|
|
| 30 |
* @param title Title of the frame.
|
|
| 31 |
* @param ignoreCase Ignore the case if true.
|
|
| 32 |
*/
|
|
| 33 | 0 |
public JInternalFrameFinder(final String title, final boolean ignoreCase) { |
| 34 | 0 |
super(javax.swing.JDesktopPane.class); |
| 35 | 0 |
setTitle(title); |
| 36 |
} |
|
| 37 |
|
|
| 38 |
/**
|
|
| 39 |
* Set the title to be matched.
|
|
| 40 |
* @param title to be matched.
|
|
| 41 |
*/
|
|
| 42 | 0 |
public final void setTitle(final String title) { |
| 43 | 0 |
m_title = title; |
| 44 |
} |
|
| 45 |
|
|
| 46 |
/**
|
|
| 47 |
* Get the title to be matched.
|
|
| 48 |
* @return title to be matched.
|
|
| 49 |
*/
|
|
| 50 | 0 |
public final String getTitle() {
|
| 51 | 0 |
return m_title;
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
/**
|
|
| 55 |
* Find the DeskTop then search the desktops for the internal
|
|
| 56 |
* frame with the given name.
|
|
| 57 |
* @param cont Container to be searched.
|
|
| 58 |
* @param index Index of the matching internal frames to return.
|
|
| 59 |
* @return The Internal Frame which matches at the given index.
|
|
| 60 |
*/
|
|
| 61 | 0 |
public Component find(final Container cont, final int index) { |
| 62 | 0 |
long date = System.currentTimeMillis() + (getWait() * 1000);
|
| 63 |
|
|
| 64 | 0 |
do {
|
| 65 | 0 |
Container[] conts; |
| 66 |
|
|
| 67 | 0 |
if (cont == null) { |
| 68 | 0 |
conts = WindowMonitor.getWindows(); |
| 69 |
} else {
|
|
| 70 | 0 |
conts = new Container[] {cont};
|
| 71 |
} |
|
| 72 |
|
|
| 73 | 0 |
int idx = -1;
|
| 74 |
|
|
| 75 | 0 |
for (int w = 0; w < conts.length; w++) { |
| 76 | 0 |
int dsk = 0;
|
| 77 | 0 |
Iterator iter = findComponentList(this, conts[w], null, index) |
| 78 |
.iterator(); |
|
| 79 |
|
|
| 80 | 0 |
while (iter.hasNext()) {
|
| 81 | 0 |
JDesktopPane desktop = (JDesktopPane) iter.next(); |
| 82 | 0 |
JInternalFrame[] frames = desktop.getAllFrames(); |
| 83 |
|
|
| 84 | 0 |
for (int i = 0; i < frames.length; i++) { |
| 85 | 0 |
String ftitle = frames[i].getTitle(); |
| 86 |
|
|
| 87 | 0 |
if (evaluate(ftitle, m_title)) {
|
| 88 | 0 |
if (getDebug()) {
|
| 89 | 0 |
System.err.println("JInternalFrame(" + dsk
|
| 90 |
+ "," + idx + ")" + frames[i].getTitle()); |
|
| 91 |
} |
|
| 92 |
|
|
| 93 | 0 |
if (idx == index) {
|
| 94 | 0 |
return frames[i];
|
| 95 |
} |
|
| 96 |
|
|
| 97 | 0 |
idx++; |
| 98 |
} |
|
| 99 |
} |
|
| 100 |
|
|
| 101 | 0 |
dsk++; |
| 102 |
} |
|
| 103 |
} |
|
| 104 |
|
|
| 105 | 0 |
pause(date); |
| 106 | 0 |
} while (System.currentTimeMillis() < date);
|
| 107 |
|
|
| 108 | 0 |
if (getDebug()) {
|
| 109 | 0 |
System.err.print("Frame not found");
|
| 110 |
} |
|
| 111 |
|
|
| 112 | 0 |
return null; |
| 113 |
} |
|
| 114 |
} |
|
| 115 |
|
|
||||||||||