0001 function varargout = ui_event_types_cb(D, action, varargin)
0002
0003
0004
0005
0006
0007 if nargin < 2
0008 error('Need action');
0009 end
0010
0011 et = event_types(D);
0012 F = gcbf;
0013
0014 switch lower(action)
0015 case 'ok'
0016 set(findobj(F,'Tag','Done'),'UserData',1)
0017 case 'cancel'
0018 set(findobj(F,'Tag','Done'),'UserData',0)
0019 case 'new'
0020 e = struct('name', 'New event', 'e_spec', []);
0021 if isempty(et), et = e; else et = [et e]; end
0022 D = event_types(D, et);
0023 [D ic] = ui_et_edit(D, length(et));
0024 if ~isempty(ic)
0025 pr_refresh_et(D, ic, F);
0026 end
0027 case 'edit'
0028 hList = findobj(F,'Tag','eList');
0029 ic = get(hList, 'Value');
0030 if isempty(ic)
0031 msgbox('Please select an event type to edit');
0032 elseif length(ic) > 1
0033 msgbox('Please select a single event type to edit');
0034 else
0035 et = event_types(D);
0036 [D ic] = ui_et_edit(D, ic);
0037 if ~isempty(ic)
0038 pr_refresh_et(D, ic, F, hList);
0039 end
0040 end
0041 case 'delete'
0042 hList = findobj(F,'Tag','eList');
0043 ic = get(hList, 'Value');
0044 if isempty(ic)
0045 msgbox('Please select event type(s) to delete');
0046 else
0047 et(ic) = [];
0048 D = event_types(D, et);
0049 pr_refresh_et(D, 1, F, hList);
0050 end
0051 otherwise
0052 error([ action ' is deviant' ]);
0053 end
0054
0055 return
0056
0057
0058
0059