01: package watij.runtime.ie;
02:
03: import com.jniwrapper.*;
04: import com.jniwrapper.win32.FunctionName;
05: import com.jniwrapper.win32.Msg;
06: import com.jniwrapper.win32.automation.types.BStr;
07: import com.jniwrapper.win32.ui.User32;
08: import com.jniwrapper.win32.ui.Wnd;
09: import watij.dialogs.PromptDialog;
10: import watij.utilities.Debug;
11: import watij.utilities.WatijResourceLoader;
12: import watij.utilities.WatijResources;
13:
14: import java.util.List;
15:
16: public class IEPromptDialog extends IEConfirmDialog implements
17: PromptDialog {
18:
19: public IEPromptDialog(Wnd dialog, IE ie) {
20: super (dialog, ie);
21: }
22:
23: public static PromptDialog findPromptDialog(IE ie) throws Exception {
24: Wnd wnd = IEUtil
25: .waitDialogWnd(WatijResourceLoader
26: .getString(WatijResources.IEPromptDialog_Title_ExplorerUserPrompt));
27: return new IEPromptDialog(wnd, ie);
28: }
29:
30: public void value(String text) throws Exception {
31: List children = dialog.getChildWindows();
32: for (int i = 0; i < children.size(); i++) {
33: Wnd childWnd = (Wnd) children.get(i);
34: IEUtil.debugWnd(childWnd, "setValueForChild");
35: if ("Edit".equals(childWnd.getWindowClassName())) {
36: final Function sendMessage = User32.getInstance()
37: .getFunction(
38: new FunctionName("SendMessage")
39: .toString());
40: IntBool result = new IntBool();
41: sendMessage.invoke(result, childWnd, new UInt(
42: Msg.WM_SETTEXT), new BStr(), new BStr(text));
43: Debug.getInstance().println(
44: "setValue result.getBooleanValue() = "
45: + result.getBooleanValue());
46: }
47: }
48: }
49:
50: public String value() throws Exception {
51: List children = dialog.getChildWindows();
52: for (int i = 0; i < children.size(); i++) {
53: Wnd childWnd = (Wnd) children.get(i);
54: IEUtil.debugWnd(childWnd, "valueForChild");
55: if ("Edit".equals(childWnd.getWindowClassName())) {
56: final Function sendMessage = User32.getInstance()
57: .getFunction(
58: new FunctionName("SendMessage")
59: .toString());
60: final Str text = new Str(1024);
61: final Int resultLength = new Int();
62: sendMessage.invoke(resultLength, childWnd, new UInt(
63: Msg.WM_GETTEXT), new Int(1024), new Pointer(
64: text));
65: return text.getValue();
66: }
67: }
68: return null;
69: }
70:
71: // public String text() throws Exception {
72: // System.out.println("IEPromptDialog.text");
73: // List children = dialog.getChildWindows();
74: // for (int i = 0; i < children.size(); i++) {
75: // Wnd childWnd = (Wnd) children.get(i);
76: // if ("Static".equals(childWnd.getWindowClassName()) && !"Script Prompt:".equals(childWnd.getWindowText())) {
77: // return childWnd.getWindowText();
78: // }
79: // }
80: // return null;
81: // }
82: }
|