use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class PostgreFDWConfigWizardPageConfig method refreshFDWProperties.
private void refreshFDWProperties() {
{
// Fill options
DBPDataSourceContainer targetDataSource = getWizard().getSelectedDataSource();
PostgreFDWConfigWizard.FDWInfo selectedFDW = getWizard().getSelectedFDW();
PropertySourceCustom propertySource = getWizard().getFdwPropertySource();
propertySource.setDefValueResolver(targetDataSource.getVariablesResolver(false));
propertySource.removeAll();
if (selectedFDW != null && selectedFDW.fdwDescriptor != null) {
propertySource.addProperties(selectedFDW.fdwDescriptor.getProperties());
} else if (selectedFDW != null) {
// Add some default props
propertySource.addProperty(new PropertyDescriptor(null, "host", "host", "Remote database host", false, String.class, "${host}", null));
propertySource.addProperty(new PropertyDescriptor(null, "port", "port", "Remote database port", false, String.class, "${port}", null));
propertySource.addProperty(new PropertyDescriptor(null, "dbname", "dbname", "Remote database name", false, String.class, "${database}", null));
}
propsEditor.loadProperties(propertySource);
}
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class PostgreFDWConfigWizardPageInput method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = UIUtils.createComposite(parent, 1);
{
Group databasesGroup = UIUtils.createControlGroup(composite, "Foreign databases", 1, GridData.FILL_BOTH, 0);
selectorPanel = new DatabaseObjectsSelectorPanel(databasesGroup, true, getWizard().getRunnableContext()) {
@Override
protected boolean isDatabaseObjectVisible(DBSObject obj) {
return super.isDatabaseObjectVisible(obj);
}
@Override
protected void onSelectionChange(Object element) {
updateState();
}
@Override
protected boolean isFolderVisible(DBNLocalFolder folder) {
List<DBPDataSourceContainer> dataSources = getWizard().getAvailableDataSources();
for (DBNDataSource ds : folder.getNestedDataSources()) {
if (dataSources.contains(ds.getDataSourceContainer())) {
return true;
}
}
return false;
}
@Override
protected boolean isDataSourceVisible(DBNDataSource dataSource) {
return getWizard().getAvailableDataSources().contains(dataSource.getDataSourceContainer());
}
};
Composite buttonsPanel = UIUtils.createComposite(databasesGroup, 2);
UIUtils.createDialogButton(buttonsPanel, "Add database", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SelectDataSourceDialog dialog = new SelectDataSourceDialog(getShell(), selectorPanel.getProject(), null);
if (dialog.open() == IDialogConstants.OK_ID) {
DBPDataSourceContainer dataSource = dialog.getDataSource();
if (dataSource != null) {
getWizard().addAvailableDataSource(dataSource);
refreshDataSources();
}
}
}
});
Button delButton = UIUtils.createDialogButton(buttonsPanel, "Remove database", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBNNode selectedNode = NavigatorUtils.getSelectedNode(selectorPanel.getSelection());
if (selectedNode instanceof DBNDatabaseNode) {
getWizard().removeAvailableDataSource(((DBNDatabaseNode) selectedNode).getDataSourceContainer());
refreshDataSources();
}
}
});
delButton.setEnabled(false);
selectorPanel.addSelectionListener(event -> {
DBNNode selectedNode = NavigatorUtils.getSelectedNode(event.getSelection());
delButton.setEnabled(selectedNode instanceof DBNDatabaseNode);
});
}
setControl(composite);
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class PostgreDebugUIAdapterFactory method getAdapter.
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adapterType == DBGEditorAdvisor.class) {
if (adaptableObject instanceof DBPDataSourceContainer) {
DBPDataSourceContainer sourceContainer = (DBPDataSourceContainer) adaptableObject;
DBPDataSource dataSource = sourceContainer.getDataSource();
if (dataSource instanceof PostgreDataSource) {
return adapterType.cast(debugEditorAdvisor);
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class AbstractNativeToolHandler method validateClientHome.
private void validateClientHome(DBRProgressMonitor monitor, SETTINGS settings) throws DBCException {
DBPDataSourceContainer dataSourceContainer = settings.getDataSourceContainer();
if (isNativeClientHomeRequired()) {
String clientHomeId = dataSourceContainer.getConnectionConfiguration().getClientHomeId();
final DBPDriver driver = dataSourceContainer.getDriver();
final List<DBPNativeClientLocation> clientLocations = driver.getNativeClientLocations();
final DBPNativeClientLocationManager locationManager = driver.getNativeClientManager();
if (locationManager != null) {
clientLocations.addAll(locationManager.findLocalClientLocations());
}
if (clientHomeId == null) {
if (!clientLocations.isEmpty()) {
settings.setClientHome(clientLocations.get(0));
} else {
settings.setClientHome(null);
}
if (settings.getClientHome() == null) {
throw new DBCException("Client binaries location is not specified");
}
} else {
DBPNativeClientLocation clientHome = DBUtils.findObject(clientLocations, clientHomeId);
if (clientHome == null) {
clientHome = settings.findNativeClientHome(clientHomeId);
}
settings.setClientHome(clientHome);
}
if (settings.getClientHome() == null) {
throw new DBCException("Native client home '" + clientHomeId + "' not found");
}
}
DBPNativeClientLocation clientHome = settings.getClientHome();
if (!isNativeClientHomeRequired() || clientHome == null) {
return;
}
try {
clientHome.validateFilesPresence(monitor);
} catch (DBException e) {
throw new DBCException("Error downloading client file(s)", e);
} catch (InterruptedException e) {
// ignore
throw new DBCException("Client file download interrupted", e);
}
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class NativeToolWizardDialog method openClientConfiguration.
private void openClientConfiguration() {
AbstractNativeToolWizard toolWizard = (AbstractNativeToolWizard) getWizard();
DBPDataSourceContainer dataSource = toolWizard.getSettings().getDataSourceContainer();
if (dataSource != null) {
NativeClientConfigDialog dialog = new NativeClientConfigDialog(getShell(), dataSource);
if (dialog.open() == IDialogConstants.OK_ID) {
toolWizard.updateErrorMessage();
updateButtons();
}
}
}
Aggregations