def pipe_delete(self, event): """Delete the date pipe. @param event: The wx event. @type event: wx event """ # Ask if this should be done. msg = "Are you sure you would like to delete the '%s' data pipe? This operation cannot be undone." % self.selected_pipe if status.show_gui and Question(msg, parent=self, size=(350, 200), default=False).ShowModal() == wx.ID_NO: return # Delete the data pipe. delete(self.selected_pipe)
def pipe_delete(self, event): """Delete the date pipe. @param event: The wx event. @type event: wx event """ # Ask if this should be done. msg = "Are you sure you would like to delete the '%s' data pipe? This operation cannot be undone." % self.selected_pipe if status.show_gui and Question(msg, parent=self, default=False).ShowModal() == wx.ID_NO: return # Delete the data pipe. delete(self.selected_pipe)
def test_deletion(self): """Test the deletion of a data pipe. The function tested is pipe_control.pipes.delete() """ # Set the current pipe to the 'orig' data pipe. name = 'orig' pipes.switch(name) # Delete the 'orig' data pipe. pipes.delete(name) # Test that the data pipe no longer exists. self.assert_(name not in ds) # Test that the current pipe is None (as the current pipe was deleted). self.assertEqual(pipes.cdp_name(), None)
def delete_analysis(self, index, reset=False): """Delete the analysis tab and data store corresponding to the index. The order of these operations is very important due to the notification of observer objects and the updates, synchronisations, etc. that follow. If the program debugging mode is on, then printouts at each stage will occur to allow the following of the code and observer object notifications. @param index: The index of the analysis to delete. @type index: int """ # Debugging set up. if status.debug: fn_name = sys._getframe().f_code.co_name mod_name = inspect.getmodule(inspect.stack()[1][0]).__name__ class_name = self.__class__.__name__ full_name = "%s.%s.%s" % (mod_name, class_name, fn_name) print("\n\n") print("debug> %s: Deleting the analysis at index %s." % (full_name, index)) # Decrement the number of analyses. self._num_analyses -= 1 # Shift the current page back one if necessary. if self._current > index: self._current -= 1 if status.debug: print("debug> %s: Switching the current analysis to index %s." % (full_name, self._current)) # Execute the analysis delete method, if it exists. if hasattr(self._analyses[index], 'delete'): if status.debug: print("debug> %s: Executing the analysis specific delete() method." % full_name) self._analyses[index].delete() wx.Yield() # Delete the tab. if status.debug: print("debug> %s: Deleting the notebook page." % full_name) self.notebook.DeletePage(index) # Delete the tab object. if status.debug: print("debug> %s: Deleting the analysis GUI object." % full_name) self._analyses.pop(index) # Data store clean up. if not reset: # Store the pipe bundle. pipe_bundle = ds.relax_gui.analyses[index].pipe_bundle # Delete the data store object. if status.debug: print("debug> %s: Deleting the data store object." % full_name) ds.relax_gui.analyses.pop(index) # Delete all data pipes associated with the analysis. for pipe in pipes.pipe_names(): if pipes.get_bundle(pipe) == pipe_bundle: if status.debug: print("debug> %s: Deleting the data pipe '%s' from the '%s' bundle." % (full_name, pipe, pipe_bundle)) pipes.delete(pipe) # No more analyses, so in the initial state. if self._num_analyses == 0: if status.debug: print("debug> %s: Setting the initial state." % full_name) self.set_init_state() # The current page has been deleted, so handle page switching to another page. elif index == self._current: # Default to the current page index - so that the switch is to the next page. page_index = self._current # Switch back one page. if self._num_analyses <= self._current: page_index = self._current - 1 # Make the switch. if status.debug: print("debug> %s: Switching to page %s." % (full_name, page_index)) self.switch_page(page_index) # Notify the observers of the change. status.observers.gui_analysis.notify()
def delete_analysis(self, index): """Delete the analysis tab and data store corresponding to the index. The order of these operations is very important due to the notification of observer objects and the updates, synchronisations, etc. that follow. If the program debugging mode is on, then printouts at each stage will occur to allow the following of the code and observer object notifications. @param index: The index of the analysis to delete. @type index: int """ # Debugging set up. if status.debug: fn_name = sys._getframe().f_code.co_name mod_name = inspect.getmodule(inspect.stack()[1][0]).__name__ class_name = self.__class__.__name__ full_name = "%s.%s.%s" % (mod_name, class_name, fn_name) print("\n\n") print("debug> %s: Deleting the analysis at index %s." % (full_name, index)) # Decrement the number of analyses. self._num_analyses -= 1 # Shift the current page back one if necessary. if self._current > index: self._current -= 1 if status.debug: print("debug> %s: Switching the current analysis to index %s." % (full_name, self._current)) # Execute the analysis delete method, if it exists. if hasattr(self._analyses[index], 'delete'): if status.debug: print("debug> %s: Executing the analysis specific delete() method." % full_name) self._analyses[index].delete() # Delete the tab. if status.debug: print("debug> %s: Deleting the notebook page." % full_name) self.notebook.DeletePage(index) # Delete the tab object. if status.debug: print("debug> %s: Deleting the analysis GUI object." % full_name) self._analyses.pop(index) # The current page has been deleted, so switch one back (if possible). if index == self._current and self._current != 0: if status.debug: print("debug> %s: Switching to page %s." % (full_name, self._current-1)) self.switch_page(self._current-1) # No more analyses, so in the initial state. if self._num_analyses == 0: if status.debug: print("debug> %s: Setting the initial state." % full_name) self.set_init_state() # Notify the observers of the change. status.observers.gui_analysis.notify() # Store the pipe bundle. pipe_bundle = ds.relax_gui.analyses[index].pipe_bundle # Delete the data store object. if status.debug: print("debug> %s: Deleting the data store object." % full_name) ds.relax_gui.analyses.pop(index) # Delete all data pipes associated with the analysis. for pipe in pipes.pipe_names(): if pipes.get_bundle(pipe) == pipe_bundle: if status.debug: print("debug> %s: Deleting the data pipe '%s' from the '%s' bundle." % (full_name, pipe, pipe_bundle)) pipes.delete(pipe)