Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions code/internal/+openminds/+abstract/Schema.m
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
obj = builtin('subsasgn', obj, subs, value);

% Assign new value and trigger event
evtData = PropertyValueChangedEventData(value, oldValue, true); % true for linked prop
evtData = PropertyValueChangedEventData(value, oldValue, true, obj); % true for linked prop
obj.notify('PropertyWithLinkedInstanceChanged', evtData)

elseif numel(subs) > 1 && strcmp(subs(2).type, '.')
Expand All @@ -360,7 +360,7 @@

% Assign new value and trigger event
linkedObj.subsasgn(subs(2:end), value);
evtData = PropertyValueChangedEventData(value, oldValue, true); % true for linked prop
evtData = PropertyValueChangedEventData(value, oldValue, true, obj); % true for linked prop
obj.notify('PropertyWithLinkedInstanceChanged', evtData)

elseif numel(subs) > 1 && strcmp(subs(2).type, '()')
Expand Down Expand Up @@ -436,10 +436,19 @@

obj = builtin('subsasgn', obj, subs, value);

if numel(obj) >= 1
if ~isempty(obj)
if obj.isSubsForPublicPropertyValue(subs)
evtData = PropertyValueChangedEventData(value, oldValue, false); % false for property which is not embedded or linked
obj.notify('InstanceChanged', evtData)
if isscalar(obj)
evtSource = obj;
else
if strcmp(subs(1).type, '()')
evtSource = builtin('subsref', obj, subs(1));
else
error('Unexpected error. Please report')
end
end
evtData = PropertyValueChangedEventData(value, oldValue, false, evtSource); % false for property which is not embedded or linked
evtSource.notify('InstanceChanged', evtData)
% fprintf('Set "primitive" property type of %s\n', class(obj))
end
end
Expand Down Expand Up @@ -701,10 +710,24 @@
% Return true if subs represent dot-indexing on a public property

tf = false;

tempSubs = subs;

% If we are indexing into a subset of the objects, lets strip
% of the first subs element.
if strcmp( tempSubs(1).type, '()' )
if isscalar(tempSubs) % i.e instance() or instance(2)
return
else
tempSubs = tempSubs(2:end);
end
end

if strcmp( subs(1).type, '.' )
% If subs represent dot-indexing, check if it is for a public
% property
if strcmp( tempSubs(1).type, '.' )
propNames = properties(obj);
tf = any( strcmp(subs(1).subs, propNames) );
tf = any( strcmp(tempSubs.subs, propNames) );
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
NewValue
OldValue
IsLinkedProperty = false
IsPropertyOf
end

methods
function obj = PropertyValueChangedEventData(newValue, oldValue, isLinkedProperty)
function obj = PropertyValueChangedEventData(newValue, oldValue, isLinkedProperty, isPropertyOf)
if nargin < 3 || isempty(isLinkedProperty)
isLinkedProperty = false;
end
obj.NewValue = newValue;
obj.OldValue = oldValue;
obj.IsLinkedProperty = isLinkedProperty;
obj.IsPropertyOf = isPropertyOf;
end
end
end