Changeset 1176

Show
Ignore:
Timestamp:
03/27/07 13:54:18 (2 years ago)
Author:
arj..@yirdis.nl
Message:

More undo fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/TODO

    r1142 r1176  
    88 
    99 - Undo functionality 
     10    - make canvas events transactional. 
    1011 
    1112 - use easysetup tools, move gaphas to a separate package and use 
  • gaphor/trunk/gaphor/UML/properties.py

    r1173 r1176  
    629629 
    630630 
     631@component.adapter(AssociationDeleteEvent) 
     632def undo_association_delete_event(event): 
     633    association = event.property 
     634    obj = event.element 
     635    value = event.old_value 
     636    def _undo_association_delete_event(): 
     637        #print 'undoing action', obj, value 
     638        # Tell the assoctaion it should not need to let the opposite 
     639        # side connect (it has it's own signal) 
     640        association._set(obj, value, from_opposite=True) 
     641    get_undo_manager().add_undo_action(_undo_association_delete_event) 
     642 
     643component.provideHandler(undo_association_delete_event) 
     644 
     645 
    631646try: 
    632647    import psyco 
  • gaphor/trunk/gaphor/UML/tests/test_properties.py

    r1173 r1176  
    11#!/usr/bin/env python 
    2 # vim:sw=4:et:ai 
    32 
    43import unittest 
     
    397396        assert a.attr == 'five' 
    398397 
    399     def test_undo_attribute(self): 
    400         import types 
     398    def test_undo_aassociation_1_x(self): 
    401399        from gaphor.services.undomanager import get_undo_manager 
    402400        undo_manager = get_undo_manager() 
     
    429427        assert b.two is a 
    430428 
     429    def test_undo_association_1_n(self): 
     430        from gaphor.services.undomanager import get_undo_manager 
     431        undo_manager = get_undo_manager() 
     432  
     433        class A(Element): pass 
     434        class B(Element): pass 
     435 
     436        A.one = association('one', B, lower=0, upper=1, opposite='two') 
     437        B.two = association('two', A, lower=0, upper='*', opposite='one') 
     438 
     439        a1 = A() 
     440        a2 = A() 
     441        b1 = B() 
     442        b2 = B() 
     443 
     444 
     445        undo_manager.begin_transaction() 
     446        b1.two = a1 
     447         
     448        undo_manager.commit_transaction() 
     449        assert a1 in b1.two 
     450        assert b1 is a1.one 
     451 
     452        undo_manager.undo_transaction() 
     453        assert len(b1.two) == 0 
     454        assert a1.one is None 
     455 
     456        undo_manager.redo_transaction() 
     457        assert a1 in b1.two 
     458        assert b1 is a1.one 
     459 
     460        undo_manager.begin_transaction() 
     461        b1.two = a2 
     462 
     463        undo_manager.commit_transaction() 
     464        assert a1 in b1.two 
     465        assert a2 in b1.two 
     466        assert b1 is a1.one 
     467        assert b1 is a2.one 
     468 
     469 
     470# vim:sw=4:et:ai 
  • gaphor/trunk/gaphor/misc/console.py

    r561 r1176  
    1717import __main__ 
    1818 
    19 banner = """GTK Interactive Python Console 
     19banner = """Gaphor Interactive Python Console 
    2020%s 
    2121""" % sys.version 
  • gaphor/trunk/gaphor/ui/namespace.py

    r1121 r1176  
    256256 
    257257        for t in toplevel: 
    258             #print 'factory::model toplevel', t, t.name 
    259258            self.new_node_from_element(t, self.root) 
    260         #print 'self.root', self.root 
    261259 
    262260    def refresh(self): 
     
    277275 
    278276    def on_get_flags(self): 
    279         """Returns the GtkTreeModelFlags for this particular type of model. 
     277        """ 
     278        Returns the GtkTreeModelFlags for this particular type of model. 
    280279        """ 
    281280        return 0 
    282281 
    283282    def on_get_n_columns(self): 
    284         """Returns the number of columns in the model. 
     283        """ 
     284        Returns the number of columns in the model. 
    285285        """ 
    286286        return 1 
    287287 
    288288    def on_get_column_type(self, index): 
    289         """Returns the type of a column in the model. 
     289        """ 
     290        Returns the type of a column in the model. 
    290291        """ 
    291292        return gobject.TYPE_PYOBJECT 
    292293 
    293294    def on_get_path (self, node): 
    294         """Returns the path for a node as a tuple (0, 1, 1). 
    295         """ 
    296         #print 'on_get_path', node 
     295        """ 
     296        Returns the path for a node as a tuple (0, 1, 1). 
     297        """ 
    297298        return self.path_from_element(node[0]) 
    298299 
    299300    def on_get_iter(self, path): 
    300         """Returns the node corresponding to the given path. 
     301        """ 
     302        Returns the node corresponding to the given path. 
    301303        The path is a tuple of values, like (0 1 1). Returns None if no 
    302304        iterator can be created. 
    303305        """ 
    304         #print 'on_get_iter', path 
    305306        return self.node_from_path(path) 
    306307 
    307308    def on_get_value(self, node, column): 
    308         """Returns the model element that matches 'node'. 
     309        """ 
     310        Returns the model element that matches 'node'. 
    309311        """ 
    310312        assert column == 0, 'column can only be 0' 
    311         #print 'on_get_value', node, column 
    312313        return node[0] 
    313314 
    314315    def on_iter_next(self, node): 
    315         """Returns the next node at this level of the tree (None if no 
     316        """ 
     317        Returns the next node at this level of the tree (None if no 
    316318        next element). 
    317319        """ 
    318         #print 'on_iter_next:', node 
    319320        try: 
    320321            parent = self.node_from_element(node[0].namespace) 
     
    329330         
    330331    def on_iter_has_child(self, node): 
    331         """Returns true if this node has children, or None. 
    332         """ 
    333         #print 'on_iter_has_child', node 
     332        """ 
     333        Returns true if this node has children, or None. 
     334        """ 
    334335        return len(node[1]) > 0 
    335336 
    336337    def on_iter_children(self, node): 
    337         """Returns the first child of this node, or None. 
    338         """ 
    339         #print 'on_iter_children' 
     338        """ 
     339        Returns the first child of this node, or None. 
     340        """ 
    340341        return node[1][0] 
    341342 
    342343    def on_iter_n_children(self, node): 
    343         """Returns the number of children of this node. 
    344         """ 
    345         #print 'on_iter_n_children' 
     344        """ 
     345        Returns the number of children of this node. 
     346        """ 
    346347        return len (node[1]) 
    347348 
    348349    def on_iter_nth_child(self, node, n): 
    349         """Returns the nth child of this node. 
    350         """ 
    351         #print "on_iter_nth_child", node, n 
     350        """ 
     351        Returns the nth child of this node. 
     352        """ 
    352353        try: 
    353354            if node is None: 
  • gaphor/trunk/setup.cfg

    r191 r1176  
     1 
     2[egg_info] 
     3# Point egg_base to compiled sources, cause some sources have to be generated 
     4egg_base=build/lib 
     5 
    16[install] 
    27install_data=$base/share/gaphor