Search in sources :

Example 1 with QMEventFilter

use of org.jkiss.dbeaver.model.qm.QMEventFilter in project dbeaver by dbeaver.

the class TransactionInfoDialog method createTransactionLogPanel.

protected void createTransactionLogPanel(Composite composite) {
    DBCExecutionContext context = getCurrentContext();
    QMEventFilter filter = context == null ? VOID_FILTER : createContextFilter(context);
    logViewer = new QueryLogViewer(composite, activeEditor.getSite(), filter, false);
    logViewer.setUseDefaultFilter(false);
    final Object gd = logViewer.getControl().getLayoutData();
    if (gd instanceof GridData) {
        ((GridData) gd).heightHint = logViewer.getControl().getHeaderHeight() + logViewer.getControl().getItemHeight() * 5;
    }
    showAllCheck = UIUtils.createCheckbox(composite, "Show all queries", "Show all transaction queries. Otherwise shows only modifying queries.", false, 1);
    showAllCheck.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateTransactionFilter();
        }
    });
    showPreviousCheck = UIUtils.createCheckbox(composite, "Show previous transactions", "Show previous transactions. Otherwise shows only active one.", false, 1);
    showPreviousCheck.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateTransactionFilter();
        }
    });
}
Also used : DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) QMEventFilter(org.jkiss.dbeaver.model.qm.QMEventFilter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) QMMObject(org.jkiss.dbeaver.model.qm.meta.QMMObject) QueryLogViewer(org.jkiss.dbeaver.ui.controls.querylog.QueryLogViewer)

Example 2 with QMEventFilter

use of org.jkiss.dbeaver.model.qm.QMEventFilter 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 = new QMEventFilter() {

        @Override
        public boolean accept(QMMetaEvent event) {
            QMMObject object = event.getObject();
            if (object instanceof QMMStatementExecuteInfo) {
                QMMStatementExecuteInfo exec = (QMMStatementExecuteInfo) object;
                if (!showPrevious && exec.getSavepoint() != currentSP) {
                    return false;
                }
                if (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;
}
Also used : QMMSessionInfo(org.jkiss.dbeaver.model.qm.meta.QMMSessionInfo) QMEventFilter(org.jkiss.dbeaver.model.qm.QMEventFilter) QMMetaEvent(org.jkiss.dbeaver.model.qm.QMMetaEvent) QMMStatementExecuteInfo(org.jkiss.dbeaver.model.qm.meta.QMMStatementExecuteInfo) DBCExecutionPurpose(org.jkiss.dbeaver.model.exec.DBCExecutionPurpose) QMMObject(org.jkiss.dbeaver.model.qm.meta.QMMObject) QMMTransactionSavepointInfo(org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo)

Example 3 with QMEventFilter

use of org.jkiss.dbeaver.model.qm.QMEventFilter in project dbeaver by dbeaver.

the class TransactionInfoDialog method updateTransactionFilter.

private void updateTransactionFilter() {
    DBCExecutionContext context = getCurrentContext();
    QMEventFilter filter = context == null ? VOID_FILTER : createContextFilter(context);
    logViewer.setFilter(filter);
    logViewer.refresh();
}
Also used : DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) QMEventFilter(org.jkiss.dbeaver.model.qm.QMEventFilter)

Example 4 with QMEventFilter

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

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;
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) QMMSessionInfo(org.jkiss.dbeaver.model.qm.meta.QMMSessionInfo) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) QMMStatementExecuteInfo(org.jkiss.dbeaver.model.qm.meta.QMMStatementExecuteInfo) DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) CoreMessages(org.jkiss.dbeaver.core.CoreMessages) QueryLogViewer(org.jkiss.dbeaver.ui.controls.querylog.QueryLogViewer) DBCExecutionPurpose(org.jkiss.dbeaver.model.exec.DBCExecutionPurpose) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) QMUtils(org.jkiss.dbeaver.model.qm.QMUtils) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) QMEventFilter(org.jkiss.dbeaver.model.qm.QMEventFilter) QMMTransactionSavepointInfo(org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo) AbstractPopupPanel(org.jkiss.dbeaver.ui.dialogs.AbstractPopupPanel) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) QMMObject(org.jkiss.dbeaver.model.qm.meta.QMMObject) QMMSessionInfo(org.jkiss.dbeaver.model.qm.meta.QMMSessionInfo) QMEventFilter(org.jkiss.dbeaver.model.qm.QMEventFilter) QMMStatementExecuteInfo(org.jkiss.dbeaver.model.qm.meta.QMMStatementExecuteInfo) DBCExecutionPurpose(org.jkiss.dbeaver.model.exec.DBCExecutionPurpose) QMMObject(org.jkiss.dbeaver.model.qm.meta.QMMObject) QMMTransactionSavepointInfo(org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo)

Example 5 with QMEventFilter

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

the class TransactionInfoDialog method createTransactionLogPanel.

protected void createTransactionLogPanel(Composite composite) {
    DBCExecutionContext context = getCurrentContext();
    QMEventFilter filter = context == null ? VOID_FILTER : createContextFilter(context);
    logViewer = new QueryLogViewer(composite, activeEditor.getSite(), filter, false, true);
    logViewer.setUseDefaultFilter(false);
    final Object gd = logViewer.getControl().getLayoutData();
    if (gd instanceof GridData) {
        ((GridData) gd).heightHint = logViewer.getControl().getHeaderHeight() + logViewer.getControl().getItemHeight() * 5;
    }
    showAllCheck = UIUtils.createCheckbox(composite, CoreMessages.transaction_info_dialog_checkbox_show_all_queries, CoreMessages.transaction_info_dialog_label_show_all_transaction_queries, false, 1);
    showAllCheck.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateTransactionFilter();
        }
    });
    showPreviousCheck = UIUtils.createCheckbox(composite, CoreMessages.transaction_info_dialog_checkbox_show_previous_transactions, CoreMessages.transaction_info_dialog_label_otherwise, false, 1);
    showPreviousCheck.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateTransactionFilter();
        }
    });
    closeOnFocusLost(logViewer.getSearchText(), logViewer.getControl(), showAllCheck, showPreviousCheck);
}
Also used : DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) QMEventFilter(org.jkiss.dbeaver.model.qm.QMEventFilter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) QMMObject(org.jkiss.dbeaver.model.qm.meta.QMMObject) QueryLogViewer(org.jkiss.dbeaver.ui.controls.querylog.QueryLogViewer)

Aggregations

QMEventFilter (org.jkiss.dbeaver.model.qm.QMEventFilter)6 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)5 QMMObject (org.jkiss.dbeaver.model.qm.meta.QMMObject)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 QueryLogViewer (org.jkiss.dbeaver.ui.controls.querylog.QueryLogViewer)3 DBCExecutionPurpose (org.jkiss.dbeaver.model.exec.DBCExecutionPurpose)2 QMMSessionInfo (org.jkiss.dbeaver.model.qm.meta.QMMSessionInfo)2 QMMStatementExecuteInfo (org.jkiss.dbeaver.model.qm.meta.QMMStatementExecuteInfo)2 QMMTransactionSavepointInfo (org.jkiss.dbeaver.model.qm.meta.QMMTransactionSavepointInfo)2 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Shell (org.eclipse.swt.widgets.Shell)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 CoreMessages (org.jkiss.dbeaver.core.CoreMessages)1 QMMetaEvent (org.jkiss.dbeaver.model.qm.QMMetaEvent)1 QMUtils (org.jkiss.dbeaver.model.qm.QMUtils)1 UIUtils (org.jkiss.dbeaver.ui.UIUtils)1