www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@cgbrowser/newproject.m

    function newproject(h, forceflag)
%NEWPROJECT Create a new project in cgbrowser
%
%  NEWPROJECT(CGB) opens a new project in the browser.  The current project
%  is closed correctly.
%  NEWPROJECT(CGB, FORCE) where FORCE is true will force the closing of the
%  previous project, guaranteeing that a new one will be created.

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


if nargin < 2
    forceflag = false;
end
if h.GUIExists
    %Create new project (untitled) and deal with current project.
    ProjectPtr = h.RootNode;
    msgID = h.addStatusMsg('Closing current project...');
    cnode = h.CurrentNode;
    csubitem = h.CurrentSubItem;
    
    % Set current node to be blank
    h.setnewnode(xregpointer, xregpointer);
    
    % Close current project
    [PROJ,msg] = close(ProjectPtr.info,forceflag);
    
    h.removeStatusMsg(msgID);
    if isempty(msg)
        deleteproject(ProjectPtr.info);
        
        msgID = h.addStatusMsg('Creating new project...');
        PROJ = cgcreateproject(mbcGetPath('cage', 'Projects', 'Untitled'));
        PROJ.setmodified(1);
        
        % Switch browser to viewing new project
        h.RootNode = PROJ;
    else
        % Keep current project and node
        h.setnewnode(cnode, csubitem);
    end
    h.removeStatusMsg(msgID);
end