'If deactivate is False, add display applications from self.display_app_containers or
self.proprietary_display_app_containers to appropriate datatypes.  If deactivate is
True, eliminates relevant display applications from appropriate datatypes.'

def load_display_applications(self, app, installed_repository_dict=None, deactivate=False):

    if installed_repository_dict:
        datatype_elems = self.proprietary_display_app_containers
    else:
        datatype_elems = self.display_app_containers
    for elem in datatype_elems:
        extension = self.get_extension(elem)
        for display_app in elem.findall('display'):
            display_file = display_app.get('file', None)
            if installed_repository_dict:
                display_path = installed_repository_dict['display_path']
                (display_file_head, display_file_tail) = os.path.split(display_file)
                config_path = os.path.join(display_path, display_file_tail)
            else:
                config_path = os.path.join(self.display_applications_path, display_file)
            try:
                inherit = galaxy.util.string_as_bool(display_app.get('inherit', 'False'))
                display_app = DisplayApplication.from_file(config_path, app)
                if display_app:
                    if (display_app.id in self.display_applications):
                        if deactivate:
                            del self.display_applications[display_app.id]
                        else:
                            display_app = self.display_applications[display_app.id]
                    elif installed_repository_dict:
                        display_app.tool_shed = installed_repository_dict['tool_shed']
                        display_app.repository_name = installed_repository_dict['repository_name']
                        display_app.repository_owner = installed_repository_dict['repository_owner']
                        display_app.installed_changeset_revision = installed_repository_dict['installed_changeset_revision']
                        display_app.old_id = display_app.id
                        tool_dicts = installed_repository_dict['tool_dicts']
                        for tool_dict in tool_dicts:
                            if (tool_dict['id'] == display_app.id):
                                display_app.guid = tool_dict['guid']
                                display_app.id = tool_dict['guid']
                                break
                    if deactivate:
                        if (display_app.id in self.display_applications):
                            del self.display_applications[display_app.id]
                        if (extension in self.datatypes_by_extension):
                            if (display_app.id in self.datatypes_by_extension[extension].display_applications):
                                del self.datatypes_by_extension[extension].display_applications[display_app.id]
                        if (inherit and ((self.datatypes_by_extension[extension], display_app) in self.inherit_display_application_by_class)):
                            self.inherit_display_application_by_class.remove((self.datatypes_by_extension[extension], display_app))
                        self.log.debug(("Deactivated    display    application    '%s'    for    datatype    '%s'." % (display_app.id, extension)))
                    else:
                        self.display_applications[display_app.id] = display_app
                        self.datatypes_by_extension[extension].add_display_application(display_app)
                        if (inherit and ((self.datatypes_by_extension[extension], display_app) not in self.inherit_display_application_by_class)):
                            self.inherit_display_application_by_class.append((self.datatypes_by_extension[extension], display_app))
                        self.log.debug(("Loaded    display    application    '%s'    for    datatype    '%s',    inherit=%s." % (display_app.id, extension, inherit)))
            except Exception:
                if deactivate:
                    self.log.exception(('Error    deactivating    display    application    (%s)' % config_path))
                else:
                    self.log.exception(('Error    loading    display    application    (%s)' % config_path))
    for (extension, d_type1) in self.datatypes_by_extension.items():
        for (d_type2, display_app) in self.inherit_display_application_by_class:
            current_app = d_type1.get_display_application(display_app.id, None)
            if ((current_app is None) and isinstance(d_type1, type(d_type2))):
                self.log.debug(("Adding    inherited    display    application    '%s'    to    datatype    '%s'" % (display_app.id, extension)))
                d_type1.add_display_application(display_app)
