Changeset 2226

Show
Ignore:
Timestamp:
02/26/08 04:06:00 (3 months ago)
Author:
arj..@yirdis.nl
Message:

connector fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/gaphor/adapters/connectors.py

    r2224 r2226  
    9090        def _disconnect(): 
    9191            self.disconnect(handle) 
    92             handle.disconnect = lambda: 0 
    9392        handle.disconnect = _disconnect 
    9493 
     
    101100        """ 
    102101        self.disconnect_constraints(handle) 
    103         # TODO: AJM: is this correct? Should move to handle.disconnect()? 
    104102        handle.connected_to = None 
     103        handle.disconnect = lambda: 0 
    105104 
    106105 
  • gaphor/trunk/gaphor/adapters/tests/test_connector.py

    r2224 r2226  
    4242        assert not comment.subject.annotatedElement, comment.subject.annotatedElement 
    4343 
    44         #print '# now connect the actor' 
     44        # now connect the actor 
    4545 
    4646        adapter = component.queryMultiAdapter((actor, line), IConnect) 
     
    7474        assert len(comment.subject.annotatedElement) == 0, comment.subject.annotatedElement 
    7575        assert not actor2.subject in comment.subject.annotatedElement, comment.subject.annotatedElement 
     76 
     77        adapter = component.queryMultiAdapter((comment, line), IConnect) 
     78 
     79        handle = line.head 
     80        adapter.disconnect(handle) 
     81         
     82 
     83    def test_commentline_class(self): 
     84        """ 
     85        Connect a CommentLine to a class and unlink the commentLine 
     86        afterwards. 
     87        """ 
     88        clazz = self.create(items.ClassItem, UML.Class) 
     89        comment = self.create(items.CommentItem, UML.Comment) 
     90        line = self.create(items.CommentLineItem) 
     91 
     92        adapter = component.queryMultiAdapter((comment, line), IConnect) 
     93        handle = line.head 
     94        adapter.connect(handle) 
     95 
     96        adapter = component.queryMultiAdapter((clazz, line), IConnect) 
     97        handle = line.tail 
     98        adapter.connect(handle) 
     99 
     100        assert clazz.subject in comment.subject.annotatedElement 
     101        assert comment.subject in clazz.subject.ownedComment 
     102 
     103        line.unlink() 
     104 
     105        assert not comment.subject.annotatedElement 
     106        assert not clazz.subject.ownedComment 
     107 
     108 
     109    def test_commentline_relationship_unlink(self): 
     110        """ 
     111        Connect a CommentLine to a relationship item. 
     112        Removing the relationship should work. 
     113 
     114        Demonstrates defect #103. 
     115        """ 
     116        clazz1 = self.create(items.ClassItem, UML.Class) 
     117        clazz2 = self.create(items.ClassItem, UML.Class) 
     118        gen = self.create(items.GeneralizationItem) 
     119 
     120        adapter = component.queryMultiAdapter((clazz1, gen), IConnect) 
     121        handle = gen.head 
     122        adapter.connect(handle) 
     123 
     124        adapter = component.queryMultiAdapter((clazz2, gen), IConnect) 
     125        handle = gen.tail 
     126        adapter.connect(handle) 
     127 
     128        assert gen.subject 
     129 
     130        # And now the comment: 
     131 
     132        comment = self.create(items.CommentItem, UML.Comment) 
     133        line = self.create(items.CommentLineItem) 
     134 
     135        adapter = component.queryMultiAdapter((comment, line), IConnect) 
     136        handle = line.head 
     137        adapter.connect(handle) 
     138 
     139        adapter = component.queryMultiAdapter((gen, line), IConnect) 
     140        handle = line.tail 
     141        adapter.connect(handle) 
     142 
     143        assert gen.subject in comment.subject.annotatedElement 
     144        assert comment.subject in gen.subject.ownedComment 
     145 
     146        gen.unlink() 
     147 
     148        assert not comment.subject.annotatedElement 
     149        assert not gen.subject 
    76150 
    77151 
  • gaphor/trunk/gaphor/diagram/activitynodes.py

    r2120 r2226  
    216216            visible=self.is_join_spec_visible) 
    217217 
    218         obj._name = obj.add_text('name', style={ 
     218        self._name = self.add_text('name', style={ 
    219219                    'text-align': self.style.name_align, 
    220220                    'text-padding': self.style.name_padding, 
     
    224224                }, editable=True) 
    225225 
    226         self.add_watch(UML.NamedElement.name, on_named_element_name) 
    227         self.add_watch(UML.JoinNode.joinSpec, on_join_node_join_spec) 
    228         self.add_watch(UML.LiteralSpecification.value, on_join_node_join_spec) 
     226        self.add_watch(UML.NamedElement.name, self.on_named_element_name) 
     227        self.add_watch(UML.JoinNode.joinSpec, self.on_join_node_join_spec) 
     228        self.add_watch(UML.LiteralSpecification.value, self.on_join_node_join_spec) 
    229229 
    230230 
     
    331331 
    332332    def on_named_element_name(self, event): 
    333         self._name.text = subject.name 
    334         self.request_update() 
     333        subject = self.subject 
     334        if subject and (event is None or event.element is subject): 
     335            self._name.text = subject.name 
     336            self.request_update() 
    335337 
    336338    def on_join_node_join_spec(self, event): 
    337339        subject = self.subject 
    338         if self.subject and is_join_node(subject) and \ 
     340        if subject and is_join_node(subject) and \ 
    339341                (event.element is subject.joinSpec or \ 
    340342                 event.element is subject.joinSpec.value): 
  • gaphor/trunk/gaphor/diagram/objectnode.py

    r2120 r2226  
    4949            visible=self._get_show_ordering) 
    5050 
    51         self.add_watch(UML.ValueSpecification) 
    52         self.add_watch(UML.ValueSpecification.value) 
     51        self.add_watch(UML.LiteralSpecification.value) 
    5352        self.add_watch(UML.ObjectNode.ordering) 
    5453 
  • gaphor/trunk/gaphor/tests/testcase.py

    r2225 r2226  
    1010 
    1111from gaphor import UML 
    12 from gaphor import storage 
     12from gaphor.storage import storage 
    1313from gaphor.application import Application 
    1414from gaphor.misc.xmlwriter import XMLWriter