RefactoringRope/IntroduceParameterDialog.py

branch
server_client_variant
changeset 181
3e3d6de2f0ca
parent 147
3f8a995f6e49
child 189
2711fdd91925
--- a/RefactoringRope/IntroduceParameterDialog.py	Sat Sep 23 12:16:59 2017 +0200
+++ b/RefactoringRope/IntroduceParameterDialog.py	Sat Sep 23 12:39:00 2017 +0200
@@ -21,27 +21,35 @@
     """
     Class implementing the Introduce Parameter dialog.
     """
-    def __init__(self, refactoring, title, introducer, 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 introducer reference to the factory introducer object
-            (rope.refactor.introduce_parameter.IntroduceParameter)
-        @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.__introducer = introducer
+        self._changeGroupName = "IntroduceParameter"
+        
+        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("new_parameter")
         self.nameEdit.selectAll()
@@ -54,33 +62,34 @@
         """
         Private slot to react to changes of the name.
         
-        @param text text entered into the edit (string)
+        @param text text entered into the edit
+        @type str
         """
-        self.__okButton.setEnabled(text != "")
+        enable = bool(text)
+        self.__okButton.setEnabled(enable)
+        self.__previewButton.setEnabled(enable)
     
     @pyqtSlot(QAbstractButton)
     def on_buttonBox_clicked(self, button):
         """
         Private slot to act on the button pressed.
         
-        @param button reference to the button pressed (QAbstractButton)
+        @param button reference to the button pressed
+        @type 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.__introducer.get_changes(self.nameEdit.text())
-            return changes
-        except Exception as err:
-            self._refactoring.handleRopeError(err, self._title, handle)
-            return None
+        self._refactoring.sendJson("CalculateIntroduceParameterChanges", {
+            "ChangeGroup": self._changeGroupName,
+            "Title": self._title,
+            "FileName": self.__filename,
+            "Offset": self.__offset,
+            "Name": self.nameEdit.text(),
+        })

eric ide

mercurial