RefactoringRope/IntroduceParameterDialog.py

branch
eric7
changeset 389
4f53795beff0
parent 374
958f34e97952
child 409
65153bf17e8d
equal deleted inserted replaced
388:cb044ec27c24 389:4f53795beff0
12 12
13 from .Ui_IntroduceParameterDialog import Ui_IntroduceParameterDialog 13 from .Ui_IntroduceParameterDialog import Ui_IntroduceParameterDialog
14 from .RefactoringDialogBase import RefactoringDialogBase 14 from .RefactoringDialogBase import RefactoringDialogBase
15 15
16 16
17 class IntroduceParameterDialog(RefactoringDialogBase, 17 class IntroduceParameterDialog(RefactoringDialogBase, Ui_IntroduceParameterDialog):
18 Ui_IntroduceParameterDialog):
19 """ 18 """
20 Class implementing the Introduce Parameter dialog. 19 Class implementing the Introduce Parameter dialog.
21 """ 20 """
21
22 def __init__(self, refactoring, title, filename, offset, parent=None): 22 def __init__(self, refactoring, title, filename, offset, parent=None):
23 """ 23 """
24 Constructor 24 Constructor
25 25
26 @param refactoring reference to the main refactoring object 26 @param refactoring reference to the main refactoring object
27 @type RefactoringServer 27 @type RefactoringServer
28 @param title title of the dialog 28 @param title title of the dialog
29 @type str 29 @type str
30 @param filename file name to be worked on 30 @param filename file name to be worked on
34 @param parent reference to the parent widget 34 @param parent reference to the parent widget
35 @type QWidget 35 @type QWidget
36 """ 36 """
37 RefactoringDialogBase.__init__(self, refactoring, title, parent) 37 RefactoringDialogBase.__init__(self, refactoring, title, parent)
38 self.setupUi(self) 38 self.setupUi(self)
39 39
40 self._changeGroupName = "IntroduceParameter" 40 self._changeGroupName = "IntroduceParameter"
41 41
42 self.__filename = filename 42 self.__filename = filename
43 self.__offset = offset 43 self.__offset = offset
44 44
45 self.__okButton = self.buttonBox.button( 45 self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok)
46 QDialogButtonBox.StandardButton.Ok)
47 self.__okButton.setEnabled(False) 46 self.__okButton.setEnabled(False)
48 self.__previewButton = self.buttonBox.addButton( 47 self.__previewButton = self.buttonBox.addButton(
49 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole) 48 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole
49 )
50 self.__previewButton.setDefault(True) 50 self.__previewButton.setDefault(True)
51 self.__previewButton.setEnabled(False) 51 self.__previewButton.setEnabled(False)
52 52
53 self.nameEdit.setText("new_parameter") 53 self.nameEdit.setText("new_parameter")
54 self.nameEdit.selectAll() 54 self.nameEdit.selectAll()
55 55
56 msh = self.minimumSizeHint() 56 msh = self.minimumSizeHint()
57 self.resize(max(self.width(), msh.width()), msh.height()) 57 self.resize(max(self.width(), msh.width()), msh.height())
58 58
59 @pyqtSlot(str) 59 @pyqtSlot(str)
60 def on_nameEdit_textChanged(self, text): 60 def on_nameEdit_textChanged(self, text):
61 """ 61 """
62 Private slot to react to changes of the name. 62 Private slot to react to changes of the name.
63 63
64 @param text text entered into the edit 64 @param text text entered into the edit
65 @type str 65 @type str
66 """ 66 """
67 enable = bool(text) 67 enable = bool(text)
68 self.__okButton.setEnabled(enable) 68 self.__okButton.setEnabled(enable)
69 self.__previewButton.setEnabled(enable) 69 self.__previewButton.setEnabled(enable)
70 70
71 @pyqtSlot(QAbstractButton) 71 @pyqtSlot(QAbstractButton)
72 def on_buttonBox_clicked(self, button): 72 def on_buttonBox_clicked(self, button):
73 """ 73 """
74 Private slot to act on the button pressed. 74 Private slot to act on the button pressed.
75 75
76 @param button reference to the button pressed 76 @param button reference to the button pressed
77 @type QAbstractButton 77 @type QAbstractButton
78 """ 78 """
79 if button == self.__previewButton: 79 if button == self.__previewButton:
80 self.requestPreview() 80 self.requestPreview()
81 elif button == self.__okButton: 81 elif button == self.__okButton:
82 self.applyChanges() 82 self.applyChanges()
83 83
84 def _calculateChanges(self): 84 def _calculateChanges(self):
85 """ 85 """
86 Protected method to initiate the calculation of the changes. 86 Protected method to initiate the calculation of the changes.
87 """ 87 """
88 self._refactoring.sendJson("CalculateIntroduceParameterChanges", { 88 self._refactoring.sendJson(
89 "ChangeGroup": self._changeGroupName, 89 "CalculateIntroduceParameterChanges",
90 "Title": self._title, 90 {
91 "FileName": self.__filename, 91 "ChangeGroup": self._changeGroupName,
92 "Offset": self.__offset, 92 "Title": self._title,
93 "Name": self.nameEdit.text(), 93 "FileName": self.__filename,
94 }) 94 "Offset": self.__offset,
95 "Name": self.nameEdit.text(),
96 },
97 )

eric ide

mercurial