int totalCols = defList.size();
for (Iterator iterator = defList.iterator(); iterator.hasNext();) {
final FactData d = (FactData) iterator.next();
for (int i = 0; i < d.fieldData.size(); i++) {
final FieldData fd = d.fieldData.get(i);
if (!fields.containsKey(fd.name)) {
int idx = fields.size() + 1;
fields.put(fd.name, new Integer(idx));
t.setWidget(idx, 0, new SmallLabel(fd.name + ":"));
Image del = new ImageButton("images/delete_item_small.gif", constants.RemoveThisRow(), new ClickListener() {
public void onClick(Widget w) {
if (Window.confirm(constants.AreYouSureYouWantToRemoveThisRow())) {
ScenarioHelper.removeFields(defList, fd.name);
outer.setWidget(1, 0, render(defList));
}
}
});
t.setWidget(idx, totalCols + 1, del);
t.getCellFormatter().setHorizontalAlignment(idx, 0, HasHorizontalAlignment.ALIGN_RIGHT);
}
}
}
int totalRows = fields.size();
t.getFlexCellFormatter().setHorizontalAlignment(totalRows + 1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
//now we go through the facts and the fields, adding them to the grid
//if a fact is missing a FieldData, we will add it in (so people can enter data later on)
col = 0;
for (Iterator iterator = defList.iterator(); iterator.hasNext();) {
final FactData d = (FactData) iterator.next();
t.setWidget(0, ++col, new SmallLabel("[" + d.name + "]"));
Image del = new ImageButton("images/delete_item_small.gif", Format.format(constants.RemoveTheColumnForScenario(), d.name), new ClickListener() {
public void onClick(Widget w) {
if (scenario.isFactNameUsed(d)) {
Window.alert(Format.format(constants.CanTRemoveThisColumnAsTheName0IsBeingUsed(), d.name));
} else if (Window.confirm(constants.AreYouSureYouWantToRemoveThisColumn())) {
scenario.removeFixture(d);
defList.remove(d);
outer.setWidget(1, 0, render(defList));
}
}
});
t.setWidget(totalRows + 1, col, del);
Map presentFields = new HashMap(fields);
for (int i = 0; i < d.fieldData.size(); i++) {
FieldData fd = d.fieldData.get(i);
int fldRow = ((Integer) fields.get(fd.name)).intValue();
t.setWidget(fldRow, col, editableCell(fd, d.type));
presentFields.remove(fd.name);
}
for (Iterator missing = presentFields.entrySet().iterator(); missing.hasNext();) {
Map.Entry e = (Map.Entry) missing.next();
int fldRow = ((Integer) e.getValue()).intValue();
FieldData fd = new FieldData((String) e.getKey(), "");
d.fieldData.add(fd);
t.setWidget(fldRow, col, editableCell(fd, d.type));
}
}