コード例 #1
0
    def write(self, oglObjects: List[OglClass]):
        """
        Write data

        Args:
            oglObjects:     list of exported objects
        """
        self.logger.info(f'export file name: {self._imageOptions.outputFileName}')
        wxYield()

        pluginVersion: str = self.getVersion()
        pyutVersion:   str = PyutVersion.getPyUtVersion()

        screenMetrics: ScreenMetrics = PyutUtils.getScreenMetrics()
        dpi: int = screenMetrics.dpiX

        oglToPdf: OglToPyUmlDefinition = OglToPyUmlDefinition(imageOptions=self._imageOptions,
                                                              dpi=dpi,
                                                              pyutVersion=pyutVersion,
                                                              pluginVersion=pluginVersion
                                                              )

        oglToPdf.toClassDefinitions(oglObjects=oglObjects)
        oglToPdf.layoutLines(oglObjects=oglObjects)
        oglToPdf.write()
コード例 #2
0
ファイル: PyutXmlV10.py プロジェクト: curiousTauseef/PyUt
    def open(self, dom: Document, project: PyutProject):
        """
        Open a file and create a diagram.

        Args:
            dom:        The minidom document
            project:    The UI Project to fill out
        """
        self.__setupProgressDialog()
        umlFrame: UmlDiagramsFrame = cast(UmlDiagramsFrame,
                                          None)  # avoid Pycharm warning
        root = self.__validateXmlVersion(dom)
        try:
            project.setCodePath(root.getAttribute("CodePath"))
            self.__updateProgressDialog(newMessage='Reading elements...',
                                        newGaugeValue=1)
            wxYield()
            toOgl: MiniDomToOglV10 = MiniDomToOglV10()
            for documentNode in dom.getElementsByTagName(
                    PyutXmlConstants.ELEMENT_DOCUMENT):

                documentNode: Element = cast(Element, documentNode)
                docTypeStr: str = documentNode.getAttribute(
                    PyutXmlConstants.ATTR_TYPE)
                self.__updateProgressDialog(
                    newMessage=
                    f'Determine Title for document type: {docTypeStr}',
                    newGaugeValue=2)
                wxYield()

                docType: DiagramType = PyutConstants.diagramTypeFromString(
                    docTypeStr)
                document: PyutDocument = project.newDocument(docType)
                document.title = self.__determineDocumentTitle(documentNode)

                umlFrame: UmlDiagramsFrame = self.__showAppropriateUmlFrame(
                    document)
                self.__positionAndSetupDiagramFrame(umlFrame=umlFrame,
                                                    documentNode=documentNode)

                self.__updateProgressDialog(newMessage='Start Conversion...',
                                            newGaugeValue=3)

                if docType == DiagramType.CLASS_DIAGRAM:
                    self.__renderClassDiagram(documentNode, toOgl, umlFrame)
                elif docType == DiagramType.USECASE_DIAGRAM:
                    self.__renderUseCaseDiagram(documentNode, toOgl, umlFrame)
                elif docType == DiagramType.SEQUENCE_DIAGRAM:
                    self.__renderSequenceDiagram(documentNode, toOgl, umlFrame)

                self.__updateProgressDialog(
                    newMessage='Conversion Complete...', newGaugeValue=4)

        except (ValueError, Exception) as e:
            self._dlgGauge.Destroy()
            PyutUtils.displayError(_(f"Can not load file {e}"))
            umlFrame.Refresh()
            return

        self.__cleanupProgressDialog(umlFrame)
コード例 #3
0
ファイル: IoPython.py プロジェクト: hasii2011/PyUt
    def read(self, oglObjects, umlFrame: UmlClassDiagramsFrame):
        """
        Reverse engineering

        Args:
            oglObjects:     list of imported objects
            umlFrame:       Pyut's UmlFrame
        """
        # Ask the user which destination file he wants
        # directory=self._askForDirectoryImport()
        # if directory=="":
        #    return False
        (lstFiles, directory) = self._askForFileImport(True)
        if len(lstFiles) == 0:
            return False

        BeginBusyCursor()
        wxYield()
        try:
            reverseEngineer: ReverseEngineerPython2 = ReverseEngineerPython2()
            reverseEngineer.reversePython(umlFrame=umlFrame,
                                          directoryName=directory,
                                          files=lstFiles)
            # TODO: Don't expose the internals
            self.logger.debug(
                f'classNames: {jsonDumps(reverseEngineer.visitor.classMethods, indent=4)}'
            )
            self.logger.debug(
                f'methods: {jsonDumps(reverseEngineer.visitor.parameters, indent=4)}'
            )
        except (ValueError, Exception) as e:
            MessageBox(f'{e}', 'Error', OK | ICON_ERROR)
        EndBusyCursor()
コード例 #4
0
ファイル: Mediator.py プロジェクト: curiousTauseef/PyUt
    def requestLollipopLocation(self, destinationClass: OglClass):

        # from org.pyut.ogl.OglInterface2 import OglInterface2
        # from org.pyut.model.PyutInterface import PyutInterface

        # destinationPosition: Tuple[float, float] = destinationClass.GetPosition()
        # anchors = destinationClass.GetAnchors()
        # self.logger.info(f'implementor: {destinationClass} at {destinationPosition}')
        #
        # pyutInterface: PyutInterface = PyutInterface(name='Sin Nombre')
        # oglInterface:  OglInterface2 = OglInterface2(pyutInterface, anchors[0])
        #
        # umlFrame: UmlClassDiagramsFrame = self.getFileHandling().getCurrentFrame()
        #
        # x = destinationPosition[0]
        # y = destinationPosition[1]
        #
        # umlFrame.addShape(oglInterface, x, y, withModelUpdate=True)
        # umlFrame.Refresh()
        #
        from org.pyut.ui.UmlClassDiagramsFrame import UmlClassDiagramsFrame

        umlFrame: UmlClassDiagramsFrame = self.getFileHandling(
        ).getCurrentFrame()

        self.__createPotentialAttachmentPoints(
            destinationClass=destinationClass, umlFrame=umlFrame)
        self.setStatusText(f'Select attachment point')
        umlFrame.Refresh()
        wxYield()
コード例 #5
0
    def onHelpVersion(self, event: CommandEvent):
        """
        Check for newer version.
        Args:
            event:
        """
        from org.pyut.general.PyutVersion import PyutVersion
        from org.pyut.general.GithubAdapter import GithubAdapter
        from org.pyut.general.SemanticVersion import SemanticVersion

        wxBeginBusyCursor()
        githubAdapter: GithubAdapter = GithubAdapter()
        latestVersion: SemanticVersion = githubAdapter.getLatestVersionNumber()

        myVersion: SemanticVersion = SemanticVersion(
            PyutVersion.getPyUtVersion())
        if myVersion < latestVersion:
            msg = _("PyUt version ") + str(latestVersion) + _(
                " is available on https://github.com/hasii2011/PyUt/releases")
        else:
            msg = _("No newer version yet !")

        wxEndBusyCursor()
        wxYield()
        PyutUtils.displayInformation(msg, _("Check for newer version"),
                                     self._parent)
コード例 #6
0
 def waitKey(umlFrame: DiagramFrame, optionalMessage: str = None):
     # input('Press enter to continue')
     if optionalMessage is None:
         MessageBox('Press Ok to continue', 'Confirm', style=OK | CENTRE)
     else:
         MessageBox(optionalMessage,
                    'Press Ok to continue',
                    style=OK | CENTRE)
     umlFrame.Refresh()
     wxYield()
コード例 #7
0
ファイル: DlgAbout.py プロジェクト: curiousTauseef/PyUt
    def _onTimer(self, event: TimerEvent):

        self.textPosition += 1

        # End of text -> restart at top
        if self.textPosition > (len(self._textToShow) + 15) * dy:
            self.textPosition = 0.0

        self.OnPanelUpdate(None)

        wxYield()
コード例 #8
0
ファイル: PyutProject.py プロジェクト: hasii2011/PyUt
    def loadFromFilename(self, filename: str) -> bool:
        """
        Load a project from a file

        Args:
            filename: filename to open

        Returns:
            `True` if the operation succeeded
        """
        # Load the file
        self.logger.info(f'loadFromFilename: {filename=}')
        BeginBusyCursor()
        from org.pyut.persistence.IoFile import IoFile  # Avoid Nuitka cyclical dependency

        io: IoFile = IoFile()
        wxYield()       # to treat the uml frame refresh in newDiagram before loading
        # Load the file
        self._filename = filename
        try:
            io.open(filename, self)
            self._modified = False
        except (ValueError, Exception) as e:
            EndBusyCursor()
            self.logger.error(f"Error loading file: {e}")
            return False

        EndBusyCursor()
        self.updateTreeText()
        wxYield()

        from org.pyut.ui.TreeNotebookHandler import TreeNotebookHandler   # avoid cyclical imports

        if len(self._documents) > 0:
            # self._mediator.getFileHandling().showFrame(self._documents[0].getFrame())
            # self._documents[0].getFrame().Refresh()
            # self._mediator.getFileHandling().showFrame(documentFrame)

            documentFrame: UmlFrameType        = self._documents[0].getFrame()
            mediator:      Mediator            = self._mediator
            tbh:           TreeNotebookHandler = mediator.getFileHandling()

            self.logger.debug(f'{documentFrame=}')
            documentFrame.Refresh()
            tbh.showFrame(documentFrame)

            if self.logger.isEnabledFor(DEBUG):
                notebook = tbh.notebook
                self.logger.debug(f'{tbh.currentFrame=} {tbh.currentProject=} {notebook.GetSelection()=}')

            return True
        else:
            return False
コード例 #9
0
ファイル: Mediator.py プロジェクト: hasii2011/PyUt
    def requestLollipopLocation(self, destinationClass: OglClass):

        from org.pyut.ui.UmlClassDiagramsFrame import UmlClassDiagramsFrame

        umlFrame: UmlClassDiagramsFrame = self.getFileHandling(
        ).getCurrentFrame()

        self.__createPotentialAttachmentPoints(
            destinationClass=destinationClass, umlFrame=umlFrame)
        self.setStatusText(f'Select attachment point')
        umlFrame.Refresh()
        wxYield()
コード例 #10
0
ファイル: ToCDAutoLayout.py プロジェクト: hasii2011/PyUt
    def _animate(self, umlFrame):
        """
        Does an animation simulation

        Args:
            umlFrame:
        """
        umlFrame.Refresh()
        self.logger.debug(f'Refreshing ...............')
        wxYield()
        t = time()
        while time() < t + 0.05:
            pass
コード例 #11
0
    def onClose(self) -> bool:
        """
        Close all files

        Returns:
            True if everything is ok
        """
        # Display warning if we are in scripting mode
        if self._mediator.isInScriptMode():
            self.logger.warning(
                "WARNING : in script mode, the non-saved projects are closed without warning"
            )

        # Close projects and ask for unsaved but modified projects
        if not self._mediator.isInScriptMode():
            for project in self._projects:
                if project.getModified() is True:
                    frames = project.getFrames()
                    if len(frames) > 0:
                        frame = frames[0]
                        frame.SetFocus()
                        wxYield()
                        self.showFrame(frame)
                    dlg = MessageDialog(
                        self.__parent,
                        _("Your diagram has not been saved! Would you like to save it?"
                          ), _("Save changes?"), YES_NO | ICON_QUESTION)
                    if dlg.ShowModal() == ID_YES:
                        # save
                        if self.saveFile() is False:
                            return False
                    dlg.Destroy()

        from org.pyut.ui.frame.PyutApplicationFrame import PyutApplicationFrame  # Prevent recursion import problem
        from org.pyut.ui.Mediator import Mediator

        # dereference all
        self.__notebook.DeleteAllPages()
        self.__notebook = None

        self.__parent = cast(PyutApplicationFrame, None)
        self._projects = cast(List[PyutProject], None)
        self._mediator = cast(Mediator, None)
        self._currentProject = cast(PyutProject, None)
        self._currentFrame = cast(UmlDiagramsFrame, None)

        self.__splitter = None
        self.__projectTree = None
        self.__splitter = None

        return True
コード例 #12
0
ファイル: PyutXmlV10.py プロジェクト: hasii2011/PyUt
    def __setupProgressDialog(self):

        self._dlgGauge = Dialog(None,
                                ID_ANY,
                                "Loading...",
                                style=STAY_ON_TOP | ICON_INFORMATION
                                | RESIZE_BORDER,
                                size=Size(250, 70))
        self._gauge: Gauge = Gauge(self._dlgGauge,
                                   ID_ANY,
                                   5,
                                   pos=Point(2, 5),
                                   size=Size(200, 30))
        self._dlgGauge.Show(True)
        wxYield()
コード例 #13
0
ファイル: Aegis.py プロジェクト: ohrite/xjob
	def ListMotion(self, evt=None):
		""" Catch movement in the input list and show informational text """
		listindex, _ = self.inlist.HitTest(evt.GetPosition())
		try:
			if listindex > -1:
				# this breaks the 4th wall of abstraction, but it IS a hack
				target = self.inlist._dict[self.inlist._ids[self.inlist.GetItemData(listindex)]]
				self.statusbar['info'] = target['name'] + ': ' +\
										 str(target['documents']) + ' documents, ' +\
										 target['sizetext']
										 #str(target['pages']) + 'pages, ' +\
				wxYield()
			else:
				self.statusbar['info'] = ''
		except Exception, inst:
			self.statusbar['info'] = 'Error in processing'
			self.statusbar.AddWarning(repr(inst))
コード例 #14
0
ファイル: PyutPlugin.py プロジェクト: hasii2011/PyUt
    def _askForFileExport(self, defaultFileName: str = '') -> str:
        """
        Called by a plugin to ask for the export file name

        Returns:
        """
        wxYield()

        outputFormat: OutputFormatType = self.getOutputFormat()

        wildCard:    str = f'{outputFormat[0]} (*. {outputFormat[1]} )|*.{outputFormat[1]}'
        file:        str = FileSelector("Choose the export file name",
                                        default_filename=defaultFileName,
                                        wildcard=wildCard,
                                        flags=FD_SAVE | FD_OVERWRITE_PROMPT | FD_CHANGE_DIR)

        return file
コード例 #15
0
    def onExport(self, event: CommandEvent):
        """
        Callback.

        Args:
            event: A command event
        """
        # Create a plugin instance
        cl = self._exportPlugins[event.GetId()]
        umlObjects: List[OglClass]      = self._mediator.getUmlObjects()
        umlFrame: UmlClassDiagramsFrame = self._mediator.getUmlFrame()
        obj = cl(umlObjects, umlFrame)
        try:
            wxYield()
            obj.doExport()
        except (ValueError, Exception) as e:
            PyutUtils.displayError(_("An error occurred while executing the selected plugin"), _("Error..."))
            self.logger.error(f'{e}')
コード例 #16
0
ファイル: MainUI.py プロジェクト: curiousTauseef/PyUt
    def onClose(self) -> bool:
        """
        Close all files

        Returns:
            True if everything is ok
        """
        # Display warning if we are in scripting mode
        if self._mediator.isInScriptMode():
            print("WARNING : in script mode, the non-saved projects are closed without warning")

        # Close projects and ask for unsaved but modified projects
        if not self._mediator.isInScriptMode():
            for project in self._projects:
                if project.getModified() is True:
                    frames = project.getFrames()
                    if len(frames) > 0:
                        frame = frames[0]
                        frame.SetFocus()
                        wxYield()
                        # if self._ctrl is not None:
                            # self._ctrl.registerUMLFrame(frame)
                        self.showFrame(frame)
                    dlg = MessageDialog(self.__parent,
                                        _("Your diagram has not been saved! Would you like to save it ?"),
                                        _("Save changes ?"), YES_NO | ICON_QUESTION)
                    if dlg.ShowModal() == ID_YES:
                        # save
                        if self.saveFile() is False:
                            return False
                    dlg.Destroy()

        # dereference all
        self.__parent = None
        self._mediator = None
        self.__splitter = None
        self.__projectTree = None
        self.__notebook.DeleteAllPages()
        self.__notebook = None
        self.__splitter = None
        self._projects = None
        self._currentProject = None
        self._currentFrame = None
コード例 #17
0
    def onImport(self, event: CommandEvent):

        self._treeNotebookHandler.newProject()
        self._treeNotebookHandler.newDocument(DiagramType.CLASS_DIAGRAM)
        self._mediator.updateTitle()
        cl = self._importPlugins[event.GetId()]

        obj = cl(self._mediator.getUmlObjects(), self._mediator.getUmlFrame())

        # Do plugin functionality
        try:
            wxYield()
            obj.doImport()
        except (ValueError, Exception) as e:
            PyutUtils.displayError(_("An error occurred while executing the selected plugin"), _("Error..."))
            self.logger.error(f'{e}')

        parent: Window = self._menu.GetWindow()

        parent.Refresh()
コード例 #18
0
ファイル: AppFrame.py プロジェクト: curiousTauseef/PyUt
    def OnImport(self, event):
        self._mainFileHandlingUI.newProject()
        self._mainFileHandlingUI.newDocument(DiagramType.CLASS_DIAGRAM)
        self._ctrl.updateTitle()
        cl = self.plugins[event.GetId()]

        obj = cl(self._ctrl.getUmlObjects(), self._ctrl.getUmlFrame())

        # Do plugin functionality
        BeginBusyCursor()
        try:
            wxYield()  # time to process the refresh in newDiagram
            obj.doImport()
        except (ValueError, Exception) as e:
            PyutUtils.displayError(
                _("An error occurred while executing the selected plugin"),
                _("Error..."), self)
            self.logger.error(f'{e}')

        EndBusyCursor()
        self.Refresh()
コード例 #19
0
ファイル: PyutProject.py プロジェクト: curiousTauseef/PyUt
    def loadFromFilename(self, filename: str) -> bool:
        """
        Load a project from a file

        Args:
            filename: filename to open

        Returns:
            `True` if the operation succeeded
        """
        # Load the file
        BeginBusyCursor()
        from org.pyut.persistence.IoFile import IoFile  # Avoid Nuitka cyclical dependency

        io: IoFile = IoFile()
        wxYield()       # to treat the uml frame refresh in newDiagram before loading
        # Load the file
        self._filename = filename
        try:
            io.open(filename, self)
            self._modified = False
        except (ValueError, Exception) as e:
            EndBusyCursor()
            PyutUtils.displayError(_(f"Error loading file: {e}"))
            return False

        EndBusyCursor()
        # Update text
        self.updateTreeText()

        # Register to mediator
        # if len(self._documents)>0:
        # self._ctrl.registerUMLFrame(self._documents[0].getFrame())
        # print ">>>PyutProject-loadFromFilename-7"
        if len(self._documents) > 0:
            self._ctrl.getFileHandling().showFrame(self._documents[0].getFrame())
            self._documents[0].getFrame().Refresh()
            return True
        else:
            return False
コード例 #20
0
    def OnInit(self):
        """
        """
        provider: SimpleHelpProvider = SimpleHelpProvider()

        HelpProvider.Set(provider)
        try:
            # Create the SplashScreen
            if self._showSplash:

                bmp: Bitmap = splashImage.GetBitmap()
                self.splash = SplashScreen(bmp,
                                           SPLASH_CENTRE_ON_PARENT
                                           | SPLASH_TIMEOUT,
                                           PyutApp.SPLASH_TIMEOUT_MSECS,
                                           parent=None,
                                           pos=wxDefaultPosition,
                                           size=wxDefaultSize)

                self.logger.debug(f'Showing splash screen')
                self.splash.Show(True)
                wxYield()

            self._frame: AppFrame = AppFrame(cast(AppFrame, None), ID_ANY,
                                             "Pyut")
            self.SetTopWindow(self._frame)
            self._AfterSplash()

            return True
        except (ValueError, Exception) as e:
            self.logger.error(f'{e}')
            dlg = MessageDialog(
                None, _(f"The following error occurred: {exc_info()[1]}"),
                _("An error occurred..."), OK | ICON_ERROR)
            errMessage: str = ErrorManager.getErrorInfo()
            self.logger.debug(errMessage)
            dlg.ShowModal()
            dlg.Destroy()
            return False
コード例 #21
0
ファイル: IoImage.py プロジェクト: hasii2011/PyUt
    def write(self, oglObjects: List[OglClass]):
        """
        Write data

        Args:
            oglObjects:     list of exported objects
        """
        self.logger.info(
            f'export file name: {self._imageOptions.outputFileName}')
        wxYield()

        pluginVersion: str = self.getVersion()
        pyutVersion: str = PyutVersion.getPyUtVersion()

        oglToPyUmlDef: OglToPyUmlDefinition = OglToPyUmlDefinition(
            imageOptions=self._imageOptions,
            pyutVersion=pyutVersion,
            pluginVersion=pluginVersion)

        oglToPyUmlDef.toClassDefinitions(oglObjects=oglObjects)
        oglToPyUmlDef.layoutLines(oglObjects=oglObjects)
        oglToPyUmlDef.write()
コード例 #22
0
ファイル: MainUI.py プロジェクト: curiousTauseef/PyUt
    def newDocument(self, docType: DiagramType):
        """
        Begin a new document

        Args:
            docType:  Type of document
        """
        project = self._currentProject
        if project is None:
            self.newProject()
            project = self.getCurrentProject()
        frame = project.newDocument(docType).getFrame()
        self._currentFrame  = frame
        self._currentProject = project

        if not self._mediator.isInScriptMode():
            shortName: str = self.shortenNotebookPageFileName(project.getFilename())
            self.__notebook.AddPage(frame, shortName)
            wxYield()
            self.__notebookCurrentPage  = self.__notebook.GetPageCount() - 1
            self.logger.info(f'Current notebook page: {self.__notebookCurrentPage}')
            self.__notebook.SetSelection(self.__notebookCurrentPage)
コード例 #23
0
    def _onFileSelectClick(self, event: CommandEvent):

        self.logger.warning(f'File Select Click')
        wxYield()

        fmtSelIdx: int = self._imageFormatChoice.GetCurrentSelection()
        outputFormat: str = self._imageFormatChoice.GetString(fmtSelIdx)

        dlg: FileDialog = FileDialog(self,
                                     message='Choose the export file name',
                                     defaultFile='PyutExport',
                                     style=FD_SAVE | FD_OVERWRITE_PROMPT
                                     | FD_CHANGE_DIR)
        if dlg.ShowModal() == ID_OK:
            wxYield()
            path: str = dlg.GetPath()
            fileName: str = dlg.GetFilename()

            self._selectedFile.SetValue(fileName)  # for simple viewing
            self._selectedFile.SetModified(True)
            self._imageOptions.outputFileName = path  # for actual us

        dlg.Destroy()
コード例 #24
0
ファイル: PyutXmlV10.py プロジェクト: hasii2011/PyUt
    def save(self, project: PyutProject) -> Document:
        """
        Save diagram in XML file.

        Args:
            project:  The project to write as XML

        Returns:
            A minidom XML Document
        """
        assert project is not None, 'Oops someone sent me a bad project'

        dlg: Dialog = Dialog(None,
                             ID_ANY,
                             "Saving...",
                             style=STAY_ON_TOP | ICON_INFORMATION
                             | RESIZE_BORDER,
                             size=Size(207, 70))
        xmlDoc: Document = Document()
        try:
            top = xmlDoc.createElement(PyutXmlConstants.TOP_LEVEL_ELEMENT)
            top.setAttribute(PyutXmlConstants.ATTR_VERSION,
                             str(PyutXml.VERSION))
            codePath: str = project.getCodePath()
            if codePath is None:
                top.setAttribute(PyutXmlConstants.ATTR_CODE_PATH, '')
            else:
                top.setAttribute(PyutXmlConstants.ATTR_CODE_PATH, codePath)

            xmlDoc.appendChild(top)

            gauge = Gauge(dlg,
                          ID_ANY,
                          100,
                          pos=Point(2, 5),
                          size=Size(200, 30))
            dlg.Show(True)
            wxYield()

            toPyutXml: OglToMiniDomV10 = OglToMiniDomV10()
            # Save all documents in the project
            for pyutDocument in project.getDocuments():

                document: PyutDocument = cast(PyutDocument, pyutDocument)
                documentNode: Element = self.__pyutDocumentToPyutXml(
                    xmlDoc=xmlDoc, pyutDocument=document)

                top.appendChild(documentNode)

                from org.pyut.ui.UmlFrame import UmlObjects

                oglObjects: UmlObjects = document.getFrame().getUmlObjects()
                for i in range(len(oglObjects)):
                    gauge.SetValue(i * 100 / len(oglObjects))
                    wxYield()
                    oglObject = oglObjects[i]
                    if isinstance(oglObject, OglClass):
                        classElement: Element = toPyutXml.oglClassToXml(
                            oglObject, xmlDoc)
                        documentNode.appendChild(classElement)
                    elif isinstance(oglObject, OglInterface2):
                        classElement = toPyutXml.oglInterface2ToXml(
                            oglObject, xmlDoc)
                        documentNode.appendChild(classElement)
                    elif isinstance(oglObject, OglNote):
                        noteElement: Element = toPyutXml.oglNoteToXml(
                            oglObject, xmlDoc)
                        documentNode.appendChild(noteElement)
                    elif isinstance(oglObject, OglText):
                        textElement: Element = toPyutXml.oglTextToXml(
                            oglObject, xmlDoc)
                        documentNode.appendChild(textElement)
                    elif isinstance(oglObject, OglActor):
                        actorElement: Element = toPyutXml.oglActorToXml(
                            oglObject, xmlDoc)
                        documentNode.appendChild(actorElement)
                    elif isinstance(oglObject, OglUseCase):
                        useCaseElement: Element = toPyutXml.oglUseCaseToXml(
                            oglObject, xmlDoc)
                        documentNode.appendChild(useCaseElement)
                    elif isinstance(oglObject, OglSDInstance):
                        sdInstanceElement: Element = toPyutXml.oglSDInstanceToXml(
                            oglObject, xmlDoc)
                        documentNode.appendChild(sdInstanceElement)
                    elif isinstance(oglObject, OglSDMessage):
                        sdMessageElement: Element = toPyutXml.oglSDMessageToXml(
                            oglObject, xmlDoc)
                        documentNode.appendChild(sdMessageElement)
                    # OglLink comes last because OglSDInstance is a subclass of OglLink
                    # Now I know why OglLink used to double inherit from LineShape, ShapeEventHandler
                    # I changed it to inherit from OglLink directly
                    elif isinstance(oglObject, OglLink):
                        linkElement: Element = toPyutXml.oglLinkToXml(
                            oglObject, xmlDoc)
                        documentNode.appendChild(linkElement)
                    else:
                        self.logger.warning(
                            f'Unhandled OGL Object: {oglObject}')
        except (ValueError, Exception) as e:
            try:
                dlg.Destroy()
                self.logger.error(f'{e}')
            except (ValueError, Exception) as e:
                self.logger.error(f'{e}')
            PyutUtils.displayError(_("Can't save file"))
            return xmlDoc

        dlg.Destroy()

        return xmlDoc
コード例 #25
0
ファイル: PyutXmlV10.py プロジェクト: hasii2011/PyUt
    def __cleanupProgressDialog(self, umlFrame: UmlDiagramsFrame):

        umlFrame.Refresh()
        self._gauge.SetValue(5)
        wxYield()
        self._dlgGauge.Destroy()
コード例 #26
0
ファイル: PyutXmlV10.py プロジェクト: hasii2011/PyUt
    def __updateProgressDialog(self, newMessage: str, newGaugeValue: int):

        self._dlgGauge.SetTitle(newMessage)
        self._gauge.SetValue(newGaugeValue)
        wxYield()
コード例 #27
0
    def save(self, project: PyutProject) -> Document:
        """
        Save diagram in XML file.

        Args:
            project:  The project to write as XML

        Returns:
            A minidom XML Document
        """
        dlg:    Dialog   = Dialog(None, -1, "Saving...", style=STAY_ON_TOP | ICON_INFORMATION | RESIZE_BORDER, size=Size(207, 70))
        xmlDoc: Document = Document()
        try:
            # xmlDoc: Document  = Document()
            top     = xmlDoc.createElement(PyutXmlConstants.TOP_LEVEL_ELEMENT)
            top.setAttribute(PyutXmlConstants.ATTR_VERSION, str(PyutXml.VERSION))
            codePath: str = project.getCodePath()
            if codePath is None:
                top.setAttribute('CodePath', '')
            else:
                top.setAttribute('CodePath', codePath)

            xmlDoc.appendChild(top)

            gauge = Gauge(dlg, -1, 100, pos=Point(2, 5), size=Size(200, 30))
            dlg.Show(True)
            wxYield()

            toPyutXml: OglToMiniDom = OglToMiniDom()
            # Save all documents in the project
            for document in project.getDocuments():

                document: PyutDocument = cast(PyutDocument, document)

                documentNode = xmlDoc.createElement(PyutXmlConstants.ELEMENT_DOCUMENT)

                docType: str = document.getType().__str__()

                documentNode.setAttribute(PyutXmlConstants.ATTR_TYPE, docType)
                documentNode.setAttribute(PyutXmlConstants.ATTR_TITLE, document.title)
                top.appendChild(documentNode)

                oglObjects: List[OglObject] = document.getFrame().getUmlObjects()
                for i in range(len(oglObjects)):
                    gauge.SetValue(i * 100 / len(oglObjects))
                    wxYield()
                    oglObject = oglObjects[i]
                    if isinstance(oglObject, OglClass):
                        # documentNode.appendChild(self._OglClass2xml(oglObject, xmlDoc))
                        classElement: Element = toPyutXml.oglClassToXml(oglObject, xmlDoc)
                        documentNode.appendChild(classElement)
                    elif isinstance(oglObject, OglNote):
                        # documentNode.appendChild(self._OglNote2xml(oglObject, xmlDoc))
                        noteElement: Element = toPyutXml.oglNoteToXml(oglObject, xmlDoc)
                        documentNode.appendChild(noteElement)
                    elif isinstance(oglObject, OglActor):
                        # documentNode.appendChild(self._OglActor2xml(oglObject, xmlDoc))
                        actorElement: Element = toPyutXml.oglActorToXml(oglObject, xmlDoc)
                        documentNode.appendChild(actorElement)
                    elif isinstance(oglObject, OglUseCase):
                        # documentNode.appendChild(self._OglUseCase2xml(oglObject, xmlDoc))
                        useCaseElement: Element = toPyutXml.oglUseCaseToXml(oglObject, xmlDoc)
                        documentNode.appendChild(useCaseElement)
                    elif isinstance(oglObject, OglSDInstance):
                        # documentNode.appendChild(self._OglSDInstance2xml(oglObject, xmlDoc))
                        sdInstanceElement: Element = toPyutXml.oglSDInstanceToXml(oglObject, xmlDoc)
                        documentNode.appendChild(sdInstanceElement)
                    elif isinstance(oglObject, OglSDMessage):
                        # documentNode.appendChild(self._OglSDMessage2xml(oglObject, xmlDoc))
                        sdMessageElement: Element = toPyutXml.oglSDMessageToXml(oglObject, xmlDoc)
                        documentNode.appendChild(sdMessageElement)
                    # OglLink comes last because OglSDInstance is a subclass of OglLink
                    # Now I know why OglLink used to double inherit from LineShape, ShapeEventHandler
                    # I changed it to inherit from OglLink directly
                    elif isinstance(oglObject, OglLink):
                        # documentNode.appendChild(self._OglLink2xml(oglObject, xmlDoc))
                        linkElement: Element = toPyutXml.oglLinkToXml(oglObject, xmlDoc)
                        documentNode.appendChild(linkElement)
        except (ValueError, Exception) as e:
            try:
                dlg.Destroy()
                self.logger.error(f'{e}')
            except (ValueError, Exception) as e:
                self.logger.error(f'{e}')
            PyutUtils.displayError(_("Can't save file"))
            return xmlDoc

        dlg.Destroy()

        return xmlDoc
コード例 #28
0
    def __updateDialog(self, newMsg: str, delay: int = 500):

        self._progressDlg.Pulse(newMsg)
        wxYield()
        wxMilliSleep(delay)