RefactoringRope/MethodToMethodObjectDialog.py

branch
server_client_variant
changeset 188
05fb0977ce1b
parent 147
3f8a995f6e49
child 189
2711fdd91925
--- a/RefactoringRope/MethodToMethodObjectDialog.py	Sun Sep 24 11:56:11 2017 +0200
+++ b/RefactoringRope/MethodToMethodObjectDialog.py	Sun Sep 24 13:42:01 2017 +0200
@@ -21,27 +21,35 @@
     """
     Class implementing the Method To Method object dialog.
     """
-    def __init__(self, refactoring, title, converter, parent=None):
+    def __init__(self, refactoring, title, filename, offset, parent=None):
         """
         Constructor
          
         @param refactoring reference to the main refactoring object
-            (Refactoring)
-        @param title title of the dialog (string)
-        @param converter reference to the converter object
-            (rope.refactor.method_object.MethodObject)
-        @param parent reference to the parent widget (QWidget)
+        @type Refactoring
+        @param title title of the dialog
+        @type str
+        @param filename file name to be worked on
+        @type str
+        @param offset offset within file
+        @type int or None
+        @param parent reference to the parent widget
+        @type QWidget
         """
         RefactoringDialogBase.__init__(self, refactoring, title, parent)
         self.setupUi(self)
         
-        self.__converter = converter
+        self._changeGroupName = "MethodToMethodObject"
+        
+        self.__filename = filename
+        self.__offset = offset
         
         self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
         self.__okButton.setEnabled(False)
         self.__previewButton = self.buttonBox.addButton(
             self.tr("Preview"), QDialogButtonBox.ActionRole)
         self.__previewButton.setDefault(True)
+        self.__previewButton.setEnabled(False)
         
         self.nameEdit.setText("_MethodObject")
         self.nameEdit.selectAll()
@@ -56,7 +64,8 @@
         
         @param text text entered into the edit (string)
         """
-        self.__okButton.setEnabled(text != "")
+        self.__okButton.setEnabled(bool(text))
+        self.__previewButton.setEnabled(bool(text))
     
     @pyqtSlot(QAbstractButton)
     def on_buttonBox_clicked(self, button):
@@ -66,21 +75,18 @@
         @param button reference to the button pressed (QAbstractButton)
         """
         if button == self.__previewButton:
-            self.previewChanges()
+            self.requestPreview()
         elif button == self.__okButton:
             self.applyChanges()
     
-    def _calculateChanges(self, handle):
+    def _calculateChanges(self):
+        """
+        Protected method to initiate the calculation of the changes.
         """
-        Protected method to calculate the changes.
-        
-        @param handle reference to the task handle
-            (rope.base.taskhandle.TaskHandle)
-        @return reference to the Changes object (rope.base.change.ChangeSet)
-        """
-        try:
-            changes = self.__converter.get_changes(self.nameEdit.text())
-            return changes
-        except Exception as err:
-            self._refactoring.handleRopeError(err, self._title, handle)
-            return None
+        self._refactoring.sendJson("CalculateMethodObjectChanges", {
+            "ChangeGroup": self._changeGroupName,
+            "Title": self._title,
+            "FileName": self.__filename,
+            "Offset": self.__offset,
+            "Name": self.nameEdit.text(),
+        })

eric ide

mercurial