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

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

componentname = 'TestBenchPanel_';
tagpf = [hParent.getproductname, componentname];

currRow = 1;
src = hParent.CLIProperties;
enablewidget = this.GenerateTestBench || this.CosimModel;

chkGenerateTB.Type = 'checkbox';
chkGenerateTB.Name = DAStudio.message('HDLShared:hdldialog:generateTB');
chkGenerateTB.Tag = [tagpf,'GenerateTestBench'];
chkGenerateTB.Source = this;
chkGenerateTB.ObjectProperty = 'GenerateTestBench';
chkGenerateTB.RowSpan = [currRow currRow];
chkGenerateTB.ColSpan = [1 2];
chkGenerateTB.Mode = true;
chkGenerateTB.DialogRefresh = true;

currRow = currRow+1;
if hParent.modifyForUSRP2filter
    % cache
    this.TestbenchLanguage_bk = this.TestbenchLanguage;
    this.TestbenchLanguage = hParent.TargetLanguage;
else
    if ~isempty(this.TestbenchLanguage_bk)
        this.TestbenchLanguage = this.TestbenchLanguage_bk;
        % clean up the cache
        this.TestbenchLanguage_bk = '';
    end
end
    
languageoptions.Type           = 'combobox';
languageoptions.Name = ['     ', DAStudio.message('HDLShared:fdhdldialog:TBlanguage')];
languageoptions.Source         = this;
languageoptions.ObjectProperty = 'TestbenchLanguage';
languageoptions.Tag            = [tagpf 'TestbenchLanguage'];
languageoptions.RowSpan        = [currRow currRow];
languageoptions.ColSpan        = [1 2];
languageoptions.Mode = true;
languageoptions.DialogRefresh = true;
languageoptions.Enabled = this.GenerateTestBench;
% g1195403, g1205800, g1216276 : force to skip SystemVerilog for filter design coder
languageoptions.Entries = {'VHDL','Verilog'};

editTBfilename.Type           = 'edit';
editTBfilename.Name = ['  ' DAStudio.message('HDLShared:fdhdldialog:fileName')];
editTBfilename.ObjectProperty = 'TestBenchName';
editTBfilename.Source         = src;
editTBfilename.Tag            = [tagpf 'TestBenchName'];
editTBfilename.RowSpan        = [currRow currRow];
editTBfilename.ColSpan        = [3 4];
editTBfilename.Mode = true;
editTBfilename.Enabled = this.GenerateTestBench;

currRow = currRow+1;
currCol = 1;
[CosimWidget, ~] = getFDHDLCosimulationWidget(this, src, currRow, currCol, tagpf, hParent.hdlFilter);

gpTop.Type = 'group';
gpTop.Name = DAStudio.message('HDLShared:hdldialog:hdltbGenerationOutput');
gpTop.Items = [{chkGenerateTB, languageoptions, editTBfilename}, CosimWidget];

gpTop.LayoutGrid = [1 6];
gpTop.ColStretch = [1 1 1 1 1 1];
gpTop.RowSpan = [1 1];
gpTop.ColSpan = [1 6];
    
topRow = 2;
[widgets, stimulusRow] = getStimulus(this, hParent, 1, 1, tagpf);

stimulusRow = stimulusRow+1;

grpstimulus.Type = 'panel';
grpstimulus.RowSpan = [1 3];
grpstimulus.ColSpan = [1 4];
grpstimulus.LayoutGrid = [stimulusRow 4];
grpstimulus.ColStretch = [0 1 0 1];
grpstimulus.RowStretch = [zeros(1, stimulusRow-1) 1];
grpstimulus.Tag = [tagpf, 'StimulusGroup'];
grpstimulus.Items = widgets;
grpstimulus.Enabled = enablewidget;
    
stimulusTab.Name  = DAStudio.message('HDLShared:fdhdldialog:stimuli');
stimulusTab.Items = {grpstimulus};

currCol = 1;
currRow = 1;
[items, currRow] = getAdditional(this, hParent, currRow, currCol, tagpf);

currRow = currRow+1;
grpotherTB.Type = 'panel';
grpotherTB.RowSpan = [1 currRow];
grpotherTB.ColSpan = [1 4];
grpotherTB.LayoutGrid = [currRow 4];
grpotherTB.ColStretch = [0 1 0 1];
grpotherTB.RowStretch = [zeros(1, currRow-1) 1];
grpotherTB.Tag = [tagpf, 'OthersGroup'];
grpotherTB.Items = items;
grpotherTB.Enabled = enablewidget;

otherTBTab.Name  = DAStudio.message('HDLShared:fdhdldialog:additionalSettings');
otherTBTab.Items = {grpotherTB};

if ~strcmpi(schemaName, 'tab')
    tbPanel.Type  = 'panel';
end

tabBody.Type = 'tab';
tabBody.Tabs = {stimulusTab, otherTBTab};
tabBody.Tag = [tagpf, 'Tab'];
tabBody.ActiveTab = this.ActiveTab; 
tabBody.TabChangedCallback = 'fdhdlcoderui.changehdlconfigtab'; 

tabg.Type = 'panel';
tabg.Items = {tabBody};
tabg.LayoutGrid = [1 1];
tabg.RowSpan = [topRow+1 topRow+1];
tabg.ColSpan = [1 6];
% tabg.Flat = true;

tbPanel.LayoutGrid = [4 6];
tbPanel.Items = [{gpTop} {tabg}];
tbPanel.RowStretch = [0 0 0 1];
tbPanel.ColStretch = [0 0 0 1 1 1];
tbPanel.Name = DAStudio.message('HDLShared:hdldialog:hdltbComponentName');

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

%----------------------------------------------------------------
function [widgets, currRow]= getStimulus(this, hParent, currRow, currCol, tagpf)

src = hParent.CLIProperties;

chkImpulse.Type = 'checkbox';
chkImpulse.Name = DAStudio.message('HDLShared:fdhdldialog:impulseResponse');
chkImpulse.Tag = [tagpf,'Impulse'];
chkImpulse.Source = this;
chkImpulse.ObjectProperty = 'Impulse';
chkImpulse.RowSpan = [currRow currRow];
chkImpulse.ColSpan = [currCol currCol];

currRow = currRow+1;

chkStep.Type = 'checkbox';
chkStep.Name = DAStudio.message('HDLShared:fdhdldialog:stepResponse');
chkStep.Tag = [tagpf,'Step'];
chkStep.Source = this;
chkStep.ObjectProperty = 'Step';
chkStep.RowSpan = [currRow currRow];
chkStep.ColSpan = [currCol currCol];
currRow = currRow+1;

chkRamp.Type = 'checkbox';
chkRamp.Name = DAStudio.message('HDLShared:fdhdldialog:rampResponse');
chkRamp.Tag = [tagpf,'Ramp'];
chkRamp.Source = this;
chkRamp.ObjectProperty = 'Ramp';
chkRamp.RowSpan = [currRow currRow];
chkRamp.ColSpan = [currCol currCol];

currRow = currRow+1;

chkChirp.Type = 'checkbox';
chkChirp.Name = DAStudio.message('HDLShared:fdhdldialog:chirpResponse');
chkChirp.Tag = [tagpf,'Chirp'];
chkChirp.Source = this;
chkChirp.ObjectProperty = 'Chirp';
chkChirp.RowSpan = [currRow currRow];
chkChirp.ColSpan = [currCol currCol];

currRow = currRow+1;

chkWNoise.Type = 'checkbox';
chkWNoise.Name = DAStudio.message('HDLShared:fdhdldialog:whiteNoiseResponse');
chkWNoise.Tag = [tagpf,'Noise'];
chkWNoise.Source = this;
chkWNoise.ObjectProperty = 'Noise';
chkWNoise.RowSpan = [currRow currRow];
chkWNoise.ColSpan = [currCol currCol];

currRow = currRow+1;

chkUser.Type = 'checkbox';
chkUser.Name = DAStudio.message('HDLShared:fdhdldialog:userDefinedResponse');
chkUser.Tag = [tagpf,'UserDefined'];
chkUser.Source = this;
chkUser.ObjectProperty = 'UserDefined';
chkUser.RowSpan = [currRow currRow];
chkUser.ColSpan = [currCol currCol];
chkUser.Mode = true;
chkUser.DialogRefresh = true;

currRow = currRow+1;

editUser.Type           = 'edit';
editUser.Name = DAStudio.message('HDLShared:fdhdldialog:userStimulus');
editUser.ObjectProperty = 'TestBenchUserStimulus';
editUser.Source         = this;
editUser.Tag = [tagpf,'UserDefinedInput'];
editUser.RowSpan        = [currRow currRow];
editUser.ColSpan        = [currCol currCol+1];
editUser.Mode = true;
editUser.Enabled = this.UserDefined;
editUser.ObjectMethod = 'dialogCallback';
editUser.MethodArgs = {'%dialog', src, 'UserDefinedInput'};
editUser.ArgDataTypes = {'handle', 'mxArray', 'string'};

currRow1 = 1;
currCol = 3;
widgetitems = [];

if hParent.hdlfilter.isVarRateSupported && strcmpi(src.AddRatePort, 'on')
    cbRateStimulus.Type           = 'edit';
    cbRateStimulus.Name = DAStudio.message('HDLShared:fdhdldialog:RateStimulus');
    cbRateStimulus.Source         = this;
    cbRateStimulus.Tag            = [tagpf 'TestbenchRateStimulus'];
    cbRateStimulus.RowSpan        = [currRow1 currRow1];
    cbRateStimulus.ColSpan        = [currCol currCol];
    cbRateStimulus.Mode = true;
    cbRateStimulus.ObjectMethod = 'dialogCallback';
    cbRateStimulus.MethodArgs = {'%dialog', src, 'TestbenchRateStimulus'};
    cbRateStimulus.ArgDataTypes = {'handle', 'mxArray', 'string'};
    widgetitems = [widgetitems {cbRateStimulus}];
end

tbTestbenchCoeffStimulus_lbl.Name    = DAStudio.message('HDLShared:hdldialog:hdltbTestbenchCoeffStimulus');
tbTestbenchCoeffStimulus_lbl.Type    = 'text';
tbTestbenchCoeffStimulus_lbl.RowSpan = [currRow1 currRow1];
tbTestbenchCoeffStimulus_lbl.ColSpan = [currCol currCol];
tbTestbenchCoeffStimulus_lbl.Visible = getEnableState(this, hParent, 'TestbenchCoeffStimulus');

tbTestbenchCoeffStimulus.Type           = 'edit';
tbTestbenchCoeffStimulus.ObjectProperty = 'TestbenchCoeffStimulus';
tbTestbenchCoeffStimulus.Source         = this;
tbTestbenchCoeffStimulus.Tag            = [tagpf 'TestbenchCoeffStimulus'];
tbTestbenchCoeffStimulus_lbl.Buddy      = tbTestbenchCoeffStimulus.Tag;
tbTestbenchCoeffStimulus.RowSpan        = [currRow1 currRow1];
tbTestbenchCoeffStimulus.ColSpan        = [currCol+1 currCol+1];
tbTestbenchCoeffStimulus.Mode = true;
tbTestbenchCoeffStimulus.Visible = tbTestbenchCoeffStimulus_lbl.Visible;
tbTestbenchCoeffStimulus.ObjectMethod = 'dialogCallback';
tbTestbenchCoeffStimulus.MethodArgs = {'%dialog', src, 'TestbenchCoeffStimulus'};
tbTestbenchCoeffStimulus.ArgDataTypes = {'handle', 'mxArray', 'string'};
tbTestbenchCoeffStimulus.DialogRefresh = true;

widgetitems = [widgetitems {tbTestbenchCoeffStimulus_lbl, tbTestbenchCoeffStimulus}];

tbTestBenchFracDelayStimulus_lbl.Name    = DAStudio.message('HDLShared:hdldialog:hdltbTestBenchFracDelayStimulus');
tbTestBenchFracDelayStimulus_lbl.Type    = 'text';
tbTestBenchFracDelayStimulus_lbl.RowSpan = [currRow1 currRow1];
tbTestBenchFracDelayStimulus_lbl.ColSpan = [currCol currCol];
tbTestBenchFracDelayStimulus_lbl.Visible = hParent.hdlFilter.showFilterHDLWidget('testbenchfracdelaystimulus');

tbTestBenchFracDelayStimulus.Type           = 'combobox';
tbTestBenchFracDelayStimulus.Source         = this; % should be implemented in cli?
tbTestBenchFracDelayStimulus.ObjectProperty = 'TestBenchFracDelayStimulusString';
tbTestBenchFracDelayStimulus.Tag            = [tagpf 'TestBenchFracDelayStimulus'];
tbTestBenchFracDelayStimulus_lbl.Buddy      = tbTestBenchFracDelayStimulus.Tag;
tbTestBenchFracDelayStimulus.RowSpan        = [currRow1 currRow1];
tbTestBenchFracDelayStimulus.ColSpan        = [currCol+1 currCol+1];
tbTestBenchFracDelayStimulus.Mode = true;
tbTestBenchFracDelayStimulus.DialogRefresh = true;
tbTestBenchFracDelayStimulus.Visible = tbTestBenchFracDelayStimulus_lbl.Visible;

widgetitems = [widgetitems {tbTestBenchFracDelayStimulus_lbl, tbTestBenchFracDelayStimulus}];

enumType = findtype('FracDelayStimulusStringType');

currRow1 = currRow1+1;

tbUserDefinedStimulus_lbl.Name    = DAStudio.message('HDLShared:hdldialog:hdltbTestBenchUserStimulus');
tbUserDefinedStimulus_lbl.Type    = 'text';
tbUserDefinedStimulus_lbl.RowSpan = [currRow1 currRow1];
tbUserDefinedStimulus_lbl.ColSpan = [currCol currCol];
tbUserDefinedStimulus_lbl.Visible = strcmpi(this.TestBenchFracDelayStimulusString, enumType.string(4));

tbUserDefinedStimulus.Type           = 'edit';
tbUserDefinedStimulus.ObjectProperty = 'TestBenchFracDelay_User_Stimulus';
tbUserDefinedStimulus.Source         = this;
tbUserDefinedStimulus.Tag            = [tagpf 'TestBenchUserStimulus'];
tbUserDefinedStimulus_lbl.Buddy      = tbUserDefinedStimulus.Tag;
tbUserDefinedStimulus.RowSpan        = [currRow1 currRow1];
tbUserDefinedStimulus.ColSpan        = [currCol+1 currCol+1];
tbUserDefinedStimulus.Mode = true;
tbUserDefinedStimulus.DialogRefresh = true;
tbUserDefinedStimulus.Visible = tbUserDefinedStimulus_lbl.Visible;
tbUserDefinedStimulus.ObjectMethod = 'dialogCallback';
tbUserDefinedStimulus.MethodArgs = {'%dialog', src, 'TestBenchFracDelay_User_Stimulus'};
tbUserDefinedStimulus.ArgDataTypes = {'handle', 'mxArray', 'string'};

widgetitems = [widgetitems {tbUserDefinedStimulus_lbl, tbUserDefinedStimulus}];

widgets = [widgetitems {chkImpulse, chkStep, chkRamp, chkChirp, ...
                chkWNoise, chkUser, editUser}];
            
            
%----------------------------------------------------------------
function [items, currRow]= getAdditional(this, hParent, currRow, currCol, tagpf)

items = [];
src = hParent.CLIProperties;
[tbWidgets, ~] = getSharedWidgets(this, src, true, currRow, currCol, tagpf);

Spacer.Type = 'panel';
Spacer.ColSpan = [3 3];

currRow = 1;
currCol = 4;

tbWidgets{end-6}.RowSpan = [currRow currRow];
tbWidgets{end-6}.ColSpan = [currCol currCol];
currRow = currRow+1;

tbWidgets{end-5}.RowSpan = [currRow currRow];
tbWidgets{end-5}.ColSpan = [currCol currCol];
currRow = currRow+1;

% Modify the common widgets to fix the filter HDL:
tbWidgets{end-4}.RowSpan = [currRow currRow];
tbWidgets{end-4}.ColSpan = [currCol currCol];

currRow = currRow+1;
tbWidgets{end-3}.RowSpan = [currRow currRow];
tbWidgets{end-3}.ColSpan = [currCol currCol];
tbWidgets{end-2}.RowSpan = [currRow currRow];
tbWidgets{end-2}.ColSpan = [currCol+1 currCol+1];

currRow = currRow+1;
tbWidgets{end-1}.RowSpan = [currRow currRow];
tbWidgets{end-1}.ColSpan = [currCol currCol];
tbWidgets{end}.RowSpan = [currRow currRow];
tbWidgets{end}.ColSpan = [currCol+1 currCol+1];

currRow = currRow+1;

items = [items tbWidgets Spacer];

tbErrorMargin_lbl.Name    = DAStudio.message('HDLShared:hdldialog:hdltbErrorMargin');
tbErrorMargin_lbl.Type    = 'text';
tbErrorMargin_lbl.RowSpan = [currRow currRow];
tbErrorMargin_lbl.ColSpan = [currCol currCol];
tbErrorMargin_lbl.Visible = getEnableState(this, hParent, 'ErrorMargin');

tbErrorMargin.Type           = 'edit';
tbErrorMargin.ObjectProperty = 'ErrorMargin';
tbErrorMargin.Source         = this;
tbErrorMargin.Tag            = [tagpf 'ErrorMargin'];
tbErrorMargin_lbl.Buddy      = tbErrorMargin.Tag;
tbErrorMargin.RowSpan        = [currRow currRow];
tbErrorMargin.ColSpan        = [currCol+1 currCol+1];
tbErrorMargin.Mode = true;
tbErrorMargin.Visible = tbErrorMargin_lbl.Visible;
tbErrorMargin.ObjectMethod = 'dialogCallback';
tbErrorMargin.MethodArgs = {'%dialog', src, 'ErrorMargin'};
tbErrorMargin.ArgDataTypes = {'handle', 'mxArray', 'string'};

if tbErrorMargin_lbl.Visible
    currRow = currRow+1;
end
items = [items {tbErrorMargin_lbl, tbErrorMargin}];

tbSimulatorFlags_lbl.Name    = DAStudio.message('HDLShared:hdldialog:hdltbSimulatorFlags');
tbSimulatorFlags_lbl.Type    = 'text';
tbSimulatorFlags_lbl.RowSpan = [currRow currRow];
tbSimulatorFlags_lbl.ColSpan = [currCol currCol];
tbSimulatorFlags_lbl.Visible = hParent.hdlFilter.showFilterHDLWidget('simulatorflags');

tbSimulatorFlags.Type           = 'edit';
tbSimulatorFlags.ObjectProperty = 'SimulatorFlags';
tbSimulatorFlags.Source         = src;
tbSimulatorFlags.Tag            = [tagpf 'SimulatorFlags'];
tbSimulatorFlags_lbl.Buddy      = tbSimulatorFlags.Tag;
tbSimulatorFlags.RowSpan        = [currRow currRow];
tbSimulatorFlags.ColSpan        = [currCol+1 currCol+1];
tbSimulatorFlags.Mode = true;
tbSimulatorFlags.Visible = tbSimulatorFlags_lbl.Visible;
if tbSimulatorFlags_lbl.Visible
    currRow = currRow+1;
end

% currRow = currRow+1;
% Spacer.Type = 'panel';
% Spacer.RowSpan = [currRow, currRow];

items = [items {tbSimulatorFlags_lbl, tbSimulatorFlags}];

% [EOF]

% LocalWords:  fdhdldialog TBlanguage hdltb tabg cli simulatorflags curr
