function loadDataFromUI(obj, addToActiveTree)
% Show dialog to select existing coverage data file to load into Data
% Repository.  If addToActiveTree is true, then the data will also be
% included in Current Cumulative Data.

%
% Copyright 2018-2019 The MathWorks, Inc.

filterspec = {'*.cvt',getString(message('Slvnv:simcoverage:cvresultsexplorer:CoverageFiles'))};
[fileName, path, ~] = uigetfile(filterspec,getString(message('Slvnv:simcoverage:cvresultsexplorer:SelectCoverageDataFile')));
if fileName ~= 0
    fullFileName = fullfile(path, fileName);
    if loadData(obj, fullFileName, addToActiveTree)
        files = strjoin(obj.incompatibleFiles, ', ');
        warndlg(getString(message('Slvnv:simcoverage:cvresultsexplorer:NotCompatibleCvdata', files)),...
            getString(message('Slvnv:simcoverage:cvresultsexplorer:Load')), 'modal');
    end
end