www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevtestplan/TemplateDialog.m

    function [T,ok]=TemplateDialog(T)
%TEMPLATEDIALOG Display template creation dialog
%
%  [T, OK] = TEMPLATEDIALOG(T) displays a dialog that lets the user choose
%  a filename and export a testplan template to it.

%  Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.


dlg = mbcgui.container.Dialog('Name','Test Plan Template Setup',...
    'Size',[250 150],...
    'Buttons','OK_CANCEL_HELP',...
    'HelpCode','xreg_makeTestplanTemplate',...
    'Resize', 'off');
figh = dlg.Figure;

p_md=address(T);
[lyt,ud]=i_createlyt(figh,p_md);

dlg.Content = lyt;
closeMode = dlg.showDialog();

OldT = T;
if strcmp(closeMode, 'OK')
    DesignDir = mbcGetPath('mbcmodel', 'Designs');
    Tname = get(ud.Name,'String');

    fname = fullfile(DesignDir, [Tname, '.mbt']);

    if ischar(fname)
        [pth,fname,ext]= fileparts(fname);
        if isempty(ext)
            ext= '.mbt';
        end
        fname= fullfile(pth,[fname,ext]);
        if exist(fname, 'file')
            resp= questdlg(sprintf('%s already exists.\n Do you want to replace it?',fname),'Template File','Yes','No','No');
            drawnow('expose');
            if ~strcmp(resp,'Yes')
                delete(figh);
                return
            end
        end

        % make template
        T = MakeTemplate(T,get(ud.Designs,'Value'),get(ud.Models,'Value'),Tname); %#ok<NASGU>
        try
            save('-mat',fname,'T');
        catch ME
            xregerror('File Error',ME.message);
        end
    end
    ok=1;
else
    ok=0;
end
T= info(OldT);

% don't free pointer - it's a dynamic copy that's shared by everyone!
delete(dlg);



function [lyt,ud]=i_createlyt(figh,p)
T= info(p);

ud.Name=uicontrol('Style','edit',...
	'Parent',figh,...
	'HorizontalAlignment','left',...
	'BackgroundColor','w',...
	'String',name(T));
NameLabel = xregGui.labelcontrol('parent', figh, ...
    'Control', ud.Name, ...
    'String', 'Name:', ...
    'ControlSizeMode', 'relative', ...
    'ControlSize', 1, ...
    'LabelSizeMode', 'absolute', ...
    'LabelSize', 50);

ud.Designs=uicontrol('Style','checkbox',...
	'Parent',figh,...
	'HorizontalAlignment','left',...
	'String','Include designs',...
	'Value',1);

ud.Models=uicontrol('Style','checkbox',...
	'Parent',figh,...
	'HorizontalAlignment','left',...
	'String','Include response models',...
	'Value',isempty(T.Responses) || numChildren(T));

lyt = xreggridbaglayout(figh,...
	'dimension',[3 1],...
	'rowsizes',[20 20 20],...
    'gapy',5,...
	'elements',{NameLabel,ud.Designs,ud.Models});