Skip to content

Commit 89a1da7

Browse files
committed
Added the ability to change source after epoch group is created
1 parent ec8f48a commit 89a1da7

File tree

4 files changed

+52
-16
lines changed

4 files changed

+52
-16
lines changed

src/main/matlab/+symphonyui/+core/+persistent/+collections/EpochGroupSet.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
properties
44
label
5-
end
6-
7-
properties (SetAccess = private)
85
source
96
end
107

@@ -38,6 +35,12 @@
3835
s = obj.objects{1}.source;
3936
end
4037
end
38+
39+
function set.source(obj, s)
40+
for i = 1:obj.size
41+
obj.get(i).source = s;
42+
end
43+
end
4144

4245
end
4346

src/main/matlab/+symphonyui/+core/+persistent/EpochGroup.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
properties
44
label
5+
source
56
end
67

78
properties (SetAccess = private)
8-
source
99
epochGroups
1010
allEpochGroups
1111
epochBlocks
@@ -40,6 +40,10 @@ function applyPreset(obj, preset)
4040
function s = get.source(obj)
4141
s = symphonyui.core.persistent.Source(obj.cobj.Source);
4242
end
43+
44+
function set.source(obj, s)
45+
obj.cobj.Source = s.cobj;
46+
end
4347

4448
function g = get.epochGroups(obj)
4549
g = obj.cellArrayFromEnumerableOrderedBy(obj.cobj.EpochGroups, 'startTime', @symphonyui.core.persistent.EpochGroup);

src/main/matlab/+symphonyui/+ui/+presenters/DataManagerPresenter.m

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function bind(obj)
6464
obj.addListener(v, 'BeginEpochGroup', @obj.onViewSelectedBeginEpochGroup);
6565
obj.addListener(v, 'EndEpochGroup', @obj.onViewSelectedEndEpochGroup);
6666
obj.addListener(v, 'SetEpochGroupLabel', @obj.onViewSetEpochGroupLabel);
67+
obj.addListener(v, 'SelectedEpochGroupSource', @obj.onViewSelectedEpochGroupSource);
6768
obj.addListener(v, 'SelectedEpochSignal', @obj.onViewSelectedEpochSignal);
6869
obj.addListener(v, 'SetProperty', @obj.onViewSetProperty);
6970
obj.addListener(v, 'AddProperty', @obj.onViewSelectedAddProperty);
@@ -340,13 +341,15 @@ function updateEpochGroupNode(obj, group)
340341
end
341342

342343
function populateDetailsForEpochGroupSet(obj, groupSet)
343-
sourceSet = symphonyui.core.persistent.collections.SourceSet(groupSet.source);
344-
344+
allSources = obj.documentationService.getExperiment().allSources;
345+
345346
obj.view.enableEpochGroupLabel(groupSet.size == 1);
346347
obj.view.setEpochGroupLabel(groupSet.label);
347348
obj.view.setEpochGroupStartTime(strtrim(datestr(groupSet.startTime, 14)));
348349
obj.view.setEpochGroupEndTime(strtrim(datestr(groupSet.endTime, 14)));
349-
obj.view.setEpochGroupSource(sourceSet.label);
350+
obj.view.enableSelectEpochGroupSource(groupSet.size == 1);
351+
obj.view.setEpochGroupSourceList(cellfun(@(s)s.label, allSources, 'UniformOutput', false), allSources);
352+
obj.view.setSelectedEpochGroupSource(groupSet.source);
350353
obj.view.setCardSelection(obj.view.EPOCH_GROUP_CARD);
351354

352355
obj.populateCommonDetailsForEntitySet(groupSet);
@@ -361,7 +364,19 @@ function onViewSetEpochGroupLabel(obj, ~, ~)
361364
obj.view.showError(x.message);
362365
return;
363366
end
364-
obj.updateNodeNamesForEpochGroupSet(groupSet)
367+
obj.updateNodeNamesForEpochGroupSet(groupSet);
368+
end
369+
370+
function onViewSelectedEpochGroupSource(obj, ~, ~)
371+
groupSet = obj.getSelectedEntitySet();
372+
try
373+
groupSet.source = obj.view.getSelectedEpochGroupSource();
374+
catch x
375+
obj.log.debug(x.message, x);
376+
obj.view.showError(x.message);
377+
return;
378+
end
379+
obj.updateNodeNamesForEpochGroupSet(groupSet);
365380
end
366381

367382
function updateNodeNamesForEpochGroupSet(obj, groupSet)

src/main/matlab/+symphonyui/+ui/+views/DataManagerView.m

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
BeginEpochGroup
1010
EndEpochGroup
1111
SetEpochGroupLabel
12+
SelectedEpochGroupSource
1213
SelectedEpochSignal
1314
SetProperty
1415
AddProperty
@@ -260,11 +261,11 @@ function createUi(obj)
260261
'Style', 'edit', ...
261262
'Enable', 'off', ...
262263
'HorizontalAlignment', 'left');
263-
obj.epochGroupCard.sourceField = uicontrol( ...
264+
obj.epochGroupCard.sourcePopupMenu = MappedPopupMenu( ...
264265
'Parent', epochGroupGrid, ...
265-
'Style', 'edit', ...
266-
'Enable', 'off', ...
267-
'HorizontalAlignment', 'left');
266+
'String', {' '}, ...
267+
'HorizontalAlignment', 'left', ...
268+
'Callback', @(h,d)notify(obj, 'SelectedEpochGroupSource'));
268269
set(epochGroupGrid, ...
269270
'Widths', [60 -1], ...
270271
'Heights', [23 23 23 23]);
@@ -672,11 +673,24 @@ function setEpochGroupStartTime(obj, t)
672673
function setEpochGroupEndTime(obj, t)
673674
set(obj.epochGroupCard.endTimeField, 'String', t);
674675
end
675-
676-
function setEpochGroupSource(obj, s)
677-
set(obj.epochGroupCard.sourceField, 'String', s);
676+
677+
function enableSelectEpochGroupSource(obj, tf)
678+
set(obj.epochGroupCard.sourcePopupMenu, 'Enable', appbox.onOff(tf));
679+
end
680+
681+
function s = getSelectedEpochGroupSource(obj)
682+
s = get(obj.epochGroupCard.sourcePopupMenu, 'Value');
678683
end
679684

685+
function setSelectedEpochGroupSource(obj, s)
686+
set(obj.epochGroupCard.sourcePopupMenu, 'Value', s);
687+
end
688+
689+
function setEpochGroupSourceList(obj, names, values)
690+
set(obj.epochGroupCard.sourcePopupMenu, 'String', names);
691+
set(obj.epochGroupCard.sourcePopupMenu, 'Values', values);
692+
end
693+
680694
function setEpochGroupNodeCurrent(obj, node)
681695
node.setIcon(symphonyui.app.App.getResource('icons/group_current.png'));
682696
menu = uicontextmenu('Parent', obj.figureHandle);
@@ -920,7 +934,7 @@ function enableSelectPreset(obj, tf)
920934
function setPresetList(obj, names, values)
921935
set(obj.presetPopupMenu, 'String', [{'Presets...', 'Add...', 'Manage...'} names]);
922936
set(obj.presetPopupMenu, 'Values', [{'Presets...', 'Add...', 'Manage...'} values]);
923-
obj.presetPopupMenu.setSeparatorIndices([3]);
937+
obj.presetPopupMenu.setSeparatorIndices(3);
924938
end
925939

926940
function p = getSelectedPreset(obj)

0 commit comments

Comments
 (0)