Changeset 2253

Show
Ignore:
Timestamp:
03/04/08 23:28:14 (2 months ago)
Author:
arj..@yirdis.nl
Message:

clean up of UML.properties and (not so) fix on InterfaceItem

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/gaphor/UML/properties.py

    r2246 r2253  
    4242    """ 
    4343    Superclass for attribute, enumeration and association. 
    44     The subclasses should define a 'name' attribute that contains the name 
     44 
     45    The subclasses should define a ``name`` attribute that contains the name 
    4546    of the property. Derived properties (derivedunion and redefine) can be 
    4647    connected, they will be notified when the value changes. 
     
    139140class enumeration(umlproperty): 
    140141    """ 
    141     Enumeration. 
    142     Element.enum = enumeration('enum', ('one', 'two', 'three'), 'one') 
     142    Enumeration 
     143 
     144      Element.enum = enumeration('enum', ('one', 'two', 'three'), 'one') 
     145 
     146    An enumeration is a special kind of attribute that can only hold a 
     147    predefined set of values. Multiplicity is always `[0..1]` 
    143148    """ 
    144149 
     
    383388                    value.unlink() 
    384389 
    385 #    def __on_unlink(self, value, pspec, obj): 
    386 #        """ 
    387 #        Disconnect when the element on the other end of the association 
    388 #        (value) sends the '__unlink__' signal. This is especially important 
    389 #        for uni-directional associations. 
    390 #        """ 
    391 #        #print '__on_unlink', name, obj, value 
    392 #        if pspec == '__unlink__': 
    393 #            self.__delete__(obj, value) 
    394 #            # re-establish unlink handler: 
    395 #            value.connect('__unlink__', self.__on_unlink, obj) 
    396 # 
    397390 
    398391class AssociationStubError(Exception): 
     
    401394 
    402395class associationstub(umlproperty): 
     396    """ 
     397    An association stub is an internal thingy that ensures all associations 
     398    are always bi-directional. This helps the application when one end of 
     399    the association is unlinked. On unlink() of an element all `umlproperty`'s 
     400    are iterated and called by their unlink() method. 
     401    """ 
    403402 
    404403    def __init__(self, association): 
     
    569568    """ 
    570569    Redefined association 
    571     Element.x = redefine('x', Element, Class, Element.assoc) 
     570 
     571      Element.redefine = redefine(Element, 'redefine', Class, Element.assoc) 
     572 
    572573    If the redefine eclipses the original property (it has the same name) 
    573574    it ensures that the original values are saved and restored. 
  • gaphor/trunk/gaphor/diagram/interface.py

    r2143 r2253  
    5656        self.add_watch(UML.Interface.ownedAttribute, self.on_class_owned_attribute) 
    5757        self.add_watch(UML.Interface.ownedOperation, self.on_class_owned_operation) 
     58        self.add_watch(UML.Implementation.contract, self.on_implementation_contract) 
    5859 
    5960    @observed 
     
    9091 
    9192    folded = property(is_folded, _set_folded) 
     93 
     94    def on_implementation_contract(self, event): 
     95        #print 'on_implementation_contract', event, event.element 
     96        if event is None or event.element.contract is self: 
     97            self.request_update() 
    9298 
    9399    def pre_update_icon(self, context): 
  • gaphor/trunk/gaphor/diagram/tests/test_interface.py

    r1616 r2253  
    33""" 
    44 
    5 import unittest 
    6  
     5from gaphor.tests.testcase import TestCase 
    76from gaphor import UML 
    87from gaphor.diagram.interface import InterfaceItem 
     
    1110 
    1211 
    13 class ClassTestCase(unittest.TestCase): 
     12class ClassTestCase(TestCase): 
    1413 
    15     def setUp(self): 
    16         self.element_factory = UML.ElementFactory() 
    17  
    18     def tearDown(self): 
    19         #self.element_factory.flush() 
    20         #assert len(self.element_factory.lselect()) == 0 
    21         pass 
     14    services = [ 'element_factory' ] 
    2215 
    2316    def test_interface(self):