def _update_toolbar ( self, has_selection ):
        """ Updates the toolbar after a selection change.
        """
        toolbar = self.toolbar
        if toolbar is not None:
            no_filter = (self.filter is None)
            if has_selection:
                indices = self.selected_indices
                start   = indices[0]
                n       = len( self.model.get_filtered_items() ) - 1
                delete  = toolbar.delete
                if self.auto_add:
                    n -= 1
                    delete.enabled = (n <= start)
                else:
                    delete.enabled = True

                deletable = self.factory.deletable
                if delete.enabled and callable( deletable ):
                    delete.enabled = reduce( lambda l, r: l and r,
                        [ deletable( item ) for item in self.selected_items ],
                        True )

                toolbar.search.enabled    = toolbar.add.enabled = True
                toolbar.move_up.enabled   = (no_filter and (start > 0))
                toolbar.move_down.enabled = (no_filter and (indices[-1] < n))
            else:
                toolbar.add.enabled     = no_filter
                toolbar.search.enabled  = toolbar.delete.enabled    = \
                toolbar.move_up.enabled = toolbar.move_down.enabled = False

    #---------------------------------------------------------------------------
    #  Handles the contents of the model being resorted:
    #---------------------------------------------------------------------------
dataset/ETHPy150Open enthought/traitsui/traitsui/wx/table_editor.py/TableEditor._update_toolbar/swapped operands of `<=`