RefactoringRope/IntroduceFactoryDialog.py

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

eric ide

mercurial