Example #1
0
    def onFileInsertProject(self, event: CommandEvent):
        """
        Insert a project into this one

        Args:
            event:
        """
        PyutUtils.displayWarning(_("The project insert is experimental, "
                                   "use it at your own risk.\n"
                                   "You risk a shapes ID duplicate with "
                                   "unexpected results !"), parent=self)

        if (self._treeNotebookHandler.getCurrentProject()) is None:
            PyutUtils.displayError(_("No project to insert this file into !"))
            return

        # Ask which project to insert
        defaultDirectory: str    = self._currentDirectoryHandler.currentDirectory

        dlg = FileDialog(self._parent, _("Choose a project"), defaultDirectory, "", "*.put", FD_OPEN)
        if dlg.ShowModal() != ID_OK:
            dlg.Destroy()
            return False
        self._currentDirectoryHandler.currentDirectory = dlg.GetPath()
        filename = dlg.GetPath()
        dlg.Destroy()

        self.logger.warning(f'inserting file: {filename}')

        # Insert the specified files
        try:
            self._treeNotebookHandler.insertFile(filename)
        except (ValueError, Exception) as e:
            PyutUtils.displayError(_(f"An error occurred while loading the project!  {e}"))
Example #2
0
    def _OnMnuRedo(self, event: CommandEvent):
        """

        Args:
            event:
        """
        if (self._mainFileHandlingUI.getCurrentFrame()) is None:
            PyutUtils.displayWarning(msg=_('No selected frame'),
                                     title=_('Huh!'))
            return
        self._mainFileHandlingUI.getCurrentFrame().getHistory().redo()
Example #3
0
    def _OnMnuFileRemoveDocument(self, event: CommandEvent):
        """
        Remove the current document from the current project

        Args:
            event:
        """
        project = self._mainFileHandlingUI.getCurrentProject()
        document = self._mainFileHandlingUI.getCurrentDocument()
        if project is not None and document is not None:
            project.removeDocument(document)
        else:
            PyutUtils.displayWarning(_("No document to remove"))
Example #4
0
    def onRemoveDocument(self, event: CommandEvent):
        """
        Remove the current document from the current project

        Args:
            event:
        """
        project  = self._treeNotebookHandler.getCurrentProject()
        document = self._treeNotebookHandler.getCurrentDocument()
        if project is not None and document is not None:
            project.removeDocument(document)
        else:
            PyutUtils.displayWarning(_("No document to remove"))
Example #5
0
    def onRedo(self, event: CommandEvent):
        """

        Args:
            event:
        """
        currentFrame = self._treeNotebookHandler.getCurrentFrame()
        if currentFrame is None:
            PyutUtils.displayWarning(msg=_('No selected/available frame'),
                                     title=_('Huh!'))
        else:
            historyManager: HistoryManager = currentFrame.getHistory()
            if historyManager.isRedoPossible() is True:
                historyManager.redo()
            else:
                PyutUtils.displayWarning(msg=_('Nothing to redo'),
                                         title=_('Huh!'))
Example #6
0
    def _isDiagramFormOpen(self, frame: UmlClassDiagramsFrame) -> bool:
        """
        Does 2 things, Checks and displays the dialog;  Oh well

        Args:
            frame:

        Returns: `True` if there is a frame open else, `False`
        """
        if frame is None:
            PyutUtils.displayWarning(
                msg=_("Please open a diagram to hold the UML"),
                title=_('Silly User'),
                parent=self._parent)
            return False
        else:
            return True
Example #7
0
    def _OnMnuFileInsertProject(self, event: CommandEvent):
        """
        Insert a project into this one

        Args:
            event:
        """
        PyutUtils.displayWarning(_("The project insert is experimental, "
                                   "use it at your own risk.\n"
                                   "You risk a shapes ID duplicate with "
                                   "unexpected results !"),
                                 parent=self)

        if (self._mainFileHandlingUI.getCurrentProject()) is None:
            PyutUtils.displayError(_("No project to insert this file into !"),
                                   parent=self)
            return

        # Ask which project to insert
        dlg = FileDialog(self, _("Choose a file"), self._lastDir, "", "*.put",
                         FD_OPEN)
        if dlg.ShowModal() != ID_OK:
            dlg.Destroy()
            return False
        self.updateCurrentDir(dlg.GetPath())
        filename = dlg.GetPath()
        dlg.Destroy()

        print(("inserting file", str(filename)))

        # Insert the specified files
        try:
            self._mainFileHandlingUI.insertFile(filename)
        except (ValueError, Exception) as e:
            PyutUtils.displayError(
                _(f"An error occurred while loading the project!  {e}"),
                parent=self)