30 """ |
30 """ |
31 QDialog.__init__(self, parent) |
31 QDialog.__init__(self, parent) |
32 self.setAttribute(Qt.WA_DeleteOnClose) |
32 self.setAttribute(Qt.WA_DeleteOnClose) |
33 self.setWindowTitle(title) |
33 self.setWindowTitle(title) |
34 |
34 |
|
35 self._ui = parent |
35 self._refactoring = refactoring |
36 self._refactoring = refactoring |
36 self._title = title |
37 self._title = title |
37 |
38 |
38 self._changesCalculated = False |
39 self._changesCalculated = False |
|
40 |
|
41 self.__queue = [] |
39 |
42 |
40 def getChangeGroupName(self): |
43 def getChangeGroupName(self): |
41 """ |
44 """ |
42 Public method to get the name of the change group. |
45 Public method to get the name of the change group. |
43 |
46 |
44 @return name of the associated change group |
47 @return name of the associated change group |
45 @rtype str |
48 @rtype str |
46 """ |
49 """ |
47 return self._changeGroupName |
50 return self._changeGroupName |
48 |
51 |
49 def calculateChanges(self): |
52 def _calculateChanges(self): |
50 """ |
53 """ |
51 Public method to initiate the calculation of changes. |
54 Protected method to initiate the calculation of changes. |
52 |
55 |
53 @exception NotImplementedError raised to indicate that this method must |
56 @exception NotImplementedError raised to indicate that this method must |
54 be overridden by subclasses |
57 be overridden by subclasses |
55 """ |
58 """ |
56 raise NotImplementedError("_calculateChanges must be overridden.") |
59 raise NotImplementedError("_calculateChanges must be overridden.") |
57 |
60 |
58 def requestPreview(self): |
61 def requestPreview(self): |
59 """ |
62 """ |
60 Public method to request a preview of the calculated changes. |
63 Public method to request a preview of the calculated changes. |
61 """ |
64 """ |
|
65 self.__queue.append(("PreviewChanges", { |
|
66 "ChangeGroup": self._changeGroupName, |
|
67 })) |
|
68 |
62 self._calculateChanges() |
69 self._calculateChanges() |
63 |
|
64 self._refactoring.sendJson("PreviewChanges", { |
|
65 "ChangeGroup": self._changeGroupName, |
|
66 }) |
|
67 |
70 |
68 def previewChanges(self, data): |
71 def previewChanges(self, data): |
69 """ |
72 """ |
70 Public method to preview the changes. |
73 Public method to preview the changes. |
71 |
74 |
81 def applyChanges(self): |
84 def applyChanges(self): |
82 """ |
85 """ |
83 Public method to apply the changes. |
86 Public method to apply the changes. |
84 """ |
87 """ |
85 if not self._changesCalculated: |
88 if not self._changesCalculated: |
86 self.calculateChanges() |
89 self.__queue.append(("ApplyChanges", { |
87 |
90 "ChangeGroup": self._changeGroupName, |
88 self._refactoring.sendJson("ApplyChanges", { |
91 "Title": self._title, |
89 "ChangeGroup": self._changeGroupName, |
92 })) |
90 "Title": self._title, |
93 self._calculateChanges() |
91 }) |
94 else: |
|
95 self._refactoring.sendJson("ApplyChanges", { |
|
96 "ChangeGroup": self._changeGroupName, |
|
97 "Title": self._title, |
|
98 }) |
92 |
99 |
93 def processChangeData(self, data): |
100 def processChangeData(self, data): |
94 """ |
101 """ |
95 Public method to process the change data sent by the refactoring |
102 Public method to process the change data sent by the refactoring |
96 client. |
103 client. |
101 subcommand = data["Subcommand"] |
108 subcommand = data["Subcommand"] |
102 if subcommand == "PreviewChanges": |
109 if subcommand == "PreviewChanges": |
103 self.previewChanges(data) |
110 self.previewChanges(data) |
104 elif subcommand == "ChangesCalculated": |
111 elif subcommand == "ChangesCalculated": |
105 self._changesCalculated = True |
112 self._changesCalculated = True |
|
113 if not self.isVisible(): |
|
114 self.show() |
|
115 if self.__queue: |
|
116 method, params = self.__queue.pop(0) |
|
117 self._refactoring.sendJson(method, params) |
106 elif subcommand == "ChangesApplied": |
118 elif subcommand == "ChangesApplied": |
107 if self._refactoring.handleRopeError(data): |
119 if self._refactoring.handleRopeError(data): |
108 self._refactoring.refreshEditors(data["ChangedFiles"]) |
120 self._refactoring.refreshEditors(data["ChangedFiles"]) |
109 p = e5App().getObject("Project") |
121 p = e5App().getObject("Project") |
110 if p.isDirty(): |
122 if p.isDirty(): |