def dispose ( self ):
        """ Disposes of the contents of an editor.
        """
        if self.toolbar_ui is not None:
            self.toolbar_ui.dispose()

        if self._ui is not None:
            self._ui.dispose()

        self.grid.on_trait_change( getattr( self,
            '_selection_%s_updated' % self.factory.selection_mode ),
            'selection_changed', remove = True )

        self.model.on_trait_change( self._model_sorted, 'sorted',
                                    remove = True )

        self.grid.dispose()
        self.model.dispose()

        # Break any links needed to allow garbage collection:
        self.grid = self.model = self.toolbar = None

        super( TableEditor, self ).dispose()

    #---------------------------------------------------------------------------
    #  Updates the editor when the object trait changes external to the editor:
    #---------------------------------------------------------------------------
dataset/ETHPy150Open enthought/traitsui/traitsui/wx/table_editor.py/TableEditor.dispose/original