private void handleEvent(final OtpErlangObject msg) throws TermParserException,
OtpErlangException {
final OtpErlangTuple tuple = (OtpErlangTuple) msg;
final String tag = ((OtpErlangAtom) tuple.elementAt(0)).atomValue();
final OtpErlangObject value = tuple.elementAt(1);
TestCaseData test;
if ("init".equals(tag)) {
// value = {Dir, Suite, Case}
label.setText("Started: " + formatTitle(value)
+ ". Compiling files, please wait...");
treeViewer.getTree().setCursor(
treeViewer.getTree().getShell().getDisplay()
.getSystemCursor(SWT.CURSOR_WAIT));
} else if ("start_failed".equals(tag)) {
// value = ?
} else if ("log_started".equals(tag)) {
// value = Dir
treeViewer.getTree().setCursor(
treeViewer.getTree().getShell().getDisplay()
.getSystemCursor(SWT.CURSOR_ARROW));
} else if ("start".equals(tag)) {
// value = {Module, Function}
final Bindings bindings = OtpErlang.match("{M:a,F:a}", value);
final String mod = bindings.getAtom("M");
final String fun = bindings.getAtom("F");
test = findCase(mod, fun);
test.setRunning();
} else if ("result".equals(tag)) {
// value = {Module, Function, Result}
final Bindings bindings = OtpErlang.match("{M:a,F:a,R}", value);
final String mod = bindings.getAtom("M");
final String fun = bindings.getAtom("F");
final OtpErlangObject result = bindings.get("R");
test = findCase(mod, fun);
if (result instanceof OtpErlangAtom) {
test.setSuccesful();
// } else {
// final BindingsImpl bindings =
// OtpErlang.match("{failure,{M:a,F:a},L,R}", result);
// final OtpErlangObject locations = bindings.get("L");
// final OtpErlangObject reason = bindings.get("R");
// test.setFailed(reason, locations);
}
} else if ("fail".equals(tag)) {
// value = {{Module, Function}, [Locations], Reason
final Bindings bindings = OtpErlang.match("{{M:a,F:a},L,R}", value);
final String mod = bindings.getAtom("M");
final String fun = bindings.getAtom("F");
final Collection<OtpErlangObject> locations = bindings.getList("L");
final OtpErlangObject reason = bindings.get("R");
test = findCase(mod, fun);
test.setFailed(reason, locations);
} else if ("skip".equals(tag)) {
// value = {Module, Function, Comment
final Bindings bindings = OtpErlang.match("{M:a,F:a,C}", value);
final String mod = bindings.getAtom("M");
final String fun = bindings.getAtom("F");
final OtpErlangObject reason = bindings.get("C");
test = findCase(mod, fun);
test.setSkipped(reason);
} else if ("done".equals(tag)) {
// value = Module, Log, {Successful,Failed,Skipped}, [Results]}
final Bindings bindings = OtpErlang.match("{M,L,{S:i,F:i,K:i},R}", value);