RefactoringRope/Refactoring.py

changeset 48
de33dc93a3ac
parent 46
a726d19facfc
child 50
a29c3d2e6dc0
child 55
d501156be247
--- a/RefactoringRope/Refactoring.py	Sat Feb 23 15:28:57 2013 +0100
+++ b/RefactoringRope/Refactoring.py	Sun Apr 14 15:13:58 2013 +0200
@@ -16,11 +16,11 @@
 import rope.base.exceptions
 
 from PyQt4.QtCore import QObject
-from PyQt4.QtGui import QMenu, QApplication, QMessageBox, QDialog, QAction
+from PyQt4.QtGui import QMenu, QApplication, QDialog, QAction
 from PyQt4.Qsci import QsciScintilla
 
 from E5Gui.E5Application import e5App
-
+from E5Gui import E5MessageBox
 from E5Gui.E5Action import E5Action
 
 import Utilities
@@ -786,7 +786,7 @@
         """
         Private slot to show some info about rope.
         """
-        QMessageBox.about(self.__ui,
+        E5MessageBox.about(self.__ui,
             self.trUtf8("About rope"),
             self.trUtf8("{0}\nVersion {1}\n\n{2}".format(
                 rope.INFO, rope.VERSION, rope.COPYRIGHT)))
@@ -894,16 +894,16 @@
             handle.reset()
         if str(type(err)).split()[-1][1:-2].split('.')[-1] == \
                                                     'ModuleSyntaxError':
-            res = QMessageBox.warning(self.__ui, title,
+            res = E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Rope error: {0}").format(str(err)),
-                QMessageBox.Ok | QMessageBox.Open)
-            if res == QMessageBox.Open:
+                E5MessageBox.Ok | E5MessageBox.Open)
+            if res == E5MessageBox.Open:
                 e5App().getObject("ViewManager").openSourceFile(
                     os.path.join(self.__e5project.getProjectPath(),
                                  err.filename),
                     err.lineno)
         else:
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Rope error: {0}").format(str(err)))
     
     def __getOffset(self, editor, line, index):
@@ -966,7 +966,7 @@
         
         if not renameModule and not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the declaration you want to rename"
                     " and try again."))
             return
@@ -985,7 +985,7 @@
             line, index, line1, index1 = aw.getSelection()
             if line != line1:
                 # selection span more than one line
-                QMessageBox.warning(self.__ui, title,
+                E5MessageBox.warning(self.__ui, title,
                     self.trUtf8("The selection must not extend beyond"
                                 " one line."))
                 return
@@ -1024,7 +1024,7 @@
         title = self.trUtf8("Change Occurrences")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight an occurrence to be changed"
                     " and try again."))
             return
@@ -1082,7 +1082,7 @@
         
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the region of code you want to extract"
                     " and try again."))
             return
@@ -1131,7 +1131,7 @@
         title = self.trUtf8("Inline")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the local variable, method or parameter"
                     " you want to inline and try again."))
             return
@@ -1173,7 +1173,7 @@
         title = self.trUtf8("Move Method")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method to move"
                     " and try again."))
             return
@@ -1251,7 +1251,7 @@
         title = self.trUtf8("Use Function")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight a global function and try again."))
             return
         
@@ -1292,7 +1292,7 @@
         title = self.trUtf8("Introduce Factory Method")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the class to introduce a factory"
                     " method for and try again."))
             return
@@ -1332,7 +1332,7 @@
         title = self.trUtf8("Introduce Parameter")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the code for the new parameter"
                     " and try again."))
             return
@@ -1437,7 +1437,7 @@
                     if self.__e5project.isDirty():
                         self.__e5project.saveProject()
             else:
-                QMessageBox.information(self.__ui, title,
+                E5MessageBox.information(self.__ui, title,
                     self.trUtf8("The selected refactoring did not produce"
                                 " any change."))
         except Exception as err:
@@ -1468,7 +1468,7 @@
         title = self.trUtf8("Change Method Signature")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method or function to change"
                     " and try again."))
             return
@@ -1508,7 +1508,7 @@
         title = self.trUtf8("Inline Argument Default")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method or function to inline"
                     " a parameter's default and try again."))
             return
@@ -1576,7 +1576,7 @@
         title = self.trUtf8("Encapsulate Attribute")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the attribute to encapsulate"
                     " and try again."))
             return
@@ -1633,7 +1633,7 @@
         title = self.trUtf8("Local Variable to Attribute")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the local variable to make an attribute"
                     " and try again."))
             return
@@ -1673,7 +1673,7 @@
         title = self.trUtf8("Replace Method With Method Object")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method or function to convert"
                     " and try again."))
             return
@@ -1710,16 +1710,12 @@
         """
         title = self.trUtf8("Undo refactoring")
         history = self.__project.history
-        res = QMessageBox.question(None,
+        res = E5MessageBox.yesNo(None,
             title,
             self.trUtf8("""Shall the refactoring <b>{0}</b> be undone?""")\
                 .format(Utilities.html_encode(
-                    history.undo_list[-1].description)),
-            QMessageBox.StandardButtons(
-                QMessageBox.No | \
-                QMessageBox.Yes),
-            QMessageBox.No)
-        if res == QMessageBox.Yes:
+                    history.undo_list[-1].description)))
+        if res:
             if not self.confirmAllBuffersSaved():
                 return
             
@@ -1743,16 +1739,12 @@
         """
         title = self.trUtf8("Redo refactoring")
         history = self.__project.history
-        res = QMessageBox.question(None,
+        res = E5MessageBox.yesNo(None,
             title,
             self.trUtf8("""Shall the refactoring <b>{0}</b> be redone?""")\
                 .format(Utilities.html_encode(
-                    history.redo_list[-1].description)),
-            QMessageBox.StandardButtons(\
-                QMessageBox.No | \
-                QMessageBox.Yes),
-            QMessageBox.No)
-        if res == QMessageBox.Yes:
+                    history.redo_list[-1].description)))
+        if res:
             if not self.confirmAllBuffersSaved():
                 return
             
@@ -1828,15 +1820,11 @@
         """
         Private slot to clear the redo and undo lists.
         """
-        res = QMessageBox.question(None,
+        res = E5MessageBox.yesNo(None,
             self.trUtf8("Clear History"),
             self.trUtf8("""Do you really want to clear the undo"""
-                        """ and redo history?"""),
-            QMessageBox.StandardButtons(\
-                QMessageBox.No | \
-                QMessageBox.Yes),
-            QMessageBox.No)
-        if res == QMessageBox.Yes:
+                        """ and redo history?"""))
+        if res:
             self.__project.history.clear()
     
     #####################################################
@@ -1855,7 +1843,7 @@
         title = self.trUtf8("Find Occurrences")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the class, method, function or variable"
                     " to search for and try again."))
             return
@@ -1891,7 +1879,7 @@
                 self.dlg.addEntry(occurrence.resource,
                     occurrence.lineno, occurrence.unsure)
         else:
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("No occurrences found."))
     
     def __queryDefinition(self):
@@ -1906,7 +1894,7 @@
         title = self.trUtf8("Find &Definition")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the class, method, function or"
                     " variable reference to search definition for and"
                     " try again."))
@@ -1935,7 +1923,7 @@
             self.dlg.show()
             self.dlg.addEntry(location.resource, location.lineno)
         else:
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("No matching definition found."))
     
     def __queryImplementations(self):
@@ -1950,7 +1938,7 @@
         title = self.trUtf8("Find Implementations")
         if not aw.hasSelectedText():
             # no selection available
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method to search for"
                             " and try again."))
             return
@@ -1985,7 +1973,7 @@
                 self.dlg.addEntry(occurrence.resource,
                     occurrence.lineno, occurrence.unsure)
         else:
-            QMessageBox.warning(self.__ui, title,
+            E5MessageBox.warning(self.__ui, title,
                 self.trUtf8("No occurrences found."))
     
     #####################################################
@@ -2006,12 +1994,12 @@
                 self.__editor.show()
                 self.__editor.editorSaved.connect(self.__configChanged)
             else:
-                QMessageBox.critical(self.__ui,
+                E5MessageBox.critical(self.__ui,
                     self.trUtf8("Configure Rope"),
                     self.trUtf8("""The Rope configuration file '{0}' does"""
                                 """ not exist.""").format(configfile))
         else:
-            QMessageBox.critical(self.__ui,
+            E5MessageBox.critical(self.__ui,
                 self.trUtf8("Configure Rope"),
                 self.trUtf8("""The Rope admin directory does not exist."""))
     
@@ -2019,15 +2007,11 @@
         """
         Private slot to update the configuration file.
         """
-        res = QMessageBox.question(self.__ui,
+        res = E5MessageBox.yesNo(self.__ui,
             self.trUtf8("Update Configuration"),
             self.trUtf8("""Shall rope's current configuration be replaced """
-                        """by a new default configuration?"""),
-            QMessageBox.StandardButtons(\
-                QMessageBox.No | \
-                QMessageBox.Yes),
-            QMessageBox.No)
-        if res == QMessageBox.Yes:
+                        """by a new default configuration?"""))
+        if res:
             src = self.__defaultConfig()
             cname = self.__ropeConfigFile()
             if src != "" and cname is not None:
@@ -2038,7 +2022,7 @@
                     self.__configChanged()
                     self.__editConfig()
                 except IOError as err:
-                    QMessageBox.critical(None,
+                    E5MessageBox.critical(None,
                         self.trUtf8("Update Configuration"),
                         self.trUtf8("""<p>The configuration could not be"""
                                     """ updated.</p><p>Reason: {0}</p>""")\
@@ -2062,15 +2046,11 @@
         Private slot to perform SOA on all modules.
         """
         title = self.trUtf8("Analyse all modules")
-        res = QMessageBox.question(self.__ui,
+        res = E5MessageBox.yesNo(self.__ui,
             title,
             self.trUtf8("""This action might take some time. """
-                        """Do you really want to perform SOA?"""),
-            QMessageBox.StandardButtons(\
-                QMessageBox.No | \
-                QMessageBox.Yes),
-            QMessageBox.No)
-        if res == QMessageBox.Yes:
+                        """Do you really want to perform SOA?"""))
+        if res:
             from ProgressHandle import ProgressHandle
             handle = ProgressHandle(title, True, self.__ui)
             handle.show()
@@ -2079,7 +2059,7 @@
                 rope.base.libutils.analyze_modules(self.__project,
                     task_handle=handle)
                 handle.reset()
-                QMessageBox.information(self.__ui,
+                E5MessageBox.information(self.__ui,
                     title,
                     self.trUtf8("""Static object analysis (SOA) done. """
                                 """SOA database updated."""))

eric ide

mercurial