RefactoringRope/Refactoring.py

changeset 14
cc9f4507be3d
parent 13
dad628301abc
child 16
65b340b40844
equal deleted inserted replaced
13:dad628301abc 14:cc9f4507be3d
693 )) 693 ))
694 self.refactoringHelpAct.triggered[()].connect( 694 self.refactoringHelpAct.triggered[()].connect(
695 self.__showRopeHelp) 695 self.__showRopeHelp)
696 self.actions.append(self.refactoringHelpAct) 696 self.actions.append(self.refactoringHelpAct)
697 697
698 self.refactoringAllSoaAct = E5Action(
699 self.trUtf8('Analyse all modules'),
700 self.trUtf8('&Analyse all modules'),
701 0, 0,
702 self,'refactoring_analyze_all')
703 self.refactoringAllSoaAct.setStatusTip(self.trUtf8(
704 'Perform static object analysis on all modules'))
705 self.refactoringAllSoaAct.setWhatsThis(self.trUtf8(
706 """<b>Analyse all modules</b>"""
707 """<p>Perform static object analysis (SOA) on all modules. """
708 """This might be time consuming. Analysis of all modules """
709 """should only be neccessary, if the project was created """
710 """with the rope plugin disabled or if files were added.</p>"""
711 ))
712 self.refactoringAllSoaAct.triggered[()].connect(
713 self.__performSOA)
714 self.actions.append(self.refactoringAllSoaAct)
715
716 self.updateConfigAct = E5Action(
717 self.trUtf8('Update Configuration'),
718 self.trUtf8('&Update Configuration'),
719 0, 0,
720 self,'refactoring_update_configuration')
721 self.updateConfigAct.setStatusTip(self.trUtf8(
722 'Generates a new configuration file overwriting the current one.'))
723 self.updateConfigAct.setWhatsThis(self.trUtf8(
724 """<b>Update Configuration</b>"""
725 """<p>Generates a new configuration file overwriting"""
726 """ the current one.</p>"""
727 ))
728 self.updateConfigAct.triggered[()].connect(
729 self.__updateConfig)
730 self.actions.append(self.updateConfigAct)
731
698 for act in self.actions: 732 for act in self.actions:
699 act.setEnabled(False) 733 act.setEnabled(False)
700 734
701 def initMenu(self): 735 def initMenu(self):
702 """ 736 """
771 hmenu.addAction(self.refactoringRedoHistoryAct) 805 hmenu.addAction(self.refactoringRedoHistoryAct)
772 hmenu.addAction(self.refactoringRedoFileHistoryAct) 806 hmenu.addAction(self.refactoringRedoFileHistoryAct)
773 hmenu.addSeparator() 807 hmenu.addSeparator()
774 hmenu.addAction(self.refactoringClearHistoryAct) 808 hmenu.addAction(self.refactoringClearHistoryAct)
775 809
810 smenu = menu.addMenu(self.trUtf8("&Utilities"))
811 smenu.addAction(self.refactoringAllSoaAct)
812 smenu.addSeparator()
813 smenu.addAction(self.updateConfigAct)
814
776 menu.addSeparator() 815 menu.addSeparator()
777 menu.addAction(self.refactoringEditConfigAct) 816 menu.addAction(self.refactoringEditConfigAct)
778 menu.addAction(self.refactoringHelpAct) 817 menu.addAction(self.refactoringHelpAct)
779 818
780 self.__mainMenu = menu 819 self.__mainMenu = menu
1945 else: 1984 else:
1946 E5MessageBox.critical(self.__ui, 1985 E5MessageBox.critical(self.__ui,
1947 self.trUtf8("Configure Rope"), 1986 self.trUtf8("Configure Rope"),
1948 self.trUtf8("""The Rope admin directory does not exist.""")) 1987 self.trUtf8("""The Rope admin directory does not exist."""))
1949 1988
1989 def __updateConfig(self):
1990 """
1991 Private slot to update the configuration file.
1992 """
1993 res = E5MessageBox.yesNo(self.__ui,
1994 self.trUtf8("Update Configuration"),
1995 self.trUtf8("""Shall rope's current configuration be replaced """
1996 """by a new default configuration?"""))
1997 if res:
1998 src = self.__defaultConfig()
1999 cname = self.__ropeConfigFile()
2000 if src != "" and cname is not None:
2001 try:
2002 f = open(cname, "w")
2003 f.write(src)
2004 f.close()
2005 self.__configChanged()
2006 self.__editConfig()
2007 except IOError as err:
2008 E5MessageBox.critical(None,
2009 self.trUtf8("Update Configuration"),
2010 self.trUtf8("""<p>The configuration could not be"""
2011 """ updated.</p><p>Reason: {0}</p>""")\
2012 .format(str(err)))
2013
1950 def __showRopeHelp(self): 2014 def __showRopeHelp(self):
1951 """ 2015 """
1952 Private slot to show help about the refactorings offered by Rope. 2016 Private slot to show help about the refactorings offered by Rope.
1953 """ 2017 """
1954 if self.__helpDialog is None: 2018 if self.__helpDialog is None:
1956 "rope", "docs", "overview.txt") 2020 "rope", "docs", "overview.txt")
1957 self.__helpDialog = \ 2021 self.__helpDialog = \
1958 HelpDialog(self.trUtf8("Help about rope refactorings"), 2022 HelpDialog(self.trUtf8("Help about rope refactorings"),
1959 helpfile) 2023 helpfile)
1960 self.__helpDialog.show() 2024 self.__helpDialog.show()
2025
2026 def __performSOA(self):
2027 """
2028 Private slot to perform SOA on all modules.
2029 """
2030 title = self.trUtf8("Analyse all modules")
2031 res = E5MessageBox.yesNo(self.__ui,
2032 title,
2033 self.trUtf8("""This action might take some time. """
2034 """Do you really want to perform SOA?"""))
2035 if res:
2036 handle = ProgressHandle(title, True, self.__ui)
2037 handle.show()
2038 QApplication.processEvents()
2039 try:
2040 rope.base.libutils.analyze_modules(self.__project,
2041 task_handle=handle)
2042 handle.reset()
2043 E5MessageBox.information(self.__ui,
2044 title,
2045 self.trUtf8("""Static object analysis (SOA) done. """
2046 """SOA database updated."""))
2047 except Exception as err:
2048 self.handleRopeError(err, title, handle)
1961 2049
1962 ################################################################## 2050 ##################################################################
1963 ## methods below are private utility methods 2051 ## methods below are private utility methods
1964 ################################################################## 2052 ##################################################################
1965 2053

eric ide

mercurial