for(Object iReport: subreports) {
crossReportCombo.addItem(iReport);
}
}
//set default
CrossReport localReport = range.getCrossReport();
if(localReport != null) {
crossReportCombo.setSelectedItem(localReport.getSubReport());
} else {
crossReportCombo.setSelectedItem(NOTUSED);
}
crossReportCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Object selValue = crossReportCombo.getSelectedItem();
if(selValue == NOTUSED) {
selValue = null;
}
QueryExecuterSub newValue = (QueryExecuterSub) selValue;
QueryExecuterSub oldValue = range.getCrossReport() == null
? null : range.getCrossReport().getSubReport();
if(oldValue == newValue
|| (oldValue != null && oldValue.equals(newValue))) {
return;
}
if(oldValue != null && !range.canRemoveCrossReport(range.getCrossReport())) {
crossReportCombo.setSelectedItem(oldValue);
Message.warning(parent, "Кросс-отчет иcпользуется и не может быть сменен");
} else {
range.setCrossReport(new CrossReport(newValue));
initCriteriaPanel();
}
}
});
}