if (editor == null)
{
return;
}
final ReportDesignerDesignTimeContext theDesignTimeContext = new ReportDesignerDesignTimeContext(getReportDesignerContext());
final DataFactory dataFactory = editor.performEdit(theDesignTimeContext, null, null);
if (dataFactory == null)
{
return;
}
try
{
final Window theParentWindow = theDesignTimeContext.getParentWindow();
theParentWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
final AbstractReportDefinition element = activeContext.getReportDefinition();
final DataFactory originalDataFactory = element.getDataFactory();
final String queryAttribute = (String) element.getAttribute(AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.QUERY);
if (StringUtils.isEmpty(queryAttribute) && dataFactory.getQueryNames().length > 0)
{
element.setAttribute(AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.QUERY, dataFactory.getQueryNames()[0]);
}
if (originalDataFactory == null || isEmpty(dataFactory))
{
element.setDataFactory(CompoundDataFactory.normalize(dataFactory));
}
else
{
final CompoundDataFactory reportDf = CompoundDataFactory.normalize(originalDataFactory);
final int position = reportDf.size();
reportDf.add(dataFactory);
activeContext.getUndo().addChange(ActionMessages.getString("AddDataFactoryAction.UndoText"),
new DataSourceEditUndoEntry(position, null, dataFactory.derive()));
element.setDataFactory(reportDf);
}
}
finally
{
if(activeContext.getReportDataSchemaModel() != null &&
activeContext.getReportDataSchemaModel().getDataFactoryException() != null) {
UncaughtExceptionsModel.getInstance().addException(activeContext.getReportDataSchemaModel().getDataFactoryException());
}
final Window theParentWindow = theDesignTimeContext.getParentWindow();
theParentWindow.setCursor(Cursor.getDefaultCursor());
}
}