summaryrefslogtreecommitdiff
path: root/cad/src/dna/command_support/BreakOrJoinStrands_Command.py
blob: 73c9de585ec018564a39b97a81d194b439954ea3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Copyright 2008 Nanorex, Inc.  See LICENSE file for details.
"""

@author: Ninad
@copyright: 2008 Nanorex, Inc.  See LICENSE file for details.
@version: $Id$

History:
2008-08-06: refactored Break and Join Strands commands to create this new class

TODO:
"""


import foundation.env as env
from commands.BuildAtoms.BuildAtoms_Command import BuildAtoms_Command
from utilities.exception_classes import AbstractMethod
from utilities.constants import CL_SUBCOMMAND

_superclass = BuildAtoms_Command

class BreakOrJoinStrands_Command(BuildAtoms_Command):
    """
    A superclass for Break Strands and Join Strands commands
    """

    #Property Manager class (overridden in subclasses)
    PM_class = None

    #Flyout toolbar class
    FlyoutToolbar_class = None

    command_level = CL_SUBCOMMAND
    command_parent = 'BUILD_DNA'
    __abstract_command_class = True #bruce 080905

    command_should_resume_prevMode = True
    command_has_its_own_PM = True



    flyoutToolbar = None


    def _getFlyoutToolBarActionAndParentCommand(self):
        """
        See superclass for documentation.
        @see: self.command_update_flyout()
        """
        flyoutActionToCheck = self._get_init_gui_flyout_action_string()
        parentCommandName = None
        return flyoutActionToCheck, parentCommandName


    def _get_init_gui_flyout_action_string(self):
        raise AbstractMethod


    def command_enter_misc_actions(self):
        """
        Overrides superclass method. See superclass for documentation.
        """
        pass

    def command_exit_misc_action(self):
        """
        Overrides superclass method. See superclass for documentation.
        """
        pass

    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 = _superclass.keep_empty_group(self, group)

        if not bool_keep:
            #Lets just not delete *ANY* DnaGroup while in BreakStrands_Command
            #Although BreakStrands 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

        return bool_keep