www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@xregtools/@MBrowser/NewNode.m

    function NewNode(h, p, showdialog)
%NEWNODE  Create a child node
%
%   NewNode( MBH )
%   NewNode( MBH, PRNTNDE )
%   NewNode( MBH, PRNTNDE, SHOWDIALOG )
%
%   PRNTNDE is a node pointer to use as parent, defaults to the current
%   node.
%   SHOWDIALOG whether to show the dialogs during process, defaults to true.

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



if h.GUIExists && ~h.GUILocked
    
    if nargin<3
        showdialog = 1;
        if nargin<2
            p = h.CurrentNode;
        end
    end
    if strcmp(p.guid,'global')
        View = GetViewData(h);
        modelActions = View.MessageService.Actions.Model;
        modelActions.NewAlternative.execute();
    else    

        
        if ~h.HideNode
            return
        end
        msgID=h.Hand.Figure.StatusBar.addMessage(sprintf('Creating %s ...',lower(p.ChildType)));
        
        set(h.Figure,'Pointer','watch')
        
        % makechildren  - this returns null pointer if unsuccessful
        
        pch= p.makechildren(showdialog);
        if ~isnull(pch)
            % this ensures that the name is unique (adds (n) if nec)
            pch.name(pch.name);
            
            % Add child to tree
            pch.treeview('add',h.Hand.Figure.TreeView);
            pDisp = pch;
            if strcmp(p.guid,'testplan') && p.numstages>1 && pch(1).numChildren==1
                % display local node for two-stage models
                pDisp = pch(1).children;
            end
            if ~h.SelectNode(pDisp(1))
                % if the new item wasn't selected
                
                % Update the list
                listview(h);
                h.doEnableStatus;
                h.RedrawNode(false)
            end
        else
            % reselect node
            h.ShowNode;
            h.ViewNode;
            h.Hand.Figure.StatusBar.removeMessage(msgID);
            msgID=h.Hand.Figure.StatusBar.addMessage('No new model available');
        end
        set(h.Figure,'Pointer',get(0,'DefaultFigurePointer'))
        
        mv_busy('delete');
        h.Hand.Figure.StatusBar.removeMessage(msgID);
    end

end