Changeset 1085

Show
Ignore:
Timestamp:
11/21/06 13:24:13 (2 years ago)
Author:
arjanmol
Message:

connecting comment line to associations works

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/branches/new-canvas/ChangeLog

    r1074 r1085  
     12006-11-20  arjan <arjan at yirdis dot nl> 
     2 
     3        * gaphor/storage.py: loading/saving works 
     4        * gaphor/adapters/connector.py: added connector for 
     5          commentline-diagramline. 
     6        * gaphor/diaram/diagramitem.py: made delete operation work. 
     7 
    182006-11-14  arjan <arjan at yirdis dot nl> 
    29 
  • gaphor/branches/new-canvas/gaphor/actions/diagramactions.py

    r1056 r1085  
    207207                items = view.selected_items 
    208208                for i in items: 
     209                    s = i.subject 
     210                    if s and len(s.presentation) == 1: 
     211                        s.unlink() 
    209212                    i.unlink() 
    210213            finally: 
     
    223226    def is_last_view(self, item): 
    224227        ''' Check if the current view is the last view to its object ''' 
    225         if item.subject and len(item.subject.presentation)==1: 
     228        if item.subject and len(item.subject.presentation) == 1: 
    226229            return True 
    227230        return False 
     
    239242        value = dialog.run() 
    240243        dialog.destroy() 
    241         if value==gtk.RESPONSE_YES: 
     244        if value == gtk.RESPONSE_YES: 
    242245            return True 
    243246        return False 
  • gaphor/branches/new-canvas/gaphor/adapters/connectors.py

    r1084 r1085  
    8585        element it's attached to, by removing the constraints. 
    8686        """ 
    87         solver = self.element.canvas.solver 
     87        solver = self.line.canvas.solver 
    8888        try: 
    8989            solver.remove_constraint(handle._connect_constraint) 
     
    153153        closest to (x, y). 
    154154        """ 
    155         h = self.line.handles() 
     155        h = self.element.handles() 
    156156        pos = (x, y) 
    157157        min_d = None 
     
    207207        connected_to = opposite.connected_to 
    208208        if connected_to is element: 
    209             #print 'item identical', connected_to, element 
    210209            return None 
    211210 
  • gaphor/branches/new-canvas/gaphor/adapters/tests/test_connector.py

    r1081 r1085  
    8282        assert not actor2.subject in comment.subject.annotatedElement, comment.subject.annotatedElement 
    8383 
     84 
    8485    def test_commentline_association(self): 
    8586        """ 
    8687        Test CommentLineItem with AssociationItem. 
     88 
     89        # TODO: check behaviour if: 
     90          1. comment line is connected to association + comment and after that 
     91             association is connected to two classes. 
     92             -> association should be connected to comment.annotatedElement 
     93          2. association is disconnected while a comment is connected: 
     94             -> association should be removed from comment.annotatedElement 
    8795        """ 
    8896        diagram = UML.create(UML.Diagram) 
    8997        comment = diagram.create(items.CommentItem, subject=UML.create(UML.Comment)) 
    9098        line = diagram.create(items.CommentLineItem) 
     99        line.head.pos = 100, 100 
     100        line.tail.pos = 100, 100 
    91101        c1 = diagram.create(items.ClassItem, subject=UML.create(UML.Class)) 
    92102        c2 = diagram.create(items.ClassItem, subject=UML.create(UML.Class)) 
     
    111121        assert type(adapter) is gaphor.adapters.connectors.CommentLineLineConnect 
    112122        handle = line.head 
     123        pos = adapter.glue(handle, handle.x, handle.y) 
     124        assert pos == (0, 10), pos 
    113125        adapter.connect(handle, handle.x, handle.y) 
    114126 
  • gaphor/branches/new-canvas/gaphor/diagram/diagramitem.py

    r1079 r1085  
    102102            self.save_property(save_func, name) 
    103103 
    104 #    def set_subject(self, subject=None): 
    105 #        """Set the subject. In addition, if there are no more presentations 
    106 #        on the subject, the subject is unlink()'ed. 
    107 #        Note that this function is different from setting the subject property 
    108 #        directly! 
    109 #        """ 
    110 #        #log.debug('set_subject %s %s' % (self.subject, subject)) 
    111 #        old = self.subject 
    112 
    113 #        # remove the subject if we have one 
    114 #        if self.subject: 
    115 #            del self.subject 
    116 
    117 #        if old and len(old.presentation) == 0: 
    118 #            #log.debug('diagramitem.unlink: No more presentations: unlinking') 
    119 #            old.unlink() 
    120 #          
    121 #        self.subject = subject 
     104    def unlink(self): 
     105        print 'DiagramItem.unlink', self, self.canvas 
     106        if self.canvas: 
     107            self.canvas.remove(self) 
     108        self.subject = None 
     109        super(DiagramItem, self).unlink() 
    122110 
    123111    def get_popup_menu(self):