public static API_DWR setHttpSessionId_and_ScriptSessionId(this API_DWR dwr, string httpSessionId, string scriptSessionId)
 {
     dwr.Dwr_Session.ScriptSessionId = scriptSessionId;
     return(dwr.setHttpSessionId(httpSessionId));
 }
 public static API_DWR setHttpSessionId(this API_DWR dwr, string httpSessionId)
 {
     dwr.Dwr_Session.HttpSessionId = httpSessionId;
     dwr.Dwr_Session.Cookie        = "JSESSIONID={0}".format(httpSessionId);
     return(dwr);
 }
        public static TreeView createTestGuiFromJavascriptInterfaces(this Panel panel, string baseUrl)
        {
            var topPanel = panel.add_Panel();
            var dwr      = new API_DWR(baseUrl);
            //			.attributes("href")
//			.values() ;


            //var rootUrl = "http://127.0.0.1:8080/dwr_war_3.0/dwr/interface/";
            //var files = new string[] {"Demo.js", "Intro.js", "Corporations.js", "People.js", "CallCenter.js" ,"UploadDownload.js"} .toList();
            //var file = rootUrl + files[5];

            //var sourceCodeViewer = topPanel.add_SourceCodeViewer();
            var files_treeView        = topPanel.insert_Left <Panel>(200).add_TreeView().sort();
            var functions_treeView    = files_treeView.insert_Below <Panel>().add_TreeView().sort();
            var ActionPanel           = topPanel.insert_Above <GroupBox>(60).add_Panel();
            var selectedFunction      = ActionPanel.add_Label("Selected Function").append_Label("...").font_bold().autoSize();
            var functionParametersRaw = ActionPanel.add_Label("Functions Parameters (Raw)", 20).append_TextBox("").width(200);
            var functionParameters    = topPanel.add_GroupBox("Function Parameters").add_DataGridView();

            functionParameters.add_Columns("name", "value");
            var invocationResponse = functionParameters.parent().insert_Right <Panel>().add_GroupBox("Invocation Response").add_TextArea();

            invocationResponse.splitContainer().splitterDistance(invocationResponse.parent().width() / 2);

            functionParametersRaw.append_Link("Invoke Method",
                                              () => {
                invocationResponse.set_Text("");
                invocationResponse.backColor("Salmon");
                var dwrMethod = (DWR_Function)functions_treeView.selected().get_Tag();
                if (dwrMethod.notNull())
                {
                    var parameters = new List <String>();
                    foreach (var row in functionParameters.rows())
                    {
                        parameters.add(row[1].str());
                    }
                    var response = dwr.invoke(dwrMethod.ClassName, dwrMethod.FunctionName, parameters.ToArray());
                    invocationResponse.set_Text(response.ResponseData);
                    invocationResponse.backColor("White");
                }
            });

            functionParametersRaw.onTextChange(
                (text) => {
                var splittedText = text.split(",");
                for (int i = 0; i < splittedText.size(); i++)
                {
                    functionParameters.get_Row(i).Cells[1].Value = splittedText[i];
                }
            });

            Func <string, DWR_Class> loadJavascriptFile =
                (url) => {
                functions_treeView.clear();
                var dwrClass = url.dwr_mapJavascriptIntoDwrClass();
                return(dwrClass);
            };

            files_treeView.afterSelect <string>(
                (file) => {
                var dwrClass = loadJavascriptFile(file);
                foreach (var function in dwrClass.Functions)
                {
                    functions_treeView.add_Node(function.FunctionName, function);
                }
                functions_treeView.selectFirst();
            });

            functions_treeView.afterSelect <DWR_Function>(
                (dwrFunction) => {
                selectedFunction.set_Text("{0}.{1}".format(dwrFunction.ClassName, dwrFunction.FunctionName));
                functionParameters.remove_Rows();
                foreach (var parameter in dwrFunction.Parameters)
                {
                    if (parameter.neq("callback"))
                    {
                        functionParameters.add_Row(parameter);
                    }
                }
                functionParametersRaw.enabled(dwrFunction.Parameters.size() > 1);
            });
            return(files_treeView);
        }