UML Diagrams

Sun, 02 May 2021 17:26:47 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 02 May 2021 17:26:47 +0200
changeset 8282
16b243bdb12f
parent 8281
184ece570a2b
child 8283
3139cbc98a14

UML Diagrams
- added code to load a saved UML diagram via the file browser or the project others browser

docs/changelog file | annotate | diff | comparison | revisions
eric6/Graphics/UMLDialog.py file | annotate | diff | comparison | revisions
eric6/Project/ProjectOthersBrowser.py file | annotate | diff | comparison | revisions
eric6/UI/Browser.py file | annotate | diff | comparison | revisions
eric6/UI/BrowserModel.py file | annotate | diff | comparison | revisions
eric6/UI/UserInterface.py file | annotate | diff | comparison | revisions
eric6/icons/breeze-dark/fileUML.svg file | annotate | diff | comparison | revisions
eric6/icons/breeze-light/fileUML.svg file | annotate | diff | comparison | revisions
eric6/icons/oxygen/fileUML.png file | annotate | diff | comparison | revisions
--- a/docs/changelog	Sun May 02 15:09:29 2021 +0200
+++ b/docs/changelog	Sun May 02 17:26:47 2021 +0200
@@ -7,6 +7,8 @@
   -- added code to get typed manual tasks
 - UML Diagrams
   -- extended the class items to show class attributes
+  -- added code to load a saved UML diagram via the file browser or
+     the project others browser
 
 Version 21.5:
 - bug fixes
--- a/eric6/Graphics/UMLDialog.py	Sun May 02 15:09:29 2021 +0200
+++ b/eric6/Graphics/UMLDialog.py	Sun May 02 17:26:47 2021 +0200
@@ -269,20 +269,24 @@
     
     # TODO: add loading of file in JSON format
     # TODO: eric7: delete the current one
-    def load(self):
+    def load(self, filename=""):
         """
         Public method to load a diagram from a file.
         
-        @return flag indicating success (boolean)
+        @param filename name of the file to be loaded
+        @type str
+        @return flag indicating success
+        @rtype bool
         """
-        filename = E5FileDialog.getOpenFileName(
-            self,
-            self.tr("Load Diagram"),
-            "",
-            self.tr("Eric Graphics File (*.e5g);;All Files (*)"))
         if not filename:
-            # Cancelled by user
-            return False
+            filename = E5FileDialog.getOpenFileName(
+                self,
+                self.tr("Load Diagram"),
+                "",
+                self.tr("Eric Graphics File (*.e5g);;All Files (*)"))
+            if not filename:
+                # Cancelled by user
+                return False
         
         try:
             with open(filename, "r", encoding="utf-8") as f:
@@ -322,9 +326,9 @@
                 return False
             try:
                 diagramType, diagramTypeString = value.strip().split(None, 1)
-                self.__diagramType = UMLDialogType(int(self.__diagramType))
+                self.__diagramType = UMLDialogType(int(diagramType))
                 self.__diagramTypeString = diagramTypeString[1:-1]
-                # remove opening an closing bracket
+                # remove opening and closing bracket
             except ValueError:
                 self.__showInvalidDataMessage(filename, linenum)
                 return False
--- a/eric6/Project/ProjectOthersBrowser.py	Sun May 02 15:09:29 2021 +0200
+++ b/eric6/Project/ProjectOthersBrowser.py	Sun May 02 17:26:47 2021 +0200
@@ -254,7 +254,8 @@
                     self.svgFile.emit(itm.fileName())
                 elif itm.isPixmapFile():
                     self.pixmapFile.emit(itm.fileName())
-                # TODO: add entry for eric graphics files
+                elif itm.isEricGraphicsFile():
+                    self.umlFile.emit(itm.fileName())
                 else:
                     if Utilities.MimeTypes.isTextFile(itm.fileName()):
                         self.sourceFile.emit(itm.fileName())
--- a/eric6/UI/Browser.py	Sun May 02 15:09:29 2021 +0200
+++ b/eric6/UI/Browser.py	Sun May 02 17:26:47 2021 +0200
@@ -67,6 +67,7 @@
     @signal pixmapFile(filename) emitted to open a pixmap file (str)
     @signal pixmapEditFile(filename) emitted to edit a pixmap file (str)
     @signal svgFile(filename) emitted to open a SVG file (str)
+    @signal umlFile(filename) emitted to open an eric UML file (str)
     @signal binaryFile(filename) emitted to open a file as binary (str)
     @signal unittestOpen(filename) emitted to open a Python file for a
         unit test (str)
@@ -80,6 +81,7 @@
     pixmapFile = pyqtSignal(str)
     pixmapEditFile = pyqtSignal(str)
     svgFile = pyqtSignal(str)
+    umlFile = pyqtSignal(str)
     binaryFile = pyqtSignal(str)
     unittestOpen = pyqtSignal(str)
     
@@ -494,7 +496,8 @@
                         self.svgFile.emit(itm.fileName())
                     elif itm.isPixmapFile():
                         self.pixmapFile.emit(itm.fileName())
-                    # TODO: add entry for eric graphics files
+                    elif itm.isEricGraphicsFile():
+                        self.umlFile.emit(itm.fileName())
                     else:
                         if Utilities.MimeTypes.isTextFile(itm.fileName()):
                             self.sourceFile[str].emit(itm.fileName())
--- a/eric6/UI/BrowserModel.py	Sun May 02 15:09:29 2021 +0200
+++ b/eric6/UI/BrowserModel.py	Sun May 02 17:26:47 2021 +0200
@@ -1155,7 +1155,6 @@
         
         self._moduleName = ''
         
-        # TODO: add icon for eric graphics file
         pixName = ""
         if self.isPython3File():
             pixName = "filePython"
@@ -1206,6 +1205,8 @@
             self._populated = False
             self._lazyPopulation = True
             self._moduleName = os.path.basename(finfo)
+        elif self.isEricGraphicsFile():
+            pixName = "fileUML"
         else:
             pixName = "fileMisc"
         
--- a/eric6/UI/UserInterface.py	Sun May 02 15:09:29 2021 +0200
+++ b/eric6/UI/UserInterface.py	Sun May 02 17:26:47 2021 +0200
@@ -403,6 +403,7 @@
         self.projectBrowser.poBrowser.pixmapEditFile.connect(self.__editPixmap)
         self.projectBrowser.poBrowser.pixmapFile.connect(self.__showPixmap)
         self.projectBrowser.poBrowser.svgFile.connect(self.__showSvg)
+        self.projectBrowser.poBrowser.umlFile.connect(self.__showUml)
         self.projectBrowser.poBrowser.binaryFile.connect(self.__openHexEditor)
         
         self.project.sourceFile.connect(self.viewmanager.openSourceFile)
@@ -504,6 +505,7 @@
             self.browser.pixmapEditFile.connect(self.__editPixmap)
             self.browser.pixmapFile.connect(self.__showPixmap)
             self.browser.svgFile.connect(self.__showSvg)
+            self.browser.umlFile.connect(self.__showUml)
             self.browser.binaryFile.connect(self.__openHexEditor)
             self.browser.unittestOpen.connect(self.__unittestScript)
             self.browser.trpreview.connect(self.__TRPreviewer)
@@ -5431,6 +5433,19 @@
         dlg = SvgDiagram(fn, self)
         dlg.show()
         
+    @pyqtSlot(str)
+    def __showUml(self, fn):
+        """
+        Private slot to show an eric graphics file in a dialog.
+        
+        @param fn name of the file to be shown
+        @type str
+        """
+        from Graphics.UMLDialog import UMLDialog, UMLDialogType
+        dlg = UMLDialog(UMLDialogType.NO_DIAGRAM, self.project, parent=self)
+        if dlg.load(fn):
+            dlg.show(fromFile=True)
+    
     def __snapshot(self):
         """
         Private slot to start the snapshot tool.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/eric6/icons/breeze-dark/fileUML.svg	Sun May 02 17:26:47 2021 +0200
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   version="1.1"
+   id="Layer_1"
+   x="0px"
+   y="0px"
+   width="22"
+   height="22"
+   viewBox="0 0 21.78 21.773196"
+   enable-background="new 0 0 396 288"
+   xml:space="preserve"
+   sodipodi:docname="uml.svg"
+   inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"><metadata
+   id="metadata69"><rdf:RDF><cc:Work
+       rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+         rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+   id="defs67" /><sodipodi:namedview
+   pagecolor="#ffffff"
+   bordercolor="#666666"
+   borderopacity="1"
+   objecttolerance="10"
+   gridtolerance="10"
+   guidetolerance="10"
+   inkscape:pageopacity="0"
+   inkscape:pageshadow="2"
+   inkscape:window-width="1901"
+   inkscape:window-height="1097"
+   id="namedview65"
+   showgrid="false"
+   inkscape:zoom="1"
+   inkscape:cx="17.966491"
+   inkscape:cy="23.569548"
+   inkscape:window-x="0"
+   inkscape:window-y="0"
+   inkscape:window-maximized="0"
+   inkscape:current-layer="Layer_1" />
+<polygon
+   fill="#fbbd16"
+   points="222.729,240.603 246.553,252.477 261.867,183.949 261.867,258.923 288.753,272.151 288.753,145.616 247.914,126.278 234.982,186.663 221.937,113.84 181.323,94.391 181.323,221.04 208.096,234.496 208.096,158.167 "
+   id="polygon2"
+   transform="matrix(0.07435014,0,0,0.07596743,-10.51139,0.06298594)" />
+<polygon
+   fill="#452e7f"
+   points="394.142,184.709 394.369,219.31 292.611,272.796 292.496,145.583 335.152,123.418 335.152,215.238 "
+   id="polygon4"
+   transform="matrix(0.07435014,0,0,0.07596743,-10.51139,0.06298594)" />
+<path
+   fill="#962444"
+   d="M 9.9570564,0.986598 7.7144328,3.0125734 c 0,0 4.3755802,2.2980148 4.9071092,2.5695984 0.531604,0.2715076 1.288117,0.7937837 0.470266,1.5668283 C 12.273956,7.9219687 11.374318,7.8175134 10.76093,7.5041478 10.147541,7.1907822 5.6084649,4.8509852 5.6084649,4.8509852 L 3.2981084,6.8564494 c 0,0 4.457217,2.318906 5.1933578,2.7158356 0.7360665,0.3970063 3.4758688,1.378809 6.0725478,-0.6894042 2.59668,-2.0682135 2.228721,-2.820291 2.228721,-2.9665283 0,-0.1462373 -0.06134,-0.9192059 -0.511157,-1.3996999 C 15.831685,4.0361586 14.523196,3.3467542 13.971146,3.0542796 13.419097,2.7618049 9.9570564,0.986598 9.9570564,0.986598 Z"
+   id="path6"
+   style="stroke-width:0.0751545" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<g
+   id="g56"
+   transform="matrix(0.07435014,0,0,0.07596743,-10.51139,0.06298594)">
+	<path
+   fill="#6d6e71"
+   d="m 393.104,167.064 c 0,4.471 -3.509,7.979 -8.076,7.979 -4.519,0 -8.123,-3.509 -8.123,-7.979 0,-4.375 3.604,-7.884 8.123,-7.884 4.568,0.001 8.076,3.509 8.076,7.884 z m -14.18,0 c 0,3.509 2.596,6.298 6.153,6.298 3.461,0 6.009,-2.789 6.009,-6.25 0,-3.51 -2.548,-6.346 -6.058,-6.346 -3.508,0.001 -6.104,2.837 -6.104,6.298 z m 4.855,4.134 h -1.827 v -7.883 c 0.722,-0.146 1.731,-0.241 3.029,-0.241 1.489,0 2.163,0.241 2.739,0.577 0.433,0.336 0.769,0.961 0.769,1.73 0,0.864 -0.672,1.538 -1.634,1.827 v 0.096 c 0.77,0.289 1.202,0.864 1.442,1.923 0.24,1.202 0.385,1.683 0.576,1.971 h -1.97 c -0.241,-0.288 -0.385,-1.01 -0.626,-1.923 -0.144,-0.865 -0.625,-1.25 -1.635,-1.25 h -0.864 v 3.173 z m 0.048,-4.47 h 0.865 c 1.01,0 1.827,-0.336 1.827,-1.153 0,-0.721 -0.528,-1.202 -1.683,-1.202 -0.481,0 -0.817,0.048 -1.01,0.097 v 2.258 z"
+   id="path54" />
+</g>
+
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/eric6/icons/breeze-light/fileUML.svg	Sun May 02 17:26:47 2021 +0200
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   version="1.1"
+   id="Layer_1"
+   x="0px"
+   y="0px"
+   width="22"
+   height="22"
+   viewBox="0 0 21.78 21.773196"
+   enable-background="new 0 0 396 288"
+   xml:space="preserve"
+   sodipodi:docname="uml.svg"
+   inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"><metadata
+   id="metadata69"><rdf:RDF><cc:Work
+       rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+         rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+   id="defs67" /><sodipodi:namedview
+   pagecolor="#ffffff"
+   bordercolor="#666666"
+   borderopacity="1"
+   objecttolerance="10"
+   gridtolerance="10"
+   guidetolerance="10"
+   inkscape:pageopacity="0"
+   inkscape:pageshadow="2"
+   inkscape:window-width="1901"
+   inkscape:window-height="1097"
+   id="namedview65"
+   showgrid="false"
+   inkscape:zoom="1"
+   inkscape:cx="17.966491"
+   inkscape:cy="23.569548"
+   inkscape:window-x="0"
+   inkscape:window-y="0"
+   inkscape:window-maximized="0"
+   inkscape:current-layer="Layer_1" />
+<polygon
+   fill="#fbbd16"
+   points="222.729,240.603 246.553,252.477 261.867,183.949 261.867,258.923 288.753,272.151 288.753,145.616 247.914,126.278 234.982,186.663 221.937,113.84 181.323,94.391 181.323,221.04 208.096,234.496 208.096,158.167 "
+   id="polygon2"
+   transform="matrix(0.07435014,0,0,0.07596743,-10.51139,0.06298594)" />
+<polygon
+   fill="#452e7f"
+   points="394.142,184.709 394.369,219.31 292.611,272.796 292.496,145.583 335.152,123.418 335.152,215.238 "
+   id="polygon4"
+   transform="matrix(0.07435014,0,0,0.07596743,-10.51139,0.06298594)" />
+<path
+   fill="#962444"
+   d="M 9.9570564,0.986598 7.7144328,3.0125734 c 0,0 4.3755802,2.2980148 4.9071092,2.5695984 0.531604,0.2715076 1.288117,0.7937837 0.470266,1.5668283 C 12.273956,7.9219687 11.374318,7.8175134 10.76093,7.5041478 10.147541,7.1907822 5.6084649,4.8509852 5.6084649,4.8509852 L 3.2981084,6.8564494 c 0,0 4.457217,2.318906 5.1933578,2.7158356 0.7360665,0.3970063 3.4758688,1.378809 6.0725478,-0.6894042 2.59668,-2.0682135 2.228721,-2.820291 2.228721,-2.9665283 0,-0.1462373 -0.06134,-0.9192059 -0.511157,-1.3996999 C 15.831685,4.0361586 14.523196,3.3467542 13.971146,3.0542796 13.419097,2.7618049 9.9570564,0.986598 9.9570564,0.986598 Z"
+   id="path6"
+   style="stroke-width:0.0751545" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<g
+   id="g56"
+   transform="matrix(0.07435014,0,0,0.07596743,-10.51139,0.06298594)">
+	<path
+   fill="#6d6e71"
+   d="m 393.104,167.064 c 0,4.471 -3.509,7.979 -8.076,7.979 -4.519,0 -8.123,-3.509 -8.123,-7.979 0,-4.375 3.604,-7.884 8.123,-7.884 4.568,0.001 8.076,3.509 8.076,7.884 z m -14.18,0 c 0,3.509 2.596,6.298 6.153,6.298 3.461,0 6.009,-2.789 6.009,-6.25 0,-3.51 -2.548,-6.346 -6.058,-6.346 -3.508,0.001 -6.104,2.837 -6.104,6.298 z m 4.855,4.134 h -1.827 v -7.883 c 0.722,-0.146 1.731,-0.241 3.029,-0.241 1.489,0 2.163,0.241 2.739,0.577 0.433,0.336 0.769,0.961 0.769,1.73 0,0.864 -0.672,1.538 -1.634,1.827 v 0.096 c 0.77,0.289 1.202,0.864 1.442,1.923 0.24,1.202 0.385,1.683 0.576,1.971 h -1.97 c -0.241,-0.288 -0.385,-1.01 -0.626,-1.923 -0.144,-0.865 -0.625,-1.25 -1.635,-1.25 h -0.864 v 3.173 z m 0.048,-4.47 h 0.865 c 1.01,0 1.827,-0.336 1.827,-1.153 0,-0.721 -0.528,-1.202 -1.683,-1.202 -0.481,0 -0.817,0.048 -1.01,0.097 v 2.258 z"
+   id="path54" />
+</g>
+
+</svg>
Binary file eric6/icons/oxygen/fileUML.png has changed

eric ide

mercurial