use of org.jkiss.dbeaver.ui.dialogs.connection.SelectDataSourceDialog in project dbeaver by dbeaver.
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()) {
SelectDataSourceDialog dialog = new SelectDataSourceDialog(HandlerUtil.getActiveShell(event), project, null);
if (dialog.open() == IDialogConstants.CANCEL_ID) {
return null;
}
dataSourceContainer = dialog.getDataSource();
}
}
return dataSourceContainer;
}
use of org.jkiss.dbeaver.ui.dialogs.connection.SelectDataSourceDialog in project dbeaver by dbeaver.
the class NavigatorHandlerAssociateScript method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final Shell activeShell = HandlerUtil.getActiveShell(event);
List<IFile> scripts = new ArrayList<>();
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
for (Iterator iter = ((IStructuredSelection) selection).iterator(); iter.hasNext(); ) {
final DBNNode node = RuntimeUtils.getObjectAdapter(iter.next(), DBNNode.class);
if (node instanceof DBNResource) {
IResource resource = ((DBNResource) node).getResource();
if (resource instanceof IFile) {
scripts.add((IFile) resource);
}
}
}
}
if (!scripts.isEmpty()) {
SelectDataSourceDialog dialog = new SelectDataSourceDialog(activeShell, scripts.get(0).getProject(), null);
if (dialog.open() == IDialogConstants.CANCEL_ID) {
return null;
}
DBPDataSourceContainer dataSource = dialog.getDataSource();
for (IFile script : scripts) {
EditorUtils.setFileDataSource(script, dataSource, true);
}
}
return null;
}
use of org.jkiss.dbeaver.ui.dialogs.connection.SelectDataSourceDialog in project dbeaver by dbeaver.
the class DataSourceManagementToolbar method showConnectionSelector.
void showConnectionSelector() {
SelectDataSourceDialog dialog = new SelectDataSourceDialog(connectionCombo.getShell(), getActiveProject(), connectionCombo.getSelectedItem());
dialog.setModeless(true);
if (dialog.open() == IDialogConstants.CANCEL_ID) {
return;
}
DBPDataSourceContainer dataSource = dialog.getDataSource();
connectionCombo.select(dataSource);
changeDataSourceSelection(dataSource);
}
Aggregations