function CCSHWConfigurationFileBrowseCallback(hObj, hDlg, ~, ~)
%CCSHWCONFIGURATIONFILEBROWSECALLBACK Callback to browse for CCS config file

% Copyright 2013-2020 The MathWorks, Inc.

if codertarget.target.isCoderTarget(hObj.getConfigSet())
    regexpstr = '[.][.][\/\\]'; %Relative path ../ or ..\
    data = codertarget.data.getParameterValue(hObj, 'Runtime.LoadCommandArg');
    CCSHWConfigFileName = data;
    if regexp(CCSHWConfigFileName, regexpstr, 'once') == 1 %Relative path used for make file
        CCSHWConfigFileName = regexprep(CCSHWConfigFileName, regexpstr, '', 'once');
    end
    curr_dir = pwd;
    [cmdPath, filename] = fileparts(codertarget.utils.replaceTokens(hObj.getConfigSet(), CCSHWConfigFileName));
    if (7 == exist(cmdPath, 'dir'))
        cd(cmdPath);
    end
    [fname, pname] = uigetfile('*.ccxml', 'Specify CCS hardware configuration file', filename);
    cd(curr_dir);
    if isequal(fname, 0) || isequal(pname, 0) % user pressed cancel
        return
    else
        editBoxTag = 'Tag_ConfigSet_CoderTarget_Runtime_CCS_HW_Configuration_File';
        fileName = fullfile(pname, fname);
        hDlg.setWidgetValue(editBoxTag, fileName);
        data = fileName;
        codertarget.data.setParameterValue(hObj, 'Runtime.LoadCommandArg', data);
    end  
end
end