function handled = eventHandler(h, eventType, obj)
%

%   Copyright 2010-2023 The MathWorks, Inc.

handled = false;
if isa(obj,"DAStudio.DAObjectProxy")
    obj = obj.getMCOSObjectReference;
end

exp = h.Explorer;
switch eventType
    case 'TreeSelectionChanged'
        if h.ShowObjectInfo
            dlg = DAStudio.ToolRoot.getOpenDialogs(h);
            for i = 1:length(dlg)
                if strcmp(dlg(i).dialogTag, 'me_view_manager_ui')
                    if strcmp(exp.ViewMode,'Content')
                        dlg(i).setVisible('views_details_link', true);  
                    else
                        dlg(i).setVisible('views_details_link', false);  
                    end                
                    dlg(i).setWidgetValue('views_details_link', ...
                                      DAStudio.message('modelexplorer:DAS:LoadingDotDotDot'));                
                    break;                
                end
            end
        end
        % Decide domain here.
        h.ActiveDomainName = h.getDomainString(obj);
        if strcmp(h.SuggestionMode, 'auto')
            % Switch views if auto switch is on
            [suggestedView, reason] = h.getSuggestedView(); %#ok
            if ~isempty(suggestedView)
                if ~strcmp(suggestedView.Name, h.ActiveView.Name)
                    h.ActiveView = suggestedView;
                    handled = false;
                end
            end
        end
        
        if strcmp(obj.getDisplayLabel, DAStudio.message('SLDD:sldd:ArchDataSectionName'))
            % Hide the spreadsheet widget if the Architectural Data is 
            % selected in the tree component
            exp.showListView(false);
        else
            % Show the spreadsheet component
            exp.showListView(true);
        end
        
    otherwise
        handled = false;
end

% LocalWords:  DAS SLDD sldd
