Search in sources :

Example 1 with QMTransactionState

use of org.jkiss.dbeaver.model.qm.QMTransactionState in project dbeaver by serge-rider.

the class PendingTransactionsDialog method loadContexts.

private void loadContexts(boolean showAllContexts) {
    contextTree.removeAll();
    // Load all open context
    for (DataSourceDescriptor dataSource : DataSourceRegistry.getAllDataSources()) {
        if (!dataSource.isConnected() || dataSource.getDataSource() == null) {
            continue;
        }
        DBCExecutionContext[] allContexts = dataSource.getDataSource().getAllContexts();
        if (ArrayUtils.isEmpty(allContexts)) {
            continue;
        }
        List<DBCExecutionContext> txnContexts = new ArrayList<>();
        for (DBCExecutionContext context : allContexts) {
            if (showAllContexts || QMUtils.isTransactionActive(context)) {
                txnContexts.add(context);
            }
        }
        if (txnContexts.isEmpty()) {
            continue;
        }
        TreeItem dsItem = new TreeItem(contextTree, SWT.NONE);
        dsItem.setText(dataSource.getName());
        dsItem.setImage(DBeaverIcons.getImage(dataSource.getObjectImage()));
        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.packColumns(contextTree);
}
Also used : ArrayList(java.util.ArrayList) QMTransactionState(org.jkiss.dbeaver.model.qm.QMTransactionState) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Aggregations

ArrayList (java.util.ArrayList)1 QMTransactionState (org.jkiss.dbeaver.model.qm.QMTransactionState)1 DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)1