r20445: add README file indicating that the swat directory is no longer relevant
[kai/samba.git] / swat.obsolete / apps / plug-ins / echo.js
1
2 // This function takes the main pane widget and jams its widget in the right
3 // sub-pane.
4
5 function _asyncEchoHandler(result, ex, id, paneWidget) {
6         var replyTextArea = null;
7         var refreshButton = null;
8         var echoTextField = null;
9
10         if (ex == null) {
11                 // We need to remove anything previously drawn in this area.
12                 paneWidget.removeAll();
13
14                 echoTextField = new qx.ui.form.TextField();
15                 echoTextField.setTop(0);
16                 echoTextField.setLeft(0);
17
18                 refreshButton = new qx.ui.form.Button("Refresh");
19                 refreshButton.setTop(0);
20                 refreshButton.setLeft(150);
21
22                 replyTextArea = new
23                         qx.ui.form.TextArea(result);
24                 replyTextArea.setWrap(true);
25                 replyTextArea.setWidth("100%");
26                 replyTextArea.setHeight("50%");
27                 replyTextArea.setTop(30);
28                 replyTextArea.setBottom(50);
29                 replyTextArea.setLeft(0);
30                 replyTextArea.setRight(20);
31         } else {
32                 alert("Async(" + id + ") exception: " + ex);
33         }
34         paneWidget.add(replyTextArea);
35         paneWidget.add(refreshButton);
36         paneWidget.add(echoTextField);
37
38         // Provide a handler for the button.
39         with (refreshButton) {
40                 addEventListener("execute", function(e) {
41                         this.debug("executed: " + this.getLabel());
42                         this.debug("echoTextField.getValue(): " + echoTextField.getValue());
43                         _echoPlugInDisplay(paneWidget, echoTextField.getValue());
44                 });
45         };
46 }
47
48 function _echoPlugInDisplay(paneWidget, echoText) {
49         if (echoText == null) {
50                 echoText = "Hello World!";
51         }
52
53         var rpc = new qx.io.remote.Rpc();
54         rpc.setTimeout(60000);
55         rpc.setUrl("/services/");
56         rpc.setServiceName("samba.adm");
57         rpc.setCrossDomain(false);
58
59         mycall = rpc.callAsync(
60                 function(result, ex, id) {
61                         _asyncEchoHandler(result, ex, id, paneWidget);
62                 },
63                 "echo",
64                 echoText);
65 }
66
67 function EchoPlugIn() {
68         var o = new Object();
69         o.display = _echoPlugInDisplay;
70         return o;
71 }