use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by dbeaver.
the class TransactionInfoDialog method createContextFilter.
protected QMEventFilter createContextFilter(DBCExecutionContext executionContext) {
if (executionContext == null) {
return VOID_FILTER;
}
final boolean showAll = showAllCheck != null && showAllCheck.getSelection();
final boolean showPrevious = showPreviousCheck != null && showPreviousCheck.getSelection();
final QMMSessionInfo currentSession = QMUtils.getCurrentSession(executionContext);
final QMMTransactionSavepointInfo currentSP = QMUtils.getCurrentTransaction(executionContext);
QMEventFilter filter = event -> {
QMMObject object = event.getObject();
if (object instanceof QMMStatementExecuteInfo) {
QMMStatementExecuteInfo exec = (QMMStatementExecuteInfo) object;
if (!showPrevious && !CommonUtils.equalObjects(exec.getSavepoint(), currentSP)) {
return false;
}
if (!showAll && !CommonUtils.equalObjects(exec.getStatement().getSession(), currentSession)) {
return false;
}
DBCExecutionPurpose purpose = exec.getStatement().getPurpose();
if (purpose == DBCExecutionPurpose.META || purpose == DBCExecutionPurpose.UTIL) {
return false;
}
return (showAll || exec.isTransactional());
}
return false;
};
return filter;
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by dbeaver.
the class TransactionInfoDialog method updateTransactionFilter.
protected void updateTransactionFilter() {
DBCExecutionContext context = getCurrentContext();
QMEventFilter filter = context == null ? VOID_FILTER : createContextFilter(context);
logViewer.setFilter(filter);
logViewer.refresh();
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by dbeaver.
the class ConnectionPageInitialization method loadDatabaseSettings.
private void loadDatabaseSettings(DBRProgressMonitor monitor, DBPDataSource dataSource) {
DBPDataSourceContainer dataSourceContainer = dataSource.getContainer();
Collection<DBPTransactionIsolation> txnLevels = CommonUtils.safeCollection(dataSource.getInfo().getSupportedTransactionsIsolation());
Integer levelCode = dataSourceContainer.getDefaultTransactionsIsolation();
UIUtils.syncExec(() -> {
autocommit.setSelection(dataSourceContainer.isDefaultAutoCommit());
// isolationLevel.setEnabled(!autocommit.getSelection());
supportedLevels.clear();
DBPTransactionIsolation defaultLevel = null;
{
if (levelCode != null && !CommonUtils.isEmpty(txnLevels)) {
for (DBPTransactionIsolation level : txnLevels) {
if (level.getCode() == levelCode) {
defaultLevel = level;
break;
}
}
}
}
isolationLevel.removeAll();
supportedLevels.clear();
for (DBPTransactionIsolation level : txnLevels) {
if (!level.isEnabled()) {
continue;
}
isolationLevel.add(level.getTitle());
supportedLevels.add(level);
if (level.equals(defaultLevel)) {
isolationLevel.select(isolationLevel.getItemCount() - 1);
}
}
});
if (dataSource instanceof DBSObjectContainer) {
DBCExecutionContext executionContext = DBUtils.getDefaultContext(dataSource, true);
DBCExecutionContextDefaults contextDefaults = executionContext.getContextDefaults();
DBSObjectContainer catalogContainer = DBUtils.getChangeableObjectContainer(contextDefaults, (DBSObjectContainer) dataSource, DBSCatalog.class);
if (catalogContainer != null) {
loadSelectableObject(monitor, catalogContainer, defaultCatalog, contextDefaults, true);
}
DBSObjectContainer schemaContainer = DBUtils.getChangeableObjectContainer(contextDefaults, (DBSObjectContainer) dataSource, DBSSchema.class);
loadSelectableObject(monitor, schemaContainer, defaultSchema, contextDefaults, false);
}
txnOptionsLoaded = true;
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by dbeaver.
the class DataSourceAutoCommitHandler method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
IWorkbenchWindow workbenchWindow = element.getServiceLocator().getService(IWorkbenchWindow.class);
if (workbenchWindow == null || workbenchWindow.getActivePage() == null) {
return;
}
IEditorPart activeEditor = workbenchWindow.getActivePage().getActiveEditor();
if (activeEditor == null) {
return;
}
boolean autoCommit = true;
DBPTransactionIsolation isolation = null;
DBCExecutionContext context = getExecutionContextFromPart(activeEditor);
if (context != null && context.isConnected()) {
DBCTransactionManager txnManager = DBUtils.getTransactionManager(context);
if (txnManager != null) {
try {
// Change auto-commit mode
autoCommit = txnManager.isAutoCommit();
isolation = txnManager.getTransactionIsolation();
} catch (DBCException e) {
log.warn(e);
}
}
} else if (activeEditor instanceof IDataSourceContainerProvider) {
DBPDataSourceContainer container = ((IDataSourceContainerProvider) activeEditor).getDataSourceContainer();
if (container != null) {
autoCommit = container.isDefaultAutoCommit();
isolation = container.getActiveTransactionsIsolation();
}
}
element.setChecked(autoCommit);
// Update command image
element.setIcon(DBeaverIcons.getImageDescriptor(autoCommit ? UIIcon.TXN_COMMIT_AUTO : UIIcon.TXN_COMMIT_MANUAL));
String isolationName = isolation == null ? "?" : isolation.getTitle();
String text = autoCommit ? NLS.bind(CoreMessages.action_menu_transaction_manualcommit_name, isolationName) : CoreMessages.action_menu_transaction_autocommit_name;
element.setText(text);
element.setTooltip(text);
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext 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);
}
});
}
Aggregations