Beispiel #1
0
 def save_dialog(self, diagram, title, ext, mime_type):
     dot_ext = f".{ext}"
     filename = (diagram.name or "export") + dot_ext
     return save_file_dialog(
         title,
         filename=filename,
         extension=ext,
         filters=[(gettext("All {ext} Files").format(ext=ext.upper()),
                   dot_ext, mime_type)],
     )
Beispiel #2
0
    def execute(self):
        filename = self.file_manager.filename
        filename = filename.replace(".gaphor",
                                    ".xmi") if filename else "model.xmi"
        filename = save_file_dialog(
            gettext("Export model to XMI file"),
            filename=filename,
            extension=".xmi",
            filters=[(gettext("All XMI Files"), ".xmi", "text/xml")],
        )

        if filename and len(filename) > 0:
            logger.debug(f"Exporting XMI model to: {filename}")
            export = exportmodel.XMIExport(self.element_factory)
            try:
                export.export(filename)
            except Exception as e:
                logger.error(
                    f"Error while saving model to file {filename}: {e}")
Beispiel #3
0
    def action_save_as(self):
        """Save the model in the element_factory by allowing the user to select
        a file name.

        Returns True if the saving actually happened.
        """

        filename = save_file_dialog(
            gettext("Save Gaphor Model As"),
            parent=self.main_window.window,
            filename=self.filename,
            extension=".gaphor",
            filters=GAPHOR_FILTER,
        )

        if filename:
            self.save(filename)
            return True

        return False