Changeset 1050

Show
Ignore:
Timestamp:
10/28/06 10:08:42 (2 years ago)
Author:
wrobell
Message:

- minor code improvements
- get rid of commented out stuff related to relationships (replaced by

IConnect based one)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/branches/new-canvas/gaphor/diagram/__init__.py

    r1049 r1050  
    6969 
    7070 
    71 #class Relationship(object): 
    72 #    """Help! What does this class do? 
    73 #    """ 
    74 # 
    75 #    def __init__(self, head_a = None, head_b = None, tail_a = None, tail_b = None): 
    76 #        super(Relationship, self).__init__() 
    77 #        self.head_relation = head_a, head_b 
    78 #        self.tail_relation = tail_a, tail_b 
    79 # 
    80 #    # python descriptor protol 
    81 #    def __get__(self, line, cls): 
    82 #        if not line: 
    83 #            return self 
    84 # 
    85 #        return self.relationship(line) 
    86 #         
    87 #    def __set__(self, line, value): 
    88 #        pass 
    89 # 
    90 #    def __delete__(self, line): 
    91 #        pass 
    92 # 
    93 #    def relationship(self, line, head_subject = None, tail_subject = None): 
    94 #        return self.find(line, self.head_relation, self.tail_relation, 
    95 #                head_subject, tail_subject) 
    96 # 
    97 #    def find(self, line, head_relation, tail_relation, 
    98 #            head_subject = None, tail_subject = None): 
    99 #        """ 
    100 #        Figure out what elements are used in a relationship. 
    101 #        """ 
    102 # 
    103 #        if not head_subject and not tail_subject: 
    104 #            head_subject = line.head.connected_to.subject 
    105 #            tail_subject = line.tail.connected_to.subject 
    106 # 
    107 #        edge_head_name = head_relation[0] 
    108 #        node_head_name = head_relation[1] 
    109 #        edge_tail_name = tail_relation[0] 
    110 #        node_tail_name = tail_relation[1] 
    111 # 
    112 #        # First check if the right subject is already connected: 
    113 #        if line.subject \ 
    114 #                and getattr(line.subject, edge_head_name) is head_subject \ 
    115 #                and getattr(line.subject, edge_tail_name) is tail_subject: 
    116 #            return line.subject 
    117 # 
    118 #        # This is the type of the relationship we're looking for 
    119 #        required_type = getattr(type(tail_subject), node_tail_name).type 
    120 # 
    121 #        # Try to find a relationship, that is already created, but not 
    122 #        # yet displayed in the diagram. 
    123 #        for gen in getattr(tail_subject, node_tail_name): 
    124 #            if not isinstance(gen, required_type): 
    125 #                continue 
    126 #                 
    127 #            gen_head = getattr(gen, edge_head_name) 
    128 #            try: 
    129 #                if not head_subject in gen_head: 
    130 #                    continue 
    131 #            except TypeError: 
    132 #                if not gen_head is head_subject: 
    133 #                    continue 
    134 # 
    135 #            # check for this entry on line.canvas 
    136 #            for item in gen.presentation: 
    137 #                # Allow line to be returned. Avoids strange 
    138 #                # behaviour during loading 
    139 #                if item.canvas is line.canvas and item is not line: 
    140 #                    break 
    141 #            else: 
    142 #                return gen 
    143 #        return None 
    144  
    14571 
    14672class DiagramItemMeta(type): 
     
    15480 
    15581    def __init__(self, name, bases, data): 
    156 #        cls = type.__new__(self, name, bases, data) 
    15782        type.__init__(self, name, bases, data) 
    15883 
    15984        self.mapUMLClass(data) 
    160         self.setStyles(bases, data) 
     85        self.setStyles(data) 
     86 
    16187 
    16288    def mapUMLClass(self, data): 
     
    177103 
    178104 
    179     def setStyles(self, bases, data): 
     105    def setStyles(self, data): 
    180106        """ 
    181107        Set item styles information by merging provided information with 
     
    187113        """ 
    188114        styles = Styles() 
    189         for c in bases
     115        for c in self.__bases__
    190116            if hasattr(c, 'styles'): 
    191117                for (name, value) in c.styles.items(): 
     
    198124        self.styles = styles 
    199125 
    200  
    201  
    202  
    203 #class LineItemMeta(DiagramItemMeta): 
    204 #    """Add support for __relationship__ (what does it do?)  
    205 #    """ 
    206 #    def __new__(cls, name, bases, data): 
    207 #        item_class = DiagramItemMeta.__new__(cls, name, bases, data) 
    208 # 
    209 #        # set line relationship 
    210 #        if '__relationship__' in data: 
    211 #            rel = data['__relationship__'] 
    212 #            if isinstance(rel, (tuple, set, list)): 
    213 #                rel = Relationship(*rel) 
    214 #                item_class.relationship = rel 
    215 # 
    216 #        # set head and tail handles 
    217 # 
    218 #        return item_class 
    219  
    220  
    221 #if __debug__:  
    222 #    # Keep track of all model elements that are created 
    223 #    from gaphor.misc.aspects import ReferenceAspect, weave_method 
    224 #    from gaphor import refs 
    225 #    weave_method(create_as, ReferenceAspect, refs) 
    226  
    227126# vim:sw=4:et