Changeset 924
- Timestamp:
- 06/02/06 02:37:25 (2 years ago)
- Files:
-
- gaphor/trunk/ChangeLog (modified) (1 diff)
- gaphor/trunk/gaphor/UML/diagram.py (modified) (1 diff)
- gaphor/trunk/gaphor/UML/element.py (modified) (6 diffs)
- gaphor/trunk/gaphor/diagram/__init__.py (modified) (2 diffs)
- gaphor/trunk/gaphor/diagram/diagramitem.py (modified) (6 diffs)
- gaphor/trunk/gaphor/diagram/groupable.py (modified) (1 diff)
- gaphor/trunk/gaphor/misc/uniqueid.py (modified) (1 diff)
- gaphor/trunk/setup.py (modified) (4 diffs)
- gaphor/trunk/tests/test-uml2.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/trunk/ChangeLog
r898 r924 1 2006-06-01 arjan <arjan at yirdis dot nl> 2 3 * some cleanup, added TODO: comments for conversion to Gaphas. 4 1 5 2006-05-29 arjan <arjan at yirdis dot nl> 2 6 gaphor/trunk/gaphor/UML/diagram.py
r897 r924 96 96 return obj 97 97 98 # TODO: remove 98 99 def substitute_item(self, item, new_item_type): 99 100 """Create a new item and replace item with the new item. gaphor/trunk/gaphor/UML/element.py
r505 r924 15 15 '__unlink__' signal to all attached signals. unlink() can not be called 16 16 recursively. 17 #relink()18 # Inverse operation of unlink(). Used by diagram items during undo operations.19 17 20 18 connect ('name', callback, *data) or … … 54 52 doc="The factory that created this element") 55 53 54 # TODO: move save/load code to adapters 56 55 def save(self, save_func): 57 56 """Save the state by calling save_func(name, value).""" … … 88 87 prop.postload(self) 89 88 90 def __unlink(self, signal): 91 """Unlink the element. For both the __unlink__ and __relink__ signal 92 the __unlink__ callback list is used. 89 def unlink(self): 90 """Unlink the element. 93 91 """ 94 92 # Uses a mutex to make sure it is not called recursively 95 93 if self.__in_unlink.testandset(): 96 94 try: 97 self.notify( signal, '__unlink__')95 self.notify('__unlink__', '__unlink__') 98 96 finally: 99 97 self.__in_unlink.unlock() 100 98 101 def unlink(self):102 """Unlink the element."""103 #log.debug('Element.unlink(%s)' % self)104 self.__unlink('__unlink__')105 106 # def relink(self):107 # """Undo the unlink operation."""108 # log.debug('Element.relink(%s)' % self)109 # self.__unlink('__relink__')110 111 99 def connect(self, names, callback, *data): 112 100 """Attach 'callback' to a list of names. Names may also be a string. 113 A name is the name o da property of the object or '__unlink__'.101 A name is the name of a property of the object or '__unlink__'. 114 102 """ 115 103 #log.debug('Element.connect(%s, %s, %s)' % (names, callback, data)) … … 118 106 cb = (callback,) + data 119 107 for name in names: 120 try: 121 o = self._observers[name] 122 if not cb in o: 123 o.append(cb) 124 except KeyError: 125 # create new entry 126 self._observers[name] = [cb] 108 self._observers.setdefault(name, []).append(cb) 127 109 128 110 def disconnect(self, callback, *data): … … 140 122 def notify(self, name, cb_name=None, pspec=None): 141 123 """Send notification to attached callbacks that a property 142 has changed. the __relink__ signal uses the callbacks for __unlink__.124 has changed. 143 125 """ 144 126 cb_list = self._observers.get(cb_name or name, ()) … … 180 162 psyco.bind(Element) 181 163 182 if __name__ == '__main__':183 a = Element()184 b = Element()185 def cb_func(name, *args):186 print ' cb_func:', name, args187 188 a.connect('ev1', cb_func, a)189 a.connect('ev1', cb_func, a)190 a.connect('ev2', cb_func, 'ev2', a)191 192 print 'notify: ev1'193 a.notify('ev1')194 print 'notify: ev2'195 a.notify('ev2')196 197 a.disconnect(cb_func, a)198 199 print 'notify: ev1'200 a.notify('ev1')201 print 'notify: ev2'202 a.notify('ev2')203 gaphor/trunk/gaphor/diagram/__init__.py
r772 r924 23 23 def get_diagram_item(element): 24 24 global _uml_to_item_map 25 try: 26 return _uml_to_item_map[element] 27 except: 28 return None 25 return _uml_to_item_map.get(element) 29 26 30 27 def set_diagram_item(element, item): … … 55 52 (diacanvas.CanvasElement in all_bases) or \ 56 53 (diacanvas.CanvasBox in all_bases) or \ 57 (diacanvas.CanvasText in all_bases) or \58 54 (diacanvas.CanvasImage in all_bases): 59 55 diacanvas.set_callbacks(item_class) gaphor/trunk/gaphor/diagram/diagramitem.py
r772 r924 9 9 10 10 from gaphor import resource 11 from gaphor.misc import uniqueid12 11 from gaphor.UML import Element, Presentation 13 12 from gaphor.UML.properties import association … … 87 86 # UML.Element interface used by properties: 88 87 88 # TODO: Use adapters for load/save functionality 89 89 def save(self, save_func): 90 90 if self.subject: … … 111 111 self.on_subject_notify(type(self).subject) 112 112 113 # TODO: remove, use signaling from gaphor.UML.Element 113 114 def unlink(self): 114 115 """Send the unlink signal and remove itself from the canvas. … … 123 124 self.set_property('parent', None) 124 125 125 # def relink(self):126 # """Relinking is done by popping the undo stack...127 # """128 # log.info('RELINK DiagramItem')129 # #self.emit('__unlink__', '__relink__')130 131 126 # gaphor.UML.Element like signal interface: 132 127 128 # TODO: remove, use signaling from gaphor.UML.Element 133 129 def connect(self, name, handler, *args): 134 130 """Connect a handler to signal name with args. … … 146 142 return id 147 143 144 # TODO: remove, use signaling from gaphor.UML.Element 148 145 def disconnect(self, handler_or_id, *args): 149 146 """Disconnect a signal handler. If handler_or_id is an integer (int) … … 318 315 # DiaCanvasItem callbacks 319 316 317 # TODO: use connectable adapter here. 320 318 def _on_glue(self, handle, wx, wy, parent_class): 321 319 """This function is used to notify the connecting item gaphor/trunk/gaphor/diagram/groupable.py
r772 r924 8 8 import diacanvas 9 9 10 # TODO: Remove alltogether (no longer used for Gaphas) 10 11 class GroupBase(diacanvas.CanvasGroupable): 11 12 """ gaphor/trunk/gaphor/misc/uniqueid.py
r465 r924 81 81 f.close() 82 82 break; 83 elif sys.platform.find('sun') >= 0: 83 elif sys.platform.find('darwin') >= 0 \ 84 or sys.platform.find('sun') >= 0: 84 85 # 85 # SunOS86 # Darwin (Mac OS X) and SunOS 86 87 # 87 88 f = os.popen("/sbin/ifconfig -a") gaphor/trunk/setup.py
r900 r924 18 18 from glob import glob 19 19 from commands import getoutput, getstatus, getstatusoutput 20 21 # Py2App should be imported before the utils classes are loaded 20 22 try: 21 23 import py2app 22 24 except ImportError: 23 print 'No py2app.' 24 py2appargs = dict() 25 print "No py2app, can't create application bundle" 25 26 else: 26 py2appargs = dict(app=['gaphor-osx.py']) 27 from modulegraph.modulegraph import AddPackagePath 28 AddPackagePath('gaphor', 'build/lib/gaphor') 29 AddPackagePath('gaphor.UML', 'build/lib/gaphor/UML') 27 30 28 31 from distutils.core import setup, Command … … 196 199 outfile = os.path.join(self.build_lib, py_model) 197 200 self.mkpath(os.path.dirname(outfile)) 198 199 # Figure out if the uml2.py (outfile) is the newest or should be 200 # generated (again). 201 if self.force or reduce(lambda a, b: newer(a,b) and a or b, 202 (model, overrides, gen, outfile)) != outfile: 201 if self.force or newer(model, outfile) \ 202 or newer(overrides, outfile) \ 203 or newer(gen, outfile): 203 204 print 'generating %s from %s...' % (py_model, model) 204 205 print ' (warnings can be ignored)' … … 380 381 "It uses the GNOME2 environment for user interaction.", 381 382 platforms=['GNOME2'], 382 all_linguas=[' ca', 'es', 'nl', 'sv'],383 all_linguas=['nl', 'es'], 383 384 packages=['gaphor', 384 385 'gaphor.UML', … … 427 428 'run': run_Gaphor 428 429 }, 429 **py2appargs 430 app=['gaphor-osx.py'], 431 options = dict( 432 py2app = dict( 433 includes=['atk', 'pango', 'cairo', 'pangocairo'], 434 # CFBundleDisplayName='Gaphor', 435 # CFBundleIdentifier='net.sourceforge.gaphor' 436 ) 437 ) 430 438 ) 431 gaphor/trunk/tests/test-uml2.py
r376 r924 6 6 7 7 class TestUML2(unittest.TestCase): 8 9 def test_element(self): 10 a = UML.Element() 11 b = UML.Element() 12 def cb_func(name, *args): 13 print ' cb_func:', name, args 14 15 a.connect('ev1', cb_func, a) 16 a.connect('ev1', cb_func, a) 17 a.connect('ev2', cb_func, 'ev2', a) 18 19 print 'notify: ev1' 20 a.notify('ev1') 21 print 'notify: ev2' 22 a.notify('ev2') 23 24 a.disconnect(cb_func, a) 25 26 print 'notify: ev1' 27 a.notify('ev1') 28 print 'notify: ev2' 29 a.notify('ev2') 8 30 9 31 def test1(self):
