Home > vbmeg > functions > gui > project_mgr_dir > project_mgr_builder_close.m

project_mgr_builder_close

PURPOSE ^

This is called by external object.

SYNOPSIS ^

function [result, errmsg] = project_mgr_builder_close(bmgr)

DESCRIPTION ^

 This is called by external object.
 Close batch builder gui.
 [USAGE]
    project_mgr_builder_close(<bmgr>);
 [IN]
      bmgr : vb_batch_mgr object.
             if this is empty, user selected "Don't save'.
 [OUT]
    result : SUCCESS or FAILURE
    errmsg : error reason

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [result, errmsg] = project_mgr_builder_close(bmgr)
0002 % This is called by external object.
0003 % Close batch builder gui.
0004 % [USAGE]
0005 %    project_mgr_builder_close(<bmgr>);
0006 % [IN]
0007 %      bmgr : vb_batch_mgr object.
0008 %             if this is empty, user selected "Don't save'.
0009 % [OUT]
0010 %    result : SUCCESS or FAILURE
0011 %    errmsg : error reason
0012 %
0013 % Copyright (C) 2011, ATR All Rights Reserved.
0014 % License : New BSD License(see VBMEG_LICENSE.txt)
0015 
0016 %
0017 % --- Previous check
0018 %
0019 if ~exist('bmgr', 'var')
0020     error('bmgr is a required parameter.');
0021 end
0022 
0023 %
0024 % --- Main Procedure
0025 %
0026 
0027 % find project_mgr figure handle
0028 current_hidden_state = get(0, 'ShowHiddenHandles');
0029 set(0, 'ShowHiddenHandles', 'on');
0030 pmgr = findobj('Tag', 'project_mgr');
0031 set(0, 'ShowHiddenHandles', current_hidden_state);
0032 if isempty(pmgr) || ~ishandle(pmgr)
0033     error('project_mgr cannot be found.');
0034 end
0035 
0036 % load data
0037 data = guidata(pmgr);
0038 
0039 H = data.H;
0040 
0041 result = SUCCESS;
0042 errmsg = '';
0043 
0044 if ~isempty(bmgr)
0045     % save batch builder.
0046     idx = get(H.builder_popup, 'Value');
0047     data.batch_builders{idx, 1} = bmgr;
0048 
0049     % save file
0050     batch_builders = data.batch_builders;
0051     try
0052         vb_save(data.project_file, 'batch_builders');
0053     catch
0054         result = FAILURE;
0055         err = lasterror;
0056         errmsg = err.message;
0057         return;
0058     end
0059 end
0060 
0061 % GUI state enable
0062 set(H.builder_popup, 'Enable', 'on');
0063 set(H.open_builder_push, 'Enable', 'on');
0064 
0065 data.batch_fig = -1;
0066 
0067 % save data
0068 guidata(pmgr, data);
0069 
0070 %
0071 %
0072 % update builder list
0073 project_mgr_view_update_builders(pmgr);

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005