final AbstractReportDefinition definition = activeContext.getReportDefinition();
if (definition instanceof SubReport == false)
{
throw new IllegalStateException();
}
final SubReport subReport = (SubReport) definition;
final Component parent = context.getView().getParent();
final Window window = LibSwingUtil.getWindowAncestor(parent);
final SubReportParameterDialog parameterDialog;
if (window instanceof JDialog)
{
parameterDialog = new SubReportParameterDialog((JDialog) window);
}
else if (window instanceof JFrame)
{
parameterDialog = new SubReportParameterDialog((JFrame) window);
}
else
{
parameterDialog = new SubReportParameterDialog();
}
final SubReportParameterDialog.EditResult editResult =
parameterDialog.performEdit(context, subReport.getInputMappings(), subReport.getExportMappings());
if (editResult == null)
{
return;
}
final ParameterMapping[] oldImportMapping = subReport.getInputMappings();
final ParameterMapping[] oldExportMapping = subReport.getExportMappings();
activeContext.getUndo().addChange(ActionMessages.getString("EditParametersAction.SubReport.Text"),
new EditSubreportParametersUndoEntry
(oldImportMapping, oldExportMapping, editResult.getImportParameters(), editResult.getExportParameters()));
subReport.setExportMappings(editResult.getExportParameters());
subReport.setInputMappings(editResult.getImportParameters());
}