root/gaphor-plugins/sandbox/kidexport/__init__.py

Revision 573, 1.1 kB (checked in by slmm, 3 years ago)

Added new Kid (http://kid.lesscode.org) based exporter for XMI. Kid is a
Pythonic templating language. The goal of this export facility is to get higher
compatibility with Poseidon's file format.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 # vim:sw=4:et
2
3 import gtk
4 from exportmodel import KidExport       
5 from gaphor.plugin import Action
6
7
8 class KidExportAction(Action):
9
10     def execute(self):
11         filename = self.get_window().get_filename()
12         if filename:
13             filename = filename.replace('.gaphor', '.xmi')
14         else:
15             filename = 'model.xmi'
16
17         filesel = gtk.FileChooserDialog(title='Export model to XMI file',
18                                         action=gtk.FILE_CHOOSER_ACTION_SAVE,
19                                         buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK))
20         filesel.set_current_name(filename)
21
22         response = filesel.run()
23         filename = filesel.get_filename()
24         filesel.destroy()
25         if response == gtk.RESPONSE_OK:
26             if filename and len(filename) > 0:
27                 log.debug('Exporting XMI model to: %s' % filename)
28                 export = KidExport()
29                 try:
30                     export.export(filename)
31                 except Exception, e:
32                     log.error('Error while saving model to file %s: %s' % (filename, e))
33
Note: See TracBrowser for help on using the browser.