public static DBSObject getActiveObject(ExecutionEvent event) {
        IWorkbenchPart activePart = HandlerUtil.getActivePart(event);

        IStructuredSelection navSelection = NavigatorUtils.getSelectionFromPart(activePart);
        if (navSelection != null) {
            DBNNode selectedNode = NavigatorUtils.getSelectedNode(navSelection);
            if (selectedNode instanceof DBNDatabaseNode) {
                return ((DBNDatabaseNode) selectedNode).getObject();
            }
        }

        return null;
    }
Get execution context from active editor or active selection
plugins/org.jkiss.dbeaver.ui.navigator/src/org/jkiss/dbeaver/ui/actions/AbstractDataSourceHandler.java