public static Dwr_ErrorMessage dwrErrorMessage(this JsonExpression jsonExpression, bool includeSourceCode)
        {
            var jsonValues = jsonExpression.jsonValues();

            if (jsonValues.isNull())
            {
                return(null);
            }

            var dwrErrorMessage = new Dwr_ErrorMessage
            {
                Cause         = jsonValues.value("cause").str(),
                JavaClassName = jsonValues.value("javaClassName").str(),
                //LocalizedMessage = jsonValues.value("localizedMessage").str(),
                Message    = jsonValues.value("message").str(),
                SourceCode = (includeSourceCode) ? jsonExpression.Source.Code : null
            };
            var stackTrace = jsonValues.value("stackTrace");

            if (stackTrace.notNull() && stackTrace is List <Statement> )
            {
                foreach (var statement in stackTrace as List <Statement> )
                {
                    var statementJson = statement.jsonValues();
                    if (statementJson.notNull())
                    {
                        dwrErrorMessage.StackTrace.Add(new Dwr_ErrorMessage_StackTrace
                        {
                            ClassName    = statementJson.value("className").str(),
                            FileName     = statementJson.value("fileName").str(),
                            LineNumber   = statementJson.value("lineNumber").str(),
                            MethodName   = statementJson.value("methodName").str(),
                            NativeMethod = statementJson.value("nativeMethod").str()
                        });
                    }
                }
            }

            return(dwrErrorMessage);
        }
        public static Action <Dwr_ErrorMessage> add_StackTraceViewer <T>(this T control, List <string> codeFolders, string regExFilter)
            where T : Control
        {
            var stackTracePanel = control.add_GroupBox("StackTrace").add_Panel();
            var stackTrace      = stackTracePanel.add_TableList();
            var codeViewer      = stackTrace.insert_Below().add_SourceCodeEditor();

            var hideGeneratedMethods = false;

            Func <string, string> resolveFile =
                (className) => {
                var virtualPath = "{0}.java".format(className.replace(".", "\\"));
                "Trying to find: {0}".info(virtualPath);
                foreach (var sourceCodeFolder in codeFolders)
                {
                    var fullPath = sourceCodeFolder.pathCombine(virtualPath);
                    if (fullPath.fileExists())
                    {
                        return(fullPath);
                    }
                }
                return("null");
            };

            Action <string, string> showTraceInCodeViewer =
                (className, lineNumber)
                => {
                var sourceCodeFile = resolveFile(className);
                if (sourceCodeFile.fileExists())
                {
                    codeViewer.enabled(true);
                    codeViewer.open(sourceCodeFile);
                    codeViewer.editor().gotoLine(lineNumber.toInt());
                    stackTrace.focus();
                }
                else
                {
                    "could not find the source code for class:{0}".error(className);
                    codeViewer.enabled(false);
                }
            };

            Dwr_ErrorMessage selectedDwrErrorMessage = null;

            Action <Dwr_ErrorMessage> showStackTrace =
                (dwrErrorMessage) => {
                selectedDwrErrorMessage = dwrErrorMessage;
                if (selectedDwrErrorMessage.isNull())
                {
                    stackTrace.clearTable();
                    codeViewer.enabled(false);
                    return;
                }
                var filteredTraces = new List <Dwr_ErrorMessage_StackTrace>();
                foreach (var trace in dwrErrorMessage.StackTrace)
                {
                    if (hideGeneratedMethods.isFalse() || trace.LineNumber.toInt() > 1)
                    {
                        if (regExFilter.valid().isFalse() || trace.ClassName.regEx(regExFilter) || trace.FileName.regEx(regExFilter) || trace.MethodName.regEx(regExFilter))
                        {
                            filteredTraces.Add(trace);
                        }
                    }
                }
                //var filteredTraces = traces;
                stackTrace.title("Showing  {0} traces".format(filteredTraces.size()));
                stackTrace.show(filteredTraces);
                stackTrace.selectFirst();
            };


            Action refreshStackTrace =
                () => {
                if (selectedDwrErrorMessage.notNull())
                {
                    showStackTrace(selectedDwrErrorMessage);
                }
                //show.info(selectedFuzzRequest);
            };

            stackTracePanel.insert_Above(30)
            .add_CheckBox("Hide Generated Methods", 0, 0, (value) => { hideGeneratedMethods = value; refreshStackTrace(); }).autoSize().check()
            .append_Label("RegEx Filter:").topAdd(2).leftAdd(40)
            .append_TextBox(regExFilter).onEnter((text) => { regExFilter = text; refreshStackTrace(); });

            stackTrace.afterSelect_get_Row(
                (row) => {
                var values = row.values();
                showTraceInCodeViewer(values[0], values[2]);
            });


            return(showStackTrace);
        }