Changeset 265
- Timestamp:
- 04/07/04 03:49:27 (5 years ago)
- Files:
-
- trunk/gaphor/data/pixmaps/pointer24.png (modified) (previous)
- trunk/gaphor/gaphor/diagram/diagramitem.py (modified) (1 diff)
- trunk/gaphor/gaphor/diagram/itemactions.py (modified) (17 diffs)
- trunk/gaphor/gaphor/ui/abstractwindow.py (modified) (2 diffs)
- trunk/gaphor/gaphor/ui/mainactions.py (modified) (8 diffs)
- trunk/gaphor/gaphor/ui/mainwindow.py (modified) (1 diff)
- trunk/gaphor/gaphor/ui/stock.py (modified) (2 diffs)
- trunk/gaphor/setup.py (modified) (1 diff)
- trunk/gaphor/utils/genUML2.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gaphor/gaphor/diagram/diagramitem.py
r225 r265 186 186 ids = self.__handler_to_id[key] 187 187 except KeyError, e: 188 log.error(e )188 log.error(e, e) 189 189 else: 190 190 for id in ids: trunk/gaphor/gaphor/diagram/itemactions.py
r263 r265 49 49 item.rename() 50 50 51 register_action(ItemRenameAction, 'Item Select')51 register_action(ItemRenameAction, 'ItemFocus') 52 52 53 53 # NOTE: attributes and operations can now only be created on classes, … … 81 81 # TODO: Select this item for editing 82 82 83 register_action(CreateAttributeAction, 'ShowAttributes' )83 register_action(CreateAttributeAction, 'ShowAttributes', 'ItemFocus') 84 84 85 85 … … 110 110 # TODO: Select this item for editing 111 111 112 register_action(CreateOperationAction, 'ShowOperations' )112 register_action(CreateOperationAction, 'ShowOperations', 'ItemFocus') 113 113 114 114 … … 126 126 item.edit() 127 127 128 register_action(EditItemAction )128 register_action(EditItemAction, 'ItemFocus') 129 129 130 130 … … 145 145 tooltip='Delete the selected attribute' 146 146 147 register_action(DeleteAttributeAction, 'ShowAttributes', 'CreateAttribute' )147 register_action(DeleteAttributeAction, 'ShowAttributes', 'CreateAttribute', 'ItemFocus') 148 148 149 149 … … 153 153 tooltip = 'Delete the selected operation' 154 154 155 register_action(DeleteOperationAction, 'ShowOperations', 'CreateOperation' )155 register_action(DeleteOperationAction, 'ShowOperations', 'CreateOperation', 'ItemFocus') 156 156 157 157 … … 236 236 item.set_property('add_segment', segment) 237 237 238 register_action(AddSegmentAction )238 register_action(AddSegmentAction, 'ItemFocus') 239 239 240 240 … … 304 304 305 305 def update(self): 306 item = get_parent_focus_item(self._window) 307 from association import AssociationItem 308 if isinstance(item, AssociationItem): 309 end = item.get_property(self.end_name) 310 if end.subject: 311 self.active = (end.subject.class_ != None) 306 try: 307 item = get_parent_focus_item(self._window) 308 from association import AssociationItem 309 if isinstance(item, AssociationItem): 310 end = item.get_property(self.end_name) 311 if end.subject: 312 self.active = (end.subject.class_ != None) 313 except NoFocusItemError: 314 pass 312 315 313 316 def execute(self): … … 323 326 end_name = 'head' 324 327 325 register_action(HeadNavigableAction )328 register_action(HeadNavigableAction, 'ItemFocus') 326 329 327 330 … … 331 334 end_name = 'tail' 332 335 333 register_action(TailNavigableAction )336 register_action(TailNavigableAction, 'ItemFocus') 334 337 335 338 … … 340 343 341 344 def update(self): 342 item = get_parent_focus_item(self._window) 343 from association import AssociationItem 344 if isinstance(item, AssociationItem): 345 end = item.get_property(self.end_name) 346 if end.subject: 347 self.active = (end.subject.aggregation == self.aggregation) 345 try: 346 item = get_parent_focus_item(self._window) 347 from association import AssociationItem 348 if isinstance(item, AssociationItem): 349 end = item.get_property(self.end_name) 350 if end.subject: 351 self.active = (end.subject.aggregation == self.aggregation) 352 except NoFocusItemError: 353 pass 348 354 349 355 def execute(self): … … 361 367 aggregation = 'none' 362 368 363 register_action(HeadNoneAction )369 register_action(HeadNoneAction, 'ItemFocus') 364 370 365 371 … … 371 377 aggregation = 'shared' 372 378 373 register_action(HeadSharedAction )379 register_action(HeadSharedAction, 'ItemFocus') 374 380 375 381 … … 381 387 aggregation = 'composite' 382 388 383 register_action(HeadCompositeAction )389 register_action(HeadCompositeAction, 'ItemFocus') 384 390 385 391 … … 391 397 aggregation = 'none' 392 398 393 register_action(TailNoneAction )399 register_action(TailNoneAction, 'ItemFocus') 394 400 395 401 … … 401 407 aggregation = 'shared' 402 408 403 register_action(TailSharedAction )409 register_action(TailSharedAction, 'ItemFocus') 404 410 405 411 … … 411 417 aggregation = 'composite' 412 418 413 register_action(TailCompositeAction )419 register_action(TailCompositeAction, 'ItemFocus') trunk/gaphor/gaphor/ui/abstractwindow.py
r231 r265 121 121 log.warning(str(e), e) 122 122 123 def _construct_as_window(self, title, size, contents):124 125 self._set_state(AbstractWindow.STATE_ACTIVE)126 127 window = gtk.Window()128 window.set_title(title)129 130 window.set_size_request(size[0], size[1])131 window.set_resizable(True)132 133 vbox = gtk.VBox()134 window.add(vbox)135 vbox.show()136 137 accel_group = gtk.AccelGroup()138 window.add_accel_group(accel_group)139 140 statusbar = gtk.Statusbar()141 vbox.pack_end(statusbar, expand=False)142 statusbar.show()143 144 # Set the contents:145 vbox.pack_end(contents, expand=True)146 147 self.menu_factory = MenuFactory(self.action_pool,148 accel_group=accel_group,149 statusbar=statusbar,150 statusbar_context=0)151 152 menubar = self.menu_factory.create_menu(self.menu)153 vbox.pack_start(menubar, expand=False)154 menubar.show()155 156 if self.toolbar:157 toolbar = self.menu_factory.create_toolbar(self.toolbar)158 #handle_box = gtk.HandleBox()159 #handle_box.add(toolbar)160 vbox.pack_start(toolbar, expand=False)161 #vbox.pack_start(handle_box, expand=False)162 #handle_box.show()163 toolbar.show()164 165 self.__destroy_id = window.connect('destroy', self._on_window_destroy)166 # On focus in/out a log handler is added to the logger.167 #window.connect('focus_in_event', self._on_window_focus_in_event)168 #window.connect('focus_out_event', self._on_window_focus_out_event)169 # Set state before commands are created, so the commands can use170 # the get_* methods.171 172 window.show()173 174 self.window = window175 self.statusbar = statusbar176 self.accel_group = accel_group177 178 def _construct_as_notebook_page(self, title, size, contents):179 self._check_state(AbstractWindow.STATE_INIT)180 #window = bonobo.ui.Window ('gaphor.' + name, title)181 182 self.window = self.owning_window.window183 self.statusbar = self.owning_window.statusbar184 185 hbox = gtk.HBox()186 hbox.show()187 188 # Set the contents:189 hbox.pack_end(contents, expand=True)190 191 self.menu_factory = MenuFactory(self.action_pool,192 accel_group=self.owning_window.accel_group,193 statusbar=self.statusbar,194 statusbar_context=0)195 196 #if self.toolbar:197 # toolbar = self.menu_factory.create_toolbar(self.toolbar)198 # toolbar.set_orientation(gtk.ORIENTATION_VERTICAL)199 # hbox.pack_start(toolbar, expand=False)200 # toolbar.show()201 202 self.__destroy_id = hbox.connect('destroy', self._on_window_destroy)203 # On focus in/out a log handler is added to the logger.204 #window.connect('focus_in_event', self._on_window_focus_in_event)205 #window.connect('focus_out_event', self._on_window_focus_out_event)206 # Set state before commands are created, so the commands can use207 # the get_* methods.208 self._set_state(AbstractWindow.STATE_ACTIVE)209 210 self.notebook_page_number = self.owning_window.new_notebook_tab(self, hbox, title)211 212 123 213 124 def _construct_window(self, name, title, size, contents): … … 224 135 self.name = name 225 136 226 if self.sub_window: 227 self._construct_as_window(title, size, contents) 228 else: 229 self._construct_as_notebook_page(title, size, contents) 137 self._set_state(AbstractWindow.STATE_ACTIVE) 138 139 window = gtk.Window(gtk.WINDOW_TOPLEVEL) 140 window.set_title(title) 141 142 window.set_size_request(size[0], size[1]) 143 window.set_resizable(True) 144 145 vbox = gtk.VBox() 146 window.add(vbox) 147 vbox.show() 148 149 accel_group = gtk.AccelGroup() 150 window.add_accel_group(accel_group) 151 152 statusbar = gtk.Statusbar() 153 vbox.pack_end(statusbar, expand=False) 154 statusbar.show() 155 156 # Set the contents: 157 vbox.pack_end(contents, expand=True) 158 159 self.menu_factory = MenuFactory(self.action_pool, 160 accel_group=accel_group, 161 statusbar=statusbar, 162 statusbar_context=0) 163 164 menubar = self.menu_factory.create_menu(self.menu) 165 vbox.pack_start(menubar, expand=False) 166 menubar.show() 167 168 if self.toolbar: 169 toolbar = self.menu_factory.create_toolbar(self.toolbar) 170 #handle_box = gtk.HandleBox() 171 #handle_box.add(toolbar) 172 vbox.pack_start(toolbar, expand=False) 173 #vbox.pack_start(handle_box, expand=False) 174 #handle_box.show() 175 toolbar.show() 176 177 self.__destroy_id = window.connect('destroy', self._on_window_destroy) 178 # On focus in/out a log handler is added to the logger. 179 #window.connect('focus_in_event', self._on_window_focus_in_event) 180 #window.connect('focus_out_event', self._on_window_focus_out_event) 181 # Set state before commands are created, so the commands can use 182 # the get_* methods. 183 184 window.show() 185 186 self.window = window 187 self.statusbar = statusbar 188 self.accel_group = accel_group 189 230 190 231 191 def _construct_popup_menu(self, menu_def, event): trunk/gaphor/gaphor/ui/mainactions.py
r251 r265 15 15 16 16 DEFAULT_EXT='.gaphor' 17 18 def main_loop(): 19 main = gobject.main_context_default() 20 while main.pending(): main.iteration(False) 21 17 22 18 23 class NewAction(Action): … … 53 58 self._window = window 54 59 60 def show_status_window(self, title, message): 61 win = gtk.Window(gtk.WINDOW_TOPLEVEL) 62 win.set_title(title) 63 win.set_position(gtk.WIN_POS_CENTER_ON_PARENT) 64 win.set_parent(self._window.get_window()) 65 label = gtk.Label(message) 66 label.set_padding(30,30) 67 win.add(label) 68 win.show_all() 69 return win 70 55 71 def execute(self): 56 72 filesel = gtk.FileSelection('Open Gaphor file') … … 60 76 response = filesel.run() 61 77 filesel.hide() 62 main = gobject.main_context_default() 63 while main.pending(): 64 main.iteration(False) 78 main_loop() 65 79 if response == gtk.RESPONSE_OK: 66 80 filename = filesel.get_filename() 67 81 if filename: 68 82 log.debug('Loading from: %s' % filename) 83 win = self.show_status_window('Loading...', 'Loading model from %s' % filename) 84 main_loop() 69 85 self.filename = filename 70 86 gc.collect() … … 86 102 log.error('Error while loading model from file %s: %s' % (filename, e)) 87 103 traceback.print_exc() 104 win.destroy() 88 105 filesel.destroy() 89 106 … … 91 108 92 109 93 class SaveA ction(Action):94 id = 'FileSave '95 stock_id = 'gtk-save '110 class SaveAsAction(Action): 111 id = 'FileSaveAs' 112 stock_id = 'gtk-save-as' 96 113 97 114 def init(self, window): … … 104 121 105 122 def on_element_factory(self, *args): 106 factory = self.factory107 if factory.values():123 #factory = gaphor.resource('ElementFactory') 124 if self.factory.values(): 108 125 self.sensitive = True 109 126 else: … … 114 131 self.factory.disconnect(self.on_element_factory) 115 132 116 def execute(self):117 filename = self._window.get_filename()118 if not filename:119 filesel = gtk.FileSelection('Save file')120 response = filesel.run()121 filesel.hide()122 main = gobject.main_context_default()123 while main.pending():124 main.iteration(False)125 if response == gtk.RESPONSE_OK:126 filename = filesel.get_filename() 127 filesel.destroy() 133 def show_status_window(self, title, message): 134 win = gtk.Window(gtk.WINDOW_TOPLEVEL) 135 win.set_title(title) 136 win.set_parent(self._window.get_window()) 137 win.set_position(gtk.WIN_POS_CENTER_ON_PARENT) 138 label = gtk.Label(message) 139 label.set_padding(30,30) 140 win.add(label) 141 win.show_all() 142 return win 143 144 def save(self, filename): 128 145 if filename and len(filename) > 0: 129 146 if not filename.endswith(DEFAULT_EXT): 130 147 filename = filename + DEFAULT_EXT 131 148 log.debug('Saving to: %s' % filename) 132 try: 133 import gaphor.storage as storage 134 storage.save(filename) 135 self._window.set_filename(filename) 136 self._window.set_message('Model saved to %s' % filename) 137 except Exception, e: 138 log.error('Failed to save to file %s: %s' % (filename, e)) 139 traceback.print_exc() 140 141 register_action(SaveAction) 142 143 144 class SaveAsAction(Action): 145 id = 'FileSaveAs' 146 stock_id = 'gtk-save-as' 147 148 def init(self, window): 149 self._window = window 150 factory = gaphor.resource('ElementFactory') 151 factory.connect(self.on_element_factory) 152 self.on_element_factory(self) 153 154 def on_element_factory(self, *args): 155 factory = gaphor.resource('ElementFactory') 156 if factory.values(): 157 self.sensitive = True 158 else: 159 self.sensitive = False 160 161 def execute(self): 162 filesel = gtk.FileSelection('Save file as') 163 response = filesel.run() 164 filesel.hide() 165 main = gobject.main_context_default() 166 while main.pending(): 167 main.iteration(False) 168 filename = None 169 if response == gtk.RESPONSE_OK: 170 filename = filesel.get_filename() 171 filesel.destroy() 172 if filename and len(filename) > 0: 173 if not filename.endswith(DEFAULT_EXT): 174 filename = filename + DEFAULT_EXT 175 log.debug('Saving to: %s' % filename) 149 win = self.show_status_window('Saving...', 'Saving model to %s' % filename) 150 main_loop() 176 151 try: 177 152 import gaphor.storage as storage … … 181 156 log.error('Failed to save to file %s: %s' % (filename, e)) 182 157 traceback.print_exc() 158 win.destroy() 159 160 def execute(self): 161 filename = self._window.get_filename() 162 filesel = gtk.FileSelection('Save file as') 163 filesel.set_filename(filename or '') 164 response = filesel.run() 165 filesel.hide() 166 main_loop() 167 filename = None 168 if response == gtk.RESPONSE_OK: 169 filename = filesel.get_filename() 170 filesel.destroy() 171 self.save(filename) 183 172 184 173 register_action(SaveAsAction) 174 175 176 class SaveAction(SaveAsAction): 177 id = 'FileSave' 178 stock_id = 'gtk-save' 179 180 def execute(self): 181 filename = self._window.get_filename() 182 if filename: 183 self.save(filename) 184 else: 185 SaveAsAction.execute(self) 186 187 register_action(SaveAction) 185 188 186 189 trunk/gaphor/gaphor/ui/mainwindow.py
r263 r265 144 144 self._construct_window(name='main', 145 145 title='Gaphor v' + gaphor.resource('Version'), 146 size=( 600, 400),146 size=(760, 580), 147 147 contents=paned) 148 148 #contents=scrolled_window) trunk/gaphor/gaphor/ui/stock.py
r263 r265 8 8 import gaphor.UML as UML 9 9 10 print '===> ',UML.__file__11 10 STOCK_POINTER = 'gaphor-pointer' 12 11 STOCK_ACTOR = 'gaphor-actor' … … 60 59 61 60 # Initialize stock icons: 62 add_stock_icon(STOCK_POINTER, icon_dir, ('pointer24.png', 'pointer16.png'))63 add_stock_icon(STOCK_ACTOR, icon_dir, ('actor24.png', 'actor16.png'), UML.Actor)64 add_stock_icon(STOCK_ASSOCIATION, icon_dir, ('association24.png', 'association16.png'), UML.Association)61 add_stock_icon(STOCK_POINTER, icon_dir, ('pointer24.png',)) 62 add_stock_icon(STOCK_ACTOR, icon_dir, ('actor24.png',), UML.Actor) 63 add_stock_icon(STOCK_ASSOCIATION, icon_dir, ('association24.png',), UML.Association) 65 64 add_stock_icon(STOCK_CLASS, icon_dir, ('class24.png',), UML.Class) 66 add_stock_icon(STOCK_DEPENDENCY, icon_dir, ('dependency24.png', 'dependency16.png'), UML.Dependency)67 add_stock_icon(STOCK_DIAGRAM, icon_dir, ('diagram24.png', 'diagram16.png'), UML.Diagram)65 add_stock_icon(STOCK_DEPENDENCY, icon_dir, ('dependency24.png',), UML.Dependency) 66 add_stock_icon(STOCK_DIAGRAM, icon_dir, ('diagram24.png',), UML.Diagram) 68 67 add_stock_icon(STOCK_COMMENT, icon_dir, ('comment24.png',), UML.Comment) 69 add_stock_icon(STOCK_COMMENT_LINE, icon_dir, ('commentline24.png', 'commentline16.png'))68 add_stock_icon(STOCK_COMMENT_LINE, icon_dir, ('commentline24.png',)) 70 69 add_stock_icon(STOCK_GENERALIZATION, icon_dir, ('generalization24.png',), UML.Generalization) 71 add_stock_icon(STOCK_OPERATION, icon_dir, ('pointer24.png', 'pointer16.png'), UML.Operation)70 add_stock_icon(STOCK_OPERATION, icon_dir, ('pointer24.png',), UML.Operation) 72 71 add_stock_icon(STOCK_PACKAGE, icon_dir, ('package24.png',), UML.Package) 73 add_stock_icon(STOCK_PROPERTY, icon_dir, ('pointer24.png', 'pointer16.png'), UML.Property)74 add_stock_icon(STOCK_PARAMETER, icon_dir, ('pointer24.png', 'pointer16.png'), UML.Parameter)75 add_stock_icon(STOCK_USECASE, icon_dir, ('usecase24.png', 'usecase16.png'), UML.UseCase)72 add_stock_icon(STOCK_PROPERTY, icon_dir, ('pointer24.png',), UML.Property) 73 add_stock_icon(STOCK_PARAMETER, icon_dir, ('pointer24.png',), UML.Parameter) 74 add_stock_icon(STOCK_USECASE, icon_dir, ('usecase24.png',), UML.UseCase) 76 75 77 76 del icon_dir trunk/gaphor/setup.py
r251 r265 75 75 self.module_check('gnome') 76 76 self.module_check('gnome.canvas') 77 self.module_check('gconf')78 self.module_check('diacanvas', ('diacanvas_version', (0, 9, 2)))77 #self.module_check('gconf') 78 self.module_check('diacanvas', ('diacanvas_version', (0, 12, 0))) 79 79 80 80 print '' trunk/gaphor/utils/genUML2.py
r219 r265 434 434 435 435 if __name__ == '__main__': 436 generate(' UML2.gaphor')436 generate('uml2.gaphor')
