RefactoringRope/ChangeOccurrencesDialog.py

branch
server_client_variant
changeset 174
04583cac110f
parent 147
3f8a995f6e49
child 177
963fc1b0ba6e
equal deleted inserted replaced
173:2cdb7c48b719 174:04583cac110f
19 class ChangeOccurrencesDialog(RefactoringDialogBase, 19 class ChangeOccurrencesDialog(RefactoringDialogBase,
20 Ui_ChangeOccurrencesDialog): 20 Ui_ChangeOccurrencesDialog):
21 """ 21 """
22 Class implementing the Change Occurrences dialog. 22 Class implementing the Change Occurrences dialog.
23 """ 23 """
24 def __init__(self, refactoring, title, renamer, parent=None): 24 def __init__(self, refactoring, title, filename, offset, parent=None):
25 """ 25 """
26 Constructor 26 Constructor
27 27
28 @param refactoring reference to the main refactoring object 28 @param refactoring reference to the main refactoring object
29 (Refactoring) 29 @type Refactoring
30 @param title title of the dialog (string) 30 @param title title of the dialog
31 @param renamer reference to the renamer object 31 @str str
32 (rope.refactor.rename.Rename) 32 @param filename file name to be worked on
33 @param parent reference to the parent widget (QWidget) 33 @type str
34 @param offset offset within file
35 @type int
36 @param parent reference to the parent widget
37 @type QWidget
34 """ 38 """
35 RefactoringDialogBase.__init__(self, refactoring, title, parent) 39 RefactoringDialogBase.__init__(self, refactoring, title, parent)
36 self.setupUi(self) 40 self.setupUi(self)
37 41
38 self.__renamer = renamer 42 self._changeGroupName = "ChangeOccurrences"
43
44 self.__filename = filename
45 self.__offset = offset
39 46
40 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) 47 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
41 self.__okButton.setEnabled(False) 48 self.__okButton.setEnabled(False)
42 self.__previewButton = self.buttonBox.addButton( 49 self.__previewButton = self.buttonBox.addButton(
43 self.tr("Preview"), QDialogButtonBox.ActionRole) 50 self.tr("Preview"), QDialogButtonBox.ActionRole)
49 @pyqtSlot(str) 56 @pyqtSlot(str)
50 def on_replaceEdit_textChanged(self, text): 57 def on_replaceEdit_textChanged(self, text):
51 """ 58 """
52 Private slot to react to changes of the new name. 59 Private slot to react to changes of the new name.
53 60
54 @param text text entered into the edit (string) 61 @param text text entered into the edit
62 @type str
55 """ 63 """
56 self.__okButton.setEnabled(text != "") 64 self.__okButton.setEnabled(text != "")
57 65
58 @pyqtSlot(QAbstractButton) 66 @pyqtSlot(QAbstractButton)
59 def on_buttonBox_clicked(self, button): 67 def on_buttonBox_clicked(self, button):
60 """ 68 """
61 Private slot to act on the button pressed. 69 Private slot to act on the button pressed.
62 70
63 @param button reference to the button pressed (QAbstractButton) 71 @param button reference to the button pressed
72 @type QAbstractButton
64 """ 73 """
65 if button == self.__previewButton: 74 if button == self.__previewButton:
66 self.previewChanges() 75 self.requestPreview()
67 elif button == self.__okButton: 76 elif button == self.__okButton:
68 self.applyChanges() 77 self.applyChanges()
69 78
70 def _calculateChanges(self, handle): 79 def _calculateChanges(self):
71 """ 80 """
72 Protected method to calculate the changes. 81 Protected method to initiate the calculation of the changes.
73
74 @param handle reference to the task handle
75 (rope.base.taskhandle.TaskHandle)
76 @return reference to the Changes object (rope.base.change.ChangeSet)
77 """ 82 """
78 try: 83 self._refactoring.sendJson("CalculateChangeOccurrencesChanges", {
79 changes = self.__renamer.get_changes( 84 "ChangeGroup": self._changeGroupName,
80 self.replaceEdit.text(), 85 "Title": self._title,
81 only_calls=self.onlyCallsCheckBox.isChecked(), 86 "FileName": self.__filename,
82 reads=self.readsCheckBox.isChecked(), 87 "Offset": self.__offset,
83 writes=self.writesCheckBox.isChecked()) 88 "NewName": self.replaceEdit.text(),
84 return changes 89 "OnlyCalls": self.onlyCallsCheckBox.isChecked(),
85 except Exception as err: 90 "Reads": self.readsCheckBox.isChecked(),
86 self._refactoring.handleRopeError(err, self._title, handle) 91 "Writes": self.writesCheckBox.isChecked(),
87 return None 92 })

eric ide

mercurial