Changeset 463
- Timestamp:
- 11/09/04 23:44:53 (4 years ago)
- Files:
-
- trunk/gaphor/ChangeLog (modified) (2 diffs)
- trunk/gaphor/FAQ (added)
- trunk/gaphor/NEWS (modified) (1 diff)
- trunk/gaphor/TODO (modified) (2 diffs)
- trunk/gaphor/data/gaphor-diagram-ui.xml (deleted)
- trunk/gaphor/data/gaphor-editor-ui.xml (deleted)
- trunk/gaphor/data/gaphor-main-ui.xml (deleted)
- trunk/gaphor/data/plugins/pngexport/plugin.xml (modified) (1 diff)
- trunk/gaphor/data/plugins/svgexport (added)
- trunk/gaphor/data/plugins/svgexport/__init__.py (added)
- trunk/gaphor/data/plugins/svgexport/plugin.xml (added)
- trunk/gaphor/data/plugins/xmiexport/__init__.py (modified) (1 diff)
- trunk/gaphor/data/plugins/xmiexport/exportmodel.py (modified) (5 diffs)
- trunk/gaphor/data/plugins/xmiexport/plugin.xml (modified) (1 diff)
- trunk/gaphor/doc/UmlMetaModel.xmi (deleted)
- trunk/gaphor/doc/stereotypes.txt (added)
- trunk/gaphor/gaphor/UML (modified) (1 prop)
- trunk/gaphor/gaphor/UML/.cvsignore (modified) (1 diff)
- trunk/gaphor/gaphor/diagram/association.py (modified) (7 diffs)
- trunk/gaphor/gaphor/diagram/itemactions.py (modified) (22 diffs)
- trunk/gaphor/gaphor/ui/diagramactions.py (modified) (1 diff)
- trunk/gaphor/gaphor/ui/mainwindow.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gaphor/ChangeLog
r462 r463 1 2004-11-10 Arjan Molenaar <arjanmolenaar@hetnet.nl> 2 3 * data/plugins/xmiexport/__init__.py: Added action with save dialog. 4 * data/plugins/xmiexport/exportmodel.py: Added timestamp, use 5 XMLWriter. 6 * FAQ: new file. 7 1 8 2004-11-09 Arjan Molenaar <arjanmolenaar@hetnet.nl> 2 9 … … 4 11 undo can work properly. 5 12 * data/plugins/alignment: Make only sensitive if items are selected. 13 * data/plugins/svgexport: New plugin. 14 * gaphor/ui/diagramactions.py: Moved SVG export code to svgexport 15 plugin. 16 * gaphor/diagram/association.py: Moved the Side A/B submenu's in 17 separate sub menu's that can be activated when the mouse pointer is 18 at the end of the association. 6 19 7 20 2004-11-07 Jeroen Vloothuis <jeroen@vloothuis.net> 21 8 22 * data/plugins/alignment: Added a plugin for adjusting the 9 23 alignment of diagram items. Currentyl does horizontal and trunk/gaphor/NEWS
r445 r463 1 0.7.0 2 ----- 3 - XMI export plugin 4 - Item alignment 5 - Full featured undo mechanism 6 - Copy/paste 7 - usability improvements 8 - require DiaCanvas2 0.14.2 9 1 10 0.6.0 2 11 ----- trunk/gaphor/TODO
r445 r463 14 14 - An option that shows the selected item (in the namespace view) in a diagram. 15 15 16 - Copy/Paste for diagramitems16 #- Copy/Paste for diagramitems 17 17 - in order to make copy/paste work, the load/save functions should be 18 18 generatlised to allow a subset to be saved/loaded (which is needed … … 38 38 on menu items 39 39 40 #- Undo/redo functionality doesn't work as espected 41 ==> Create our own UndoManager, this should also register connect/disconnect 42 actions on gaphor.UML classes. 43 AJM: Looks like it really works now. 40 #- Undo/redo functionality 44 41 45 42 - Exporting diagrams to UML XMI (work in progress), trunk/gaphor/data/plugins/pngexport/plugin.xml
r440 r463 29 29 Add optional dependencies to this action. The action is then updated 30 30 when actions defined in the depends tag are executed. 31 - ->32 <depends action=""/>33 31 --> 32 <depends action="TabChange"/> 34 33 </action> 35 34 </provide> trunk/gaphor/data/plugins/xmiexport/__init__.py
r406 r463 1 1 # vim:sw=4:et 2 2 3 import gtk 3 4 from exportmodel import XMIExport 5 from gaphor.plugin import Action 6 7 8 class XMIExportAction(Action): 9 10 def execute(self): 11 filesel = gtk.FileSelection('Export model to XMI file') 12 filesel.set_modal(True) 13 filename = self.get_window().get_filename() 14 if filename: 15 filename = filename.replace('.gaphor', '.xmi') 16 else: 17 filename = 'model.xmi' 18 filesel.set_filename(filename) 19 20 response = filesel.run() 21 filesel.hide() 22 if response == gtk.RESPONSE_OK: 23 filename = filesel.get_filename() 24 if filename and len(filename) > 0: 25 #self.filename = filename 26 log.debug('Exporting XMI model to: %s' % filename) 27 export = XMIExport() 28 try: 29 export.export(filename) 30 except Exception, e: 31 log.error('Error while saving model to file %s: %s' % (filename, e)) 32 trunk/gaphor/data/plugins/xmiexport/exportmodel.py
r447 r463 1 1 # vim:sw=4:et 2 2 3 from xml.sax.saxutils import XMLGenerator 3 #from xml.sax.saxutils import XMLGenerator 4 import time 4 5 import gaphor 5 6 from gaphor import UML 6 from gaphor.plugin import Action 7 8 try: 9 dict() 10 except: 11 from UserDict import UserDict as dict 7 from gaphor.misc.xmlwriter import XMLWriter 8 12 9 class XMLAttributes(dict): 13 10 def getLength(self): … … 27 24 return self[name] 28 25 29 class XMIExport(Action): 26 27 class XMIExport(object): 30 28 31 29 def handleClass(self, xmi, node): … … 215 213 216 214 217 def export(self): 218 out=open('/Users/vloothuis/test.xmi','w') 219 xmi=XMLGenerator(out) 215 def export(self, filename): 216 #out=open('/Users/vloothuis/test.xmi','w') 217 out=open(filename,'w') 218 219 xmi=XMLWriter(out) 220 220 221 221 # Start XML generation … … 223 223 attributes['xmi.version']='1.2' 224 224 attributes['xmlns:UML']='org.omg.xmi.namespace.UML' 225 attributes['timestamp'] ='Tue Sep 28 10:48:06 CEST 2004' # TODO!225 attributes['timestamp'] = time.strftime('%a %b %d %H:%M:%S %Z %Y') 226 226 xmi.startElement('XMI', attrs=attributes) 227 227 … … 274 274 xmi.endElement('XMI.content') 275 275 276 def execute(self):277 self.export()278 trunk/gaphor/data/plugins/xmiexport/plugin.xml
r406 r463 25 25 label="XMI Export" 26 26 tooltip="Export the model to XMI" 27 class="XMIExport " slot="FileExportSlot">27 class="XMIExportAction" slot="FileExportSlot"> 28 28 <!-- 29 29 Add optional dependencies to this action. The action is then updated trunk/gaphor/gaphor/UML
- Property svn:ignore changed from
*.pyc
*.pyo
modelelements.py to
*.pyc
*.pyo
- Property svn:ignore changed from
trunk/gaphor/gaphor/UML/.cvsignore
r123 r463 1 1 *.pyc 2 2 *.pyo 3 modelelements.pytrunk/gaphor/gaphor/diagram/association.py
r460 r463 54 54 'AssociationInvertDirection', 55 55 'separator', 56 'Side _A', (57 'Head_isNavigable',58 'separator',59 'Head_AggregationNone',60 'Head_AggregationShared',61 'Head_AggregationComposite'),62 'Side _B', (63 'Tail_isNavigable',64 'separator',65 'Tail_AggregationNone',66 'Tail_AggregationShared',67 'Tail_AggregationComposite')56 # 'Side _A', ( 57 # 'Head_isNavigable', 58 # 'separator', 59 # 'Head_AggregationNone', 60 # 'Head_AggregationShared', 61 # 'Head_AggregationComposite'), 62 # 'Side _B', ( 63 # 'Tail_isNavigable', 64 # 'separator', 65 # 'Tail_AggregationNone', 66 # 'Tail_AggregationShared', 67 # 'Tail_AggregationComposite') 68 68 ) 69 69 … … 73 73 # AssociationEnds are really inseperable from the AssociationItem. 74 74 # We give them the same id as the association item. 75 self._head_end = AssociationEnd( )75 self._head_end = AssociationEnd(end="head") 76 76 self._head_end.set_child_of(self) 77 self._tail_end = AssociationEnd( )77 self._tail_end = AssociationEnd(end="tail") 78 78 self._tail_end.set_child_of(self) 79 79 … … 454 454 FONT='sans 10' 455 455 456 def __init__(self, id=None): 456 head_popup_menu = ( 457 'Head_isNavigable', 458 'separator', 459 'Head_AggregationNone', 460 'Head_AggregationShared', 461 'Head_AggregationComposite' 462 ) 463 464 tail_popup_menu = ( 465 'Tail_isNavigable', 466 'separator', 467 'Tail_AggregationNone', 468 'Tail_AggregationShared', 469 'Tail_AggregationComposite' 470 ) 471 472 def __init__(self, id=None, end=None): 457 473 self.__gobject_init__() 458 474 DiagramItem.__init__(self, id) 475 self._end = end 459 476 self.set_flags(diacanvas.COMPOSITE) 460 477 … … 477 494 478 495 self._name_bounds = self._mult_bounds = (0, 0, 0, 0) 496 self._point1 = self._point2 = (0, 0) 479 497 480 498 # Ensure we call the right connect functions: … … 486 504 DiagramItem.postload(self) 487 505 #self.set_text() 506 507 def get_popup_menu(self): 508 if self.subject: 509 if self._end == 'head': 510 return self.head_popup_menu 511 else: 512 return self.tail_popup_menu 513 elif self.parent: 514 return self.parent.get_popup_menu() 488 515 489 516 def set_text(self): … … 630 657 self._mult.set_pos((p1[0] + mult_dx, p1[1] + mult_dy)) 631 658 659 self._point1 = p1 660 self._point2 = p2 661 632 662 def on_subject_notify(self, pspec, notifiers=()): 633 663 DiagramItem.on_subject_notify(self, pspec, … … 681 711 d1 = drp(self._name_bounds, p) 682 712 d2 = drp(self._mult_bounds, p) 683 return min(d1, d2) 713 try: 714 d3 = diacanvas.geometry.distance_point_point(self._point1, p) 715 d4, dummy = diacanvas.geometry.distance_line_point(self._point1, self._point2, p, 1.0, diacanvas.shape.CAP_ROUND) 716 if d3 < 15 and d4 < 5: 717 d3 = 0.0 718 except Exception, e: 719 log.error("Could not determine distance", e) 720 d3 = 1000.0 721 return min(d1, d2, d3) 684 722 685 723 def on_shape_iter(self): trunk/gaphor/gaphor/diagram/itemactions.py
r455 r463 109 109 def execute(self): 110 110 item = get_parent_focus_item(self._window) 111 #get_undo_manager().begin_transaction()112 111 item.subject.isAbstract = self.active 113 #get_undo_manager().commit_transaction()114 112 115 113 weave_method(AbstractClassAction.execute, UndoTransactionAspect) … … 145 143 elemfact = gaphor.resource(UML.ElementFactory) 146 144 147 #get_undo_manager().begin_transaction()148 145 attribute = elemfact.create(UML.Property) 149 146 attribute.parse('new') … … 160 157 view.start_editing(vf, wx, wy) 161 158 break 162 #get_undo_manager().commit_transaction()163 159 164 160 weave_method(CreateAttributeAction.execute, UndoTransactionAspect) … … 190 186 elemfact = gaphor.resource(UML.ElementFactory) 191 187 192 #get_undo_manager().begin_transaction()193 188 operation = elemfact.create(UML.Operation) 194 189 operation.parse('new()') … … 204 199 view.start_editing(vf, wx, wy) 205 200 break 206 #get_undo_manager().commit_transaction()207 201 208 202 weave_method(CreateOperationAction.execute, UndoTransactionAspect) … … 219 213 item = self._window.get_current_diagram_view().focus_item.item 220 214 #assert isinstance(subject, (UML.Property, UML.Operation)) 221 #get_undo_manager().begin_transaction()222 215 item.subject.unlink() 223 #get_undo_manager().commit_transaction()224 216 225 217 … … 261 253 def execute(self): 262 254 item = get_parent_focus_item(self._window) 263 #get_undo_manager().begin_transaction()264 255 item.set_property('show-attributes', self.active) 265 #get_undo_manager().commit_transaction()266 256 267 257 weave_method(DeleteOperationAction.execute, UndoTransactionAspect) … … 289 279 def execute(self): 290 280 item = get_parent_focus_item(self._window) 291 #get_undo_manager().begin_transaction()292 281 item.set_property('show-operations', self.active) 293 #get_undo_manager().commit_transaction()294 282 295 283 weave_method(ShowOperationsAction.execute, UndoTransactionAspect) … … 326 314 item, segment = self.get_item_and_segment() 327 315 if item: 328 #get_undo_manager().begin_transaction()329 316 item.set_property('add_segment', segment) 330 #get_undo_manager().commit_transaction()331 317 332 318 weave_method(AddSegmentAction.execute, UndoTransactionAspect) … … 350 336 item, segment = self.get_item_and_segment() 351 337 if item: 352 #get_undo_manager().begin_transaction()353 338 item.set_property('del_segment', segment) 354 #get_undo_manager().commit_transaction()355 339 356 340 weave_method(DeleteSegmentAction.execute, UndoTransactionAspect) … … 377 361 fi = get_parent_focus_item(self._window) 378 362 assert isinstance(fi, diacanvas.CanvasLine) 379 #get_undo_manager().begin_transaction()380 363 if self.active and len(fi.handles) < 3: 381 364 fi.set_property('add_segment', 0) 382 365 fi.set_property('orthogonal', self.active) 383 #get_undo_manager().commit_transaction()384 366 385 367 weave_method(OrthogonalAction.execute, UndoTransactionAspect) … … 407 389 fi = get_parent_focus_item(self._window) 408 390 assert isinstance(fi, diacanvas.CanvasLine) 409 #get_undo_manager().begin_transaction()410 391 fi.set_property('horizontal', self.active) 411 #get_undo_manager().commit_transaction()412 392 413 393 weave_method(OrthogonalAlignmentAction.execute, UndoTransactionAspect) … … 438 418 fi = get_parent_focus_item(self._window) 439 419 assert isinstance(fi, AssociationItem) 440 #get_undo_manager().begin_transaction()441 420 fi.set_property('show-direction', self.active) 442 421 … … 484 463 assert item.subject 485 464 assert isinstance(item.subject, UML.Property) 486 #get_undo_manager().begin_transaction()487 465 item.set_navigable(self.active) 488 #get_undo_manager().commit_transaction()489 466 490 467 weave_method(NavigableAction.execute, UndoTransactionAspect) … … 526 503 subject = get_parent_focus_item(self._window).get_property(self.end_name).subject 527 504 assert isinstance(subject, UML.Property) 528 #get_undo_manager().begin_transaction()529 505 subject.aggregation = self.aggregation 530 #get_undo_manager().commit_transaction()531 506 532 507 weave_method(AggregationAction.execute, UndoTransactionAspect) … … 664 639 if self.active: 665 640 item = get_parent_focus_item(self._window) 666 #get_undo_manager().begin_transaction()667 641 item.set_dependency_type(self.dependency_type) 668 642 #item.auto_dependency = False 669 643 self._window.get_action_pool().execute('AutoDependency', active=False) 670 #get_undo_manager().commit_transaction()671 644 672 645 weave_method(DependencyTypeAction.execute, UndoTransactionAspect) … … 727 700 def execute(self): 728 701 item = get_parent_focus_item(self._window) 729 #get_undo_manager().begin_transaction()730 702 item.auto_dependency = self.active 731 #get_undo_manager().commit_transaction()732 703 733 704 weave_method(AutoDependencyAction.execute, UndoTransactionAspect) … … 754 725 def execute(self): 755 726 item = get_parent_focus_item(self._window) 756 #get_undo_manager().begin_transaction()757 727 item.subject.isIndirectlyInstantiated = self.active 758 #get_undo_manager().commit_transaction()759 728 760 729 weave_method(IndirectlyInstantiatedComponentAction.execute, UndoTransactionAspect) … … 803 772 # get method to move the element: moveUp or moveDown 804 773 move = getattr(self._getElements(cls, item), self.move_action) 805 #get_undo_manager().begin_transaction()806 774 move(item.subject) 807 #get_undo_manager().commit_transaction()808 775 self._window.execute_action('ItemFocus') 809 776 … … 856 823 #log.debug('Action %s: %s' % (self.id, item.subject.name)) 857 824 858 #get_undo_manager().begin_transaction()859 825 item.set_property('drawing-style', InterfaceItem.DRAW_ICON) 860 #get_undo_manager().commit_transaction()861 826 862 827 weave_method(FoldAction.execute, UndoTransactionAspect) … … 873 838 #log.debug('Action %s: %s' % (self.id, item.subject.name)) 874 839 875 #get_undo_manager().begin_transaction()876 840 item.set_property('drawing-style', InterfaceItem.DRAW_COMPARTMENT) 877 #get_undo_manager().commit_transaction()878 841 # Make sure lines are updated properly: 879 842 item.canvas.update_now() … … 902 865 else: 903 866 self.sensitive = isinstance(item, ClassItem) 904 if self.sensitive :867 if self.sensitive and item.subject: 905 868 self.active = self.stereotype in item.subject.appliedStereotype 869 else: 870 self.active = False 906 871 907 872 def execute(self): 908 873 item = get_parent_focus_item(self._window) 909 #get_undo_manager().begin_transaction()910 874 if self.active: 911 875 item.subject.appliedStereotype = self.stereotype 912 876 else: 913 877 del item.subject.appliedStereotype[self.stereotype] 914 #get_undo_manager().commit_transaction()915 878 916 879 weave_method(ApplyStereotypeAction.execute, UndoTransactionAspect) trunk/gaphor/gaphor/ui/diagramactions.py
r460 r463 34 34 register_action(CloseTabAction) 35 35 36 37 class ExportSVGAction(Action):38 id = 'FileExportSVG'39 label = '_Export SVG'40 tooltip = 'Write the contents of this diagram to a SVG file'41 42 def init(self, window):43 self.filename = None44 self._window = window45 46 def update(self):47 tab = self._window.get_current_diagram_tab()48 self.sensitive = tab and True or False49 50 def execute(self):51 filesel = gtk.FileSelection('Export diagram to SVG file')52 filesel.set_modal(True)53 filesel.set_filename(self.filename or self._window.get_current_diagram().name + '.svg' or 'export.svg')54 55 #filesel.ok_button.connect('clicked', self.on_ok_button_pressed, filesel)56 #filesel.cancel_button.connect('clicked',57 # self.on_cancel_button_pressed, filesel)58 59 #filesel.show()60 response = filesel.run()61 filesel.hide()62 if response == gtk.RESPONSE_OK:63 filename = filesel.get_filename()64 if filename and len(filename) > 0:65 self.filename = filename66 log.debug('Exporting SVG image to: %s' % filename)67 canvas = self._window.get_current_diagram_tab().get_canvas()68 export = diacanvas.ExportSVG()69 try:70 export.render (canvas)71 export.save(filename)72 except Exception, e:73 log.error('Error while saving model to file %s: %s' % (filename, e))74 75 register_action(ExportSVGAction)76 36 77 37 class UndoStackAction(Action): trunk/gaphor/gaphor/ui/mainwindow.py
r460 r463 69 69 '<FileImportSlot>',), 70 70 _('_Export'), ( 71 'FileExportSVG', 72 '<FileExportSlot>'), 71 '<FileExportSlot>',), 73 72 'separator', 74 73 'FileCloseTab',
