Search in sources :

Example 6 with ProjectRegistry

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;
}
Also used : DataSourceRegistry(org.jkiss.dbeaver.registry.DataSourceRegistry) ProjectRegistry(org.jkiss.dbeaver.registry.ProjectRegistry) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) IProject(org.eclipse.core.resources.IProject) Nullable(org.jkiss.code.Nullable)

Aggregations

ProjectRegistry (org.jkiss.dbeaver.registry.ProjectRegistry)6 IProject (org.eclipse.core.resources.IProject)2 DBeaverCore (org.jkiss.dbeaver.core.DBeaverCore)2 File (java.io.File)1 IResource (org.eclipse.core.resources.IResource)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Nullable (org.jkiss.code.Nullable)1 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)1 DBPResourceHandler (org.jkiss.dbeaver.model.app.DBPResourceHandler)1 DefaultCertificateStorage (org.jkiss.dbeaver.model.impl.app.DefaultCertificateStorage)1 DBNModel (org.jkiss.dbeaver.model.navigator.DBNModel)1 DBNProject (org.jkiss.dbeaver.model.navigator.DBNProject)1 OSDescriptor (org.jkiss.dbeaver.model.runtime.OSDescriptor)1 DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)1 DataSourceRegistry (org.jkiss.dbeaver.registry.DataSourceRegistry)1 IPluginService (org.jkiss.dbeaver.runtime.IPluginService)1 KeepAliveJob (org.jkiss.dbeaver.runtime.jobs.KeepAliveJob)1 GlobalProxyAuthenticator (org.jkiss.dbeaver.runtime.net.GlobalProxyAuthenticator)1 GlobalProxySelector (org.jkiss.dbeaver.runtime.net.GlobalProxySelector)1