def setUp(self): """ Initialize. @author C.Dutoit """ # Initialize mediator and error manager ctrl = Mediator.getMediator() ctrl.setScriptMode() fileHandling = MainUI(None, ctrl) ctrl.registerFileHandling(fileHandling) errorManager = ctrl.getErrorManager() errorManager.changeType(ErrorViewTypes.RAISE_ERROR_VIEW) whereWeAre: str = getcwd() PyutUtils.setBasePath(whereWeAre) # Create wx application # For python 3 and wx 4.x we need to save it so it does not get GC'ed self.app = App() # Create frame # baseFrame = wxFrame(None, -1, "", size=(10, 10)) baseFrame = Frame(None, -1, "", size=(10, 10)) umlFrame = UmlFrame(baseFrame, None) umlFrame.Show(True) self._umlFrame = umlFrame
def setUpClass(cls): PyutPreferences.determinePreferencesLocation( ) # Side effect; not a good move cls.clsApp = PyUtApp() # Create frame baseFrame: Frame = Frame(None, ID_ANY, "", size=(10, 10)) # noinspection PyTypeChecker umlFrame = UmlFrame(baseFrame, None) umlFrame.Show(True) cls.clsFrame = umlFrame
def __displayTheLinks(self, oglLinks: OglLinks, umlFrame: UmlFrame): """ Place the OGL links on the input frame at their respective positions Args: oglLinks: A dictionary of OGL links umlFrame: The UML Frame to place the OGL objects on """ for oglLink in oglLinks: umlFrame.GetDiagram().AddShape(oglLink, withModelUpdate=True)
def _animate(self, umlFrame: UmlFrame): """ Does an animation simulation Args: umlFrame: """ umlFrame.Refresh() self.logger.debug(f'Refreshing ...............') wxYield() t = time() while time() < t + 0.05: pass
def __cleanupProgressDialog(self, umlFrame: UmlFrame): umlFrame.Refresh() self._gauge.SetValue(5) wxYield() self._dlgGauge.Destroy()
def __displayAnOglObject(self, oglObject: OglObject, umlFrame: UmlFrame): x, y = oglObject.GetPosition() umlFrame.addShape(oglObject, x, y)
def __displayTheSDMessages(self, oglSDMessages: OglSDMessages, umlFrame: UmlFrame): for oglSDMessage in oglSDMessages.values(): oglSDMessage: OglSDMessage = cast(OglSDMessage, oglSDMessage) umlFrame.getDiagram().AddShape(oglSDMessage)
def doAction(self, umlObjects: List[OglClass], selectedObjects: List[OglClass], umlFrame: UmlFrame): """ Args: umlObjects: list of the uml objects of the diagram selectedObjects: list of the selected objects umlFrame: The diagram frame """ if umlFrame is None: self.displayNoUmlFrame() return ctrl = getMediator() project = ctrl.getFileHandling().getProjectFromFrame(umlFrame) if project.getCodePath() == "": dlg = DirDialog(None, _("Choose the root directory for the code"), getcwd()) if dlg.ShowModal() == ID_OK: codeDir = dlg.GetPath() self.logger.info(f"Chosen directory is {codeDir}") umlFrame.setCodePath(codeDir) dlg.Destroy() else: return oglClasses = [x for x in selectedObjects if isinstance(x, OglClass)] if len(oglClasses) == 0: self.logger.info("Nothing selected") return oldDir = getcwd() chdir(project.getCodePath()) sysPath.append(getcwd()) # plug = IoPython(None, None) plug = IoPython(cast(OglObject, None), cast(UmlFrame, None)) normalDir = getcwd() for oglClass in oglClasses: pyutClass = oglClass.getPyutObject() filename = pyutClass.getFilename() if filename == "": dlg = FileDialog(None, _("Choose the file for this UML class"), project.getCodePath(), "", "*.py", FD_OPEN) if dlg.ShowModal() != ID_OK: dlg.Destroy() continue filename = dlg.GetPaths()[0] self.logger.info(f"Chosen filename is {filename}") pyutClass.setFilename(filename) dlg.Destroy() modulename = filename[:-3] # remove ".py" try: # normalDir = getcwd() path, name = osPath.split(osPath.abspath(modulename)) chdir(path) module = __import__(name) importlib.reload(module) chdir(normalDir) except ImportError as ie: self.logger.error( f"Error while trying to import module '{str(modulename)}' --- '{ie}'" ) chdir(normalDir) continue orgClass = module.__dict__[pyutClass.getName()] plug.getPyutClass(orgClass, filename, pyutClass) oglClass.autoResize() chdir(oldDir)