Exemplo n.º 1
0
    def load(self, filename):
        """Load the Gaphor model from the supplied file name.  A status window
        displays the loading progress.  The load generator updates the progress
        queue.  The loader is passed to a GIdleThread which executes the load
        generator.  If loading is successful, the filename is set."""

        queue = Queue()
        status_window = StatusWindow(
            gettext("Loading..."),
            gettext("Loading model from {filename}").format(filename=filename),
            parent=self.main_window.window,
            queue=queue,
        )

        try:
            loader = storage.load_generator(filename.encode("utf-8"),
                                            self.element_factory)
            worker = GIdleThread(loader, queue)

            worker.start()
            worker.wait()

            if worker.error:
                worker.reraise()

            self.filename = filename
            self.event_manager.handle(FileLoaded(self, filename))
        except (QueueEmpty, QueueFull):
            error_handler(message=gettext(
                "Error while loading model from file {filename}").format(
                    filename=filename))
            raise
        finally:
            status_window.destroy()
Exemplo n.º 2
0
    def load(self, filename):
        """Load the Gaphor model from the supplied file name.  A status window
        displays the loading progress.  The load generator updates the progress
        queue.  The loader is passed to a GIdleThread which executes the load
        generator.  If loading is successful, the filename is set."""

        self.logger.info('Loading file')
        self.logger.debug('Path is %s' % filename)

        main_window = self.main_window

        queue = Queue()
        status_window = StatusWindow(_('Loading...'),\
                                     _('Loading model from %s') % filename,\
                                     parent=main_window.window,\
                                     queue=queue)

        loader = storage.load_generator(filename, self.element_factory)
        worker = GIdleThread(loader, queue)

        worker.start()
        worker.wait()
        
        if worker.error:
            self.logger.error('Error loading file: ', exc_info=worker.exc_info)
            #self.logger.error(worker.error)

        self.filename = filename

        status_window.destroy()
Exemplo n.º 3
0
    def load(self, filename):
        """Load the Gaphor model from the supplied file name.

        A status window displays the loading progress.  The load
        generator updates the progress queue.  The loader is passed to a
        GIdleThread which executes the load generator.  If loading is
        successful, the filename is set.
        """

        queue = Queue()
        status_window = StatusWindow(
            gettext("Loading..."),
            gettext("Loading model from {filename}").format(filename=filename),
            parent=self.main_window.window,
            queue=queue,
        )

        try:
            loader = storage.load_generator(
                filename.encode("utf-8"), self.element_factory, self.modeling_language
            )
            worker = GIdleThread(loader, queue)

            worker.start()
            worker.wait()

            if worker.error:
                worker.reraise()

            self.filename = filename
            self.event_manager.handle(FileLoaded(self, filename))
        except Exception:
            error_handler(
                message=gettext("Unable to open model “{filename}”.").format(
                    filename=filename
                ),
                secondary_message=gettext(
                    "This file does not contain a valid Gaphor model."
                ),
                window=self.main_window.window,
            )
            raise
        finally:
            status_window.destroy()
Exemplo n.º 4
0
    def load(self, filename):
        """Load the Gaphor model from the supplied file name.  A status window
        displays the loading progress.  The load generator updates the progress
        queue.  The loader is passed to a GIdleThread which executes the load
        generator.  If loading is successful, the filename is set."""

        log.info("Loading file")
        log.debug("Path is %s" % filename)

        queue = Queue()

        try:
            main_window = self.main_window
            status_window = StatusWindow(
                _("Loading..."),
                _("Loading model from %s") % filename,
                parent=main_window.window,
                queue=queue,
            )
        except component.interfaces.ComponentLookupError:
            status_window = None

        try:
            loader = storage.load_generator(
                filename.encode("utf-8"), self.element_factory
            )
            worker = GIdleThread(loader, queue)

            worker.start()
            worker.wait()

            if worker.error:
                worker.reraise()

            self.filename = filename
        except:
            error_handler(
                message=_("Error while loading model from file %s") % filename
            )
            raise
        finally:
            if status_window is not None:
                status_window.destroy()
Exemplo n.º 5
0
    def load(self, filename):
        """Load the Gaphor model from the supplied file name.  A status window
        displays the loading progress.  The load generator updates the progress
        queue.  The loader is passed to a GIdleThread which executes the load
        generator.  If loading is successful, the filename is set."""

        log.info("Loading file")
        log.debug("Path is %s" % filename)

        queue = Queue()

        try:
            main_window = self.main_window
            status_window = StatusWindow(
                _("Loading..."),
                _("Loading model from %s") % filename,
                parent=main_window.window,
                queue=queue,
            )
        except component.interfaces.ComponentLookupError:
            status_window = None

        try:
            loader = storage.load_generator(
                filename.encode("utf-8"), self.element_factory
            )
            worker = GIdleThread(loader, queue)

            worker.start()
            worker.wait()

            if worker.error:
                worker.reraise()

            self.filename = filename
        except:
            error_handler(
                message=_("Error while loading model from file %s") % filename
            )
            raise
        finally:
            if status_window is not None:
                status_window.destroy()
Exemplo n.º 6
0
    def load(self, filename):
        """Load the Gaphor model from the supplied file name.  A status window
        displays the loading progress.  The load generator updates the progress
        queue.  The loader is passed to a GIdleThread which executes the load
        generator.  If loading is successful, the filename is set."""

        queue = Queue()
        status_window: Optional[StatusWindow]
        try:
            main_window = self.main_window
            status_window = StatusWindow(
                _("Loading..."),
                _("Loading model from %s") % filename,
                parent=main_window.window,
                queue=queue,
            )
        except:
            log.warning("Could not create status window, proceding without.")
            status_window = None

        try:
            loader = storage.load_generator(filename.encode("utf-8"),
                                            self.element_factory)
            worker = GIdleThread(loader, queue)

            worker.start()
            worker.wait()

            if worker.error:
                worker.reraise()

            self.filename = filename
        except:
            error_handler(message=_("Error while loading model from file %s") %
                          filename)
            raise
        finally:
            if status_window is not None:
                status_window.destroy()