%% populate
%    update all the textboxes to the current page of the pvs
%    results
% inputs:
%   object:ValidationReport - current object
% outputs:
%   none
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function [] = populate(object)
% temporarily used to reset colours
object.gui.check_call([],[]);
set(object.edit_tcc,'string',char(object.PVS_results(object.page).TCC));
set(object.edit_seq,'string',char(object.PVS_results(object.page).seq));
set(object.label_page,'string',[num2str(object.page) '  of  ' num2str(size(object.PVS_results,2))]);
counter = [];
counter_display = [];
enum_array = [];
if size(object.PVS_results(object.page).ce,2) == 0
    counter_display = ['no counter example generated'];
    
else
    for i = 1:2:size(object.PVS_results(object.page).ce,2)
        
        
        % need to do some translation back to matlab syntax
        new_value = regexprep(char(object.PVS_results(object.page).ce(i+1)),'FALSE',' 0 ');
        new_value = regexprep(new_value,'TRUE',' 1 ');
        % try to evaluate what gets returned might be a fraction, if it is
        % an enumerated type need to do some more work.
            
        % check if new_value contains any characters [a-zA-z]
        isstring = regexp(char(new_value),'[a-zA-Z]','match');
        if ~isempty(isstring)
            % value is an alpha string
            
            % search in list if alpha already assigned
            [found, index] = ismember(char(new_value),enum_array);
            if found
                 value = index;
            else
                enum_array = [enum_array {char(new_value)}];
                value = size(enum_array,2);
            end
        else
            % value is numeric
            eval(['value = ' char(new_value) ';']);
            new_value = num2str(value);
        end
        
        % need different string for output vs evaulation
        counter_display = [counter_display char(object.PVS_results(object.page).ce(i)) ' = ' char(new_value) ';' sprintf('\n')];
        counter = [counter char(object.PVS_results(object.page).ce(i)) ' = ' num2str(value) ';' sprintf('\n')];
    end
    
    
    object.gui.evaluate_counter(counter);
end
set(object.edit_ce,'string',counter_display);
end