14 import rope |
14 import rope |
15 import rope.base.libutils |
15 import rope.base.libutils |
16 import rope.base.exceptions |
16 import rope.base.exceptions |
17 |
17 |
18 from PyQt4.QtCore import QObject |
18 from PyQt4.QtCore import QObject |
19 from PyQt4.QtGui import QMenu, QApplication, QMessageBox, QDialog, QAction |
19 from PyQt4.QtGui import QMenu, QApplication, QDialog, QAction |
20 from PyQt4.Qsci import QsciScintilla |
20 from PyQt4.Qsci import QsciScintilla |
21 |
21 |
22 from E5Gui.E5Application import e5App |
22 from E5Gui.E5Application import e5App |
23 |
23 from E5Gui import E5MessageBox |
24 from E5Gui.E5Action import E5Action |
24 from E5Gui.E5Action import E5Action |
25 |
25 |
26 import Utilities |
26 import Utilities |
27 |
27 |
28 |
28 |
784 |
784 |
785 def __ropeInfo(self): |
785 def __ropeInfo(self): |
786 """ |
786 """ |
787 Private slot to show some info about rope. |
787 Private slot to show some info about rope. |
788 """ |
788 """ |
789 QMessageBox.about(self.__ui, |
789 E5MessageBox.about(self.__ui, |
790 self.trUtf8("About rope"), |
790 self.trUtf8("About rope"), |
791 self.trUtf8("{0}\nVersion {1}\n\n{2}".format( |
791 self.trUtf8("{0}\nVersion {1}\n\n{2}".format( |
792 rope.INFO, rope.VERSION, rope.COPYRIGHT))) |
792 rope.INFO, rope.VERSION, rope.COPYRIGHT))) |
793 |
793 |
794 def __canUndo(self): |
794 def __canUndo(self): |
892 """ |
892 """ |
893 if handle is not None: |
893 if handle is not None: |
894 handle.reset() |
894 handle.reset() |
895 if str(type(err)).split()[-1][1:-2].split('.')[-1] == \ |
895 if str(type(err)).split()[-1][1:-2].split('.')[-1] == \ |
896 'ModuleSyntaxError': |
896 'ModuleSyntaxError': |
897 res = QMessageBox.warning(self.__ui, title, |
897 res = E5MessageBox.warning(self.__ui, title, |
898 self.trUtf8("Rope error: {0}").format(str(err)), |
898 self.trUtf8("Rope error: {0}").format(str(err)), |
899 QMessageBox.Ok | QMessageBox.Open) |
899 E5MessageBox.Ok | E5MessageBox.Open) |
900 if res == QMessageBox.Open: |
900 if res == E5MessageBox.Open: |
901 e5App().getObject("ViewManager").openSourceFile( |
901 e5App().getObject("ViewManager").openSourceFile( |
902 os.path.join(self.__e5project.getProjectPath(), |
902 os.path.join(self.__e5project.getProjectPath(), |
903 err.filename), |
903 err.filename), |
904 err.lineno) |
904 err.lineno) |
905 else: |
905 else: |
906 QMessageBox.warning(self.__ui, title, |
906 E5MessageBox.warning(self.__ui, title, |
907 self.trUtf8("Rope error: {0}").format(str(err))) |
907 self.trUtf8("Rope error: {0}").format(str(err))) |
908 |
908 |
909 def __getOffset(self, editor, line, index): |
909 def __getOffset(self, editor, line, index): |
910 """ |
910 """ |
911 Private method to get the offset into the text treating CRLF as ONE character. |
911 Private method to get the offset into the text treating CRLF as ONE character. |
983 offset = None |
983 offset = None |
984 else: |
984 else: |
985 line, index, line1, index1 = aw.getSelection() |
985 line, index, line1, index1 = aw.getSelection() |
986 if line != line1: |
986 if line != line1: |
987 # selection span more than one line |
987 # selection span more than one line |
988 QMessageBox.warning(self.__ui, title, |
988 E5MessageBox.warning(self.__ui, title, |
989 self.trUtf8("The selection must not extend beyond" |
989 self.trUtf8("The selection must not extend beyond" |
990 " one line.")) |
990 " one line.")) |
991 return |
991 return |
992 index = int(index + (index1 - index) / 2) |
992 index = int(index + (index1 - index) / 2) |
993 # keep it inside the object |
993 # keep it inside the object |
1022 return |
1022 return |
1023 |
1023 |
1024 title = self.trUtf8("Change Occurrences") |
1024 title = self.trUtf8("Change Occurrences") |
1025 if not aw.hasSelectedText(): |
1025 if not aw.hasSelectedText(): |
1026 # no selection available |
1026 # no selection available |
1027 QMessageBox.warning(self.__ui, title, |
1027 E5MessageBox.warning(self.__ui, title, |
1028 self.trUtf8("Highlight an occurrence to be changed" |
1028 self.trUtf8("Highlight an occurrence to be changed" |
1029 " and try again.")) |
1029 " and try again.")) |
1030 return |
1030 return |
1031 |
1031 |
1032 if not self.confirmBufferIsSaved(aw): |
1032 if not self.confirmBufferIsSaved(aw): |
1129 return |
1129 return |
1130 |
1130 |
1131 title = self.trUtf8("Inline") |
1131 title = self.trUtf8("Inline") |
1132 if not aw.hasSelectedText(): |
1132 if not aw.hasSelectedText(): |
1133 # no selection available |
1133 # no selection available |
1134 QMessageBox.warning(self.__ui, title, |
1134 E5MessageBox.warning(self.__ui, title, |
1135 self.trUtf8("Highlight the local variable, method or parameter" |
1135 self.trUtf8("Highlight the local variable, method or parameter" |
1136 " you want to inline and try again.")) |
1136 " you want to inline and try again.")) |
1137 return |
1137 return |
1138 |
1138 |
1139 if not self.confirmAllBuffersSaved(): |
1139 if not self.confirmAllBuffersSaved(): |
1171 return |
1171 return |
1172 |
1172 |
1173 title = self.trUtf8("Move Method") |
1173 title = self.trUtf8("Move Method") |
1174 if not aw.hasSelectedText(): |
1174 if not aw.hasSelectedText(): |
1175 # no selection available |
1175 # no selection available |
1176 QMessageBox.warning(self.__ui, title, |
1176 E5MessageBox.warning(self.__ui, title, |
1177 self.trUtf8("Highlight the method to move" |
1177 self.trUtf8("Highlight the method to move" |
1178 " and try again.")) |
1178 " and try again.")) |
1179 return |
1179 return |
1180 |
1180 |
1181 if not self.confirmAllBuffersSaved(): |
1181 if not self.confirmAllBuffersSaved(): |
1249 return |
1249 return |
1250 |
1250 |
1251 title = self.trUtf8("Use Function") |
1251 title = self.trUtf8("Use Function") |
1252 if not aw.hasSelectedText(): |
1252 if not aw.hasSelectedText(): |
1253 # no selection available |
1253 # no selection available |
1254 QMessageBox.warning(self.__ui, title, |
1254 E5MessageBox.warning(self.__ui, title, |
1255 self.trUtf8("Highlight a global function and try again.")) |
1255 self.trUtf8("Highlight a global function and try again.")) |
1256 return |
1256 return |
1257 |
1257 |
1258 if not self.confirmAllBuffersSaved(): |
1258 if not self.confirmAllBuffersSaved(): |
1259 return |
1259 return |
1290 return |
1290 return |
1291 |
1291 |
1292 title = self.trUtf8("Introduce Factory Method") |
1292 title = self.trUtf8("Introduce Factory Method") |
1293 if not aw.hasSelectedText(): |
1293 if not aw.hasSelectedText(): |
1294 # no selection available |
1294 # no selection available |
1295 QMessageBox.warning(self.__ui, title, |
1295 E5MessageBox.warning(self.__ui, title, |
1296 self.trUtf8("Highlight the class to introduce a factory" |
1296 self.trUtf8("Highlight the class to introduce a factory" |
1297 " method for and try again.")) |
1297 " method for and try again.")) |
1298 return |
1298 return |
1299 |
1299 |
1300 if not self.confirmAllBuffersSaved(): |
1300 if not self.confirmAllBuffersSaved(): |
1330 return |
1330 return |
1331 |
1331 |
1332 title = self.trUtf8("Introduce Parameter") |
1332 title = self.trUtf8("Introduce Parameter") |
1333 if not aw.hasSelectedText(): |
1333 if not aw.hasSelectedText(): |
1334 # no selection available |
1334 # no selection available |
1335 QMessageBox.warning(self.__ui, title, |
1335 E5MessageBox.warning(self.__ui, title, |
1336 self.trUtf8("Highlight the code for the new parameter" |
1336 self.trUtf8("Highlight the code for the new parameter" |
1337 " and try again.")) |
1337 " and try again.")) |
1338 return |
1338 return |
1339 |
1339 |
1340 if not self.confirmAllBuffersSaved(): |
1340 if not self.confirmAllBuffersSaved(): |
1435 self.__project.do(changes) |
1435 self.__project.do(changes) |
1436 self.refreshEditors(changes) |
1436 self.refreshEditors(changes) |
1437 if self.__e5project.isDirty(): |
1437 if self.__e5project.isDirty(): |
1438 self.__e5project.saveProject() |
1438 self.__e5project.saveProject() |
1439 else: |
1439 else: |
1440 QMessageBox.information(self.__ui, title, |
1440 E5MessageBox.information(self.__ui, title, |
1441 self.trUtf8("The selected refactoring did not produce" |
1441 self.trUtf8("The selected refactoring did not produce" |
1442 " any change.")) |
1442 " any change.")) |
1443 except Exception as err: |
1443 except Exception as err: |
1444 self.handleRopeError(err, title) |
1444 self.handleRopeError(err, title) |
1445 |
1445 |
1466 return |
1466 return |
1467 |
1467 |
1468 title = self.trUtf8("Change Method Signature") |
1468 title = self.trUtf8("Change Method Signature") |
1469 if not aw.hasSelectedText(): |
1469 if not aw.hasSelectedText(): |
1470 # no selection available |
1470 # no selection available |
1471 QMessageBox.warning(self.__ui, title, |
1471 E5MessageBox.warning(self.__ui, title, |
1472 self.trUtf8("Highlight the method or function to change" |
1472 self.trUtf8("Highlight the method or function to change" |
1473 " and try again.")) |
1473 " and try again.")) |
1474 return |
1474 return |
1475 |
1475 |
1476 if not self.confirmAllBuffersSaved(): |
1476 if not self.confirmAllBuffersSaved(): |
1506 return |
1506 return |
1507 |
1507 |
1508 title = self.trUtf8("Inline Argument Default") |
1508 title = self.trUtf8("Inline Argument Default") |
1509 if not aw.hasSelectedText(): |
1509 if not aw.hasSelectedText(): |
1510 # no selection available |
1510 # no selection available |
1511 QMessageBox.warning(self.__ui, title, |
1511 E5MessageBox.warning(self.__ui, title, |
1512 self.trUtf8("Highlight the method or function to inline" |
1512 self.trUtf8("Highlight the method or function to inline" |
1513 " a parameter's default and try again.")) |
1513 " a parameter's default and try again.")) |
1514 return |
1514 return |
1515 |
1515 |
1516 if not self.confirmAllBuffersSaved(): |
1516 if not self.confirmAllBuffersSaved(): |
1574 return |
1574 return |
1575 |
1575 |
1576 title = self.trUtf8("Encapsulate Attribute") |
1576 title = self.trUtf8("Encapsulate Attribute") |
1577 if not aw.hasSelectedText(): |
1577 if not aw.hasSelectedText(): |
1578 # no selection available |
1578 # no selection available |
1579 QMessageBox.warning(self.__ui, title, |
1579 E5MessageBox.warning(self.__ui, title, |
1580 self.trUtf8("Highlight the attribute to encapsulate" |
1580 self.trUtf8("Highlight the attribute to encapsulate" |
1581 " and try again.")) |
1581 " and try again.")) |
1582 return |
1582 return |
1583 |
1583 |
1584 if not self.confirmAllBuffersSaved(): |
1584 if not self.confirmAllBuffersSaved(): |
1631 return |
1631 return |
1632 |
1632 |
1633 title = self.trUtf8("Local Variable to Attribute") |
1633 title = self.trUtf8("Local Variable to Attribute") |
1634 if not aw.hasSelectedText(): |
1634 if not aw.hasSelectedText(): |
1635 # no selection available |
1635 # no selection available |
1636 QMessageBox.warning(self.__ui, title, |
1636 E5MessageBox.warning(self.__ui, title, |
1637 self.trUtf8("Highlight the local variable to make an attribute" |
1637 self.trUtf8("Highlight the local variable to make an attribute" |
1638 " and try again.")) |
1638 " and try again.")) |
1639 return |
1639 return |
1640 |
1640 |
1641 if not self.confirmAllBuffersSaved(): |
1641 if not self.confirmAllBuffersSaved(): |
1671 return |
1671 return |
1672 |
1672 |
1673 title = self.trUtf8("Replace Method With Method Object") |
1673 title = self.trUtf8("Replace Method With Method Object") |
1674 if not aw.hasSelectedText(): |
1674 if not aw.hasSelectedText(): |
1675 # no selection available |
1675 # no selection available |
1676 QMessageBox.warning(self.__ui, title, |
1676 E5MessageBox.warning(self.__ui, title, |
1677 self.trUtf8("Highlight the method or function to convert" |
1677 self.trUtf8("Highlight the method or function to convert" |
1678 " and try again.")) |
1678 " and try again.")) |
1679 return |
1679 return |
1680 |
1680 |
1681 if not self.confirmAllBuffersSaved(): |
1681 if not self.confirmAllBuffersSaved(): |
1708 """ |
1708 """ |
1709 Private slot to undo the last refactoring. |
1709 Private slot to undo the last refactoring. |
1710 """ |
1710 """ |
1711 title = self.trUtf8("Undo refactoring") |
1711 title = self.trUtf8("Undo refactoring") |
1712 history = self.__project.history |
1712 history = self.__project.history |
1713 res = QMessageBox.question(None, |
1713 res = E5MessageBox.yesNo(None, |
1714 title, |
1714 title, |
1715 self.trUtf8("""Shall the refactoring <b>{0}</b> be undone?""")\ |
1715 self.trUtf8("""Shall the refactoring <b>{0}</b> be undone?""")\ |
1716 .format(Utilities.html_encode( |
1716 .format(Utilities.html_encode( |
1717 history.undo_list[-1].description)), |
1717 history.undo_list[-1].description))) |
1718 QMessageBox.StandardButtons( |
1718 if res: |
1719 QMessageBox.No | \ |
|
1720 QMessageBox.Yes), |
|
1721 QMessageBox.No) |
|
1722 if res == QMessageBox.Yes: |
|
1723 if not self.confirmAllBuffersSaved(): |
1719 if not self.confirmAllBuffersSaved(): |
1724 return |
1720 return |
1725 |
1721 |
1726 from ProgressHandle import ProgressHandle |
1722 from ProgressHandle import ProgressHandle |
1727 changes = history.undo_list[-1] |
1723 changes = history.undo_list[-1] |
1741 """ |
1737 """ |
1742 Private slot to redo the last refactoring. |
1738 Private slot to redo the last refactoring. |
1743 """ |
1739 """ |
1744 title = self.trUtf8("Redo refactoring") |
1740 title = self.trUtf8("Redo refactoring") |
1745 history = self.__project.history |
1741 history = self.__project.history |
1746 res = QMessageBox.question(None, |
1742 res = E5MessageBox.yesNo(None, |
1747 title, |
1743 title, |
1748 self.trUtf8("""Shall the refactoring <b>{0}</b> be redone?""")\ |
1744 self.trUtf8("""Shall the refactoring <b>{0}</b> be redone?""")\ |
1749 .format(Utilities.html_encode( |
1745 .format(Utilities.html_encode( |
1750 history.redo_list[-1].description)), |
1746 history.redo_list[-1].description))) |
1751 QMessageBox.StandardButtons(\ |
1747 if res: |
1752 QMessageBox.No | \ |
|
1753 QMessageBox.Yes), |
|
1754 QMessageBox.No) |
|
1755 if res == QMessageBox.Yes: |
|
1756 if not self.confirmAllBuffersSaved(): |
1748 if not self.confirmAllBuffersSaved(): |
1757 return |
1749 return |
1758 |
1750 |
1759 from ProgressHandle import ProgressHandle |
1751 from ProgressHandle import ProgressHandle |
1760 changes = history.redo_list[-1] |
1752 changes = history.redo_list[-1] |
1826 |
1818 |
1827 def __clearHistory(self): |
1819 def __clearHistory(self): |
1828 """ |
1820 """ |
1829 Private slot to clear the redo and undo lists. |
1821 Private slot to clear the redo and undo lists. |
1830 """ |
1822 """ |
1831 res = QMessageBox.question(None, |
1823 res = E5MessageBox.yesNo(None, |
1832 self.trUtf8("Clear History"), |
1824 self.trUtf8("Clear History"), |
1833 self.trUtf8("""Do you really want to clear the undo""" |
1825 self.trUtf8("""Do you really want to clear the undo""" |
1834 """ and redo history?"""), |
1826 """ and redo history?""")) |
1835 QMessageBox.StandardButtons(\ |
1827 if res: |
1836 QMessageBox.No | \ |
|
1837 QMessageBox.Yes), |
|
1838 QMessageBox.No) |
|
1839 if res == QMessageBox.Yes: |
|
1840 self.__project.history.clear() |
1828 self.__project.history.clear() |
1841 |
1829 |
1842 ##################################################### |
1830 ##################################################### |
1843 ## Find actions |
1831 ## Find actions |
1844 ##################################################### |
1832 ##################################################### |
1853 return |
1841 return |
1854 |
1842 |
1855 title = self.trUtf8("Find Occurrences") |
1843 title = self.trUtf8("Find Occurrences") |
1856 if not aw.hasSelectedText(): |
1844 if not aw.hasSelectedText(): |
1857 # no selection available |
1845 # no selection available |
1858 QMessageBox.warning(self.__ui, title, |
1846 E5MessageBox.warning(self.__ui, title, |
1859 self.trUtf8("Highlight the class, method, function or variable" |
1847 self.trUtf8("Highlight the class, method, function or variable" |
1860 " to search for and try again.")) |
1848 " to search for and try again.")) |
1861 return |
1849 return |
1862 |
1850 |
1863 if not self.confirmAllBuffersSaved(): |
1851 if not self.confirmAllBuffersSaved(): |
1889 self.dlg.show() |
1877 self.dlg.show() |
1890 for occurrence in occurrences: |
1878 for occurrence in occurrences: |
1891 self.dlg.addEntry(occurrence.resource, |
1879 self.dlg.addEntry(occurrence.resource, |
1892 occurrence.lineno, occurrence.unsure) |
1880 occurrence.lineno, occurrence.unsure) |
1893 else: |
1881 else: |
1894 QMessageBox.warning(self.__ui, title, |
1882 E5MessageBox.warning(self.__ui, title, |
1895 self.trUtf8("No occurrences found.")) |
1883 self.trUtf8("No occurrences found.")) |
1896 |
1884 |
1897 def __queryDefinition(self): |
1885 def __queryDefinition(self): |
1898 """ |
1886 """ |
1899 Private slot to handle the Find Definition action |
1887 Private slot to handle the Find Definition action |
1904 return |
1892 return |
1905 |
1893 |
1906 title = self.trUtf8("Find &Definition") |
1894 title = self.trUtf8("Find &Definition") |
1907 if not aw.hasSelectedText(): |
1895 if not aw.hasSelectedText(): |
1908 # no selection available |
1896 # no selection available |
1909 QMessageBox.warning(self.__ui, title, |
1897 E5MessageBox.warning(self.__ui, title, |
1910 self.trUtf8("Highlight the class, method, function or" |
1898 self.trUtf8("Highlight the class, method, function or" |
1911 " variable reference to search definition for and" |
1899 " variable reference to search definition for and" |
1912 " try again.")) |
1900 " try again.")) |
1913 return |
1901 return |
1914 |
1902 |
1933 from MatchesDialog import MatchesDialog |
1921 from MatchesDialog import MatchesDialog |
1934 self.dlg = MatchesDialog(self.__ui, False) |
1922 self.dlg = MatchesDialog(self.__ui, False) |
1935 self.dlg.show() |
1923 self.dlg.show() |
1936 self.dlg.addEntry(location.resource, location.lineno) |
1924 self.dlg.addEntry(location.resource, location.lineno) |
1937 else: |
1925 else: |
1938 QMessageBox.warning(self.__ui, title, |
1926 E5MessageBox.warning(self.__ui, title, |
1939 self.trUtf8("No matching definition found.")) |
1927 self.trUtf8("No matching definition found.")) |
1940 |
1928 |
1941 def __queryImplementations(self): |
1929 def __queryImplementations(self): |
1942 """ |
1930 """ |
1943 Private slot to handle the Find Implementations action. |
1931 Private slot to handle the Find Implementations action. |
1948 return |
1936 return |
1949 |
1937 |
1950 title = self.trUtf8("Find Implementations") |
1938 title = self.trUtf8("Find Implementations") |
1951 if not aw.hasSelectedText(): |
1939 if not aw.hasSelectedText(): |
1952 # no selection available |
1940 # no selection available |
1953 QMessageBox.warning(self.__ui, title, |
1941 E5MessageBox.warning(self.__ui, title, |
1954 self.trUtf8("Highlight the method to search for" |
1942 self.trUtf8("Highlight the method to search for" |
1955 " and try again.")) |
1943 " and try again.")) |
1956 return |
1944 return |
1957 |
1945 |
1958 if not self.confirmAllBuffersSaved(): |
1946 if not self.confirmAllBuffersSaved(): |
1983 self.dlg.show() |
1971 self.dlg.show() |
1984 for occurrence in occurrences: |
1972 for occurrence in occurrences: |
1985 self.dlg.addEntry(occurrence.resource, |
1973 self.dlg.addEntry(occurrence.resource, |
1986 occurrence.lineno, occurrence.unsure) |
1974 occurrence.lineno, occurrence.unsure) |
1987 else: |
1975 else: |
1988 QMessageBox.warning(self.__ui, title, |
1976 E5MessageBox.warning(self.__ui, title, |
1989 self.trUtf8("No occurrences found.")) |
1977 self.trUtf8("No occurrences found.")) |
1990 |
1978 |
1991 ##################################################### |
1979 ##################################################### |
1992 ## Various actions |
1980 ## Various actions |
1993 ##################################################### |
1981 ##################################################### |
2004 from QScintilla.MiniEditor import MiniEditor |
1992 from QScintilla.MiniEditor import MiniEditor |
2005 self.__editor = MiniEditor(configfile) |
1993 self.__editor = MiniEditor(configfile) |
2006 self.__editor.show() |
1994 self.__editor.show() |
2007 self.__editor.editorSaved.connect(self.__configChanged) |
1995 self.__editor.editorSaved.connect(self.__configChanged) |
2008 else: |
1996 else: |
2009 QMessageBox.critical(self.__ui, |
1997 E5MessageBox.critical(self.__ui, |
2010 self.trUtf8("Configure Rope"), |
1998 self.trUtf8("Configure Rope"), |
2011 self.trUtf8("""The Rope configuration file '{0}' does""" |
1999 self.trUtf8("""The Rope configuration file '{0}' does""" |
2012 """ not exist.""").format(configfile)) |
2000 """ not exist.""").format(configfile)) |
2013 else: |
2001 else: |
2014 QMessageBox.critical(self.__ui, |
2002 E5MessageBox.critical(self.__ui, |
2015 self.trUtf8("Configure Rope"), |
2003 self.trUtf8("Configure Rope"), |
2016 self.trUtf8("""The Rope admin directory does not exist.""")) |
2004 self.trUtf8("""The Rope admin directory does not exist.""")) |
2017 |
2005 |
2018 def __updateConfig(self): |
2006 def __updateConfig(self): |
2019 """ |
2007 """ |
2020 Private slot to update the configuration file. |
2008 Private slot to update the configuration file. |
2021 """ |
2009 """ |
2022 res = QMessageBox.question(self.__ui, |
2010 res = E5MessageBox.yesNo(self.__ui, |
2023 self.trUtf8("Update Configuration"), |
2011 self.trUtf8("Update Configuration"), |
2024 self.trUtf8("""Shall rope's current configuration be replaced """ |
2012 self.trUtf8("""Shall rope's current configuration be replaced """ |
2025 """by a new default configuration?"""), |
2013 """by a new default configuration?""")) |
2026 QMessageBox.StandardButtons(\ |
2014 if res: |
2027 QMessageBox.No | \ |
|
2028 QMessageBox.Yes), |
|
2029 QMessageBox.No) |
|
2030 if res == QMessageBox.Yes: |
|
2031 src = self.__defaultConfig() |
2015 src = self.__defaultConfig() |
2032 cname = self.__ropeConfigFile() |
2016 cname = self.__ropeConfigFile() |
2033 if src != "" and cname is not None: |
2017 if src != "" and cname is not None: |
2034 try: |
2018 try: |
2035 f = open(cname, "w") |
2019 f = open(cname, "w") |
2036 f.write(src) |
2020 f.write(src) |
2037 f.close() |
2021 f.close() |
2038 self.__configChanged() |
2022 self.__configChanged() |
2039 self.__editConfig() |
2023 self.__editConfig() |
2040 except IOError as err: |
2024 except IOError as err: |
2041 QMessageBox.critical(None, |
2025 E5MessageBox.critical(None, |
2042 self.trUtf8("Update Configuration"), |
2026 self.trUtf8("Update Configuration"), |
2043 self.trUtf8("""<p>The configuration could not be""" |
2027 self.trUtf8("""<p>The configuration could not be""" |
2044 """ updated.</p><p>Reason: {0}</p>""")\ |
2028 """ updated.</p><p>Reason: {0}</p>""")\ |
2045 .format(str(err))) |
2029 .format(str(err))) |
2046 |
2030 |
2060 def __performSOA(self): |
2044 def __performSOA(self): |
2061 """ |
2045 """ |
2062 Private slot to perform SOA on all modules. |
2046 Private slot to perform SOA on all modules. |
2063 """ |
2047 """ |
2064 title = self.trUtf8("Analyse all modules") |
2048 title = self.trUtf8("Analyse all modules") |
2065 res = QMessageBox.question(self.__ui, |
2049 res = E5MessageBox.yesNo(self.__ui, |
2066 title, |
2050 title, |
2067 self.trUtf8("""This action might take some time. """ |
2051 self.trUtf8("""This action might take some time. """ |
2068 """Do you really want to perform SOA?"""), |
2052 """Do you really want to perform SOA?""")) |
2069 QMessageBox.StandardButtons(\ |
2053 if res: |
2070 QMessageBox.No | \ |
|
2071 QMessageBox.Yes), |
|
2072 QMessageBox.No) |
|
2073 if res == QMessageBox.Yes: |
|
2074 from ProgressHandle import ProgressHandle |
2054 from ProgressHandle import ProgressHandle |
2075 handle = ProgressHandle(title, True, self.__ui) |
2055 handle = ProgressHandle(title, True, self.__ui) |
2076 handle.show() |
2056 handle.show() |
2077 QApplication.processEvents() |
2057 QApplication.processEvents() |
2078 try: |
2058 try: |
2079 rope.base.libutils.analyze_modules(self.__project, |
2059 rope.base.libutils.analyze_modules(self.__project, |
2080 task_handle=handle) |
2060 task_handle=handle) |
2081 handle.reset() |
2061 handle.reset() |
2082 QMessageBox.information(self.__ui, |
2062 E5MessageBox.information(self.__ui, |
2083 title, |
2063 title, |
2084 self.trUtf8("""Static object analysis (SOA) done. """ |
2064 self.trUtf8("""Static object analysis (SOA) done. """ |
2085 """SOA database updated.""")) |
2065 """SOA database updated.""")) |
2086 except Exception as err: |
2066 except Exception as err: |
2087 self.handleRopeError(err, title, handle) |
2067 self.handleRopeError(err, title, handle) |