use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class DatabaseNavigatorLabelProvider method getForeground.
@Override
public Color getForeground(Object element) {
if (element instanceof DBNNode) {
DBNNode node = (DBNNode) element;
if (node instanceof DBNDataSource) {
DBPDataSourceContainer ds = ((DBNDataSource) element).getDataSourceContainer();
Color bgColor = UIUtils.getConnectionColor(ds.getConnectionConfiguration());
return bgColor == null ? null : UIUtils.getContrastColor(bgColor);
}
if (node.isLocked()) {
return lockedForeground;
}
if (node instanceof DBSWrapper && ((DBSWrapper) node).getObject() != null && !((DBSWrapper) node).getObject().isPersisted()) {
return transientForeground;
}
}
return null;
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class GotoObjectDialog method fillContentProvider.
@Override
protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
DBSStructureAssistant structureAssistant = DBUtils.getAdapter(DBSStructureAssistant.class, context.getDataSource());
if (structureAssistant == null) {
return;
}
String nameMask = ((ObjectFilter) itemsFilter).getNameMask();
DBRProgressMonitor monitor = RuntimeUtils.makeMonitor(progressMonitor);
try {
monitor.beginTask("Search for '" + nameMask + "'", 100);
List<DBSObjectType> typesToSearch = new ArrayList<>();
for (DBSObjectType type : structureAssistant.getSearchObjectTypes()) {
if (!isValidObjectType(type)) {
// Skip attributes (columns), methods, etc
continue;
}
if (!Boolean.TRUE.equals(enabledTypes.get(type.getTypeName()))) {
continue;
}
typesToSearch.add(type);
}
ObjectFinder objectFinder = new ObjectFinder(structureAssistant, monitor, context, typesToSearch, nameMask);
DBExecUtils.tryExecuteRecover(monitor, context.getDataSource(), objectFinder);
DBPDataSourceContainer dsContainer = context.getDataSource().getContainer();
for (DBSObjectReference ref : objectFinder.getResult()) {
DBSObjectFilter filter = dsContainer.getObjectFilter(ref.getObjectClass(), ref.getContainer(), true);
if (filter == null || !filter.isEnabled() || filter.matches(ref.getName())) {
contentProvider.add(ref, itemsFilter);
}
}
} catch (DBException e) {
throw new CoreException(GeneralUtils.makeExceptionStatus(e));
} finally {
monitor.done();
}
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class DebugUtils method findDatabaseObject.
public static DBSObject findDatabaseObject(DBGController controller, Object identifier, DBRProgressMonitor monitor) throws DBException {
DBPDataSourceContainer container = controller.getDataSourceContainer();
Map<String, Object> context = controller.getDebugConfiguration();
return resolveDatabaseObject(container, context, identifier, monitor);
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class DatabaseLaunchDelegate method launch.
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
DBPDataSourceContainer datasourceDescriptor = DebugUtils.getDataSourceContainer(configuration);
DBGController controller = createController(datasourceDescriptor, configuration.getAttributes());
if (controller == null) {
String message = NLS.bind("Unable to find debug controller for datasource {0}", datasourceDescriptor);
throw new CoreException(DebugUtils.newErrorStatus(message));
}
DatabaseProcess process = createProcess(launch, configuration.getName());
DatabaseDebugTarget target = createDebugTarget(launch, controller, process);
target.connect(monitor);
launch.addDebugTarget(target);
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by serge-rider.
the class PostgreFDWConfigWizardPageConfig method loadSettings.
private void loadSettings() {
DBPDataSourceContainer targetDataSource = getWizard().getSelectedDataSource();
if (targetDataSource == null) {
setErrorMessage("No target data source");
return;
}
// Fill FDW list
try {
getWizard().getRunnableContext().run(false, true, monitor -> {
try {
schemaList = new ArrayList<>();
schemaList.addAll(getWizard().getDatabase().getSchemas(monitor));
// Fill from both installed FDW and pre-configured FDW
fdwList = new ArrayList<>();
for (PostgreForeignDataWrapper fdw : CommonUtils.safeCollection(getWizard().getDatabase().getForeignDataWrappers(monitor))) {
PostgreFDWConfigWizard.FDWInfo fdwInfo = new PostgreFDWConfigWizard.FDWInfo();
fdwInfo.installedFDW = fdw;
fdwList.add(fdwInfo);
}
for (FDWConfigDescriptor fdw : FDWConfigRegistry.getInstance().getConfigDescriptors()) {
boolean found = false;
for (PostgreFDWConfigWizard.FDWInfo fdwInfo : fdwList) {
if (fdwInfo.getId().equals(fdw.getFdwId())) {
fdwInfo.fdwDescriptor = fdw;
found = true;
break;
}
}
if (!found) {
PostgreFDWConfigWizard.FDWInfo fdwInfo = new PostgreFDWConfigWizard.FDWInfo();
fdwInfo.fdwDescriptor = fdw;
fdwList.add(fdwInfo);
}
}
} catch (DBException e) {
throw new InvocationTargetException(e);
}
});
} catch (InvocationTargetException e) {
log.debug(e.getTargetException());
setErrorMessage(e.getTargetException().getMessage());
return;
} catch (InterruptedException e) {
return;
}
setErrorMessage(null);
// Detect FDW from target container
PostgreFDWConfigWizard.FDWInfo fdwInfo = getWizard().getSelectedFDW();
if (fdwInfo == null) {
FDWConfigDescriptor fdwConfig = FDWConfigRegistry.getInstance().findFirstMatch(targetDataSource);
if (fdwConfig != null) {
for (PostgreFDWConfigWizard.FDWInfo fdw : fdwList) {
if (fdw.fdwDescriptor == fdwConfig) {
fdwInfo = fdw;
break;
}
}
}
}
fdwCombo.removeAll();
for (PostgreFDWConfigWizard.FDWInfo fdw : fdwList) {
String fdwName = fdw.getId();
if (!CommonUtils.isEmpty(fdw.getDescription())) {
fdwName += " (" + fdw.getDescription() + ")";
}
fdwCombo.add(fdwName);
}
if (fdwInfo != null) {
getWizard().setSelectedFDW(fdwInfo);
fdwCombo.setText(fdwInfo.getId());
}
schemaCombo.removeAll();
for (PostgreSchema schema : schemaList) {
schemaCombo.add(schema.getName());
}
PostgreSchema selectedSchema = getWizard().getSelectedSchema();
if (selectedSchema != null) {
schemaCombo.setText(selectedSchema.getName());
} else {
PostgreSchema publicSchema = DBUtils.findObject(schemaList, PostgreConstants.PUBLIC_SCHEMA_NAME);
if (publicSchema != null) {
schemaCombo.setText(publicSchema.getName());
getWizard().setSelectedSchema(publicSchema);
}
}
refreshFDWProperties();
if (CommonUtils.isEmpty(fdwServerText.getText())) {
String fdwServerId = (fdwInfo == null ? targetDataSource.getDriver().getId() : fdwInfo.getId()) + "_srv";
getWizard().setFdwServerId(fdwServerId);
fdwServerText.setText(fdwServerId);
}
// Fill entities
targetDataSourceText.setText(targetDataSource.getName());
targetDriverText.setText(targetDataSource.getDriver().getName());
entityTable.removeAll();
for (DBNDatabaseNode entityNode : getWizard().getSelectedEntities()) {
TableItem item = new TableItem(entityTable, SWT.NONE);
item.setImage(0, DBeaverIcons.getImage(entityNode.getNodeIconDefault()));
item.setText(0, entityNode.getNodeFullName());
}
UIUtils.packColumns(entityTable, false);
propsEditor.repackColumns();
updatePageCompletion();
}
Aggregations