function addToSlice(sys, uiObj)
    
    % Utility function to add subsystem to slice.
    % This function is called by util_menu_callback.m.
    
    %   Copyright 2014-2015 The MathWorks, Inc.

    dlgSrc = uiObj.getDialogSource;
    sc = dlgSrc.sigListPanel.Model;

    if isempty(sys) || length(sys) > 1
        mex = MException('ModelSlicer:InvalidSubsystemSelection',...
            getString(message('Sldv:ModelSlicer:Transform:OnlyOneAtomicSS')));
        modelslicerprivate('MessageHandler','single_error',mex,sc.modelSlicer.model,true);
        return;
    end
    
    sliceSubSystemH = get_param(sys(1),'Handle');

    try
        Transform.SubsystemSliceUtils.checkCompatibility(sliceSubSystemH ,sc.useCvd,[]);
    catch mex
        % Generating error to Message Viewer
        modelslicerprivate('MessageHandler','single_error',mex,sc.modelSlicer.model,true);
        return;
    end
    sc.addSliceSubsystem(sliceSubSystemH);
    scfg = dlgSrc.Model;
    if scfg.requireAutoRefresh
        sc.refresh;
    else
        uiObj.refresh;
    end
    uiObj.show();  % Bring UI to front
end
