Changeset 265

Show
Ignore:
Timestamp:
04/07/04 03:49:27 (5 years ago)
Author:
arjanmol
Message:

*** empty log message ***

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gaphor/gaphor/diagram/diagramitem.py

    r225 r265  
    186186                ids = self.__handler_to_id[key] 
    187187            except KeyError, e: 
    188                 log.error(e
     188                log.error(e, e
    189189            else: 
    190190                for id in ids: 
  • trunk/gaphor/gaphor/diagram/itemactions.py

    r263 r265  
    4949        item.rename() 
    5050 
    51 register_action(ItemRenameAction, 'ItemSelect') 
     51register_action(ItemRenameAction, 'ItemFocus') 
    5252 
    5353# NOTE: attributes and operations can now only be created on classes, 
     
    8181        # TODO: Select this item for editing 
    8282 
    83 register_action(CreateAttributeAction, 'ShowAttributes'
     83register_action(CreateAttributeAction, 'ShowAttributes', 'ItemFocus'
    8484 
    8585 
     
    110110        # TODO: Select this item for editing 
    111111 
    112 register_action(CreateOperationAction, 'ShowOperations'
     112register_action(CreateOperationAction, 'ShowOperations', 'ItemFocus'
    113113 
    114114 
     
    126126        item.edit() 
    127127 
    128 register_action(EditItemAction
     128register_action(EditItemAction, 'ItemFocus'
    129129 
    130130 
     
    145145    tooltip='Delete the selected attribute' 
    146146 
    147 register_action(DeleteAttributeAction, 'ShowAttributes', 'CreateAttribute'
     147register_action(DeleteAttributeAction, 'ShowAttributes', 'CreateAttribute', 'ItemFocus'
    148148 
    149149 
     
    153153    tooltip = 'Delete the selected operation' 
    154154 
    155 register_action(DeleteOperationAction, 'ShowOperations', 'CreateOperation'
     155register_action(DeleteOperationAction, 'ShowOperations', 'CreateOperation', 'ItemFocus'
    156156 
    157157 
     
    236236            item.set_property('add_segment', segment) 
    237237             
    238 register_action(AddSegmentAction
     238register_action(AddSegmentAction, 'ItemFocus'
    239239 
    240240 
     
    304304 
    305305    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 
    312315 
    313316    def execute(self): 
     
    323326    end_name = 'head' 
    324327 
    325 register_action(HeadNavigableAction
     328register_action(HeadNavigableAction, 'ItemFocus'
    326329 
    327330 
     
    331334    end_name = 'tail' 
    332335 
    333 register_action(TailNavigableAction
     336register_action(TailNavigableAction, 'ItemFocus'
    334337 
    335338 
     
    340343 
    341344    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 
    348354 
    349355    def execute(self): 
     
    361367    aggregation = 'none' 
    362368 
    363 register_action(HeadNoneAction
     369register_action(HeadNoneAction, 'ItemFocus'
    364370 
    365371 
     
    371377    aggregation = 'shared' 
    372378 
    373 register_action(HeadSharedAction
     379register_action(HeadSharedAction, 'ItemFocus'
    374380 
    375381 
     
    381387    aggregation = 'composite' 
    382388 
    383 register_action(HeadCompositeAction
     389register_action(HeadCompositeAction, 'ItemFocus'
    384390 
    385391 
     
    391397    aggregation = 'none' 
    392398 
    393 register_action(TailNoneAction
     399register_action(TailNoneAction, 'ItemFocus'
    394400 
    395401 
     
    401407    aggregation = 'shared' 
    402408 
    403 register_action(TailSharedAction
     409register_action(TailSharedAction, 'ItemFocus'
    404410 
    405411 
     
    411417    aggregation = 'composite' 
    412418 
    413 register_action(TailCompositeAction
     419register_action(TailCompositeAction, 'ItemFocus'
  • trunk/gaphor/gaphor/ui/abstractwindow.py

    r231 r265  
    121121            log.warning(str(e), e) 
    122122 
    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 use 
    170         # the get_* methods. 
    171  
    172         window.show() 
    173  
    174         self.window = window 
    175         self.statusbar = statusbar 
    176         self.accel_group = accel_group 
    177  
    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.window 
    183         self.statusbar = self.owning_window.statusbar 
    184  
    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 use 
    207         # 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  
    212123 
    213124    def _construct_window(self, name, title, size, contents): 
     
    224135        self.name = name 
    225136 
    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 
    230190 
    231191    def _construct_popup_menu(self, menu_def, event): 
  • trunk/gaphor/gaphor/ui/mainactions.py

    r251 r265  
    1515 
    1616DEFAULT_EXT='.gaphor' 
     17 
     18def main_loop(): 
     19    main = gobject.main_context_default() 
     20    while main.pending(): main.iteration(False) 
     21 
    1722 
    1823class NewAction(Action): 
     
    5358        self._window = window 
    5459 
     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 
    5571    def execute(self): 
    5672        filesel = gtk.FileSelection('Open Gaphor file') 
     
    6076        response = filesel.run() 
    6177        filesel.hide() 
    62         main = gobject.main_context_default() 
    63         while main.pending(): 
    64             main.iteration(False) 
     78        main_loop() 
    6579        if response == gtk.RESPONSE_OK: 
    6680            filename = filesel.get_filename() 
    6781            if filename: 
    6882                log.debug('Loading from: %s' % filename) 
     83                win = self.show_status_window('Loading...', 'Loading model from %s' % filename) 
     84                main_loop() 
    6985                self.filename = filename 
    7086                gc.collect() 
     
    86102                    log.error('Error while loading model from file %s: %s' % (filename, e)) 
    87103                    traceback.print_exc() 
     104                win.destroy() 
    88105        filesel.destroy() 
    89106 
     
    91108 
    92109 
    93 class SaveAction(Action): 
    94     id = 'FileSave
    95     stock_id = 'gtk-save
     110class SaveAsAction(Action): 
     111    id = 'FileSaveAs
     112    stock_id = 'gtk-save-as
    96113 
    97114    def init(self, window): 
     
    104121 
    105122    def on_element_factory(self, *args): 
    106         factory = self.factory 
    107         if factory.values(): 
     123        #factory = gaphor.resource('ElementFactory') 
     124        if self.factory.values(): 
    108125            self.sensitive = True 
    109126        else: 
     
    114131            self.factory.disconnect(self.on_element_factory) 
    115132 
    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): 
    128145        if filename and len(filename) > 0: 
    129146            if not filename.endswith(DEFAULT_EXT): 
    130147                filename = filename + DEFAULT_EXT 
    131148            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() 
    176151            try: 
    177152                import gaphor.storage as storage 
     
    181156                log.error('Failed to save to file %s: %s' % (filename, e)) 
    182157                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) 
    183172 
    184173register_action(SaveAsAction) 
     174 
     175 
     176class 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 
     187register_action(SaveAction) 
    185188 
    186189 
  • trunk/gaphor/gaphor/ui/mainwindow.py

    r263 r265  
    144144        self._construct_window(name='main', 
    145145                               title='Gaphor v' + gaphor.resource('Version'), 
    146                                size=(600, 400), 
     146                               size=(760, 580), 
    147147                               contents=paned) 
    148148                               #contents=scrolled_window) 
  • trunk/gaphor/gaphor/ui/stock.py

    r263 r265  
    88import gaphor.UML as UML 
    99 
    10 print '===> ',UML.__file__ 
    1110STOCK_POINTER = 'gaphor-pointer' 
    1211STOCK_ACTOR = 'gaphor-actor' 
     
    6059 
    6160# 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) 
     61add_stock_icon(STOCK_POINTER,   icon_dir, ('pointer24.png',)) 
     62add_stock_icon(STOCK_ACTOR,     icon_dir, ('actor24.png',), UML.Actor) 
     63add_stock_icon(STOCK_ASSOCIATION, icon_dir, ('association24.png',), UML.Association) 
    6564add_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) 
     65add_stock_icon(STOCK_DEPENDENCY, icon_dir, ('dependency24.png',), UML.Dependency) 
     66add_stock_icon(STOCK_DIAGRAM,   icon_dir, ('diagram24.png',), UML.Diagram) 
    6867add_stock_icon(STOCK_COMMENT,   icon_dir, ('comment24.png',), UML.Comment) 
    69 add_stock_icon(STOCK_COMMENT_LINE, icon_dir, ('commentline24.png', 'commentline16.png')) 
     68add_stock_icon(STOCK_COMMENT_LINE, icon_dir, ('commentline24.png',)) 
    7069add_stock_icon(STOCK_GENERALIZATION, icon_dir, ('generalization24.png',), UML.Generalization) 
    71 add_stock_icon(STOCK_OPERATION, icon_dir, ('pointer24.png', 'pointer16.png'), UML.Operation) 
     70add_stock_icon(STOCK_OPERATION, icon_dir, ('pointer24.png',), UML.Operation) 
    7271add_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) 
     72add_stock_icon(STOCK_PROPERTY,  icon_dir, ('pointer24.png',), UML.Property) 
     73add_stock_icon(STOCK_PARAMETER, icon_dir, ('pointer24.png',), UML.Parameter) 
     74add_stock_icon(STOCK_USECASE,   icon_dir, ('usecase24.png',), UML.UseCase) 
    7675 
    7776del icon_dir 
  • trunk/gaphor/setup.py

    r251 r265  
    7575        self.module_check('gnome') 
    7676        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))) 
    7979 
    8080        print '' 
  • trunk/gaphor/utils/genUML2.py

    r219 r265  
    434434 
    435435if __name__ == '__main__': 
    436     generate('UML2.gaphor') 
     436    generate('uml2.gaphor')