forked from sccn/mobilab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mobiAnnotator.m
51 lines (51 loc) · 1.93 KB
/
mobiAnnotator.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
classdef mobiAnnotator < handle
properties, container;end
properties(SetObservable), text;end
properties(Hidden=true), listenerHandle;end
methods
function obj = mobiAnnotator(arg,txt)
if nargin < 1, arg = [];end
if nargin < 2, txt = {date};end
obj.container = arg;
obj.text = txt;
obj.listenerHandle = addlistener(obj,'text','PostSet',@mobiAnnotator.saveTextHandle);
end
%%
function h = editor(obj), h = editNotes(obj);end
function disp(obj), disp(char(obj.text));end
%%
function set.text(obj,arg)
if iscellstr(arg)
obj.text = arg;
elseif ischar(arg)
obj.text{1} = arg;
end
end
%%
function text = saveobj(obj)
text = obj.text;
if strcmp(text(end),char(13)), text(end) = [];end
if length(text) == 1, text = [];end
end
%%
function equal(obj,arg)
if nargin < 1, error('The expression to the left of the equals sign is not a valid target for an assignment.');end
if iscellstr(arg), obj.text = arg(:);
else error('Property ''text'' must be a cell array of ''char''.');
end
end
end
methods(Static)
function saveTextHandle(src,evnt) %#ok
notes = evnt.AffectedObject.text;
if isa(evnt.AffectedObject.container,'coreStreamObject')
disp(['Saving notes in: ' evnt.AffectedObject.container.header]);
save(evnt.AffectedObject.container.header,'-mat','-append','notes');
else
file = [evnt.AffectedObject.container.mobiDataDirectory filesep 'notes_' evnt.AffectedObject.container.sessionUUID '.txt'];
disp(['Saving notes in: ' file]);
cell2textfile(file,notes);
end
end
end
end