function CLBConfigurationHeaderFileBrowseCallback(hObj, hDlg, ~, ~)
%CLBConfigurationHeaderFileBrowseCallback Callback to browse for CLB config header file

% Copyright 2021 The MathWorks, Inc.

if codertarget.target.isCoderTarget(hObj.getConfigSet())
    regexpstr = '[.][.][\/\\]'; %Relative path ../ or ..\
    regexpstr1 = '[.][\/\\]'; %Relative path ./ or .\
    data = codertarget.data.getParameterValue(hObj, 'CLB.HEADER');
    CLBHeaderFileName = data;
    hCS = hObj.getConfigSet();
    modelName = get_param(hCS.getModel, 'Name');
    modelPath = which (modelName);
    [modelPath, ~] = fileparts(modelPath);
    if regexp(CLBHeaderFileName, regexpstr, 'once') == 1 %Path relative to model
        CLBHeaderFileName = fullfile(modelPath, CLBHeaderFileName);
    elseif regexp(CLBHeaderFileName, regexpstr1, 'once') == 1
        CLBHeaderFileName = fullfile(modelPath, CLBHeaderFileName);
    end
    %this will be modified once CCS workspace is present
    curr_dir = pwd;
    [headerPath, filename] = fileparts(codertarget.utils.replaceTokens(hObj.getConfigSet(), CLBHeaderFileName));
    if (7 == exist(headerPath, 'dir'))
        cd(headerPath);
    end
    [fname, pname] = uigetfile('*.h', 'Specify CLB Config header file', filename);
    cd(curr_dir);
    if isequal(fname, 0) || isequal(pname, 0) % user pressed cancel
        return
    else
        editBoxTag = 'Tag_ConfigSet_CoderTarget_CLB_HEADER_Browse';
        fileName = fullfile(pname, fname);
        hDlg.setWidgetValue(editBoxTag, fileName);
        data = fileName;
        codertarget.data.setParameterValue(hObj, 'CLB.HEADER', data);
    end  
end
end