use of org.jkiss.dbeaver.registry.ProjectRegistry in project dbeaver by serge-rider.
the class OpenHandler method getCurrentConnection.
@Nullable
private static DBPDataSourceContainer getCurrentConnection(ExecutionEvent event) {
DBPDataSourceContainer dataSourceContainer = getDataSourceContainer(event, false);
final ProjectRegistry projectRegistry = DBeaverCore.getInstance().getProjectRegistry();
IProject project = dataSourceContainer != null ? dataSourceContainer.getRegistry().getProject() : projectRegistry.getActiveProject();
if (dataSourceContainer == null) {
final DataSourceRegistry dataSourceRegistry = projectRegistry.getDataSourceRegistry(project);
if (dataSourceRegistry == null) {
return null;
}
if (dataSourceRegistry.getDataSources().size() == 1) {
dataSourceContainer = dataSourceRegistry.getDataSources().get(0);
} else if (!dataSourceRegistry.getDataSources().isEmpty()) {
dataSourceContainer = SelectDataSourceDialog.selectDataSource(HandlerUtil.getActiveShell(event), project);
}
}
return dataSourceContainer;
}
Aggregations