function dlgstruct = getDetailsDialogSchema(h, ~)
%

%   Copyright 2012-2022 The MathWorks, Inc.
view = h.getActiveView;
% Visible objects
visible = h.VisibleCount;
% Possible objects
possible = h.PossibleCount;
% Number of hidden objects
hidden = possible - visible;
% 
settingsStr = calculateSettingsString(h);
% construct the message to display
infoString = DAStudio.message('modelexplorer:DAS:ViewDetails',...
                visible, possible, hidden, settingsStr);
im = DAStudio.imExplorer(h.Explorer);
filterString = im.getListFilterString();
if ~isempty(filterString)
    filterMessage = DAStudio.message('modelexplorer:DAS:FilterDetails', filterString);               
    infoString = sprintf('%s\n\n%s', infoString, filterMessage);
end

% Prepare dialog schema
spacer_top_text.Type       = 'panel';
spacer_top_text.RowSpan    = [1 1];
spacer_top_text.ColSpan    = [1 2];

info_icon.Type        = 'image';
info_icon.Tag         = 'count_details_info_icon';
info_icon.FilePath    = fullfile(matlabroot, 'toolbox', 'shared', ...
                                 'dastudio', 'resources', 'dialog_info_32.png');    
info_icon.RowSpan     = [2 2];
info_icon.ColSpan     = [1 1];
    
message.Type = 'text';
message.Name = infoString;
message.Tag = 'details_message_item';
message.ColSpan = [2 2];
message.RowSpan = [2 2];

spacer_right_text.Type       = 'panel';
spacer_right_text.RowSpan    = [2 2];
spacer_right_text.ColSpan    = [3 3];

info.Type        = 'panel';
info.Items       = {spacer_top_text, info_icon, message, spacer_right_text};
info.LayoutGrid  = [2 3];
info.RowSpan     = [1 1];
info.ColSpan     = [1 1];

dlgstruct.DialogTitle = view.Name;
dlgstruct.LayoutGrid = [1 1];
dlgstruct.StandaloneButtonSet = {'Ok'}; % no button bar
dlgstruct.Sticky = true; % modal
dlgstruct.DialogTag = 'me_view_manager_view_details';
dlgstruct.Items = {info};

%
%
%
function settingsStr = calculateSettingsString(manager)
settingsStr = '';
if ishandle(manager.Explorer)
    actionArr = {'VIEW_SHOWMASKEDSUBSYSTEMS', DAStudio.message('modelexplorer:DAS:MaskedSubsystemsID'); ...                     
                 'VIEW_SHOWLINKEDSUBSYSTEMS', DAStudio.message('modelexplorer:DAS:LibraryLinksID'); ...                     
                 'NEWLINESEPARATOR', '\n'; ...
                 'VIEW_SLCONTAINERS', ''; ...
                 'VIEW_SLBLOCKS', ''; ...
                 'VIEW_SLNAMEDLINES', ''; ...
                 'VIEW_SLLINES', ''; ...
                 'VIEW_SLANNOTATIONS', ''; ...
                 'NEWLINESEPARATOR', '\n';
                 'VIEW_SFCONTAINERS', ''; ...
                 'VIEW_SFSTATES', ''; ...
                 'VIEW_SFTRANSITIONS', ''; ...
                 'VIEW_SFJUNCTIONS', ''; ...
                 'VIEW_SFEVENTS', ''; ...
                 'VIEW_DATA', '';};
    
    outStr = '';
    ac = DAStudio.ActionManager;
    for i = 1:length(actionArr)
        action = [];
        if strcmp(char(actionArr{i,1}), 'NEWLINESEPARATOR')
            if ~isempty(outStr)
                settingsStr = sprintf('%s\n   %s', settingsStr, outStr);
                outStr = '';
            end
        else
            action = ac.createDefaultAction(manager.Explorer, char(actionArr{i,1}));
        end
        if ~isempty(action) && strcmp(action.on, 'off')                              
            if isempty(char(actionArr{i,2}))
                text = strrep(action.text, '&','');
            else
                text = char(actionArr{i,2});
            end
            if isempty(outStr) && ~strcmp(text,'\n')
                outStr = sprintf('%s', text);
            else                    
                outStr = sprintf('%s, %s', outStr, text);                    
            end
        end
    end
    if ~isempty(outStr)
        settingsStr = sprintf('%s\n   %s', settingsStr, outStr);
    end
    % Set none if nothing is there
    if isempty(settingsStr)
        settingsStr = DAStudio.message('modelexplorer:DAS:NoneID');
    end
end

