use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class DBNBookmark method getNodeDescription.
@Override
public String getNodeDescription() {
String dsInfo = "";
Collection<DBPDataSourceContainer> dataSources = getAssociatedDataSources();
if (!CommonUtils.isEmpty(dataSources)) {
DBPDataSourceContainer dataSource = dataSources.iterator().next();
dsInfo = " ('" + dataSource.getName() + "' - " + dataSource.getDriver().getName() + ")";
}
return storage.getDescription() + dsInfo;
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class AuthModelSelector method loadSettings.
public void loadSettings(DBPDataSourceContainer dataSourceContainer, DBPAuthModelDescriptor activeAuthModel, String defaultAuthModelId) {
this.activeDataSource = dataSourceContainer;
this.selectedAuthModel = activeAuthModel;
this.allAuthModels = activeDataSource.getDriver() == DriverDescriptor.NULL_DRIVER ? DataSourceProviderRegistry.getInstance().getAllAuthModels() : DataSourceProviderRegistry.getInstance().getApplicableAuthModels(activeDataSource.getDriver());
this.allAuthModels.removeIf(o -> modelFilter != null && !modelFilter.isValidElement(o));
this.allAuthModels.sort((Comparator<DBPAuthModelDescriptor>) (o1, o2) -> AuthModelDatabaseNative.ID.equals(o1.getId()) ? -1 : (AuthModelDatabaseNative.ID.equals(o2.getId()) ? 1 : o1.getName().compareTo(o2.getName())));
if (selectedAuthModel == null && !CommonUtils.isEmpty(defaultAuthModelId)) {
// Set default to native
for (DBPAuthModelDescriptor amd : allAuthModels) {
if (amd.getId().equals(defaultAuthModelId)) {
selectedAuthModel = amd;
break;
}
}
if (selectedAuthModel == null) {
// First one
selectedAuthModel = allAuthModels.get(0);
}
}
changeAuthModel();
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
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, DBWorkbench.getPlatform().getWorkspace().getProject(scripts.get(0).getProject()), null);
if (dialog.open() == IDialogConstants.CANCEL_ID) {
return null;
}
DBPDataSourceContainer dataSource = dialog.getDataSource();
for (IFile script : scripts) {
EditorUtils.setFileDataSource(script, new SimpleDatabaseEditorContext(dataSource));
DBNUtils.refreshNavigatorResource(script, dataSource);
}
}
return null;
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class NNAHDataSourceReadOnly method handleNodeAction.
@Override
public void handleNodeAction(INavigatorModelView view, DBNNode node, Event event, boolean defaultAction) {
if (node instanceof DBNDatabaseNode) {
DBPDataSourceContainer dataSourceContainer = ((DBNDatabaseNode) node).getDataSourceContainer();
UIServiceConnections serviceConnections = DBWorkbench.getService(UIServiceConnections.class);
if (serviceConnections != null) {
serviceConnections.openConnectionEditor(dataSourceContainer, "ConnectionPageGeneral");
}
}
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class WMIConnectionPage method loadSettings.
@Override
public void loadSettings() {
// Load values from new connection info
DBPDataSourceContainer activeDataSource = site.getActiveDataSource();
DBPConnectionConfiguration connectionInfo = activeDataSource.getConnectionConfiguration();
if (connectionInfo.getHostName() == null) {
connectionInfo.setHostName(DEFAULT_HOST);
}
if (connectionInfo.getDatabaseName() == null) {
connectionInfo.setDatabaseName(DEFAULT_NAMESPACE);
}
if (hostText != null) {
hostText.setText(CommonUtils.notEmpty(connectionInfo.getHostName()));
}
if (domainText != null) {
domainText.setText(CommonUtils.notEmpty(connectionInfo.getServerName()));
}
if (namespaceCombo != null) {
namespaceCombo.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
}
super.loadSettings();
}
Aggregations