Home > vbmeg > functions > gui > vb_input_settings > vb_input_settings_set_item.m

vb_input_settings_set_item

PURPOSE ^

SYNOPSIS ^

function item = vb_input_settings_set_item(item)

DESCRIPTION ^

 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 item = vb_input_settings_set_item(item)
0002 %
0003 % Copyright (C) 2011, ATR All Rights Reserved.
0004 % License : New BSD License(see VBMEG_LICENSE.txt)
0005 
0006 type = vb_input_settings_get_prop(item, 'type');
0007 
0008 switch(type)
0009     case 'single file selection'
0010          title = vb_input_settings_get_prop(item, 'title');
0011          ext   = vb_input_settings_get_prop(item, 'extension');
0012          if ~iscell(ext)
0013              ext = {ext};
0014          end
0015          [d_, f_] = vb_file_select(ext, title, false);
0016          if ~isempty(d_) && ~isempty(f_)
0017              file = fullfile(d_, filesep, f_{1});
0018              item = vb_input_settings_set_prop(item, 'value', file);
0019          end
0020     case 'multiple file selection'
0021          title = vb_input_settings_get_prop(item, 'title');
0022          ext   = vb_input_settings_get_prop(item, 'extension');
0023          [d_, f_] = vb_file_select({ext}, title, false);
0024          if ~isempty(d_) && ~isempty(f_)
0025              for j=1:length(f_)
0026                  files{j} = fullfile(d_, filesep, f_{j});
0027              end
0028              item = vb_input_settings_set_prop(item, 'value', files);
0029          end
0030     case 'directory selection'
0031          d_ = vb_input_settings_get_prop(item, 'value');
0032          d = dir_dialog(d_);
0033          if ~isempty(d)
0034              item = vb_input_settings_set_prop(item, 'value', d);
0035          end
0036     case 'string input'
0037          title = vb_input_settings_get_prop(item, 'title');
0038          value = vb_input_settings_get_prop(item, 'value');
0039          if isempty(value)
0040              value = '';
0041          end
0042          str = inputdlg(title, 'Input', 1, {value});
0043          if isempty(str), return; end
0044          item = vb_input_settings_set_prop(item, 'value', str{1});
0045     otherwise
0046         error('Unknown edit type was specified.');
0047 end
0048 
0049 if nargout ~= 1
0050     error('function caller should receive item.');
0051 end

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