32 self.setAttribute(Qt.WA_DeleteOnClose) |
32 self.setAttribute(Qt.WA_DeleteOnClose) |
33 self.setWindowTitle(title) |
33 self.setWindowTitle(title) |
34 |
34 |
35 self._refactoring = refactoring |
35 self._refactoring = refactoring |
36 self._title = title |
36 self._title = title |
|
37 |
|
38 self._changesCalculated = False |
|
39 |
|
40 def getChangeGroupName(self): |
|
41 """ |
|
42 Public method to get the name of the change group. |
|
43 |
|
44 @return name of the associated change group |
|
45 @rtype str |
|
46 """ |
|
47 return self._changeGroupName |
37 |
48 |
38 def calculateChanges(self): |
49 def calculateChanges(self): |
39 """ |
50 """ |
40 Public method to initiate the calculation of changes. |
51 Public method to initiate the calculation of changes. |
41 |
52 |
42 @exception NotImplementedError raised to indicate that this method must |
53 @exception NotImplementedError raised to indicate that this method must |
43 be overridden by subclasses |
54 be overridden by subclasses |
44 """ |
55 """ |
45 raise NotImplementedError("_calculateChanges must be overridden.") |
56 raise NotImplementedError("_calculateChanges must be overridden.") |
|
57 |
|
58 def requestPreview(self): |
|
59 """ |
|
60 Public method to request a preview of the calculated changes. |
|
61 """ |
|
62 self._calculateChanges() |
|
63 |
|
64 self._refactoring.sendJson("PreviewChanges", { |
|
65 "ChangeGroup": self._changeGroupName, |
|
66 }) |
46 |
67 |
47 def previewChanges(self, data): |
68 def previewChanges(self, data): |
48 """ |
69 """ |
49 Public method to preview the changes. |
70 Public method to preview the changes. |
50 |
71 |
59 |
80 |
60 def applyChanges(self): |
81 def applyChanges(self): |
61 """ |
82 """ |
62 Public method to apply the changes. |
83 Public method to apply the changes. |
63 """ |
84 """ |
|
85 if not self._changesCalculated: |
|
86 self.calculateChanges() |
|
87 |
64 self._refactoring.sendJson("ApplyChanges", { |
88 self._refactoring.sendJson("ApplyChanges", { |
65 "ChangeGroup": self._changeGroupName, |
89 "ChangeGroup": self._changeGroupName, |
|
90 "Title": self._title, |
66 }) |
91 }) |
67 ## if changes is not None: |
|
68 ## self.__createProgressHandle(False) |
|
69 ## try: |
|
70 ## self._refactoring.getProject().do(changes, self.__handle) |
|
71 ## except Exception as err: |
|
72 ## self._refactoring.handleRopeError( |
|
73 ## err, self._title, self.__handle) |
|
74 ## self.__handle.reset() |
|
75 ## self.__handle = None |
|
76 |
92 |
77 def processChangeData(self, data): |
93 def processChangeData(self, data): |
78 """ |
94 """ |
79 Public method to process the change data sent by the refactoring |
95 Public method to process the change data sent by the refactoring |
80 client. |
96 client. |
83 @type dict |
99 @type dict |
84 """ |
100 """ |
85 subcommand = data["Subcommand"] |
101 subcommand = data["Subcommand"] |
86 if subcommand == "PreviewChanges": |
102 if subcommand == "PreviewChanges": |
87 self.previewChanges(data) |
103 self.previewChanges(data) |
|
104 elif subcommand == "ChangesCalculated": |
|
105 self._changesCalculated = True |
88 elif subcommand == "ChangesApplied": |
106 elif subcommand == "ChangesApplied": |
89 self._refactoring.refreshEditors(data["ChangedFiles"]) |
107 if self._refactoring.handleRopeError(data): |
90 p = e5App().getObject("Project") |
108 self._refactoring.refreshEditors(data["ChangedFiles"]) |
91 if p.isDirty(): |
109 p = e5App().getObject("Project") |
92 p.saveProject() |
110 if p.isDirty(): |
93 |
111 p.saveProject() |
|
112 |
94 self.accept() |
113 self.accept() |
95 |
114 |
96 def closeEvent(self, evt): |
115 def closeEvent(self, evt): |
97 """ |
116 """ |
98 Protected method handling close events. |
117 Protected method handling close events. |