function hiliteResultInFPT(this, blockObject)
%% Highlights result in FPT given a block object handle in Simulink Canvas

% Copyright 2018-2020 The MathWorks, Inc.

    fxptui.showFPT;

    % Query for currently selected run s in FPT
    lastUsedQuery = this.FPTInstance.getDataController().getLastUsedQuery(); 
    selectedRuns = lastUsedQuery.SelectedRuns;
        
    % If no runs are selected, no results can be highlighted 
    if isempty(selectedRuns)
        fxptui.showdialog('resultNotFound',fxptui.message('resultsNotCollectedWarnMsg'));
        return;
    end
    
    matchingResultIds = {};
    resultInfo = [];
    for idx=1:numel(selectedRuns)
        % Find the results matching the blockObject handle in the given run
        [matchingResultIds, resultInfo] = this.getResultInRunForBlockObject(blockObject, selectedRuns{idx});
        if numel(matchingResultIds) > 0
            break;
        end
    end
    if isempty(matchingResultIds)
        % if is true when the result is empty in all the runs or
        % results do not have any interesting info to show.
        fxptui.showdialog('resultNotFound',this.getMissingResultMessage(resultInfo));
        return;
    end

    % g1895228 - Select the first result of the matching set of results and
    % highlight it in FPT spreadsheet
    scopingId = matchingResultIds{1}{1};
    if ~this.isWithinProvidedScope(scopingId)
        % if the block is not within the provided scope then we need to
        % select the parent tree node first and then the result
        this.FPTInstance.selectTreeAndThenResultInUI(blockObject.getParent, scopingId);
    else
        this.FPTInstance.selectResultInUI(scopingId);
    end

end
