11 import contextlib |
11 import contextlib |
12 |
12 |
13 from PyQt6.QtCore import pyqtSignal |
13 from PyQt6.QtCore import pyqtSignal |
14 from PyQt6.QtWidgets import QDialog, QInputDialog, QMenu |
14 from PyQt6.QtWidgets import QDialog, QInputDialog, QMenu |
15 |
15 |
16 from E5Gui import E5MessageBox |
16 from E5Gui import EricMessageBox |
17 |
17 |
18 from UI.BrowserModel import ( |
18 from UI.BrowserModel import ( |
19 BrowserFileItem, BrowserClassItem, BrowserMethodItem, |
19 BrowserFileItem, BrowserClassItem, BrowserMethodItem, |
20 BrowserClassAttributeItem, BrowserImportItem |
20 BrowserClassAttributeItem, BrowserImportItem |
21 ) |
21 ) |
822 packagePath = os.path.join(packagePath, name) |
822 packagePath = os.path.join(packagePath, name) |
823 if not os.path.exists(packagePath): |
823 if not os.path.exists(packagePath): |
824 try: |
824 try: |
825 os.mkdir(packagePath) |
825 os.mkdir(packagePath) |
826 except OSError as err: |
826 except OSError as err: |
827 E5MessageBox.critical( |
827 EricMessageBox.critical( |
828 self, |
828 self, |
829 self.tr("Add new Python package"), |
829 self.tr("Add new Python package"), |
830 self.tr( |
830 self.tr( |
831 """<p>The package directory <b>{0}</b> could""" |
831 """<p>The package directory <b>{0}</b> could""" |
832 """ not be created. Aborting...</p>""" |
832 """ not be created. Aborting...</p>""" |
837 if not os.path.exists(packageFile): |
837 if not os.path.exists(packageFile): |
838 try: |
838 try: |
839 with open(packageFile, "w", encoding="utf-8"): |
839 with open(packageFile, "w", encoding="utf-8"): |
840 pass |
840 pass |
841 except OSError as err: |
841 except OSError as err: |
842 E5MessageBox.critical( |
842 EricMessageBox.critical( |
843 self, |
843 self, |
844 self.tr("Add new Python package"), |
844 self.tr("Add new Python package"), |
845 self.tr( |
845 self.tr( |
846 """<p>The package file <b>{0}</b> could""" |
846 """<p>The package file <b>{0}</b> could""" |
847 """ not be created. Aborting...</p>""" |
847 """ not be created. Aborting...</p>""" |
1070 itm = self.model().item(self.currentIndex()) |
1070 itm = self.model().item(self.currentIndex()) |
1071 try: |
1071 try: |
1072 fn = itm.fileName() |
1072 fn = itm.fileName() |
1073 except AttributeError: |
1073 except AttributeError: |
1074 fn = itm.dirName() |
1074 fn = itm.dirName() |
1075 res = E5MessageBox.yesNo( |
1075 res = EricMessageBox.yesNo( |
1076 self, |
1076 self, |
1077 self.tr("Class Diagram"), |
1077 self.tr("Class Diagram"), |
1078 self.tr("""Include class attributes?"""), |
1078 self.tr("""Include class attributes?"""), |
1079 yesDefault=True) |
1079 yesDefault=True) |
1080 |
1080 |
1092 try: |
1092 try: |
1093 fn = itm.fileName() |
1093 fn = itm.fileName() |
1094 except AttributeError: |
1094 except AttributeError: |
1095 fn = itm.dirName() |
1095 fn = itm.dirName() |
1096 package = fn if os.path.isdir(fn) else os.path.dirname(fn) |
1096 package = fn if os.path.isdir(fn) else os.path.dirname(fn) |
1097 res = E5MessageBox.yesNo( |
1097 res = EricMessageBox.yesNo( |
1098 self, |
1098 self, |
1099 self.tr("Imports Diagram"), |
1099 self.tr("Imports Diagram"), |
1100 self.tr("""Include imports from external modules?""")) |
1100 self.tr("""Include imports from external modules?""")) |
1101 |
1101 |
1102 from Graphics.UMLDialog import UMLDialog, UMLDialogType |
1102 from Graphics.UMLDialog import UMLDialog, UMLDialogType |
1113 try: |
1113 try: |
1114 fn = itm.fileName() |
1114 fn = itm.fileName() |
1115 except AttributeError: |
1115 except AttributeError: |
1116 fn = itm.dirName() |
1116 fn = itm.dirName() |
1117 package = fn if os.path.isdir(fn) else os.path.dirname(fn) |
1117 package = fn if os.path.isdir(fn) else os.path.dirname(fn) |
1118 res = E5MessageBox.yesNo( |
1118 res = EricMessageBox.yesNo( |
1119 self, |
1119 self, |
1120 self.tr("Package Diagram"), |
1120 self.tr("Package Diagram"), |
1121 self.tr("""Include class attributes?"""), |
1121 self.tr("""Include class attributes?"""), |
1122 yesDefault=True) |
1122 yesDefault=True) |
1123 |
1123 |
1129 |
1129 |
1130 def __showApplicationDiagram(self): |
1130 def __showApplicationDiagram(self): |
1131 """ |
1131 """ |
1132 Private method to handle the application diagram context menu action. |
1132 Private method to handle the application diagram context menu action. |
1133 """ |
1133 """ |
1134 res = E5MessageBox.yesNo( |
1134 res = EricMessageBox.yesNo( |
1135 self, |
1135 self, |
1136 self.tr("Application Diagram"), |
1136 self.tr("Application Diagram"), |
1137 self.tr("""Include module names?"""), |
1137 self.tr("""Include module names?"""), |
1138 yesDefault=True) |
1138 yesDefault=True) |
1139 |
1139 |