RefactoringRope/RefactoringDialogBase.py

branch
server_client_variant
changeset 173
2cdb7c48b719
parent 172
c8890f852917
child 189
2711fdd91925
diff -r c8890f852917 -r 2cdb7c48b719 RefactoringRope/RefactoringDialogBase.py
--- a/RefactoringRope/RefactoringDialogBase.py	Mon Sep 18 20:05:28 2017 +0200
+++ b/RefactoringRope/RefactoringDialogBase.py	Tue Sep 19 18:59:14 2017 +0200
@@ -32,10 +32,13 @@
         self.setAttribute(Qt.WA_DeleteOnClose)
         self.setWindowTitle(title)
         
+        self._ui = parent
         self._refactoring = refactoring
         self._title = title
         
         self._changesCalculated = False
+        
+        self.__queue = []
     
     def getChangeGroupName(self):
         """
@@ -46,9 +49,9 @@
         """
         return self._changeGroupName
     
-    def calculateChanges(self):
+    def _calculateChanges(self):
         """
-        Public method to initiate the calculation of changes.
+        Protected method to initiate the calculation of changes.
         
         @exception NotImplementedError raised to indicate that this method must
             be overridden by subclasses
@@ -59,11 +62,11 @@
         """
         Public method to request a preview of the calculated changes.
         """
-        self._calculateChanges()
+        self.__queue.append(("PreviewChanges", {
+            "ChangeGroup": self._changeGroupName,
+        }))
         
-        self._refactoring.sendJson("PreviewChanges", {
-            "ChangeGroup": self._changeGroupName,
-        })
+        self._calculateChanges()
     
     def previewChanges(self, data):
         """
@@ -83,12 +86,16 @@
         Public method to apply the changes.
         """
         if not self._changesCalculated:
-            self.calculateChanges()
-        
-        self._refactoring.sendJson("ApplyChanges", {
-            "ChangeGroup": self._changeGroupName,
-            "Title": self._title,
-        })
+            self.__queue.append(("ApplyChanges", {
+                "ChangeGroup": self._changeGroupName,
+                "Title": self._title,
+            }))
+            self._calculateChanges()
+        else:
+            self._refactoring.sendJson("ApplyChanges", {
+                "ChangeGroup": self._changeGroupName,
+                "Title": self._title,
+            })
     
     def processChangeData(self, data):
         """
@@ -103,6 +110,11 @@
             self.previewChanges(data)
         elif subcommand == "ChangesCalculated":
             self._changesCalculated = True
+            if not self.isVisible():
+                self.show()
+            if self.__queue:
+                method, params = self.__queue.pop(0)
+                self._refactoring.sendJson(method, params)
         elif subcommand == "ChangesApplied":
             if self._refactoring.handleRopeError(data):
                 self._refactoring.refreshEditors(data["ChangedFiles"])

eric ide

mercurial