use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
the class DataSourceTransactionLogHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final Shell activeShell = HandlerUtil.getActiveShell(event);
IEditorPart editor = HandlerUtil.getActiveEditor(event);
DBCExecutionContext context = null;
if (editor instanceof DBPContextProvider) {
context = ((DBPContextProvider) editor).getExecutionContext();
}
TransactionLogDialog.showDialog(activeShell, context);
return null;
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
the class PendingTransactionsDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
contextTree = new Tree(composite, SWT.FULL_SELECTION | SWT.BORDER);
contextTree.setHeaderVisible(true);
contextTree.setLinesVisible(true);
TreeColumn colName = new TreeColumn(contextTree, SWT.NONE);
colName.setText("Connection");
TreeColumn colTxn = new TreeColumn(contextTree, SWT.RIGHT);
colTxn.setText("Transaction");
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = contextTree.getHeaderHeight() + contextTree.getItemHeight() * 5;
contextTree.setLayoutData(gd);
contextTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (e.item != null && e.item.getData() instanceof DBCExecutionContext) {
selectedContext = (DBCExecutionContext) e.item.getData();
} else {
selectedContext = null;
}
boolean hasTransaction = selectedContext != null && QMUtils.isTransactionActive(selectedContext, false);
commitButton.setEnabled(hasTransaction);
rollbackButton.setEnabled(hasTransaction);
logViewer.setFilter(createContextFilter(selectedContext));
logViewer.refresh();
}
});
closeOnFocusLost(contextTree);
{
Composite controlPanel = UIUtils.createPlaceholder(composite, 3, 5);
controlPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final Button showAllCheck = UIUtils.createCheckbox(controlPanel, "Show all connections", "Show all datasource connections. Otherwise shows only transactional connections.", false, 1);
showAllCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
loadContexts(showAllCheck.getSelection());
}
});
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
showAllCheck.setLayoutData(gd);
commitButton = UIUtils.createPushButton(controlPanel, "Commit", DBeaverIcons.getImage(UIIcon.TXN_COMMIT));
commitButton.setEnabled(false);
commitButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
endTransaction(true);
}
});
rollbackButton = UIUtils.createPushButton(controlPanel, "Rollback", DBeaverIcons.getImage(UIIcon.TXN_ROLLBACK));
rollbackButton.setEnabled(false);
rollbackButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
endTransaction(false);
}
});
closeOnFocusLost(showAllCheck, commitButton, rollbackButton);
}
super.createTransactionLogPanel(composite);
loadContexts(false);
return parent;
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
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 serge-rider.
the class DatabaseEditorInputFactory method saveState.
public static void saveState(IMemento memento, DatabaseEditorInput input) {
if (!DBWorkbench.getPlatform().getPreferenceStore().getBoolean(DatabaseEditorPreferences.PROP_SAVE_EDITORS_STATE)) {
return;
}
final DBCExecutionContext context = input.getExecutionContext();
if (context == null) {
// Detached - nothing to save
return;
}
if (input.getDatabaseObject() != null && !input.getDatabaseObject().isPersisted()) {
return;
}
final DBNDatabaseNode node = input.getNavigatorNode();
memento.putString(TAG_CLASS, input.getClass().getName());
memento.putString(TAG_PROJECT, context.getDataSource().getContainer().getProject().getName());
memento.putString(TAG_DATA_SOURCE, context.getDataSource().getContainer().getId());
memento.putString(TAG_NODE, node.getNodeItemPath());
memento.putString(TAG_NODE_NAME, node.getNodeName());
if (!CommonUtils.isEmpty(input.getDefaultPageId())) {
memento.putString(TAG_ACTIVE_PAGE, input.getDefaultPageId());
}
if (!CommonUtils.isEmpty(input.getDefaultFolderId())) {
memento.putString(TAG_ACTIVE_FOLDER, input.getDefaultFolderId());
}
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
the class AbstractSessionEditor method createEditorControl.
@Override
public void createEditorControl(Composite parent) {
final DBCExecutionContext executionContext = getExecutionContext();
if (executionContext != null) {
setPartName("Sessions - " + executionContext.getDataSource().getContainer().getName());
sessionsViewer = createSessionViewer(executionContext, parent);
sessionsViewer.loadSettings(this);
sessionsViewer.refreshSessions();
}
}
Aggregations