Search in sources :

Example 41 with DBCExecutionContext

use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by dbeaver.

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();
    }
}
Also used : DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext)

Example 42 with DBCExecutionContext

use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by dbeaver.

the class NavigatorUtils method addSetDefaultObjectAction.

private static void addSetDefaultObjectAction(IWorkbenchSite workbenchSite, IMenuManager manager, DBNNode selectedNode) {
    // Add "Set active object" menu
    boolean addSetActive = false;
    if (selectedNode.isPersisted() && selectedNode instanceof DBNDatabaseNode && !(selectedNode instanceof DBNDatabaseFolder) && ((DBNDatabaseNode) selectedNode).getObject() != null) {
        DBSObject selectedObject = ((DBNDatabaseNode) selectedNode).getObject();
        DBPDataSource dataSource = ((DBNDatabaseNode) selectedNode).getDataSource();
        if (dataSource != null) {
            DBCExecutionContext defaultContext = dataSource.getDefaultInstance().getDefaultContext(new VoidProgressMonitor(), false);
            DBCExecutionContextDefaults contextDefaults = defaultContext.getContextDefaults();
            if (contextDefaults != null) {
                if ((selectedObject instanceof DBSCatalog && contextDefaults.supportsCatalogChange() && contextDefaults.getDefaultCatalog() != selectedObject) || (selectedObject instanceof DBSSchema && contextDefaults.supportsSchemaChange() && contextDefaults.getDefaultSchema() != selectedObject)) {
                    addSetActive = true;
                }
            }
        }
    }
    if (addSetActive) {
        manager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_SET_DEFAULT));
    }
    manager.add(new Separator());
}
Also used : DBSSchema(org.jkiss.dbeaver.model.struct.rdb.DBSSchema) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBCExecutionContextDefaults(org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults) DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) DBSCatalog(org.jkiss.dbeaver.model.struct.rdb.DBSCatalog) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)

Example 43 with DBCExecutionContext

use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by dbeaver.

the class ResultSetValueController method getValueManager.

@Override
public IValueManager getValueManager() {
    DBSAttributeBase valueType = binding.getPresentationAttribute();
    final DBCExecutionContext executionContext = getExecutionContext();
    Class<?> valueObjectType = binding.getValueHandler().getValueObjectType(valueType);
    if (valueObjectType == Object.class) {
        // Try to get type from value itself
        Object value = getValue();
        if (value != null) {
            valueObjectType = value.getClass();
        }
    }
    return ValueManagerRegistry.findValueManager(executionContext == null ? null : executionContext.getDataSource(), valueType, valueObjectType);
}
Also used : DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) DBSAttributeBase(org.jkiss.dbeaver.model.struct.DBSAttributeBase) DBSTypedObject(org.jkiss.dbeaver.model.struct.DBSTypedObject)

Example 44 with DBCExecutionContext

use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by dbeaver.

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();
}
Also used : DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) DBDDataFilter(org.jkiss.dbeaver.model.data.DBDDataFilter) DBDAttributeConstraint(org.jkiss.dbeaver.model.data.DBDAttributeConstraint)

Example 45 with DBCExecutionContext

use of org.jkiss.dbeaver.model.exec.DBCExecutionContext in project dbeaver by dbeaver.

the class ExplainPlanViewer method refresh.

@Override
public void refresh() {
    DBCQueryPlanner planner;
    DBCExecutionContext executionContext = contextProvider.getExecutionContext();
    if (executionContext != null) {
        DBPDataSource dataSource = executionContext.getDataSource();
        planner = GeneralUtils.adapt(dataSource, DBCQueryPlanner.class);
    } else {
        planner = null;
    }
    if (planner == null) {
        DBWorkbench.getPlatformUI().showError("No SQL Plan", "This datasource doesn't support execution plans");
    } else {
        explainService = LoadingJob.createService(new ExplainPlanService(planner, executionContext, lastQuery.getText(), lastQueryId), planPresentationContainer.createVisualizer());
        explainService.schedule();
    }
}
Also used : DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource)

Aggregations

DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)107 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)27 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)22 DBException (org.jkiss.dbeaver.DBException)21 DBPContextProvider (org.jkiss.dbeaver.model.DBPContextProvider)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)16 DBCExecutionContextDefaults (org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults)16 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)15 GridData (org.eclipse.swt.layout.GridData)12 IEditorPart (org.eclipse.ui.IEditorPart)12 DBCException (org.jkiss.dbeaver.model.exec.DBCException)12 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)12 ArrayList (java.util.ArrayList)10 Composite (org.eclipse.swt.widgets.Composite)10 DBSCatalog (org.jkiss.dbeaver.model.struct.rdb.DBSCatalog)10 DBSSchema (org.jkiss.dbeaver.model.struct.rdb.DBSSchema)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)8 NotNull (org.jkiss.code.NotNull)8