RefactoringRope/MethodToMethodObjectDialog.py

changeset 13
dad628301abc
child 18
92ed128e0d6e
equal deleted inserted replaced
12:75fff1da56b6 13:dad628301abc
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Method To Method object dialog.
8 """
9
10 from PyQt4.QtCore import pyqtSlot
11 from PyQt4.QtGui import QDialogButtonBox, QAbstractButton
12
13 from Ui_MethodToMethodObjectDialog import Ui_MethodToMethodObjectDialog
14 from RefactoringDialogBase import RefactoringDialogBase
15
16 class MethodToMethodObjectDialog(RefactoringDialogBase,
17 Ui_MethodToMethodObjectDialog):
18 """
19 Class implementing the Method To Method object dialog.
20 """
21 def __init__(self, refactoring, title, converter, parent = None):
22 """
23 Constructor
24
25 @param refactoring reference to the main refactoring object
26 (Refactoring)
27 @param title title of the dialog (string)
28 @param converter reference to the converter object
29 (rope.refactor.method_object.MethodObject)
30 @param parent reference to the parent widget (QWidget)
31 """
32 RefactoringDialogBase.__init__(self, refactoring, title, parent)
33 self.setupUi(self)
34
35 self.__converter = converter
36
37 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
38 self.__okButton.setEnabled(False)
39 self.__previewButton = self.buttonBox.addButton(
40 self.trUtf8("Preview"), QDialogButtonBox.ActionRole)
41 self.__previewButton.setDefault(True)
42
43 self.nameEdit.setText("_MethodObject")
44 self.nameEdit.selectAll()
45
46 @pyqtSlot(str)
47 def on_nameEdit_textChanged(self, text):
48 """
49 Private slot to react to changes of the name.
50
51 @param text text entered into the edit (QString)
52 """
53 self.__okButton.setEnabled(text != "")
54
55 @pyqtSlot(QAbstractButton)
56 def on_buttonBox_clicked(self, button):
57 """
58 Private slot to act on the button pressed.
59
60 @param button reference to the button pressed (QAbstractButton)
61 """
62 if button == self.__previewButton:
63 self.previewChanges()
64 elif button == self.__okButton:
65 self.applyChanges()
66
67 def _calculateChanges(self, handle):
68 """
69 Protected method to calculate the changes.
70
71 @param handle reference to the task handle
72 (rope.base.taskhandle.TaskHandle)
73 @return reference to the Changes object (rope.base.change.ChangeSet)
74 """
75 try:
76 changes = self.__converter.get_changes(self.nameEdit.text())
77 return changes
78 except Exception as err:
79 self._refactoring.handleRopeError(err, self._title, handle)
80 return None

eric ide

mercurial