RefactoringRope/Refactoring.py

changeset 14
cc9f4507be3d
parent 13
dad628301abc
child 16
65b340b40844
diff -r dad628301abc -r cc9f4507be3d RefactoringRope/Refactoring.py
--- a/RefactoringRope/Refactoring.py	Sun Jan 30 17:35:48 2011 +0100
+++ b/RefactoringRope/Refactoring.py	Sun Jan 30 17:53:38 2011 +0100
@@ -695,6 +695,40 @@
             self.__showRopeHelp)
         self.actions.append(self.refactoringHelpAct)
         
+        self.refactoringAllSoaAct = E5Action(
+                self.trUtf8('Analyse all modules'),
+                self.trUtf8('&Analyse all modules'),
+                0, 0,
+                self,'refactoring_analyze_all')
+        self.refactoringAllSoaAct.setStatusTip(self.trUtf8(
+            'Perform static object analysis on all modules'))
+        self.refactoringAllSoaAct.setWhatsThis(self.trUtf8(
+            """<b>Analyse all modules</b>"""
+            """<p>Perform static object analysis (SOA) on all modules. """
+            """This might be time consuming. Analysis of all modules """
+            """should only be neccessary, if the project was created """
+            """with the rope plugin disabled or if files were added.</p>"""
+        ))
+        self.refactoringAllSoaAct.triggered[()].connect(
+            self.__performSOA)
+        self.actions.append(self.refactoringAllSoaAct)
+        
+        self.updateConfigAct = E5Action(
+                self.trUtf8('Update Configuration'),
+                self.trUtf8('&Update Configuration'),
+                0, 0,
+                self,'refactoring_update_configuration')
+        self.updateConfigAct.setStatusTip(self.trUtf8(
+            'Generates a new configuration file overwriting the current one.'))
+        self.updateConfigAct.setWhatsThis(self.trUtf8(
+            """<b>Update Configuration</b>"""
+            """<p>Generates a new configuration file overwriting"""
+            """ the current one.</p>"""
+        ))
+        self.updateConfigAct.triggered[()].connect(
+            self.__updateConfig)
+        self.actions.append(self.updateConfigAct)
+        
         for act in self.actions:
             act.setEnabled(False)
     
@@ -773,6 +807,11 @@
         hmenu.addSeparator()
         hmenu.addAction(self.refactoringClearHistoryAct)
         
+        smenu = menu.addMenu(self.trUtf8("&Utilities"))
+        smenu.addAction(self.refactoringAllSoaAct)
+        smenu.addSeparator()
+        smenu.addAction(self.updateConfigAct)
+        
         menu.addSeparator()
         menu.addAction(self.refactoringEditConfigAct)
         menu.addAction(self.refactoringHelpAct)
@@ -1947,6 +1986,31 @@
                 self.trUtf8("Configure Rope"),
                 self.trUtf8("""The Rope admin directory does not exist."""))
     
+    def __updateConfig(self):
+        """
+        Private slot to update the configuration file.
+        """
+        res = E5MessageBox.yesNo(self.__ui,
+            self.trUtf8("Update Configuration"),
+            self.trUtf8("""Shall rope's current configuration be replaced """
+                        """by a new default configuration?"""))
+        if res:
+            src = self.__defaultConfig()
+            cname = self.__ropeConfigFile()
+            if src != "" and cname is not None:
+                try:
+                    f = open(cname, "w")
+                    f.write(src)
+                    f.close()
+                    self.__configChanged()
+                    self.__editConfig()
+                except IOError as err:
+                    E5MessageBox.critical(None,
+                        self.trUtf8("Update Configuration"),
+                        self.trUtf8("""<p>The configuration could not be"""
+                                    """ updated.</p><p>Reason: {0}</p>""")\
+                            .format(str(err)))
+    
     def __showRopeHelp(self):
         """
         Private slot to show help about the refactorings offered by Rope.
@@ -1959,6 +2023,30 @@
                            helpfile)
         self.__helpDialog.show()
     
+    def __performSOA(self):
+        """
+        Private slot to perform SOA on all modules.
+        """
+        title = self.trUtf8("Analyse all modules")
+        res = E5MessageBox.yesNo(self.__ui,
+            title,
+            self.trUtf8("""This action might take some time. """
+                        """Do you really want to perform SOA?"""))
+        if res:
+            handle = ProgressHandle(title, True, self.__ui)
+            handle.show()
+            QApplication.processEvents()
+            try:
+                rope.base.libutils.analyze_modules(self.__project, 
+                    task_handle=handle)
+                handle.reset()
+                E5MessageBox.information(self.__ui,
+                    title,
+                    self.trUtf8("""Static object analysis (SOA) done. """
+                                """SOA database updated."""))
+            except Exception as err:
+                self.handleRopeError(err, title, handle)
+    
     ##################################################################
     ## methods below are private utility methods
     ##################################################################

eric ide

mercurial