Search in sources :

Example 1 with DBPDataSourceInfo

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

the class DataSourceTransactionModeContributor method fillContributionItems.

@Override
protected void fillContributionItems(final List<IContributionItem> menuItems) {
    IWorkbenchWindow window = DBeaverUI.getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IEditorPart activePart = window.getActivePage().getActiveEditor();
    DBPDataSourceContainer container = AbstractDataSourceHandler.getDataSourceContainer(activePart);
    DBPDataSource dataSource = null;
    if (container != null) {
        dataSource = container.getDataSource();
    }
    if (dataSource == null) {
        return;
    }
    final DBPDataSourceInfo dsInfo = dataSource.getInfo();
    DBCTransactionManager txnManager = DBUtils.getTransactionManager(dataSource.getDefaultContext(false));
    if (txnManager != null) {
        menuItems.add(ActionUtils.makeCommandContribution(window, CoreCommands.CMD_TOGGLE_AUTOCOMMIT, CommandContributionItem.STYLE_CHECK));
        menuItems.add(new Separator());
        // Transactions
        DBPTransactionIsolation txnLevelCurrent = null;
        try {
            txnLevelCurrent = txnManager.getTransactionIsolation();
        } catch (DBCException ex) {
            log.warn("Can't determine current transaction isolation level", ex);
        }
        for (DBPTransactionIsolation txi : CommonUtils.safeCollection(dsInfo.getSupportedTransactionsIsolation())) {
            if (!txi.isEnabled()) {
                continue;
            }
            menuItems.add(ActionUtils.makeActionContribution(new TransactionIsolationAction(dataSource, txi, txi.equals(txnLevelCurrent)), true));
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DBPTransactionIsolation(org.jkiss.dbeaver.model.DBPTransactionIsolation) DBCException(org.jkiss.dbeaver.model.exec.DBCException) IEditorPart(org.eclipse.ui.IEditorPart) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DBPDataSourceInfo(org.jkiss.dbeaver.model.DBPDataSourceInfo) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) Separator(org.eclipse.jface.action.Separator) DBCTransactionManager(org.jkiss.dbeaver.model.exec.DBCTransactionManager)

Aggregations

Separator (org.eclipse.jface.action.Separator)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)1 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)1 DBPDataSourceInfo (org.jkiss.dbeaver.model.DBPDataSourceInfo)1 DBPTransactionIsolation (org.jkiss.dbeaver.model.DBPTransactionIsolation)1 DBCException (org.jkiss.dbeaver.model.exec.DBCException)1 DBCTransactionManager (org.jkiss.dbeaver.model.exec.DBCTransactionManager)1