listExecutionTrace.add((ExecutionTrace) f);
}
}
int layoutRow = 1;
int executionTraceLine = 0;
ExecutionTrace previousEx = null;
for (int i = 0; i < fixtures.size(); i++) {
final Object f = fixtures.get(i);
if (f instanceof ExecutionTrace) {
previousEx = (ExecutionTrace) f;
HorizontalPanel h = new HorizontalPanel();
h.add(getNewExpectationButton(previousEx, scenario));
h.add(new SmallLabel(constants.EXPECT()));
editorLayout.setWidget(layoutRow, 0, h);
final ExecutionTrace et = (ExecutionTrace) previousEx;
Image del = new ImageButton("images/delete_item_small.gif", constants.DeleteItem(), new ClickListener() {
public void onClick(Widget w) {
if (Window.confirm(constants.AreYouSureYouWantToRemoveThisItem())) {
scenario.removeExecutionTrace(et);
renderEditor();
}
}
});
h.add(del);
executionTraceLine++;
if (executionTraceLine >= listExecutionTrace.size()) {
executionTraceLine = listExecutionTrace.size() - 1;
}
editorLayout.setWidget(layoutRow, 1, new ExecutionWidget(previousEx, showResults));
//layout.setWidget(layoutRow, 2, getNewExpectationButton(previousEx, scenario, availableRules));
editorLayout.getFlexCellFormatter().setHorizontalAlignment(layoutRow, 2, HasHorizontalAlignment.ALIGN_LEFT);
} else if (f instanceof Map) {
HorizontalPanel h = new HorizontalPanel();
h.add(getNewDataButton(previousEx, scenario, listExecutionTrace.get(executionTraceLine)));
h.add(new SmallLabel(constants.GIVEN()));
editorLayout.setWidget(layoutRow, 0, h);
layoutRow++;
Map given = (Map) f;
VerticalPanel vert = new VerticalPanel();
for (Iterator iterator = given.entrySet().iterator(); iterator.hasNext();) {
Map.Entry e = (Map.Entry) iterator.next();
List itemList = (List) given.get(e.getKey());
if (e.getKey().equals(ScenarioHelper.RETRACT_KEY)) {
vert.add(new RetractWidget(itemList,
scenario));
} else if (e.getKey().equals(ScenarioHelper.ACTIVATE_RULE_FLOW_GROUP)) {
vert.add(new ActivateRuleFlowWidget(itemList,
scenario));
} else {
vert.add(new DataInputWidget((String) e.getKey(),
itemList,
false,
scenario,
sce,
this,
listExecutionTrace.get(executionTraceLine)));
}
}
if (given.size() > 0) {
editorLayout.setWidget(layoutRow, 1, vert);
} else {
editorLayout.setWidget(layoutRow, 1, new HTML("<i><small>" + constants.AddInputDataAndExpectationsHere() + "</small></i>"));
}
} else {
List l = (List) f;
Fixture first = (Fixture) l.get(0);
if (first instanceof VerifyFact) {
doVerifyFacts(l,
editorLayout,
layoutRow,
scenario,
listExecutionTrace.get(executionTraceLine));
} else if (first instanceof VerifyRuleFired) {
editorLayout.setWidget(layoutRow,
1,
new VerifyRulesFiredWidget(l,
scenario,
showResults));
}
}
layoutRow++;
}
//add more execution sections.
Button addExecute = new Button(constants.MoreDotDot());
addExecute.setTitle(constants.AddAnotherSectionOfDataAndExpectations());
addExecute.addClickListener(new ClickListener() {
public void onClick(Widget w) {
scenario.fixtures.add(new ExecutionTrace());
renderEditor();
}
});
editorLayout.setWidget(layoutRow, 0, addExecute);
//layout.getFlexCellFormatter().setHorizontalAlignment(layoutRow, 1, HasHorizontalAlignment.ALIGN_CENTER);