// Edit data-source from structure panel
reportDesignerContext.getActiveContext().getSelectionModel().setSelectedElements(new Object[]{dataFactory});
final EditQueryAction editQueryAction = new EditQueryAction();
editQueryAction.setReportDesignerContext(reportDesignerContext);
editQueryAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, ""));
final int idx = availableDataSourcesModel.indexOf(dataFactory);
if (idx == -1)
{
throw new IllegalStateException("DataSource Model is out of sync with the GUI");