use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class PendingTransactionsDialog method loadContexts.
private void loadContexts(boolean showAllContexts) {
contextTree.removeAll();
// Load all open context
for (DBPDataSourceContainer dataSource : DataSourceRegistry.getAllDataSources()) {
if (!dataSource.isConnected() || dataSource.getDataSource() == null) {
continue;
}
for (DBSInstance instance : dataSource.getDataSource().getAvailableInstances()) {
DBCExecutionContext[] allContexts = instance.getAllContexts();
if (ArrayUtils.isEmpty(allContexts)) {
continue;
}
List<DBCExecutionContext> txnContexts = new ArrayList<>();
for (DBCExecutionContext context : allContexts) {
if (showAllContexts || QMUtils.isTransactionActive(context, false)) {
txnContexts.add(context);
}
}
if (txnContexts.isEmpty()) {
continue;
}
TreeItem dsItem = new TreeItem(contextTree, SWT.NONE);
dsItem.setText(dataSource.getName());
dsItem.setImage(DBeaverIcons.getImage(dataSource.getDriver().getIcon()));
dsItem.setData(dataSource);
for (DBCExecutionContext context : txnContexts) {
QMTransactionState txnState = QMUtils.getTransactionState(context);
TreeItem contextItem = new TreeItem(dsItem, SWT.NONE);
contextItem.setText(0, context.getContextName());
String stateString = String.valueOf(txnState.getUpdateCount()) + "/" + String.valueOf(txnState.getExecuteCount());
contextItem.setText(1, stateString);
contextItem.setData(context);
}
dsItem.setExpanded(true);
}
}
UIUtils.asyncExec(new Runnable() {
@Override
public void run() {
UIUtils.packColumns(contextTree);
}
});
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class DataSourceInvalidateHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
DBCExecutionContext context = getActiveExecutionContext(event, false);
if (context != null) {
invalidateDataSource(context.getDataSource());
} else {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof IDataSourceContainerProviderEx) {
// Try to set the same container.
// It should trigger connection instantiation if for some reason it was lost (SQLEditor specific?)
DBPDataSourceContainer dsContainer = ((IDataSourceContainerProviderEx) editor).getDataSourceContainer();
if (dsContainer != null) {
((IDataSourceContainerProviderEx) editor).setDataSourceContainer(null);
((IDataSourceContainerProviderEx) editor).setDataSourceContainer(dsContainer);
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class DataSourceToolbarHandler method handleDataSourceEvent.
@Override
public void handleDataSourceEvent(final DBPEvent event) {
if (workbenchWindow.getWorkbench().isClosing()) {
return;
}
DBPDataSourceContainer currentDataSource = DataSourceToolbarUtils.getCurrentDataSource(workbenchWindow);
if ((event.getAction() == DBPEvent.Action.OBJECT_UPDATE && event.getObject() == currentDataSource) || (event.getAction() == DBPEvent.Action.OBJECT_SELECT && Boolean.TRUE.equals(event.getEnabled()) && DBUtils.getContainer(event.getObject()) == currentDataSource)) {
UIUtils.asyncExec(this::updateToolbar);
}
// TODO: replace with something smarter
if (event.getAction() == DBPEvent.Action.OBJECT_UPDATE && event.getEnabled() != null) {
DataSourcePropertyTester.firePropertyChange(DataSourcePropertyTester.PROP_CONNECTED);
DataSourcePropertyTester.firePropertyChange(DataSourcePropertyTester.PROP_TRANSACTIONAL);
UIUtils.asyncExec(() -> {
if (workbenchWindow instanceof WorkbenchWindow) {
((WorkbenchWindow) workbenchWindow).updateActionBars();
}
});
}
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class DatabaseDebugConfigurationTab method createConnectionSettingsGroup.
protected void createConnectionSettingsGroup(Composite composite) {
Group group = UIUtils.createControlGroup(composite, DebugUIMessages.DatabaseTab_connection_group_text, 4, GridData.FILL_HORIZONTAL, SWT.DEFAULT);
UIUtils.createControlLabel(group, DebugUIMessages.DatabaseTab_datasource_label_text);
connectionCombo = new SelectDataSourceCombo(group) {
@Override
protected void onDataSourceChange(DBPDataSourceContainer dataSource) {
String driverName = dataSource == null ? "" : dataSource.getDriver().getFullName();
driverText.setText(driverName);
setDirty(true);
loadConnectionDebugTypes();
updateLaunchConfigurationDialog();
}
};
connectionCombo.addItem(null);
for (DBPDataSourceContainer ds : DataSourceRegistry.getAllDataSources()) {
connectionCombo.addItem(ds);
}
driverText = UIUtils.createLabelText(group, DebugUIMessages.DatabaseTab_driver_label_text, "", SWT.READ_ONLY);
}
use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.
the class DatabaseDebugConfigurationTab method loadConnectionDebugTypes.
private void loadConnectionDebugTypes() {
for (Control c : typesGroup.getChildren()) {
c.dispose();
}
DBPDataSourceContainer dataSource = connectionCombo.getSelectedItem();
if (dataSource == null) {
UIUtils.createInfoLabel(typesGroup, "Select a connection to see available debug types");
} else {
List<DebugConfigurationPanelDescriptor> panels = DebugConfigurationPanelRegistry.getInstance().getPanels(dataSource);
if (CommonUtils.isEmpty(panels)) {
UIUtils.createInfoLabel(typesGroup, "Driver '" + dataSource.getDriver().getFullName() + "' doesn't support debugging");
} else {
for (DebugConfigurationPanelDescriptor panel : panels) {
Button typeSelector = new Button(typesGroup, SWT.RADIO);
typeSelector.setText(panel.getName());
if (!CommonUtils.isEmpty(panel.getDescription())) {
typeSelector.setToolTipText(panel.getDescription());
}
typeSelector.setData(panel);
if (panel.isValid()) {
typeSelector.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (typeSelector.getSelection()) {
setDirty(true);
setDebugType(connectionCombo.getSelectedItem(), (DebugConfigurationPanelDescriptor) typeSelector.getData());
typesGroup.getParent().layout(true, true);
}
}
});
} else {
typeSelector.setEnabled(false);
}
}
}
}
setDebugType(dataSource, null);
typesGroup.getParent().layout(true, true);
}
Aggregations