use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
the class SQLObjectResolver method resolveAll.
@Override
protected String[] resolveAll(final TemplateContext context) {
final List<T> entities = new ArrayList<>();
if (context instanceof DBPContextProvider) {
final DBCExecutionContext executionContext = ((DBPContextProvider) context).getExecutionContext();
if (executionContext != null) {
RuntimeUtils.runTask(new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
resolveObjects(monitor, executionContext, context, entities);
} catch (DBException e) {
throw new InvocationTargetException(e);
}
}
}, "Resolve object references", 1000);
}
}
if (!CommonUtils.isEmpty(entities)) {
String[] result = new String[entities.size()];
for (int i = 0; i < entities.size(); i++) {
T entity = entities.get(i);
result[i] = entity.getName();
}
return result;
}
return super.resolveAll(context);
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext 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);
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();
}
});
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
the class TransactionInfoDialog method updateTransactionFilter.
private 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 serge-rider.
the class NavigatorHandlerObjectGoto method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
DBCExecutionContext context = null;
DBSObject container = null;
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof DBPContextProvider) {
context = ((DBPContextProvider) activePart).getExecutionContext();
} else if (activePart instanceof INavigatorModelView) {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof DBSWrapper) {
DBSObject object = ((DBSWrapper) element).getObject();
if (object != null) {
container = object;
while (container instanceof DBSFolder) {
container = container.getParentObject();
}
DBPDataSource dataSource = object.getDataSource();
if (dataSource != null) {
context = dataSource.getDefaultContext(true);
}
}
}
}
}
if (context == null) {
DBUserInterface.getInstance().showError("Go to object", "No active datasource");
return null;
}
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
GotoObjectDialog dialog = new GotoObjectDialog(HandlerUtil.getActiveShell(event), context, container);
dialog.open();
Object[] objectsToOpen = dialog.getResult();
if (!ArrayUtils.isEmpty(objectsToOpen)) {
Collection<DBNDatabaseNode> nodes = NavigatorHandlerObjectBase.getNodesByObjects(Arrays.asList(objectsToOpen));
for (DBNDatabaseNode node : nodes) {
NavigatorUtils.openNavigatorNode(node, workbenchWindow);
}
}
return null;
}
use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by serge-rider.
the class ResultSetFilterPanel method setCustomDataFilter.
private void setCustomDataFilter() {
DBCExecutionContext context = viewer.getExecutionContext();
if (context == null) {
return;
}
String condition = filtersText.getText();
StringBuilder currentCondition = new StringBuilder();
SQLUtils.appendConditionString(viewer.getModel().getDataFilter(), context.getDataSource(), null, currentCondition, true);
if (currentCondition.toString().trim().equals(condition.trim())) {
// The same
return;
}
DBDDataFilter newFilter = new DBDDataFilter(viewer.getModel().getDataFilter());
for (DBDAttributeConstraint ac : newFilter.getConstraints()) {
ac.setCriteria(null);
}
newFilter.setWhere(condition);
viewer.setDataFilter(newFilter, true);
//viewer.getControl().setFocus();
}
Aggregations