Example #1
0
    def action_new_from_template(self):
        """This menu action opens the new model from template dialog."""

        filters = [
            {
                "name": _("Gaphor Models"),
                "pattern": "*.gaphor"
            },
            {
                "name": _("All Files"),
                "pattern": "*"
            },
        ]

        file_dialog = FileDialog(_("New Gaphor Model From Template"),
                                 filters=filters)

        filename = file_dialog.selection

        file_dialog.destroy()

        log.debug(filename)

        if filename:
            self.load(filename)
            self.filename = None
            self.event_manager.handle(FileManagerStateChanged(self))
Example #2
0
    def action_open(self):
        """This menu action opens the standard model open dialog."""

        filters = [
            {
                "name": _("Gaphor Models"),
                "pattern": "*.gaphor"
            },
            {
                "name": _("All Files"),
                "pattern": "*"
            },
        ]

        file_dialog = FileDialog(_("Open Gaphor Model"), filters=filters)

        filename = file_dialog.selection

        file_dialog.destroy()

        log.debug(filename)

        if filename:
            self.load(filename)
            self.event_manager.handle(FileManagerStateChanged(self))
Example #3
0
    def save_dialog(self, diagram, title, ext):

        filename = (diagram.name or "export") + ext
        file_dialog = FileDialog(title, action="save", filename=filename)

        save = False
        while True:
            filename = file_dialog.selection
            if os.path.exists(filename):
                question = (
                    _(
                        "The file %s already exists. Do you want to "
                        "replace it with the file you are exporting "
                        "to?"
                    )
                    % filename
                )
                question_dialog = QuestionDialog(question)
                answer = question_dialog.answer
                question_dialog.destroy()
                if answer:
                    save = True
                    break
            else:
                save = True
                break

        file_dialog.destroy()

        if save and filename:
            return filename
Example #4
0
    def save_dialog(self, diagram, title, ext):

        filename = (diagram.name or "export") + ext
        file_dialog = FileDialog(title, action="save", filename=filename)

        save = False
        while True:
            filename = file_dialog.selection
            if os.path.exists(filename):
                question = gettext(
                    "The file {filename} already exists. Do you want to replace it?"
                ).format(filename=filename)
                question_dialog = QuestionDialog(question)
                answer = question_dialog.answer
                question_dialog.destroy()
                if answer:
                    save = True
                    break
            else:
                save = True
                break

        file_dialog.destroy()

        if save and filename:
            return filename
Example #5
0
    def action_new_from_template(self):
        """This menu action opens the new model from template dialog."""

        filters = [
            {
                "name": gettext("Gaphor Models"),
                "pattern": "*.gaphor"
            },
            {
                "name": gettext("All Files"),
                "pattern": "*"
            },
        ]

        file_dialog = FileDialog(gettext("New Gaphor Model From Template"),
                                 filters=filters)

        filename = file_dialog.selection

        file_dialog.destroy()

        log.debug(filename)

        if filename:
            self.load(filename)
            self.filename = None
Example #6
0
    def save_dialog(self, diagram, title, ext):

        filename = (diagram.name or "export") + ext
        file_dialog = FileDialog(title, action="save", filename=filename)

        save = False
        while True:
            filename = file_dialog.selection
            if os.path.exists(filename):
                question = (_("The file %s already exists. Do you want to "
                              "replace it with the file you are exporting "
                              "to?") % filename)
                question_dialog = QuestionDialog(question)
                answer = question_dialog.answer
                question_dialog.destroy()
                if answer:
                    save = True
                    break
            else:
                save = True
                break

        file_dialog.destroy()

        if save and filename:
            return filename
Example #7
0
    def file_dialog(self, title):
        file_dialog = FileDialog(title,
                                 filters=FILTERS,
                                 parent=self.main_window.window)

        filename = file_dialog.selection

        file_dialog.destroy()

        log.debug(filename)

        return filename
Example #8
0
    def action_open(self):
        """This menu action opens the standard model open dialog."""

        filters = [{'name':_('Gaphor Models'), 'pattern':'*.gaphor'},\
                   {'name':_('All Files'), 'pattern':'*'}]

        file_dialog = FileDialog(_('Open Gaphor Model'),\
                                 filters = filters)
        
        filename = file_dialog.selection
        
        file_dialog.destroy()

        log.debug(filename)

        if filename:
            self.load(filename)
            self.component_registry.handle(FileManagerStateChanged(self))
Example #9
0
    def action_open(self):
        """This menu action opens the standard model open dialog."""

        filters = [{'name':_('Gaphor Models'), 'pattern':'*.gaphor'},\
                   {'name':_('All Files'), 'pattern':'*'}]

        file_dialog = FileDialog(_('Open Gaphor Model'),\
                                 filters = filters)
        
        filename = file_dialog.selection
        
        file_dialog.destroy()

        log.debug(filename)

        if filename:
            self.load(filename)
            self.component_registry.handle(FileManagerStateChanged(self))
Example #10
0
    def action_open(self):
        """This menu action opens the standard model open dialog."""

        filters = [
            {"name": _("Gaphor Models"), "pattern": "*.gaphor"},
            {"name": _("All Files"), "pattern": "*"},
        ]

        file_dialog = FileDialog(_("Open Gaphor Model"), filters=filters)

        filename = file_dialog.selection

        file_dialog.destroy()

        log.debug(filename)

        if filename:
            self.load(filename)
            self.component_registry.handle(FileManagerStateChanged(self))
Example #11
0
    def action_new_from_template(self):
        """This menu action opens the new model from template dialog."""

        filters = [{'name':_('Gaphor Models'), 'pattern':'*.gaphor'},\
                   {'name':_('All Files'), 'pattern':'*'}]

        file_dialog = FileDialog(_('New Gaphor Model From Template'),\
                                 filters = filters)
        
        filename = file_dialog.selection
        
        file_dialog.destroy()
        
        log.debug(filename)

        if filename:
            self.load(filename)
            self.filename = None
            self.component_registry.handle(FileManagerStateChanged(self))
Example #12
0
    def action_new_from_template(self):
        """This menu action opens the new model from template dialog."""

        filters = [{'name':_('Gaphor Models'), 'pattern':'*.gaphor'},\
                   {'name':_('All Files'), 'pattern':'*'}]

        file_dialog = FileDialog(_('New Gaphor Model From Template'),\
                                 filters = filters)
        
        filename = file_dialog.selection
        
        file_dialog.destroy()
        
        log.debug(filename)

        if filename:
            self.load(filename)
            self.filename = None
            self.component_registry.handle(FileManagerStateChanged(self))
Example #13
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.
        """

        file_dialog = FileDialog(
            gettext("Save Gaphor Model As"), action="save", filename=self.filename
        )

        filename = file_dialog.selection

        file_dialog.destroy()

        if filename:
            self.save(filename)
            return True

        return False
Example #14
0
    def action_new_from_template(self):
        """This menu action opens the new model from template dialog."""

        filters = [
            {"name": _("Gaphor Models"), "pattern": "*.gaphor"},
            {"name": _("All Files"), "pattern": "*"},
        ]

        file_dialog = FileDialog(_("New Gaphor Model From Template"), filters=filters)

        filename = file_dialog.selection

        file_dialog.destroy()

        log.debug(filename)

        if filename:
            self.load(filename)
            self.filename = None
            self.component_registry.handle(FileManagerStateChanged(self))
Example #15
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.
        """

        file_dialog = FileDialog(_('Save Gaphor Model As'),\
                                 action='save',\
                                 filename=self.filename)
        
        filename = file_dialog.selection
        
        file_dialog.destroy()
        
        if filename:
            self.save(filename)
            self.component_registry.handle(FileManagerStateChanged(self))
            return True

        return False
Example #16
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.
        """

        file_dialog = FileDialog(
            _("Save Gaphor Model As"), action="save", filename=self.filename
        )

        filename = file_dialog.selection

        file_dialog.destroy()

        if filename:
            self.save(filename)
            self.component_registry.handle(FileManagerStateChanged(self))
            return True

        return False
Example #17
0
    def action_open(self):
        """This menu action opens the standard model open dialog."""

        filters = [
            {
                "name": gettext("Gaphor Models"),
                "pattern": "*.gaphor"
            },
            {
                "name": gettext("All Files"),
                "pattern": "*"
            },
        ]

        file_dialog = FileDialog(gettext("Open Gaphor Model"), filters=filters)

        filename = file_dialog.selection

        file_dialog.destroy()

        log.debug(filename)

        if filename:
            self.load(filename)
Example #18
0
    def execute(self):
        filename = self.file_manager.filename
        filename = filename.replace(".gaphor", ".xmi") if filename else "model.xmi"
        file_dialog = FileDialog(
            gettext("Export model to XMI file"), action="save", filename=filename
        )

        filename = file_dialog.selection

        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}")
Example #19
0
    def execute(self):
        filename = self.main_window.get_filename()
        if filename:
            filename = filename.replace('.gaphor', '.xmi')
        else:
            filename = 'model.xmi'

        file_dialog = FileDialog(_('Export model to XMI file'),\
                                 action='save',\
                                 filename=filename)
        
        filename = file_dialog.selection
        
        if filename and len(filename) > 0:
            log.debug('Exporting XMI model to: %s' % filename)
            export = exportmodel.XMIExport(self.element_factory)
            try:
                export.export(filename)
            except Exception as e:
                log.error('Error while saving model to file %s: %s' % (filename, e))
Example #20
0
    def execute(self):
        filename = self.main_window.get_filename()
        if filename:
            filename = filename.replace(".gaphor", ".xmi")
        else:
            filename = "model.xmi"

        file_dialog = FileDialog(
            _("Export model to XMI file"), action="save", filename=filename
        )

        filename = file_dialog.selection

        if filename and len(filename) > 0:
            logger.debug("Exporting XMI model to: %s" % filename)
            export = exportmodel.XMIExport(self.element_factory)
            try:
                export.export(filename)
            except Exception as e:
                logger.error("Error while saving model to file %s: %s" % (filename, e))