report = designer.report;
// If we have been handed a aggregate field's widget, find the widget of
// the original field.
if (fieldWidget.getField() instanceof AggregateField) {
final Field fieldToAggregate = getAggregateField().getField();
final FieldWidget[] list = new FieldWidget[1];
designer.withWidgetsDo(new FieldWidgetWalker() {
public void step(FieldWidget fw) {
Field f = fw.getField();
if (f == fieldToAggregate)
list[0] = fw;
}
});
fieldWidget = list[0];
// Reset window title
setTitle(I18N.get("AggregatesWin.title_prefix") + ' ' + fieldWidget);
}
// Create a hash that maps either a group or a report footer section to
// the associated existing aggregate widget.
final HashMap aggregates = new HashMap();
final AbstractList subs =
designer.report.getAggregateFieldsFor(fieldWidget.getField());
designer.withWidgetsDo(new FieldWidgetWalker() {
public void step(FieldWidget fw) {
Field f = fw.getField();
if (subs.contains(f)) {
Object key = ((AggregateField)f).getGroup();
if (key == null)
key = fw.getField().getSection();
aggregates.put(key, fw);