if (log.isDebugEnabled())
{
log.debug("valueChanged : selected node - " + node);
}
StyledDocument statsDoc = stats.getStyledDocument();
try
{
statsDoc.remove(0, statsDoc.getLength());
sampleDataField.setText("");
results.setText("");
if (node != null)
{
SampleResult res = (SampleResult) node.getUserObject();
if (log.isDebugEnabled())
{
log.debug("valueChanged1 : sample result - " + res);
}
if (res != null)
{
// load time label
log.debug("valueChanged1 : load time - " + res.getTime());
if (res != null && res.getSamplerData() != null)
{
String sd;
String rh = res.getRequestHeaders();
if (rh==null)
{
sd=res.getSamplerData().trim();
} else {
sd=res.getSamplerData().trim()
+"\n"+rh;
}
sampleDataField.setText(sd);
}
statsDoc.insertString(
statsDoc.getLength(),
"Load time: " + res.getTime() + "\n",
null);
String responseCode = res.getResponseCode();
log.debug(
"valueChanged1 : response code - " + responseCode);
int responseLevel = 0;
if (responseCode != null)
{
try
{
responseLevel =
Integer.parseInt(responseCode) / 100;
}
catch (NumberFormatException numberFormatException)
{
// no need to change the foreground color
}
}
Style style = null;
switch (responseLevel)
{
case 3 :
style = statsDoc.getStyle("Redirect");
break;
case 4 :
style = statsDoc.getStyle("ClientError");
break;
case 5 :
style = statsDoc.getStyle("ServerError");
break;
}
statsDoc.insertString(
statsDoc.getLength(),
"HTTP response code: " + responseCode + "\n",
style);
// response message label
String responseMsgStr = res.getResponseMessage();
log.debug(
"valueChanged1 : response message - " + responseMsgStr);
statsDoc.insertString(
statsDoc.getLength(),
"HTTP response message: " + responseMsgStr + "\n",
null);
statsDoc.insertString(
statsDoc.getLength(),
"\nHTTP response headers:\n" + res.getResponseHeaders() + "\n",
null);
// get the text response and image icon
// to determine which is NOT null