Changeset 2254

Show
Ignore:
Timestamp:
03/05/08 12:50:17 (2 months ago)
Author:
arj..@yirdis.nl
Message:

updated transition, so guard condition updates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/gaphor/diagram/states/tests/test_pseudostates.py

    r2242 r2254  
    1111    Initial pseudostate item test cases. 
    1212    """ 
     13 
    1314    def test_initial_pseudostate(self): 
    1415        """Test creation of initial pseudostate 
  • gaphor/trunk/gaphor/diagram/states/transition.py

    r2251 r2254  
    2323        NamedLine.__init__(self, id) 
    2424        self._guard = self.add_text('guard.specification.value', editable=True) 
    25         self.add_watch(UML.Transition.guard
    26         self.add_watch(UML.Constraint.specification
    27         self.add_watch(UML.LiteralSpecification.value
     25        self.add_watch(UML.Transition.guard, self.on_guard
     26        self.add_watch(UML.Constraint.specification, self.on_guard
     27        self.add_watch(UML.LiteralSpecification.value, self.on_guard
    2828 
    2929 
     
    3535            self._guard.text = self.subject.guard.specification.value 
    3636        super(TransitionItem, self).postload() 
     37 
     38 
     39    def on_guard(self, event): 
     40        if not self.subject: 
     41            return 
     42        element = event.element 
     43        guard = self.subject.guard 
     44        if event is None or \ 
     45                (element is self.subject) or \ 
     46                (element is guard) or \ 
     47                (guard and element is guard.specification): 
     48            try: 
     49                self._guard.text = self.subject.guard.specification.value or '' 
     50            except AttributeError: 
     51                # Have a no-value here 
     52                self._guard.text = '' 
     53            self.request_update() 
    3754 
    3855