RefactoringRope/Refactoring.py

changeset 19
32dd7dbf3e8e
parent 16
65b340b40844
child 20
83b71483e198
--- a/RefactoringRope/Refactoring.py	Sun Jan 30 18:27:42 2011 +0100
+++ b/RefactoringRope/Refactoring.py	Sun Jan 30 19:00:34 2011 +0100
@@ -37,7 +37,6 @@
 
 from E5Gui.E5Application import e5App
 
-from E5Gui import E5MessageBox
 from E5Gui.E5Action import E5Action
 
 from QScintilla.MiniEditor import MiniEditor
@@ -826,7 +825,7 @@
         """
         Private slot to show some info about rope.
         """
-        E5MessageBox.about(self.__ui,
+        QMessageBox.about(self.__ui,
             self.trUtf8("About rope"),
             self.trUtf8("{0}\nVersion {1}\n\n{2}".format(
                 rope.INFO, rope.VERSION, rope.COPYRIGHT)))
@@ -934,7 +933,7 @@
             handle.reset()
         if str(type(err)).split()[-1][1:-2].split('.')[-1] == \
                                                     'ModuleSyntaxError':
-            res = E5MessageBox.warning(self.__ui, title,
+            res = QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Rope error: {0}").format(str(err)), 
                 QMessageBox.Ok | QMessageBox.Open)
             if res == QMessageBox.Open:
@@ -943,7 +942,7 @@
                                  err.filename), 
                     err.lineno)
         else:
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Rope error: {0}").format(str(err)))
 
     ##################################################################
@@ -990,7 +989,7 @@
         
         if not renameModule and not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the declaration you want to rename"
                     " and try again."))
             return 
@@ -1009,7 +1008,7 @@
             line, index, line1, index1 = aw.getSelection()
             if line != line1:
                 # selection span more than one line
-                E5MessageBox.warning(self.__ui, title,
+                QMessageBox.warning(self.__ui, title,
                     self.trUtf8("The selection must not extend beyond"
                                 " one line."))
                 return 
@@ -1046,7 +1045,7 @@
         title = self.trUtf8("Change Occurrences")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight an occurrence to be changed"
                     " and try again."))
             return 
@@ -1102,7 +1101,7 @@
         
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the region of code you want to extract"
                     " and try again."))
             return 
@@ -1149,7 +1148,7 @@
         title = self.trUtf8("Inline")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the local variable, method or parameter"
                     " you want to inline and try again."))
             return 
@@ -1189,7 +1188,7 @@
         title = self.trUtf8("Move Method")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method to move"
                     " and try again."))
             return 
@@ -1258,7 +1257,7 @@
         title = self.trUtf8("Use Function")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight a global function and try again."))
             return 
         
@@ -1297,7 +1296,7 @@
         title = self.trUtf8("Introduce Factory Method")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the class to introduce a factory"
                     " method for and try again."))
             return 
@@ -1335,7 +1334,7 @@
         title = self.trUtf8("Introduce Parameter")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the code for the new parameter"
                     " and try again."))
             return 
@@ -1431,7 +1430,7 @@
                     if self.__e5project.isDirty():
                         self.__e5project.saveProject()
             else:
-                E5MessageBox.information(self.__ui, title,
+                QMessageBox.information(self.__ui, title,
                     self.trUtf8("The selected refactoring did not produce"
                                 " any change."))
         except Exception as err:
@@ -1461,7 +1460,7 @@
         title = self.trUtf8("Change Method Signature")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method or function to change"
                     " and try again."))
             return 
@@ -1499,7 +1498,7 @@
         title = self.trUtf8("Inline Argument Default")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method or function to inline"
                     " a parameter's default and try again."))
             return 
@@ -1564,7 +1563,7 @@
         title = self.trUtf8("Encapsulate Attribute")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the attribute to encapsulate"
                     " and try again."))
             return 
@@ -1618,7 +1617,7 @@
         title = self.trUtf8("Local Variable to Attribute")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the local variable to make an attribute"
                     " and try again."))
             return 
@@ -1656,7 +1655,7 @@
         title = self.trUtf8("Replace Method With Method Object")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method or function to convert"
                     " and try again."))
             return 
@@ -1691,7 +1690,7 @@
         """
         title = self.trUtf8("Undo refactoring")
         history = self.__project.history
-        res = E5MessageBox.question(None,
+        res = QMessageBox.question(None,
             title,
             self.trUtf8("""Shall the refactoring <b>{0}</b> be undone?""")\
                 .format(Utilities.html_encode(
@@ -1723,7 +1722,7 @@
         """
         title = self.trUtf8("Redo refactoring")
         history = self.__project.history
-        res = E5MessageBox.question(None,
+        res = QMessageBox.question(None,
             title,
             self.trUtf8("""Shall the refactoring <b>{0}</b> be redone?""")\
                 .format(Utilities.html_encode(
@@ -1803,7 +1802,7 @@
         """
         Private slot to clear the redo and undo lists.
         """
-        res = E5MessageBox.question(None,
+        res = QMessageBox.question(None,
             self.trUtf8("Clear History"),
             self.trUtf8("""Do you really want to clear the undo"""
                         """ and redo history?"""),
@@ -1830,7 +1829,7 @@
         title = self.trUtf8("Find Occurrences")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the class, method, function or variable"
                     " to search for and try again."))
             return 
@@ -1863,7 +1862,7 @@
                 self.dlg.addEntry(occurrence.resource, 
                     occurrence.lineno, occurrence.unsure)
         else:
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("No occurrences found."))
     
     def __queryDefinition(self):
@@ -1878,7 +1877,7 @@
         title = self.trUtf8("Find &Definition")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the class, method, function or"
                     " variable reference to search definition for and"
                     " try again."))
@@ -1905,7 +1904,7 @@
             self.dlg.show()
             self.dlg.addEntry(location.resource, location.lineno)
         else:
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("No matching definition found."))
     
     def __queryImplementations(self):
@@ -1920,7 +1919,7 @@
         title = self.trUtf8("Find Implementations")
         if not aw.hasSelectedText():
             # no selection available
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("Highlight the method to search for"
                             " and try again."))
             return 
@@ -1952,7 +1951,7 @@
                 self.dlg.addEntry(occurrence.resource, 
                     occurrence.lineno, occurrence.unsure)
         else:
-            E5MessageBox.warning(self.__ui, title,
+            QMessageBox.warning(self.__ui, title,
                 self.trUtf8("No occurrences found."))
     
     #####################################################
@@ -1976,12 +1975,12 @@
                     self.connect(self.__editor, SIGNAL("editorSaved"), 
                         self.__configChanged)
             else:
-                E5MessageBox.critical(self.__ui,
+                QMessageBox.critical(self.__ui,
                     self.trUtf8("Configure Rope"),
                     self.trUtf8("""The Rope configuration file '{0}' does"""
                                 """ not exist.""").format(configfile))
         else:
-            E5MessageBox.critical(self.__ui,
+            QMessageBox.critical(self.__ui,
                 self.trUtf8("Configure Rope"),
                 self.trUtf8("""The Rope admin directory does not exist."""))
     
@@ -1989,11 +1988,15 @@
         """
         Private slot to update the configuration file.
         """
-        res = E5MessageBox.yesNo(self.__ui,
+        res = QMessageBox.question(self.__ui,
             self.trUtf8("Update Configuration"),
             self.trUtf8("""Shall rope's current configuration be replaced """
-                        """by a new default configuration?"""))
-        if res:
+                        """by a new default configuration?"""),
+            QMessageBox.StandardButtons(\
+                QMessageBox.No | \
+                QMessageBox.Yes),
+            QMessageBox.No)
+        if res == QMessageBox.Yes:
             src = self.__defaultConfig()
             cname = self.__ropeConfigFile()
             if src != "" and cname is not None:
@@ -2004,7 +2007,7 @@
                     self.__configChanged()
                     self.__editConfig()
                 except IOError as err:
-                    E5MessageBox.critical(None,
+                    QMessageBox.critical(None,
                         self.trUtf8("Update Configuration"),
                         self.trUtf8("""<p>The configuration could not be"""
                                     """ updated.</p><p>Reason: {0}</p>""")\
@@ -2027,11 +2030,15 @@
         Private slot to perform SOA on all modules.
         """
         title = self.trUtf8("Analyse all modules")
-        res = E5MessageBox.yesNo(self.__ui,
+        res = QMessageBox.question(self.__ui,
             title,
             self.trUtf8("""This action might take some time. """
-                        """Do you really want to perform SOA?"""))
-        if res:
+                        """Do you really want to perform SOA?"""),
+            QMessageBox.StandardButtons(\
+                QMessageBox.No | \
+                QMessageBox.Yes),
+            QMessageBox.No)
+        if res == QMessageBox.Yes:
             handle = ProgressHandle(title, True, self.__ui)
             handle.show()
             QApplication.processEvents()
@@ -2039,7 +2046,7 @@
                 rope.base.libutils.analyze_modules(self.__project, 
                     task_handle=handle)
                 handle.reset()
-                E5MessageBox.information(self.__ui,
+                QMessageBox.information(self.__ui,
                     title,
                     self.trUtf8("""Static object analysis (SOA) done. """
                                 """SOA database updated."""))

eric ide

mercurial