--- a/RefactoringRope/GetterSetterDialog.py Sat Jun 25 18:06:56 2022 +0200 +++ b/RefactoringRope/GetterSetterDialog.py Wed Sep 21 15:30:34 2022 +0200 @@ -18,10 +18,11 @@ """ Class implementing the encapsulate attribute dialog. """ + def __init__(self, refactoring, title, filename, offset, parent=None): """ Constructor - + @param refactoring reference to the main refactoring object @type RefactoringServer @param title title of the dialog @@ -35,78 +36,81 @@ """ RefactoringDialogBase.__init__(self, refactoring, title, parent) self.setupUi(self) - + self._changeGroupName = "GetterSetter" - + self.__filename = filename self.__offset = offset - - self.__okButton = self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok) + + self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) self.__okButton.setEnabled(False) self.__previewButton = self.buttonBox.addButton( - self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole) + self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole + ) self.__previewButton.setDefault(True) self.__previewButton.setEnabled(False) - + self.__fieldName = "" - - self._refactoring.sendJson("RequestFieldName", { - "ChangeGroup": self._changeGroupName, - "Title": self._title, - "FileName": self.__filename, - "Offset": self.__offset, - }) - + + self._refactoring.sendJson( + "RequestFieldName", + { + "ChangeGroup": self._changeGroupName, + "Title": self._title, + "FileName": self.__filename, + "Offset": self.__offset, + }, + ) + def __processFieldName(self, data): """ Private method to process the field name data sent by the refactoring client in order to polish the dialog. - + @param data dictionary containing the inline type data @type dict """ self.__fieldName = data["Name"] - + self.on_typeCheckBox_toggled(False) - + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + def __updateUI(self): """ Private slot to update the UI. """ enable = bool(self.getterEdit.text()) and bool(self.setterEdit.text()) - + self.__okButton.setEnabled(enable) self.__previewButton.setEnabled(enable) - + @pyqtSlot(str) def on_getterEdit_textChanged(self, text): """ Private slot to react to changes of the getter method. - + @param text text entered into the edit @type str """ self.__updateUI() - + @pyqtSlot(str) def on_setterEdit_textChanged(self, text): """ Private slot to react to changes of the setter method. - + @param text text entered into the edit @type str """ self.__updateUI() - + @pyqtSlot(bool) def on_typeCheckBox_toggled(self, checked): """ Private slot to react to changes of the type checkbox. - + @param checked state of the checkbox @type bool """ @@ -114,16 +118,14 @@ self.getterEdit.setText("get_{0}".format(self.__fieldName)) self.setterEdit.setText("set_{0}".format(self.__fieldName)) else: - self.getterEdit.setText( - "get{0}".format(self.__fieldName.capitalize())) - self.setterEdit.setText( - "set{0}".format(self.__fieldName.capitalize())) - + self.getterEdit.setText("get{0}".format(self.__fieldName.capitalize())) + self.setterEdit.setText("set{0}".format(self.__fieldName.capitalize())) + @pyqtSlot(QAbstractButton) def on_buttonBox_clicked(self, button): """ Private slot to act on the button pressed. - + @param button reference to the button pressed @type QAbstractButton """ @@ -131,25 +133,28 @@ self.requestPreview() elif button == self.__okButton: self.applyChanges() - + def _calculateChanges(self): """ Protected method to initiate the calculation of the changes. """ - self._refactoring.sendJson("CalculateEncapsulateFieldChanges", { - "ChangeGroup": self._changeGroupName, - "Title": self._title, - "FileName": self.__filename, - "Offset": self.__offset, - "Getter": self.getterEdit.text(), - "Setter": self.setterEdit.text(), - }) - + self._refactoring.sendJson( + "CalculateEncapsulateFieldChanges", + { + "ChangeGroup": self._changeGroupName, + "Title": self._title, + "FileName": self.__filename, + "Offset": self.__offset, + "Getter": self.getterEdit.text(), + "Setter": self.setterEdit.text(), + }, + ) + def processChangeData(self, data): """ Public method to process the change data sent by the refactoring client. - + @param data dictionary containing the change data @type dict """