def init_gui(self):
     """
     Initialize GUI for this mode 
     """
     previousCommand = self.commandSequencer.prevMode 
     if previousCommand.commandName == 'BUILD_DNA':
         try:
             self.flyoutToolbar = previousCommand.flyoutToolbar
             #Need a better way to deal with changing state of the 
             #corresponding action in the flyout toolbar. To be revised 
             #during command toolbar cleanup 
             self.flyoutToolbar.breakStrandAction.setChecked(True)
         except AttributeError:
             self.flyoutToolbar = None
     
     if self.propMgr is None:
         self.propMgr = OrderDna_PropertyManager(self)
         #@bug BUG: following is a workaround for bug 2494.
         #This bug is mitigated as propMgr object no longer gets recreated
         #for modes -- niand 2007-08-29
         changes.keep_forever(self.propMgr)  
         
     self.propMgr.show()
class OrderDna_Command(EditCommand): 
    """
    
    """
    # class constants
    
    commandName = 'ORDER_DNA'
    default_mode_status_text = ""
    featurename = "Order DNA"
         
    hover_highlighting_enabled = True
    GraphicsMode_class = OrderDna_GraphicsMode
   
    command_can_be_suspended = False
    command_should_resume_prevMode = True 
    command_has_its_own_gui = True
    
    flyoutToolbar = None

    def init_gui(self):
        """
        Initialize GUI for this mode 
        """
        previousCommand = self.commandSequencer.prevMode 
        if previousCommand.commandName == 'BUILD_DNA':
            try:
                self.flyoutToolbar = previousCommand.flyoutToolbar
                #Need a better way to deal with changing state of the 
                #corresponding action in the flyout toolbar. To be revised 
                #during command toolbar cleanup 
                self.flyoutToolbar.breakStrandAction.setChecked(True)
            except AttributeError:
                self.flyoutToolbar = None
        
        if self.propMgr is None:
            self.propMgr = OrderDna_PropertyManager(self)
            #@bug BUG: following is a workaround for bug 2494.
            #This bug is mitigated as propMgr object no longer gets recreated
            #for modes -- niand 2007-08-29
            changes.keep_forever(self.propMgr)  
            
        self.propMgr.show()
            
        
    def restore_gui(self):
        """
        Restore the GUI 
        """
        if self.propMgr is not None:
            self.propMgr.close()
    
    def keep_empty_group(self, group):
        """
        Returns True if the empty group should not be automatically deleted. 
        otherwise returns False. The default implementation always returns 
        False. Subclasses should override this method if it needs to keep the
        empty group for some reasons. Note that this method will only get called
        when a group has a class constant autdelete_when_empty set to True. 
        (and as of 2008-03-06, it is proposed that dna_updater calls this method
        when needed. 
        @see: Command.keep_empty_group() which is overridden here. 
        """
        
        bool_keep = EditCommand.keep_empty_group(self, group)
        
        if not bool_keep:
            #Lets just not delete *ANY* DnaGroup while in OrderDna_Command
            #Although OrderDna command can only be accessed through
            #BuildDna_EditCommand, it could happen (due to a bug) that the 
            #previous command is not BuildDna_Editcommand. So bool_keep 
            #in that case will return False propmting dna updater to even delete
            #the empty DnaGroup (if it becomes empty for some reasons) of the 
            #BuildDna command. To avoid this ,this method will instruct 
            # to keep all instances of DnaGroup even when they might be empty.            
            if isinstance(group, self.assy.DnaGroup):
                bool_keep = True
            #Commented out code that shows what I was planning to implement 
            #earlier. 
            ##previousCommand = self.commandSequencer.prevMode 
            ##if previousCommand.commandName == 'BUILD_DNA':
                ##if group is previousCommand.struct:
                    ##bool_keep = True                                
        
        return bool_keep