function undo(h)

%% Pop the latest undo transaction from the @recorder stack and undo it.
%% Then fire a datachange event for each of the affected time series
recorder = tsguis.recorder;
if ~isempty(recorder.Undo)
    % If we are about to undo an operation that created a time series 
    % throw a warning
    if ~isempty(recorder.Undo(end).Warnstring)
        ButtonName = questdlg(sprintf('%s. Continue?',recorder.Undo(end).Warnstring),...
            'Time Series Tools','OK','Cancel','OK');
        if strcmp(ButtonName,'Cancel')
            return
        end
    end

    % Pop the latest transaction and undo it
    trans = recorder.popundo;
    trans.undo;
    
    % Update the affected time series
    thesets = get(h.TSnode.getChildren,{'Timeseries'});
    ind = find(trans.getts(thesets));
    for k=1:length(ind)
        thesets{ind(k)}.send('datachange');
    end
    
end

    