RefactoringRope/IntroduceFactoryDialog.py

branch
server_client_variant
changeset 180
a33ef7ab8c54
parent 147
3f8a995f6e49
child 181
3e3d6de2f0ca
equal deleted inserted replaced
179:8ae4e95f5fa6 180:a33ef7ab8c54
18 18
19 class IntroduceFactoryDialog(RefactoringDialogBase, Ui_IntroduceFactoryDialog): 19 class IntroduceFactoryDialog(RefactoringDialogBase, Ui_IntroduceFactoryDialog):
20 """ 20 """
21 Class implementing the Introduce Factory dialog. 21 Class implementing the Introduce Factory dialog.
22 """ 22 """
23 def __init__(self, refactoring, title, introducer, parent=None): 23 def __init__(self, refactoring, title, filename, offset, parent=None):
24 """ 24 """
25 Constructor 25 Constructor
26 26
27 @param refactoring reference to the main refactoring object 27 @param refactoring reference to the main refactoring object
28 (Refactoring) 28 @type Refactoring
29 @param title title of the dialog (string) 29 @param title title of the dialog
30 @param introducer reference to the factory introducer object 30 @type str
31 (rope.refactor.introduce_factory.IntroduceFactoryRefactoring) 31 @param filename file name to be worked on
32 @param parent reference to the parent widget (QWidget) 32 @type str
33 @param offset offset within file
34 @type int or None
35 @param parent reference to the parent widget
36 @type QWidget
33 """ 37 """
34 RefactoringDialogBase.__init__(self, refactoring, title, parent) 38 RefactoringDialogBase.__init__(self, refactoring, title, parent)
35 self.setupUi(self) 39 self.setupUi(self)
36 40
37 self.__introducer = introducer 41 self._changeGroupName = "IntroduceFactory"
42
43 self.__filename = filename
44 self.__offset = offset
38 45
39 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) 46 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
40 self.__okButton.setEnabled(False) 47 self.__okButton.setEnabled(False)
41 self.__previewButton = self.buttonBox.addButton( 48 self.__previewButton = self.buttonBox.addButton(
42 self.tr("Preview"), QDialogButtonBox.ActionRole) 49 self.tr("Preview"), QDialogButtonBox.ActionRole)
43 self.__previewButton.setDefault(True) 50 self.__previewButton.setDefault(True)
51 self.__previewButton.setEnabled(False)
44 52
45 self.nameEdit.setText("create") 53 self.nameEdit.setText("create")
46 self.nameEdit.selectAll() 54 self.nameEdit.selectAll()
47 55
48 msh = self.minimumSizeHint() 56 msh = self.minimumSizeHint()
53 """ 61 """
54 Private slot to react to changes of the name. 62 Private slot to react to changes of the name.
55 63
56 @param text text entered into the edit (string) 64 @param text text entered into the edit (string)
57 """ 65 """
58 self.__okButton.setEnabled(text != "") 66 enable = bool(text)
67 self.__okButton.setEnabled(enable)
68 self.__previewButton.setEnabled(enable)
59 69
60 @pyqtSlot(QAbstractButton) 70 @pyqtSlot(QAbstractButton)
61 def on_buttonBox_clicked(self, button): 71 def on_buttonBox_clicked(self, button):
62 """ 72 """
63 Private slot to act on the button pressed. 73 Private slot to act on the button pressed.
64 74
65 @param button reference to the button pressed (QAbstractButton) 75 @param button reference to the button pressed
76 @type QAbstractButton
66 """ 77 """
67 if button == self.__previewButton: 78 if button == self.__previewButton:
68 self.previewChanges() 79 self.requestPreview()
69 elif button == self.__okButton: 80 elif button == self.__okButton:
70 self.applyChanges() 81 self.applyChanges()
71 82
72 def _calculateChanges(self, handle): 83 def _calculateChanges(self):
73 """ 84 """
74 Protected method to calculate the changes. 85 Protected method to initiate the calculation of the changes.
75
76 @param handle reference to the task handle
77 (rope.base.taskhandle.TaskHandle)
78 @return reference to the Changes object (rope.base.change.ChangeSet)
79 """ 86 """
80 try: 87 self._refactoring.sendJson("CalculateIntroduceFactoryChanges", {
81 changes = self.__introducer.get_changes( 88 "ChangeGroup": self._changeGroupName,
82 self.nameEdit.text(), 89 "Title": self._title,
83 global_factory=self.globalButton.isChecked(), 90 "FileName": self.__filename,
84 task_handle=handle) 91 "Offset": self.__offset,
85 return changes 92 "Name": self.nameEdit.text(),
86 except Exception as err: 93 "GlobalFactory": self.globalButton.isChecked(),
87 self._refactoring.handleRopeError(err, self._title, handle) 94 })
88 return None

eric ide

mercurial