function glbPanel = getTabDialogSchema(this, hParent, schemaName)
%GETTABDIALOGSCHEMA   Get the tabDialogSchema.

%   Author(s): J.Sun
%   Copyright 2008-2023 The MathWorks, Inc.
%     

enableWidget = true;

componentname = 'GlobalSettings_';
tag = [hParent.getproductname, componentname];
filtobj = hParent.filterObj;
currRow = 1;

[widgets, currRow] = getSharedWidgets(this, hParent.CLIProperties, enableWidget, currRow, 'main', tag);

clkinputOP = 'ClockInputs';
clkinput_lbl.Type = 'text';
clkinput_lbl.Name = DAStudio.message('HDLShared:fdhdldialog:clockInputs');
clkinput_lbl.RowSpan = [currRow, currRow];
clkinput_lbl.ColSpan = [3 3];

clkinput.Type           = 'combobox';
clkinput.Source         = this;
a                         = hdlcoderprops.hdlcoderpropsDataType.HDLClockInputsType;
cbEntries                 = a.Strings;
clkinput.Entries        = getTranslatedStringcell('HDLShared:fdhdldialog',cbEntries);
defaultindx = find(strcmpi(cbEntries,hParent.CLIProperties.ClockInputs));
if ~isempty(defaultindx)
    clkinput.Value = defaultindx - 1;
end
clkinput.Tag            = [tag clkinputOP];
clkinput_lbl.Buddy      = clkinput.Tag;
clkinput.RowSpan        = [currRow, currRow];
clkinput.ColSpan        = [4 4];
clkinput.Mode = true;
clkinput.DialogRefresh = true;
clkinput.Enabled = getEnableState(this, hParent, 'ClockInputs');
clkinput.ObjectMethod = 'selectComboboxEntryCLI';
clkinput.MethodArgs  = {'%value', 'ClockInputs', cbEntries, hParent.CLIProperties};
clkinput.ArgDataTypes = {'mxArray', 'string', 'mxArray', 'mxArray'};
if clkinput.Enabled == false
    hParent.CLIProperties.ClockInputs = 'Single';
end

currRow = currRow+1;
removereset_lbl.Type = 'text';
removereset_lbl.Name = DAStudio.message('HDLShared:fdhdldialog:FilterRemoveReset');
removereset_lbl.RowSpan = [currRow, currRow];
removereset_lbl.ColSpan = [1 1];

removereset.Type = 'combobox';
a = findtype('UIFilterResetTypeEnum');
cbEntries = a.Strings;
removereset.Entries = getTranslatedStringcell('HDLShared:fdhdldialog',cbEntries);
defaultindx = find(strcmpi(cbEntries,this.RemoveResetFrom));
if ~isempty(defaultindx)
    removereset.Value = defaultindx - 1;
end
removereset.Tag = [tag 'RemoveResetFrom'];
removereset_lbl.Buddy = removereset.Tag;
removereset.RowSpan = [currRow, currRow];
removereset.ColSpan = [2 2];
removereset.Source = this;
removereset.Mode = true;
removereset.ObjectMethod = 'selectComboboxEntry';
removereset.MethodArgs  = {'%dialog', '%value', 'RemoveResetFrom', cbEntries};
removereset.ArgDataTypes = {'handle', 'mxArray', 'string', 'mxArray'};


widgets = [widgets {clkinput_lbl, clkinput, removereset_lbl, removereset}];

clksg.Type = 'panel';
clksg.Name = DAStudio.message('HDLShared:hdldialog:hdlglblsettingClockSettingGroup');
clksg.Items = widgets;
clksg.LayoutGrid = [currRow 4];
clksg.ColStretch = [0 1 0 1];
clksg.Tag = [tag, 'ClockSettingsGroup'];

currRow = 1;
[genTabwidgets, currRow] = getSharedWidgets(this, hParent.CLIProperties, enableWidget, currRow, 'general', tag);

VectorPrefixOP = 'VectorPrefix';
lblVectorPrefix.Type = 'text';
lblVectorPrefix.Name = DAStudio.message('HDLShared:fdhdldialog:vectorPrefix');
lblVectorPrefix.RowSpan = [currRow, currRow];
lblVectorPrefix.ColSpan = [3 3];

txtVectorPrefix.Type = 'edit';
txtVectorPrefix.ObjectProperty = VectorPrefixOP;
txtVectorPrefix.Tag = [tag,VectorPrefixOP];
lblVectorPrefix.Buddy = txtVectorPrefix.Tag;
txtVectorPrefix.RowSpan = [currRow, currRow];
txtVectorPrefix.ColSpan = [4 4];
txtVectorPrefix.Source = hParent.CLIProperties;
txtVectorPrefix.Mode = true;
txtVectorPrefix.Enabled = strcmpi(hParent.CLIProperties.TargetLanguage, 'VHDL');

currRow = currRow+1;
% Add fdhdlc specific widgets
CoeffPrefixOP = 'CoeffPrefix';
lblCoeffPrefix.Type = 'text';
lblCoeffPrefix.Name = DAStudio.message('HDLShared:fdhdldialog:coeffPrefix');
lblCoeffPrefix.RowSpan = [currRow, currRow];
lblCoeffPrefix.ColSpan = [1 1];

txtCoeffPrefix.Type = 'edit';
txtCoeffPrefix.ObjectProperty = CoeffPrefixOP;
txtCoeffPrefix.Tag = [tag,CoeffPrefixOP];
lblCoeffPrefix.Buddy = txtCoeffPrefix.Tag;
txtCoeffPrefix.RowSpan = [currRow, currRow];
txtCoeffPrefix.ColSpan = [2 2];
txtCoeffPrefix.Source = hParent.CLIProperties;
txtCoeffPrefix.Mode = true;

currRow = currRow+1;
InstancePrefixOP = 'InstancePrefix';
lblInstancePrefix.Type = 'text';
lblInstancePrefix.Name = DAStudio.message('HDLShared:fdhdldialog:instancePrefix');
lblInstancePrefix.RowSpan = [currRow, currRow];
lblInstancePrefix.ColSpan = [1 1];

txtInstancePrefix.Type = 'edit';
txtInstancePrefix.ObjectProperty = InstancePrefixOP;
txtInstancePrefix.Tag = [tag,InstancePrefixOP];
lblInstancePrefix.Buddy = txtInstancePrefix.Tag;
txtInstancePrefix.RowSpan = [currRow, currRow];
txtInstancePrefix.ColSpan = [2 2];
txtInstancePrefix.Source = hParent.CLIProperties;
txtInstancePrefix.Mode = true;

currRow = currRow+1;
spacer.Type = 'panel';
spacer.RowSpan = [currRow, currRow];
spacer.ColSpan = [1 4];

grpGeneral.Type = 'panel';
grpGeneral.Name = '';
% grpGeneral.RowSpan = [1 currRow]; 
% grpGeneral.ColSpan = [1 4];
grpGeneral.LayoutGrid = [currRow 4];
grpGeneral.ColStretch = [0 1 0 1];
grpGeneral.RowStretch = [zeros(1, currRow-1) 1];
grpGeneral.Tag = [tag, 'GeneralGroup'];
grpGeneral.Items = [genTabwidgets {lblCoeffPrefix, txtCoeffPrefix, ...
                        lblInstancePrefix, txtInstancePrefix, ...
                        lblVectorPrefix, txtVectorPrefix, spacer}];

% General tab panel
genTab.Name  = DAStudio.message('HDLShared:hdldialog:hdlglblsettingGeneralGroup');
genTab.Items = {grpGeneral};

currRow = 1;
[prtsTabwidgets, currRow] = getSharedWidgets(this, hParent.CLIProperties, enableWidget, currRow, 'ports', tag);

for i=1:length(prtsTabwidgets)
    if isfield(prtsTabwidgets{i}, 'ObjectProperty')...
        && strcmpi(prtsTabwidgets{i}.ObjectProperty, 'ClockEnableOutputPort')
        prtsTabwidgets{i}.Enabled = getEnableState(this, hParent, 'ClockEnableOutputPort');
        break;
    end
end


currRow = currRow+1;
currCol = 1;

% Add filter specific
inputportOP = 'InputPort'; 
inputport_lbl.Type = 'text';
inputport_lbl.Name = DAStudio.message('HDLShared:fdhdldialog:inputPort');
inputport_lbl.RowSpan = [currRow, currRow];
inputport_lbl.ColSpan = [currCol, currCol];

inputport.Type = 'edit';
inputport.ObjectProperty = inputportOP;
inputport.Tag = [tag inputportOP];
inputport_lbl.Buddy = inputport.Tag;
inputport.RowSpan = [currRow, currRow];
inputport.ColSpan = [currCol+1 currCol+1];
inputport.Source = hParent.CLIProperties;
inputport.Mode = true;
inputport.Enabled = enableWidget;

prtsTabwidgets = [prtsTabwidgets {inputport_lbl, inputport}];

currRow = currRow+1;
outputportOP = 'OutputPort';
outputport_lbl.Type = 'text';
outputport_lbl.Name = DAStudio.message('HDLShared:fdhdldialog:outputPort');
outputport_lbl.RowSpan = [currRow, currRow];
outputport_lbl.ColSpan = [currCol, currCol];

outputport.Type = 'edit';
outputport.ObjectProperty = outputportOP;
outputport.Tag = [tag outputportOP];
outputport_lbl.Buddy = outputport.Tag;
outputport.RowSpan = [currRow, currRow];
outputport.ColSpan = [currCol+1 currCol+1];
outputport.Source = hParent.CLIProperties;
outputport.Mode = true;
outputport.Enabled = enableWidget;

prtsTabwidgets = [prtsTabwidgets {outputport_lbl, outputport}];

if hParent.hdlFilter.isComplexInputSupported == true
    if hParent.modifyForUSRP2filter
        % cache the value
        this.InputComplex_bk = this.InputComplex;
        this.InputComplex = 'Complex';
    else
        if ~isempty(this.InputComplex_bk)
            this.InputComplex = this.InputComplex_bk;
            % clean up the cache
            this.InputComplex_bk = '';
        end
    end
    
    currRow = currRow+1;
    inputComplexity_lbl.Type = 'text';
    inputComplexity_lbl.Name = DAStudio.message('HDLShared:fdhdldialog:InputComplex');
    inputComplexity_lbl.RowSpan = [currRow, currRow];
    inputComplexity_lbl.ColSpan = [currCol, currCol];

    inputComplexity.Type           = 'combobox';
    inputComplexity.Source         = this;
    a = findtype('InputComplexityType');
    cbEntries                      = a.Strings;
    inputComplexity.Entries        = getTranslatedStringcell('HDLShared:fdhdldialog',cbEntries);
    defaultindx = find(strcmpi(cbEntries,this.InputComplex));
    if ~isempty(defaultindx)
        inputComplexity.Value = defaultindx - 1;
    end
    inputComplexity.Tag            = [tag 'InputComplex'];
    inputComplexity_lbl.Buddy = inputComplexity.Tag;
    inputComplexity.RowSpan        = [currRow, currRow];
    inputComplexity.ColSpan        = [currCol+1 currCol+1];
    inputComplexity.Mode = true;
    inputComplexity.DialogRefresh = true;
    inputComplexity.Enabled = enableWidget;
    inputComplexity.ObjectMethod = 'dialogCallback';
    inputComplexity.MethodArgs = {'%dialog', hParent.CLIProperties, 'InputComplex', this, '%value', cbEntries};
    inputComplexity.ArgDataTypes = {'handle', 'mxArray', 'string', 'handle', 'mxArray','mxArray'};

    prtsTabwidgets = [prtsTabwidgets {inputComplexity_lbl, inputComplexity}];
end

if getEnableState(this, hParent, 'fracdelayport')
    currRow = currRow+1;
    fracdelayportOP = 'FracDelayPort';
    fracdelayport_lbl.Type = 'text';
    fracdelayport_lbl.Name = DAStudio.message('HDLShared:fdhdldialog:factoryDelayPort');
    fracdelayport_lbl.RowSpan = [currRow, currRow];
    fracdelayport_lbl.ColSpan = [currCol, currCol];

    fracdelayport.Type = 'edit';
    fracdelayport.ObjectProperty = fracdelayportOP;
    fracdelayport.Tag = [tag fracdelayportOP];
    fracdelayport_lbl.Buddy = fracdelayport.Tag;
    fracdelayport.RowSpan = [currRow, currRow];
    fracdelayport.ColSpan = [currCol+1 currCol+1];
    fracdelayport.Source = hParent.CLIProperties;
    fracdelayport.Mode = true;
    fracdelayport.Enabled = enableWidget;
    prtsTabwidgets = [prtsTabwidgets {fracdelayport_lbl, fracdelayport}];
end

currRow = currRow+1;
addinputreg.Type = 'checkbox';
addinputreg.Name = DAStudio.message('HDLShared:fdhdldialog:addInputRegister');
addinputreg.Tag = [tag,'AddInputRegister'];
addinputreg.Source = this;
addinputreg.RowSpan = [currRow, currRow];
addinputreg.ColSpan = [currCol, currCol+1];
addinputreg.Mode = true;
addinputreg.ObjectMethod = 'setCheckBox';
addinputreg.Value        = strcmpi(hParent.CLIProperties.AddInputRegister, 'on');
addinputreg.MethodArgs   = {'%value', 'AddInputRegister', hParent.CLIProperties};
addinputreg.ArgDataTypes = {'mxArray', 'string', 'mxArray'};
archit = hParent.hArchit.Architecture;

currRow = currRow+1;
addoutputreg.Type = 'checkbox';
addoutputreg.Name = DAStudio.message('HDLShared:fdhdldialog:addOutputRegister');
addoutputreg.Tag = [tag,'AddOutputRegister'];
addoutputreg.Source = this;
addoutputreg.RowSpan = [currRow, currRow];
addoutputreg.ColSpan = [currCol, currCol+1];
addoutputreg.Mode = true;
addoutputreg.ObjectMethod = 'setCheckBox';
addoutputreg.Value        = strcmpi(hParent.CLIProperties.AddOutputRegister, 'on');
addoutputreg.MethodArgs   = {'%value', 'AddOutputRegister', hParent.CLIProperties};
addoutputreg.ArgDataTypes = {'mxArray', 'string', 'mxArray'};

if fdhdlcoderui.issupportedsos(filtobj) && ...
        (strcmpi(archit,'fully serial') || strcmpi(archit,'partly serial'))
    addinputreg.Enabled = false;
    hParent.CLIProperties.AddInputRegister = 'on';
    
    addoutputreg.Enabled = false;
    hParent.CLIProperties.AddOutputRegister = 'on';
else
    addinputreg.Enabled = true;
    addoutputreg.Enabled = true;
end

if strcmpi(hParent.hArchit.Architecture, 'Distributed arithmetic (DA)')
    addinputreg.Enabled = false;
    hParent.CLIProperties.AddInputRegister = 'on';
    
    addoutputreg.Enabled = false;
    hParent.CLIProperties.AddOutputRegister = 'on';
end

prtsTabwidgets = [prtsTabwidgets {addinputreg, addoutputreg}];

grpPorts.Type = 'panel';
grpPorts.LayoutGrid = [currRow+1 4];
grpPorts.ColStretch = [0 1 0 1];
grpPorts.RowStretch = [zeros(1, currRow) 1];
grpPorts.Tag = [tag, 'PortsGroup'];
grpPorts.Items = prtsTabwidgets;
    
% General tab panel
prtsTab.Name  = DAStudio.message('HDLShared:hdldialog:hdlglblsettingPortsGroup');
prtsTab.Items = {grpPorts};

currRow = 1;
[advTabwidgets, currRow] = getSharedWidgets(this, hParent.CLIProperties, enableWidget, currRow, 'advanced', tag);

% Update the 'CastBeforeSum' widget ebable state
for i=1:length(advTabwidgets)
    if strcmpi(advTabwidgets{i}.MethodArgs{2}, 'CastBeforeSum')
        advTabwidgets{i}.Enabled = getEnableState(this, hParent, 'CastBeforeSum');
        break;
    end
end

grpAdvanced.Type = 'panel';
% grpAdvanced.Name = DAStudio.message('HDLShared:hdldialog:hdlglblsettingAdvancedGroup');
% grpAdvanced.RowSpan = [1 currRow];
% grpAdvanced.ColSpan = [1 4];
grpAdvanced.LayoutGrid = [currRow 4];
grpAdvanced.ColStretch = [0 0 0 0];
grpAdvanced.RowStretch = [zeros(1, currRow-1) 1];
grpAdvanced.Tag = [tag, 'AdvancedGroup'];

grpAdvanced.Items = advTabwidgets;
    
advTab.Name = DAStudio.message('HDLShared:hdldialog:hdlglblsettingAdvancedGroup');
advTab.Items = {grpAdvanced};

tabBody.Type = 'tab';
tabBody.Tabs = {genTab,prtsTab,advTab};
tabBody.Tag = [tag, 'Tab'];
tabBody.ActiveTab = this.ActiveTab; 
tabBody.TabChangedCallback = 'fdhdlcoderui.changehdlconfigtab'; 

%
% Additional settings group
%
tabg.Type = 'group';
tabg.Name = DAStudio.message('HDLShared:hdldialog:hdlglblsettingAdditionalSettingGroup');
tabg.Items = {tabBody};
tabg.LayoutGrid = [1 1];

spacer.Type     = 'panel';
spacer.RowSpan = [3 3];
spacer.ColSpan = [1 2];
    
if strcmpi(schemaName, 'tab')
    glbPanel.Items = {clksg,tabg};    
else        

    clksg.RowSpan = [1 1];
    clksg.ColSpan = [1 2];

    tabg.RowSpan = [2 2];
    tabg.ColSpan = [1 2];

    glbPanel.Type  = 'panel';
    glbPanel.Items = {clksg, tabg, spacer};
    
    glbPanel.LayoutGrid = [3 2];
    glbPanel.RowStretch = [0 0 1];
    glbPanel.ColStretch = [0 0];
end

if hParent.modifyForUSRP2filter    
    for i=1:length(glbPanel.Items)
        glbPanel.Items{i}.Enabled = false;
    end
end

glbPanel.Name = DAStudio.message('HDLShared:hdldialog:hdlglblsettingsComponentName');% 'HDL Settings';

% [EOF]

% LocalWords:  fdhdldialog fdhdlc grp curr fracdelayport ebable fdhdlcoderui
