classdef InstallTpSoftware2 < matlab.hwmgr.internal.hwsetup.ListTpTools
    % InstallTpSoftware - Screen implementation to enable users to select the
    % CCS Tool chain.

    %   Copyright 2017-2023 The MathWorks, Inc.
    properties(Access = private)
        BusySpinner
        screenReady = false;
    end

    methods
        function obj = InstallTpSoftware2(varargin)
            % call to the base class constructor
            obj@matlab.hwmgr.internal.hwsetup.ListTpTools(varargin{:});

            % Set 3p details
            obj.SetTPDetails(); % method that sets TP info
            obj.ListTpDownloadTable.Position = [20 40 435 270];
            obj.ListTpDownloadTable.ColumnName = {message('TIC2000:hwsetup:Name').getString, ...
                message('TIC2000:hwsetup:Version').getString, ...
                message('TIC2000:hwsetup:Download').getString};
            % Help Text
            obj.HelpText.WhatToConsider = [message('TIC2000:hwsetup:InstallTpCCSInfo').getString ...
                '<br>' '<br>' message('TIC2000:hwsetup:InstallTpSUITEInfo').getString ...
                '<br>' '<br>' message('TIC2000:hwsetup:InstallTpC2000WareInfo').getString];
            obj.HelpText.AboutSelection = '';
            % Set Description and init widgets for SoC
            if strcmp(obj.Workflow.BaseCode, 'TIC2000_BLOCKSET')
                % Set Title
                obj.Title.Text = [message('TIC2000:hwsetup:InstallTpTitleSoC').getString];
                obj.Description.Text = ...
                    message('TIC2000:hwsetup:InstallTpDescriptionSoC').getString;

                % Configure widgets while looking for 3P details
                % Disable Next
                obj.NextButton.Enable = 'off';
                % Hide Back and Cancel
                obj.BackButton.Visible = 'off';
                % Initialize spinner
                obj.BusySpinner = matlab.hwmgr.internal.hwsetup.BusyOverlay.getInstance(obj.ContentPanel);
                obj.BusySpinner.Text = message('TIC2000:hwsetup:AutoFind3P').getString;
                obj.BusySpinner.Visible = 'on';
                % Show the screen
                obj.show();
                % update the widgets as 3p tools are searched
                obj.initScreen();
            else
                % Set Title
                obj.BusySpinner.Visible = 'off';
                obj.Title.Text = [message('TIC2000:hwsetup:InstallTpTitle').getString];
                obj.Description.Text = ...
                    message('TIC2000:hwsetup:InstallTpDescription').getString;
                obj.NextButton.Enable = 'on';
            end
            % Do not place any code below this line in this function
            obj.screenReady = true;
        end

        function out = getNextScreenID(obj)
            if ~isobject(obj) || isempty(obj.screenReady) || ~(obj.screenReady)
                % Placeholder if user clicks next quickly before the screen is
                % populated with options stay in the same screen
                out = [];
            else
                if strcmp(obj.Workflow.BaseCode, 'TIC2000_BLOCKSET')
                    if obj.Workflow.isNeededValidateSUITE
                        out = 'codertarget.tic2000.hwsetup.ValidateControlSUITE';
                    elseif any(contains(obj.Workflow.SelectedProcessors, 'TI F28044'))
                        out = 'codertarget.tic2000.hwsetup.ValidateF28044';
                    else
                        out = 'codertarget.tic2000.hwsetup.ValidateCCS';
                    end
                    if isempty(obj.Workflow.ControlSUITEInstallLocation)
                        % Check registry to pick installed controlSUITE during setup
                        obj.disableScreen();
                        obj.BusySpinner = matlab.hwmgr.internal.hwsetup.BusyOverlay.getInstance(obj.ContentPanel);
                        obj.BusySpinner.Text = message('TIC2000:hwsetup:AutoFind3P').getString;

                        [obj.Workflow.ControlSUITEInstallLocation, obj.Workflow.ControlSUITEInstallVersion] ...
                            = obj.Workflow.HardwareInterface.getControlSUITEInfo();
                        obj.enableScreen;
                    end
                else
                    if obj.Workflow.autoInstall3PTool(1).validationScreenRequired
                        out = 'codertarget.tic2000.hwsetup.ValidateCGT';
                    elseif (obj.Workflow.required3PToolCount == 2) && ...
                            obj.Workflow.autoInstall3PTool(2).validationScreenRequired
                        out = 'codertarget.tic2000.hwsetup.ValidateARMCGT';
                        % Skipping TI CGT - update the version and location
                        obj.Workflow.CGTVersion = obj.Workflow.autoInstall3PTool(1).version;
                        obj.Workflow.CGTLocation = obj.Workflow.autoInstall3PTool(1).registeredInstallFolder;
                    else
                        % Skipping TI and ARM CGT - update the version and location
                        obj.Workflow.CGTVersion = obj.Workflow.autoInstall3PTool(1).version;
                        obj.Workflow.CGTLocation = obj.Workflow.autoInstall3PTool(1).registeredInstallFolder;
                        if (obj.Workflow.required3PToolCount == 2)
                            obj.Workflow.ARMCGTVersion = obj.Workflow.autoInstall3PTool(2).version;
                            obj.Workflow.ARMCGTLocation = obj.Workflow.autoInstall3PTool(2).registeredInstallFolder;
                        end
                        if obj.Workflow.isNeededValidateSUITE
                            out = 'codertarget.tic2000.hwsetup.ValidateControlSUITE';
                        elseif any(contains(obj.Workflow.SelectedProcessors, 'TI F28044'))
                            out = 'codertarget.tic2000.hwsetup.ValidateF28044';
                        elseif any(contains(obj.Workflow.SelectedProcessors, 'TI F280x'))
                            out = 'codertarget.tic2000.hwsetup.ValidateF280x';
                        elseif any(contains(obj.Workflow.SelectedProcessors, 'TI F281x'))
                            out = 'codertarget.tic2000.hwsetup.ValidateF281x';
                        else
                            out = 'codertarget.tic2000.hwsetup.ValidateCCS';
                        end
                    end
                    if obj.Workflow.isNeededValidateSUITE && isempty(obj.Workflow.ControlSUITEInstallLocation)
                        % Check registry to pick installed controlSUITE during setup
                        obj.disableScreen();
                        obj.BusySpinner = matlab.hwmgr.internal.hwsetup.BusyOverlay.getInstance(obj.ContentPanel);
                        obj.BusySpinner.Text = message('TIC2000:hwsetup:AutoFind3P').getString;

                        [obj.Workflow.ControlSUITEInstallLocation, obj.Workflow.ControlSUITEInstallVersion] ...
                            = obj.Workflow.HardwareInterface.getControlSUITEInfo();
                        obj.enableScreen;
                    end
                end
                % Disable next button to prevent multiple press
                obj.NextButton.Enable = 'off';
            end
        end

        function autoFind3P(obj)
            % call the logics for auto-detections here.
            % get CCS, controlSUITE and F28044 information
            try
                [obj.Workflow.CCSInstallLocation, obj.Workflow.CCSInstallVersion, ...
                    obj.Workflow.ControlSUITEInstallLocation, obj.Workflow.ControlSUITEInstallVersion, ...
                    obj.Workflow.F28044Location, obj.Workflow.F28044Version, obj.Workflow.F280xLocation, obj.Workflow.F280xVersion, ...
                    obj.Workflow.F281xLocation, obj.Workflow.F281xVersion, ...
                    obj.Workflow.C2000WareLocation, obj.Workflow.C2000WareVersion] ...
                    = obj.Workflow.HardwareInterface.getCCSAndControlSUITEInfo(obj);

                % Set C2000Warelocation properly
                if ~isempty(obj.Workflow.C2000WareVersion)
                    obj.Workflow.C2000WareLocation = fullfile(obj.Workflow.C2000WareLocation, ['C2000Ware_', obj.Workflow.C2000WareVersion]);
                else
                    obj.Workflow.C2000WareLocation = '';
                end
            catch
                % ignore error
            end
            % Set visiblity as on

        end

        function reinit(obj)
            if strcmp(obj.Workflow.BaseCode, 'TIC2000_BLOCKSET')
                obj.initScreen();
            else
                if ~isempty(obj.BusySpinner) && strcmpi(obj.BusySpinner.Visible, 'on')
                    obj.BusySpinner.Visible = 'off';
                end
                obj.SetTPDetails();
                obj.NextButton.Enable = 'on'; % Show Next
            end
        end

        function out = getPreviousScreenID(obj)
            if strcmp(obj.Workflow.BaseCode, 'TIC2000_BLOCKSET')
                out = 'codertarget.tic2000.hwsetup.SelectProcessors';
            else
                out = 'codertarget.tic2000.hwsetup.InstallTpSoftware1';
            end
        end

        function SetTPDetails(obj)
            selectedprocessors = obj.Workflow.SelectedProcessors;

            % get installed version of the TPs
            % ccsversion
            ccsversion = obj.Workflow.CCSInstallVersion;

            %%%%%%%%% check CCS required. .................%%%%%%%%%
            ccslocation  = obj.Workflow.CCSInstallLocation;
            if ~isempty(ccsversion)
                % Extract only first digit from version
                versionNumber = str2double(regexp(ccsversion, '(\d+)(\.|$)', 'match'));
                switch numel(versionNumber)
                    case 0
                        versionMajor = 0;  %if regexp fails, if version number is weird
                    case 1
                        % No need to handle corner cases here as version is
                        % read from registry
                        versionMajor = versionNumber(1)*100;
                    case 2
                        versionMajor = versionNumber(1)*100 + versionNumber(2)*10; 
                    case 3
                        versionMajor = versionNumber(1)*100 + versionNumber(2)*10 + versionNumber(3);
                    otherwise
                        versionMajor = versionNumber(1)*100 + versionNumber(2)*10 + versionNumber(3);
                end
                % Find the latest tested version
                notTestedVersion = versionMajor ~= str2double(strrep(message('TIC2000:hwsetup:CCSVersion').getString, '.', ''));
            else
                if ispc
                    ccsversion = message('TIC2000:hwsetup:NotInstalled').getString; % not installed
                else
                %In Linux 3p might be installed but currently we are unable to detect location 
                    ccsversion = message('TIC2000:hwsetup:NotDetected').getString; 
                end
                notTestedVersion = false;
            end

            if isempty(ccslocation)
                % now check if ccs ware installed
                CCSHyperlinkText = [message('TIC2000:hwsetup:Install').getString ' ' message('TIC2000:hwsetup:CCSVersion').getString];
                CCSURL = obj.Workflow.CCSDownloadURL;
            else
                CCSProcessorCCXMLMapObj = obj.Workflow.CCSProcessorCCXMLMapObj;
                ccsNeededIdx =0;
                ccssupportedIdx =0;

                for i=1:numel(selectedprocessors)
                    if any(ismember(CCSProcessorCCXMLMapObj.keys, selectedprocessors{i}))
                        if contains(ccslocation, 'ccsv4', 'IgnoreCase', true)
                            versionfile_evaluate = fullfile(ccslocation, 'common', 'targetdb', 'Devices', CCSProcessorCCXMLMapObj(selectedprocessors{i}));
                        else
                            versionfile_evaluate = fullfile(ccslocation, 'ccs_base', 'common', 'targetdb', 'devices', CCSProcessorCCXMLMapObj(selectedprocessors{i}));
                        end
                        ccsNeededIdx = ccsNeededIdx + 1;
                        if 2 == exist(versionfile_evaluate, 'file')
                            ccssupportedIdx = ccssupportedIdx + 1;
                        end
                    end
                end

                if notTestedVersion
                    CCSHyperlinkText = [message('TIC2000:hwsetup:Install').getString ' ' message('TIC2000:hwsetup:CCSVersion').getString];
                    CCSURL = obj.Workflow.CCSDownloadURL;
                else
                    if ccsNeededIdx == 0
                        % check if 28004 and 28044 will work
                        CCSHyperlinkText = message('TIC2000:hwsetup:InstallTpUpgradeNA').getString;
                        CCSURL = '';
                    elseif ccsNeededIdx == ccssupportedIdx
                        CCSHyperlinkText = message('TIC2000:hwsetup:InstallTpUpgradeNotReq').getString;
                        CCSURL = '';
                    elseif ccssupportedIdx == 0 % Registry path not found
                        CCSHyperlinkText = [message('TIC2000:hwsetup:Install').getString ' ' message('TIC2000:hwsetup:CCSVersion').getString];
                        CCSURL = obj.Workflow.CCSDownloadURL;
                        if ispc
                            ccsversion = message('TIC2000:hwsetup:NotInstalled').getString; % not installed
                        else
                        %In Linux 3p might be installed but currently we are unable to detect location
                            ccsversion = message('TIC2000:hwsetup:NotDetected').getString;
                        end
                    else
                        CCSHyperlinkText = [message('TIC2000:hwsetup:Install').getString ' ' message('TIC2000:hwsetup:CCSVersion').getString];
                        CCSURL = obj.Workflow.CCSDownloadURL;
                    end
                end
            end

            % controlsuiteversion
            controlsuiteversion = obj.Workflow.ControlSUITEInstallVersion;
            CSVer = obj.Workflow.HardwareInterface.getControlSUITEVersion(obj.Workflow.ControlSUITEInstallLocation);
            if isempty(CSVer)
                if ~isempty(controlsuiteversion)
                    CSVer = controlsuiteversion;
                    obj.Workflow.ControlSUITEInstallVersion = CSVer;
                else
                    % is control suite installed
                    % This is required for cases when isNeededValidateSUITE is
                    % false and version is empty
                    if ispc
                        CSVer = message('TIC2000:hwsetup:NotInstalled').getString;% not installed
                    else
                    %In Linux 3p might be installed but currently we are unable to detect location
                        CSVer = message('TIC2000:hwsetup:NotDetected').getString;
                    end
                end
            else
                obj.Workflow.ControlSUITEInstallVersion = CSVer;
            end

            %%%%%%%%% check controlsuite required .................%%%%%%%%%
            % check selected processors and controlsuite list
            controlSUTIEAvailVersionMapObj = obj.Workflow.controlSUTIEAvailVersionMapObj;
            resultprocessors = intersect(obj.Workflow.SelectedProcessors, controlSUTIEAvailVersionMapObj.keys);

            if ~isempty(resultprocessors)
                obj.Workflow.isNeededValidateSUITE = true;
            else
                obj.Workflow.isNeededValidateSUITE = false;
            end
            if obj.Workflow.isNeededValidateSUITE

                suitelocation  = obj.Workflow.ControlSUITEInstallLocation;
                if isempty(suitelocation)
                    % now check if suite ware installed
                    suiteHyperlinkText = message('TIC2000:hwsetup:InstallLatest').getString;
                    suiteURL = obj.Workflow.controlSUITEDownloadURL;
                elseif isempty(controlsuiteversion)
                    % is control suit installed
                    suiteURL = obj.Workflow.controlSUITEDownloadURL;
                    suiteHyperlinkText = message('TIC2000:hwsetup:InstallLatest').getString;
                else
                    ProcessorControlSUTIEMapObj = obj.Workflow.ProcessorControlSUTIEMapObj;
                    controlSUTIEAvailVersionMapObj = obj.Workflow.controlSUTIEAvailVersionMapObj;
                    suiteNeededIdx =0;
                    suitesupportedIdx =0;

                    for i=1:numel(selectedprocessors)
                        if any(ismember(controlSUTIEAvailVersionMapObj.keys, selectedprocessors{i}))
                            path_evaluate = fullfile(suitelocation, ProcessorControlSUTIEMapObj(selectedprocessors{i}));
                            suiteNeededIdx = suiteNeededIdx + 1;
                            if 7 == exist(path_evaluate, 'dir')
                                suitesupportedIdx = suitesupportedIdx + 1;
                            end
                        end
                    end

                    if suiteNeededIdx == 0
                        % check if 28004and 28044 will work
                        suiteHyperlinkText = message('TIC2000:hwsetup:InstallTpUpgradeNA').getString;
                        suiteURL = '';
                    elseif suiteNeededIdx == suitesupportedIdx
                        suiteHyperlinkText = message('TIC2000:hwsetup:InstallTpUpgradeNotReq').getString;
                        suiteURL = '';
                    elseif suitesupportedIdx == 0 % Registry path not found
                        if isempty(controlsuiteversion)
                            suiteHyperlinkText = message('TIC2000:hwsetup:InstallLatest').getString;
                            suiteURL = obj.Workflow.controlSUITEDownloadURL;
                            if ispc
                                CSVer = message('TIC2000:hwsetup:NotInstalled').getString; %not installed
                            else
                            %In Linux 3p might be installed but currently we are unable to detect location
                                CSVer = message('TIC2000:hwsetup:NotDetected').getString;
                            end
                        else
                            suiteHyperlinkText = message('TIC2000:hwsetup:InstallTpUpgradeReq').getString;
                            suiteURL = obj.Workflow.controlSUITEDownloadURL;
                        end
                    else
                        suiteHyperlinkText = message('TIC2000:hwsetup:InstallTpUpgradeReq').getString;
                        suiteURL = obj.Workflow.controlSUITEDownloadURL;
                    end
                end
            else
                suiteHyperlinkText = message('TIC2000:hwsetup:InstallTpUpgradeNA').getString;
                suiteURL = '';
            end

            %%%%%%%%%%% Check C2000 Ware details -  F28004x -  %%%%%%%%%%%%%%%
            c2000warelocation = obj.Workflow.C2000WareLocation;
            c2000wareVersion = obj.Workflow.C2000WareVersion;
            if isempty(c2000warelocation)
                if ispc
                    c2000wareVersion = message('TIC2000:hwsetup:NotInstalled').getString;%not installed
                else
                %In Linux 3p might be installed but currently we are unable to detect location
                    c2000wareVersion = message('TIC2000:hwsetup:NotDetected').getString;
                end
            end
            ProcessorC2000WareMapObj = obj.Workflow.ProcessorC2000WareMapObj;
            wareNeededIdx =0;
            waresupportedIdx =0;

            for i=1:numel(selectedprocessors)
                if any(ismember(ProcessorC2000WareMapObj.keys, selectedprocessors{i}))
                    path_evaluate = fullfile(c2000warelocation, ProcessorC2000WareMapObj(selectedprocessors{i}));
                    wareNeededIdx = wareNeededIdx + 1;
                    if 7 == exist(path_evaluate, 'dir')
                        waresupportedIdx = waresupportedIdx + 1;
                    end
                end
            end

            if wareNeededIdx == 0
                c2000wareHyperlinkText = message('TIC2000:hwsetup:InstallTpUpgradeNA').getString;
                c2000wareURL = '';
            elseif ~isempty(c2000warelocation) && ~contains(c2000warelocation, obj.Workflow.HardwareInterface.C2000WareVersionTag, 'IgnoreCase', true)
                c2000wareHyperlinkText = message('TIC2000:hwsetup:InstallC2000WareTested').getString;
                c2000wareURL = obj.Workflow.C2000WareDownloadURL;
                %This is needed because C2000warelocation may be default 'C2000Ware_' and the version will be empty when travsersing back to this screen
                if isempty(c2000wareVersion)
                    if ispc
                        c2000wareVersion = message('TIC2000:hwsetup:NotInstalled').getString;%not installed
                    else
                    %In Linux 3p might be installed but currently we are unable to detect location
                        c2000wareVersion = message('TIC2000:hwsetup:NotDetected').getString;
                    end
                end
            elseif wareNeededIdx == waresupportedIdx
                c2000wareHyperlinkText = message('TIC2000:hwsetup:InstallTpUpgradeNotReq').getString;
                c2000wareURL = '';
            elseif waresupportedIdx == 0 % Registry path not found
                if isempty(c2000wareVersion)
                    c2000wareHyperlinkText = message('TIC2000:hwsetup:InstallC2000WareTested').getString;
                    c2000wareURL = obj.Workflow.C2000WareDownloadURL;
                    if ispc
                        c2000wareVersion = message('TIC2000:hwsetup:NotInstalled').getString;
                    else
                    %In Linux 3p might be installed but currently we are unable to detect location
                        c2000wareVersion = message('TIC2000:hwsetup:NotDetected').getString;
                    end
                else
                    c2000wareHyperlinkText = message('TIC2000:hwsetup:InstallC2000WareTested').getString;
                    c2000wareURL = obj.Workflow.C2000WareDownloadURL;
                end
            else
                c2000wareHyperlinkText = message('TIC2000:hwsetup:InstallC2000WareTested').getString;
                c2000wareURL = obj.Workflow.C2000WareDownloadURL;
            end
            obj.Workflow.C2000WareVersion = c2000wareVersion;

            needAboutSelection = 0;
            % Assign tpDownload details
            if ~isempty(CCSURL)
                CCSDetails = ['<a href="' CCSURL '">' CCSHyperlinkText '</a>'];
                needAboutSelection = 1;
            else
                CCSDetails = CCSHyperlinkText;
            end
            % Assign tpDownload details
            if ~isempty(suiteURL)
                controlSUITEDetails = ['<a href="' suiteURL '">' suiteHyperlinkText '</a>'];
                needAboutSelection = 1;
            else
                controlSUITEDetails = suiteHyperlinkText;
            end
            if ~isempty(c2000wareURL)
                c2000wareDetails = ['<a href="' c2000wareURL '">' c2000wareHyperlinkText '</a>'];
                needAboutSelection = 1;
            else
                c2000wareDetails = c2000wareHyperlinkText;
            end
            if strcmp(obj.Workflow.BaseCode, 'TIC2000_BLOCKSET')
                %set tptable properties for SoC spkg
                obj.ListTpDownloadTable.Name = ...
                    {message('TIC2000:hwsetup:InstallTpCCS').getString, ...
                    message('TIC2000:hwsetup:InstallTpC2000Ware').getString};
                obj.ListTpDownloadTable.Version = {ccsversion, c2000wareVersion};
                obj.ListTpDownloadTable.Details = {CCSDetails, c2000wareDetails};
            else
                %set tptable properties for EC spkg
                obj.ListTpDownloadTable.Name = ...
                    {message('TIC2000:hwsetup:InstallTpControlSUITE').getString, ...
                    message('TIC2000:hwsetup:InstallTpCCS').getString, ...
                    message('TIC2000:hwsetup:InstallTpC2000Ware').getString};
                obj.ListTpDownloadTable.Version = {CSVer, ccsversion, c2000wareVersion};
                obj.ListTpDownloadTable.Details = {controlSUITEDetails, CCSDetails, c2000wareDetails};
            end

            %%%%%%%%%%% Add F28044 specific 3p details %%%%%%%%%%%%%%%
            if any(contains(obj.Workflow.SelectedProcessors, 'TI F28044'))
                % Add F28044 details into the tp table - remove this
                % section when F28044 support is withdrawn
                if exist(obj.Workflow.F28044Location, 'dir') ~= 7% check again, to make sure if no installation found
                    F28044URLText = message('TIC2000:hwsetup:InstallTpF28044Tested').getString;
                    F28044Details = ['<a href="' obj.Workflow.F28044URL '">' F28044URLText '</a>'];
                    if ispc
                        F28044Version = message('TIC2000:hwsetup:NotInstalled').getString;
                    else
                    %In Linux 3p might be installed but currently we are unable to detect location
                        F28044Version = message('TIC2000:hwsetup:NotDetected').getString;
                    end
                    needAboutSelection = 1;
                elseif contains(obj.Workflow.F28044Location, 'v130', 'IgnoreCase', true)% if installation is found
                    F28044Version = '130';
                    F28044Details = message('TIC2000:hwsetup:InstallTpUpgradeNotReq').getString;
                else
                    F28044URLText = message('TIC2000:hwsetup:Install').getString;
                    F28044Details = ['<a href="' obj.Workflow.F28044URL '">' F28044URLText '</a>'];
                    F28044Version = char(regexpi(obj.Workflow.F28044Location, '\\v\d+|$', 'match'));
                    F28044Version = strrep(F28044Version, '\v', '');
                    needAboutSelection = 1;
                end
                obj.ListTpDownloadTable.Name{end+1} = ...
                    message('TIC2000:hwsetup:InstallTpF28044').getString;
                obj.ListTpDownloadTable.Version{end+1} = F28044Version;% not installed F28044
                obj.ListTpDownloadTable.Details{end+1} = F28044Details;
            end

            %%%%%%%%%%% Add F280x specific 3p details %%%%%%%%%%%%%%%
            if any(contains(obj.Workflow.SelectedProcessors, 'TI F280x'))
                % Add F280x details into the tp table - remove this
                % section when F280x support is withdrawn
                if exist(obj.Workflow.F280xLocation, 'dir') ~= 7% check again, to make sure if no installation found
                    F280xURLText = message('TIC2000:hwsetup:InstallTpF280xTested').getString;
                    F280xDetails = ['<a href="' obj.Workflow.F280xURL '">' F280xURLText '</a>'];
                    if ispc
                        F280xVersion = message('TIC2000:hwsetup:NotInstalled').getString;
                    else
                    %In Linux 3p might be installed but currently we are unable to detect location
                        F280xVersion = message('TIC2000:hwsetup:NotDetected').getString;
                    end
                    needAboutSelection = 1;
                elseif contains(obj.Workflow.F280xLocation, 'v170', 'IgnoreCase', true)% if installation is found
                    F280xVersion = '170';
                    F280xDetails = message('TIC2000:hwsetup:InstallTpUpgradeNotReq').getString;
                else
                    F280xURLText = message('TIC2000:hwsetup:InstallTpF280xTested').getString;
                    F280xDetails = ['<a href="' obj.Workflow.F280xURL '">' F280xURLText '</a>'];
                    F280xVersion = char(regexpi(obj.Workflow.F280xLocation, '\\v\d+|$', 'match'));
                    F280xVersion = strrep(F280xVersion, '\v', '');
                    needAboutSelection = 1;
                end
                obj.ListTpDownloadTable.Name{end+1} = ...
                    message('TIC2000:hwsetup:InstallTpF280x').getString;
                obj.ListTpDownloadTable.Version{end+1} = F280xVersion;% not installed F280x
                obj.ListTpDownloadTable.Details{end+1} = F280xDetails;
            end

            %%%%%%%%%%% Add F281x specific 3p details %%%%%%%%%%%%%%%
            if any(contains(obj.Workflow.SelectedProcessors, 'TI F281x'))
                % Add F281x details into the tp table - remove this
                % section when F281x support is withdrawn
                if exist(obj.Workflow.F281xLocation, 'dir') ~= 7% check again, to make sure if no installation found
                    F281xURLText = message('TIC2000:hwsetup:InstallTpF281xTested').getString;
                    F281xDetails = ['<a href="' obj.Workflow.F281xURL '">' F281xURLText '</a>'];
                    if ispc
                        F281xVersion = message('TIC2000:hwsetup:NotInstalled').getString;
                    else
                    %In Linux 3p might be installed but currently we are unable to detect location
                        F281xVersion = message('TIC2000:hwsetup:NotDetected').getString;
                    end
                    needAboutSelection = 1;
                elseif contains(obj.Workflow.F281xLocation, 'v120', 'IgnoreCase', true)% if installation is found
                    F281xVersion = '120';
                    F281xDetails = message('TIC2000:hwsetup:InstallTpUpgradeNotReq').getString;
                else
                    F281xURLText = message('TIC2000:hwsetup:InstallTpF281xTested').getString;
                    F281xDetails = ['<a href="' obj.Workflow.F281xURL '">' F281xURLText '</a>'];
                    F281xVersion = char(regexpi(obj.Workflow.F281xLocation, '\\v\d+|$', 'match'));
                    F281xVersion = strrep(F281xVersion, '\v', '');
                    needAboutSelection = 1;
                end                
                obj.ListTpDownloadTable.Name{end+1} = ...
                    message('TIC2000:hwsetup:InstallTpF281x').getString;
                obj.ListTpDownloadTable.Version{end+1} = F281xVersion;% not installed F281x
                obj.ListTpDownloadTable.Details{end+1} = F281xDetails;
            end

            if needAboutSelection
                obj.HelpText.AboutSelection = [message('TIC2000:hwsetup:InstallTpAdditional').getString];
            end
        end
    end

    %----------------------------------------------------------------------
    % Helper methods
    %----------------------------------------------------------------------
    methods(Access = private)
        function initScreen(obj)
            %INITSCREEN helper that is called on screen load. It updates
            %the screen widgets while 3p tools are searched.

            obj.BusySpinner.Visible = 'on';
            % Trigger the callback
            obj.autoFind3P();
            % Set 3p details
            obj.SetTPDetails(); % method that sets TP info
            % Turn - Off Spinner
            obj.BusySpinner.Visible = 'off';
            obj.NextButton.Enable = 'on'; % Show Next
            obj.BackButton.Visible = 'on';
        end
    end

end