51 @param plugin reference to the plugin object |
51 @param plugin reference to the plugin object |
52 @type RefactoringRopePlugin |
52 @type RefactoringRopePlugin |
53 @param parent parent |
53 @param parent parent |
54 @type QObject |
54 @type QObject |
55 """ |
55 """ |
|
56 from .FileSystemCommands import EricFileSystemCommands |
|
57 |
56 super().__init__("RefactoringServer", parent=parent) |
58 super().__init__("RefactoringServer", parent=parent) |
57 |
59 |
58 self.__plugin = plugin |
60 self.__plugin = plugin |
59 self.__ui = parent |
61 self.__ui = parent |
60 self.__vm = ericApp().getObject("ViewManager") |
62 self.__vm = ericApp().getObject("ViewManager") |
70 |
72 |
71 self.__progressDialog = None |
73 self.__progressDialog = None |
72 self.__helpDialog = None |
74 self.__helpDialog = None |
73 self.__historyDialog = None |
75 self.__historyDialog = None |
74 self.__refactoringDialogs = {} |
76 self.__refactoringDialogs = {} |
75 |
|
76 from .FileSystemCommands import EricFileSystemCommands |
|
77 |
77 |
78 self.__fsCommands = EricFileSystemCommands(self.__ericProject) |
78 self.__fsCommands = EricFileSystemCommands(self.__ericProject) |
79 |
79 |
80 self.__methodMapping = { |
80 self.__methodMapping = { |
81 "Config": self.__setConfig, |
81 "Config": self.__setConfig, |
180 self.refactoringRenameAct = EricAction( |
180 self.refactoringRenameAct = EricAction( |
181 self.tr("Rename"), self.tr("&Rename"), 0, 0, self, "refactoring_rename" |
181 self.tr("Rename"), self.tr("&Rename"), 0, 0, self, "refactoring_rename" |
182 ) |
182 ) |
183 self.refactoringRenameAct.setStatusTip(self.tr("Rename the highlighted object")) |
183 self.refactoringRenameAct.setStatusTip(self.tr("Rename the highlighted object")) |
184 self.refactoringRenameAct.setWhatsThis( |
184 self.refactoringRenameAct.setWhatsThis( |
185 self.tr( |
185 self.tr("""<b>Rename</b><p>Rename the highlighted Python object.</p>""") |
186 """<b>Rename</b>""" """<p>Rename the highlighted Python object.</p>""" |
|
187 ) |
|
188 ) |
186 ) |
189 self.refactoringRenameAct.triggered.connect(self.__rename) |
187 self.refactoringRenameAct.triggered.connect(self.__rename) |
190 self.actions.append(self.refactoringRenameAct) |
188 self.actions.append(self.refactoringRenameAct) |
191 |
189 |
192 self.refactoringRenameLocalAct = EricAction( |
190 self.refactoringRenameLocalAct = EricAction( |
761 ) |
759 ) |
762 self.refactoringClearHistoryAct.setStatusTip( |
760 self.refactoringClearHistoryAct.setStatusTip( |
763 self.tr("Clear the refactoring history") |
761 self.tr("Clear the refactoring history") |
764 ) |
762 ) |
765 self.refactoringClearHistoryAct.setWhatsThis( |
763 self.refactoringClearHistoryAct.setWhatsThis( |
766 self.tr( |
764 self.tr("""<b>Clear History</b><p>Clears the refactoring history.</p>""") |
767 """<b>Clear History</b>""" """<p>Clears the refactoring history.</p>""" |
|
768 ) |
|
769 ) |
765 ) |
770 self.refactoringClearHistoryAct.triggered.connect(self.__clearHistory) |
766 self.refactoringClearHistoryAct.triggered.connect(self.__clearHistory) |
771 self.actions.append(self.refactoringClearHistoryAct) |
767 self.actions.append(self.refactoringClearHistoryAct) |
772 |
768 |
773 ##################################################### |
769 ##################################################### |
1039 @param result dictionary containing the error information |
1035 @param result dictionary containing the error information |
1040 @type dict |
1036 @type dict |
1041 @return flag indicating, that the error is to be ignored |
1037 @return flag indicating, that the error is to be ignored |
1042 @rtype bool |
1038 @rtype bool |
1043 """ |
1039 """ |
|
1040 from .ErrorDialog import ErrorDialog |
|
1041 |
1044 if "Error" not in result: |
1042 if "Error" not in result: |
1045 return True |
1043 return True |
1046 |
1044 |
1047 title = result.get("Title", self.tr("Rope Error")) |
1045 title = result.get("Title", self.tr("Rope Error")) |
1048 |
1046 |
1061 result["ErrorLine"], |
1059 result["ErrorLine"], |
1062 ) |
1060 ) |
1063 elif result["Error"] == "InterruptedTaskError": |
1061 elif result["Error"] == "InterruptedTaskError": |
1064 return True |
1062 return True |
1065 else: |
1063 else: |
1066 from .ErrorDialog import ErrorDialog |
|
1067 |
|
1068 ErrorDialog( |
1064 ErrorDialog( |
1069 title, |
1065 title, |
1070 self.tr("Rope error: {0}").format(result["ErrorString"]), |
1066 self.tr("Rope error: {0}").format(result["ErrorString"]), |
1071 traceback=result["Traceback"], |
1067 traceback=result["Traceback"], |
1072 parent=self.__ui, |
1068 parent=self.__ui, |
1156 the local file |
1152 the local file |
1157 @type bool |
1153 @type bool |
1158 @param renameModule flag indicating a module rename refactoring |
1154 @param renameModule flag indicating a module rename refactoring |
1159 @type bool |
1155 @type bool |
1160 """ |
1156 """ |
|
1157 from .RenameDialog import RenameDialog |
|
1158 |
1161 aw = self.__vm.activeWindow() |
1159 aw = self.__vm.activeWindow() |
1162 |
1160 |
1163 if aw is None: |
1161 if aw is None: |
1164 return |
1162 return |
1165 |
1163 |
1166 if not renameModule and not aw.hasSelectedText(): |
1164 if not renameModule and not aw.hasSelectedText(): |
1167 # no selection available |
1165 # no selection available |
1168 EricMessageBox.warning( |
1166 EricMessageBox.warning( |
1169 self.__ui, |
1167 self.__ui, |
1170 title, |
1168 title, |
1171 self.tr( |
1169 self.tr("Highlight the declaration you want to rename and try again."), |
1172 "Highlight the declaration you want to rename" " and try again." |
|
1173 ), |
|
1174 ) |
1170 ) |
1175 return |
1171 return |
1176 |
1172 |
1177 if isLocal: |
1173 if isLocal: |
1178 if not self.confirmBufferIsSaved(aw): |
1174 if not self.confirmBufferIsSaved(aw): |
1192 if line != line1: |
1188 if line != line1: |
1193 # selection span more than one line |
1189 # selection span more than one line |
1194 EricMessageBox.warning( |
1190 EricMessageBox.warning( |
1195 self.__ui, |
1191 self.__ui, |
1196 title, |
1192 title, |
1197 self.tr("The selection must not extend beyond" " one line."), |
1193 self.tr("The selection must not extend beyond one line."), |
1198 ) |
1194 ) |
1199 return |
1195 return |
1200 index = int(index + (index1 - index) / 2) |
1196 index = int(index + (index1 - index) / 2) |
1201 # keep it inside the object |
1197 # keep it inside the object |
1202 offset = self.__getOffset(aw, line, index) |
1198 offset = self.__getOffset(aw, line, index) |
1203 selectedText = aw.selectedText() |
1199 selectedText = aw.selectedText() |
1204 |
1200 |
1205 from .RenameDialog import RenameDialog |
|
1206 |
|
1207 dlg = RenameDialog( |
1201 dlg = RenameDialog( |
1208 self, |
1202 self, |
1209 title, |
1203 title, |
1210 filename, |
1204 filename, |
1211 offset, |
1205 offset, |
1231 if not aw.hasSelectedText(): |
1227 if not aw.hasSelectedText(): |
1232 # no selection available |
1228 # no selection available |
1233 EricMessageBox.warning( |
1229 EricMessageBox.warning( |
1234 self.__ui, |
1230 self.__ui, |
1235 title, |
1231 title, |
1236 self.tr("Highlight an occurrence to be changed" " and try again."), |
1232 self.tr("Highlight an occurrence to be changed and try again."), |
1237 ) |
1233 ) |
1238 return |
1234 return |
1239 |
1235 |
1240 if not self.confirmBufferIsSaved(aw): |
1236 if not self.confirmBufferIsSaved(aw): |
1241 return |
1237 return |
1242 |
1238 |
1243 filename = aw.getFileName() |
1239 filename = aw.getFileName() |
1244 line, index, line1, index1 = aw.getSelection() |
1240 line, index, line1, index1 = aw.getSelection() |
1245 offset = self.__getOffset(aw, line, index) |
1241 offset = self.__getOffset(aw, line, index) |
1246 |
|
1247 from .ChangeOccurrencesDialog import ChangeOccurrencesDialog |
|
1248 |
1242 |
1249 dlg = ChangeOccurrencesDialog(self, title, filename, offset, parent=self.__ui) |
1243 dlg = ChangeOccurrencesDialog(self, title, filename, offset, parent=self.__ui) |
1250 changeGroup = dlg.getChangeGroupName() |
1244 changeGroup = dlg.getChangeGroupName() |
1251 self.__refactoringDialogs[changeGroup] = dlg |
1245 self.__refactoringDialogs[changeGroup] = dlg |
1252 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1246 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1299 filename = aw.getFileName() |
1295 filename = aw.getFileName() |
1300 startline, startcolumn, endline, endcolumn = aw.getSelection() |
1296 startline, startcolumn, endline, endcolumn = aw.getSelection() |
1301 startOffset = self.__getOffset(aw, startline, startcolumn) |
1297 startOffset = self.__getOffset(aw, startline, startcolumn) |
1302 endOffset = self.__getOffset(aw, endline, endcolumn) |
1298 endOffset = self.__getOffset(aw, endline, endcolumn) |
1303 |
1299 |
1304 from .ExtractDialog import ExtractDialog |
|
1305 |
|
1306 dlg = ExtractDialog( |
1300 dlg = ExtractDialog( |
1307 self, title, filename, startOffset, endOffset, kind, parent=self.__ui |
1301 self, title, filename, startOffset, endOffset, kind, parent=self.__ui |
1308 ) |
1302 ) |
1309 changeGroup = dlg.getChangeGroupName() |
1303 changeGroup = dlg.getChangeGroupName() |
1310 self.__refactoringDialogs[changeGroup] = dlg |
1304 self.__refactoringDialogs[changeGroup] = dlg |
1342 |
1338 |
1343 filename = aw.getFileName() |
1339 filename = aw.getFileName() |
1344 line, index, line1, index1 = aw.getSelection() |
1340 line, index, line1, index1 = aw.getSelection() |
1345 offset = self.__getOffset(aw, line, index) |
1341 offset = self.__getOffset(aw, line, index) |
1346 |
1342 |
1347 from .InlineDialog import InlineDialog |
|
1348 |
|
1349 dlg = InlineDialog(self, title, filename, offset, parent=self.__ui) |
1343 dlg = InlineDialog(self, title, filename, offset, parent=self.__ui) |
1350 changeGroup = dlg.getChangeGroupName() |
1344 changeGroup = dlg.getChangeGroupName() |
1351 self.__refactoringDialogs[changeGroup] = dlg |
1345 self.__refactoringDialogs[changeGroup] = dlg |
1352 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1346 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1353 dlg.show() |
1347 dlg.show() |
1373 if not aw.hasSelectedText(): |
1369 if not aw.hasSelectedText(): |
1374 # no selection available |
1370 # no selection available |
1375 EricMessageBox.warning( |
1371 EricMessageBox.warning( |
1376 self.__ui, |
1372 self.__ui, |
1377 title, |
1373 title, |
1378 self.tr("Highlight the method to move" " and try again."), |
1374 self.tr("Highlight the method to move and try again."), |
1379 ) |
1375 ) |
1380 return |
1376 return |
1381 else: |
1377 else: |
1382 title = self.tr("Move Current Module") |
1378 title = self.tr("Move Current Module") |
1383 |
1379 |
1389 line, index, line1, index1 = aw.getSelection() |
1385 line, index, line1, index1 = aw.getSelection() |
1390 offset = self.__getOffset(aw, line, index) |
1386 offset = self.__getOffset(aw, line, index) |
1391 else: |
1387 else: |
1392 offset = None |
1388 offset = None |
1393 |
1389 |
1394 from .MoveDialog import MoveDialog |
|
1395 |
|
1396 dlg = MoveDialog(self, title, filename, offset, parent=self.__ui) |
1390 dlg = MoveDialog(self, title, filename, offset, parent=self.__ui) |
1397 changeGroup = dlg.getChangeGroupName() |
1391 changeGroup = dlg.getChangeGroupName() |
1398 self.__refactoringDialogs[changeGroup] = dlg |
1392 self.__refactoringDialogs[changeGroup] = dlg |
1399 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1393 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1400 dlg.show() |
1394 dlg.show() |
1425 |
1421 |
1426 filename = aw.getFileName() |
1422 filename = aw.getFileName() |
1427 line, index, line1, index1 = aw.getSelection() |
1423 line, index, line1, index1 = aw.getSelection() |
1428 offset = self.__getOffset(aw, line, index) |
1424 offset = self.__getOffset(aw, line, index) |
1429 |
1425 |
1430 from .UseFunctionDialog import UseFunctionDialog |
|
1431 |
|
1432 dlg = UseFunctionDialog(self, title, filename, offset, parent=self.__ui) |
1426 dlg = UseFunctionDialog(self, title, filename, offset, parent=self.__ui) |
1433 changeGroup = dlg.getChangeGroupName() |
1427 changeGroup = dlg.getChangeGroupName() |
1434 self.__refactoringDialogs[changeGroup] = dlg |
1428 self.__refactoringDialogs[changeGroup] = dlg |
1435 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1429 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1436 dlg.show() |
1430 dlg.show() |
1466 |
1462 |
1467 filename = aw.getFileName() |
1463 filename = aw.getFileName() |
1468 line, index, line1, index1 = aw.getSelection() |
1464 line, index, line1, index1 = aw.getSelection() |
1469 offset = self.__getOffset(aw, line, index) |
1465 offset = self.__getOffset(aw, line, index) |
1470 |
1466 |
1471 from .IntroduceFactoryDialog import IntroduceFactoryDialog |
|
1472 |
|
1473 dlg = IntroduceFactoryDialog(self, title, filename, offset, parent=self.__ui) |
1467 dlg = IntroduceFactoryDialog(self, title, filename, offset, parent=self.__ui) |
1474 changeGroup = dlg.getChangeGroupName() |
1468 changeGroup = dlg.getChangeGroupName() |
1475 self.__refactoringDialogs[changeGroup] = dlg |
1469 self.__refactoringDialogs[changeGroup] = dlg |
1476 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1470 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1477 dlg.show() |
1471 dlg.show() |
1478 |
1472 |
1479 def __introduceParameter(self): |
1473 def __introduceParameter(self): |
1480 """ |
1474 """ |
1481 Private slot to introduce a parameter in a function. |
1475 Private slot to introduce a parameter in a function. |
1482 """ |
1476 """ |
|
1477 from .IntroduceParameterDialog import IntroduceParameterDialog |
|
1478 |
1483 aw = self.__vm.activeWindow() |
1479 aw = self.__vm.activeWindow() |
1484 |
1480 |
1485 if aw is None: |
1481 if aw is None: |
1486 return |
1482 return |
1487 |
1483 |
1489 if not aw.hasSelectedText(): |
1485 if not aw.hasSelectedText(): |
1490 # no selection available |
1486 # no selection available |
1491 EricMessageBox.warning( |
1487 EricMessageBox.warning( |
1492 self.__ui, |
1488 self.__ui, |
1493 title, |
1489 title, |
1494 self.tr("Highlight the code for the new parameter" " and try again."), |
1490 self.tr("Highlight the code for the new parameter and try again."), |
1495 ) |
1491 ) |
1496 return |
1492 return |
1497 |
1493 |
1498 if not self.confirmAllBuffersSaved(): |
1494 if not self.confirmAllBuffersSaved(): |
1499 return |
1495 return |
1500 |
1496 |
1501 filename = aw.getFileName() |
1497 filename = aw.getFileName() |
1502 line, index, line1, index1 = aw.getSelection() |
1498 line, index, line1, index1 = aw.getSelection() |
1503 offset = self.__getOffset(aw, line, index) |
1499 offset = self.__getOffset(aw, line, index) |
1504 |
|
1505 from .IntroduceParameterDialog import IntroduceParameterDialog |
|
1506 |
1500 |
1507 dlg = IntroduceParameterDialog(self, title, filename, offset, parent=self.__ui) |
1501 dlg = IntroduceParameterDialog(self, title, filename, offset, parent=self.__ui) |
1508 changeGroup = dlg.getChangeGroupName() |
1502 changeGroup = dlg.getChangeGroupName() |
1509 self.__refactoringDialogs[changeGroup] = dlg |
1503 self.__refactoringDialogs[changeGroup] = dlg |
1510 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1504 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1565 if aw.hasSelectedText(): |
1561 if aw.hasSelectedText(): |
1566 line, index, line1, index1 = aw.getSelection() |
1562 line, index, line1, index1 = aw.getSelection() |
1567 offset = self.__getOffset(aw, line, index) |
1563 offset = self.__getOffset(aw, line, index) |
1568 else: |
1564 else: |
1569 offset = None |
1565 offset = None |
1570 |
|
1571 from .ConfirmationDialog import ConfirmationDialog |
|
1572 |
1566 |
1573 dlg = ConfirmationDialog( |
1567 dlg = ConfirmationDialog( |
1574 self, |
1568 self, |
1575 title, |
1569 title, |
1576 "Imports", |
1570 "Imports", |
1617 if not aw.hasSelectedText(): |
1613 if not aw.hasSelectedText(): |
1618 # no selection available |
1614 # no selection available |
1619 EricMessageBox.warning( |
1615 EricMessageBox.warning( |
1620 self.__ui, |
1616 self.__ui, |
1621 title, |
1617 title, |
1622 self.tr("Highlight the method or function to change" " and try again."), |
1618 self.tr("Highlight the method or function to change and try again."), |
1623 ) |
1619 ) |
1624 return |
1620 return |
1625 |
1621 |
1626 if not self.confirmAllBuffersSaved(): |
1622 if not self.confirmAllBuffersSaved(): |
1627 return |
1623 return |
1628 |
1624 |
1629 filename = aw.getFileName() |
1625 filename = aw.getFileName() |
1630 line, index, line1, index1 = aw.getSelection() |
1626 line, index, line1, index1 = aw.getSelection() |
1631 offset = self.__getOffset(aw, line, index) |
1627 offset = self.__getOffset(aw, line, index) |
1632 |
|
1633 from .ChangeSignatureDialog import ChangeSignatureDialog |
|
1634 |
1628 |
1635 dlg = ChangeSignatureDialog(self, title, filename, offset, parent=self.__ui) |
1629 dlg = ChangeSignatureDialog(self, title, filename, offset, parent=self.__ui) |
1636 changeGroup = dlg.getChangeGroupName() |
1630 changeGroup = dlg.getChangeGroupName() |
1637 self.__refactoringDialogs[changeGroup] = dlg |
1631 self.__refactoringDialogs[changeGroup] = dlg |
1638 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1632 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1666 |
1662 |
1667 filename = aw.getFileName() |
1663 filename = aw.getFileName() |
1668 line, index, line1, index1 = aw.getSelection() |
1664 line, index, line1, index1 = aw.getSelection() |
1669 offset = self.__getOffset(aw, line, index) |
1665 offset = self.__getOffset(aw, line, index) |
1670 |
1666 |
1671 from .InlineArgumentDefaultDialog import InlineArgumentDefaultDialog |
|
1672 |
|
1673 dlg = InlineArgumentDefaultDialog( |
1667 dlg = InlineArgumentDefaultDialog( |
1674 self, title, filename, offset, parent=self.__ui |
1668 self, title, filename, offset, parent=self.__ui |
1675 ) |
1669 ) |
1676 changeGroup = dlg.getChangeGroupName() |
1670 changeGroup = dlg.getChangeGroupName() |
1677 self.__refactoringDialogs[changeGroup] = dlg |
1671 self.__refactoringDialogs[changeGroup] = dlg |
1724 if not aw.hasSelectedText(): |
1720 if not aw.hasSelectedText(): |
1725 # no selection available |
1721 # no selection available |
1726 EricMessageBox.warning( |
1722 EricMessageBox.warning( |
1727 self.__ui, |
1723 self.__ui, |
1728 title, |
1724 title, |
1729 self.tr("Highlight the attribute to encapsulate" " and try again."), |
1725 self.tr("Highlight the attribute to encapsulate and try again."), |
1730 ) |
1726 ) |
1731 return |
1727 return |
1732 |
1728 |
1733 if not self.confirmAllBuffersSaved(): |
1729 if not self.confirmAllBuffersSaved(): |
1734 return |
1730 return |
1735 |
1731 |
1736 filename = aw.getFileName() |
1732 filename = aw.getFileName() |
1737 line, index, line1, index1 = aw.getSelection() |
1733 line, index, line1, index1 = aw.getSelection() |
1738 offset = self.__getOffset(aw, line, index) |
1734 offset = self.__getOffset(aw, line, index) |
1739 |
|
1740 from .GetterSetterDialog import GetterSetterDialog |
|
1741 |
1735 |
1742 dlg = GetterSetterDialog(self, title, filename, offset, parent=self.__ui) |
1736 dlg = GetterSetterDialog(self, title, filename, offset, parent=self.__ui) |
1743 changeGroup = dlg.getChangeGroupName() |
1737 changeGroup = dlg.getChangeGroupName() |
1744 self.__refactoringDialogs[changeGroup] = dlg |
1738 self.__refactoringDialogs[changeGroup] = dlg |
1745 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1739 dlg.finished.connect(lambda: self.__refactoringDialogClosed(changeGroup)) |
1772 |
1768 |
1773 filename = aw.getFileName() |
1769 filename = aw.getFileName() |
1774 line, index, line1, index1 = aw.getSelection() |
1770 line, index, line1, index1 = aw.getSelection() |
1775 offset = self.__getOffset(aw, line, index) |
1771 offset = self.__getOffset(aw, line, index) |
1776 |
1772 |
1777 from .ConfirmationDialog import ConfirmationDialog |
|
1778 |
|
1779 dlg = ConfirmationDialog( |
1773 dlg = ConfirmationDialog( |
1780 self, |
1774 self, |
1781 title, |
1775 title, |
1782 "LocalToAttribute", |
1776 "LocalToAttribute", |
1783 "CalculateLocalToAttributeChanges", |
1777 "CalculateLocalToAttributeChanges", |
1805 if not aw.hasSelectedText(): |
1801 if not aw.hasSelectedText(): |
1806 # no selection available |
1802 # no selection available |
1807 EricMessageBox.warning( |
1803 EricMessageBox.warning( |
1808 self.__ui, |
1804 self.__ui, |
1809 title, |
1805 title, |
1810 self.tr( |
1806 self.tr("Highlight the method or function to convert and try again."), |
1811 "Highlight the method or function to convert" " and try again." |
|
1812 ), |
|
1813 ) |
1807 ) |
1814 return |
1808 return |
1815 |
1809 |
1816 if not self.confirmAllBuffersSaved(): |
1810 if not self.confirmAllBuffersSaved(): |
1817 return |
1811 return |
1818 |
1812 |
1819 filename = aw.getFileName() |
1813 filename = aw.getFileName() |
1820 line, index, line1, index1 = aw.getSelection() |
1814 line, index, line1, index1 = aw.getSelection() |
1821 offset = self.__getOffset(aw, line, index) |
1815 offset = self.__getOffset(aw, line, index) |
1822 |
|
1823 from .MethodToMethodObjectDialog import MethodToMethodObjectDialog |
|
1824 |
1816 |
1825 dlg = MethodToMethodObjectDialog( |
1817 dlg = MethodToMethodObjectDialog( |
1826 self, title, filename, offset, parent=self.__ui |
1818 self, title, filename, offset, parent=self.__ui |
1827 ) |
1819 ) |
1828 changeGroup = dlg.getChangeGroupName() |
1820 changeGroup = dlg.getChangeGroupName() |
1836 |
1828 |
1837 def __showProjectHistory(self): |
1829 def __showProjectHistory(self): |
1838 """ |
1830 """ |
1839 Private method to show the project refactoring history. |
1831 Private method to show the project refactoring history. |
1840 """ |
1832 """ |
|
1833 from .HistoryDialog import HistoryDialog |
|
1834 |
1841 if self.__historyDialog is not None: |
1835 if self.__historyDialog is not None: |
1842 self.__historyDialog.close() |
1836 self.__historyDialog.close() |
1843 |
|
1844 from .HistoryDialog import HistoryDialog |
|
1845 |
1837 |
1846 self.__historyDialog = HistoryDialog(self, parent=self.__ui) |
1838 self.__historyDialog = HistoryDialog(self, parent=self.__ui) |
1847 self.__historyDialog.finished.connect(self.__historyDialogClosed) |
1839 self.__historyDialog.finished.connect(self.__historyDialogClosed) |
1848 self.__historyDialog.show() |
1840 self.__historyDialog.show() |
1849 |
1841 |
1850 def __showFileHistory(self): |
1842 def __showFileHistory(self): |
1851 """ |
1843 """ |
1852 Private method to show the refactoring history of the current file. |
1844 Private method to show the refactoring history of the current file. |
1853 """ |
1845 """ |
|
1846 from .HistoryDialog import HistoryDialog |
|
1847 |
1854 aw = self.__vm.activeWindow() |
1848 aw = self.__vm.activeWindow() |
1855 |
1849 |
1856 if aw is None: |
1850 if aw is None: |
1857 return |
1851 return |
1858 |
1852 |
1859 if self.__historyDialog is not None: |
1853 if self.__historyDialog is not None: |
1860 self.__historyDialog.close() |
1854 self.__historyDialog.close() |
1861 |
|
1862 from .HistoryDialog import HistoryDialog |
|
1863 |
1855 |
1864 filename = aw.getFileName() |
1856 filename = aw.getFileName() |
1865 if filename: |
1857 if filename: |
1866 self.__historyDialog = HistoryDialog( |
1858 self.__historyDialog = HistoryDialog( |
1867 self, filename=filename, parent=self.__ui |
1859 self, filename=filename, parent=self.__ui |
1942 the client. |
1934 the client. |
1943 |
1935 |
1944 @param result dictionary containing the result data |
1936 @param result dictionary containing the result data |
1945 @type dict |
1937 @type dict |
1946 """ |
1938 """ |
|
1939 from .MatchesDialog import MatchesDialog |
|
1940 |
1947 if self.handleRopeError(result): |
1941 if self.handleRopeError(result): |
1948 title = result["Title"] |
1942 title = result["Title"] |
1949 if result["EntriesCount"] > 0: |
1943 if result["EntriesCount"] > 0: |
1950 from .MatchesDialog import MatchesDialog |
|
1951 |
|
1952 self.dlg = MatchesDialog(self.__ui, True) |
1944 self.dlg = MatchesDialog(self.__ui, True) |
1953 self.dlg.show() |
1945 self.dlg.show() |
1954 for occurrence in result["Entries"]: |
1946 for occurrence in result["Entries"]: |
1955 self.dlg.addEntry( |
1947 self.dlg.addEntry( |
1956 # file name, lineno, unsure |
1948 # file name, lineno, unsure |
1997 the client. |
1989 the client. |
1998 |
1990 |
1999 @param result dictionary containing the result data |
1991 @param result dictionary containing the result data |
2000 @type dict |
1992 @type dict |
2001 """ |
1993 """ |
|
1994 from .MatchesDialog import MatchesDialog |
|
1995 |
2002 if self.handleRopeError(result): |
1996 if self.handleRopeError(result): |
2003 title = result["Title"] |
1997 title = result["Title"] |
2004 if "Location" in result: |
1998 if "Location" in result: |
2005 location = result["Location"] |
1999 location = result["Location"] |
2006 |
|
2007 from .MatchesDialog import MatchesDialog |
|
2008 |
2000 |
2009 self.dlg = MatchesDialog(self.__ui, False) |
2001 self.dlg = MatchesDialog(self.__ui, False) |
2010 self.dlg.show() |
2002 self.dlg.show() |
2011 self.dlg.addEntry(location[0], location[1]) |
2003 self.dlg.addEntry(location[0], location[1]) |
2012 # file name, lineno |
2004 # file name, lineno |
2048 the client. |
2040 the client. |
2049 |
2041 |
2050 @param result dictionary containing the result data |
2042 @param result dictionary containing the result data |
2051 @type dict |
2043 @type dict |
2052 """ |
2044 """ |
|
2045 from .MatchesDialog import MatchesDialog |
|
2046 |
2053 if self.handleRopeError(result): |
2047 if self.handleRopeError(result): |
2054 title = result["Title"] |
2048 title = result["Title"] |
2055 if result["EntriesCount"] > 0: |
2049 if result["EntriesCount"] > 0: |
2056 from .MatchesDialog import MatchesDialog |
|
2057 |
|
2058 self.dlg = MatchesDialog(self.__ui, True) |
2050 self.dlg = MatchesDialog(self.__ui, True) |
2059 self.dlg.show() |
2051 self.dlg.show() |
2060 for occurrence in result["Entries"]: |
2052 for occurrence in result["Entries"]: |
2061 self.dlg.addEntry( |
2053 self.dlg.addEntry( |
2062 # file name, lineno, unsure |
2054 # file name, lineno, unsure |
2075 |
2067 |
2076 def __editConfig(self): |
2068 def __editConfig(self): |
2077 """ |
2069 """ |
2078 Private slot to open the rope configuration file in an editor. |
2070 Private slot to open the rope configuration file in an editor. |
2079 """ |
2071 """ |
|
2072 from eric7.QScintilla.MiniEditor import MiniEditor |
|
2073 |
2080 ropedir = self.__ropeConfig["RopeFolderName"] |
2074 ropedir = self.__ropeConfig["RopeFolderName"] |
2081 configfile = "" |
2075 configfile = "" |
2082 if ropedir and os.path.exists(ropedir): |
2076 if ropedir and os.path.exists(ropedir): |
2083 configfile = os.path.join(ropedir, "config.py") |
2077 configfile = os.path.join(ropedir, "config.py") |
2084 if os.path.exists(configfile): |
2078 if os.path.exists(configfile): |
2085 from eric7.QScintilla.MiniEditor import MiniEditor |
|
2086 |
|
2087 self.__editor = MiniEditor(configfile) |
2079 self.__editor = MiniEditor(configfile) |
2088 self.__editor.show() |
2080 self.__editor.show() |
2089 self.__editor.editorSaved.connect(self.__configChanged) |
2081 self.__editor.editorSaved.connect(self.__configChanged) |
2090 else: |
2082 else: |
2091 EricMessageBox.critical( |
2083 EricMessageBox.critical( |
2092 self.__ui, |
2084 self.__ui, |
2093 self.tr("Configure Rope"), |
2085 self.tr("Configure Rope"), |
2094 self.tr( |
2086 self.tr( |
2095 """The Rope configuration file '{0}' does""" """ not exist.""" |
2087 """The Rope configuration file '{0}' does not exist.""" |
2096 ).format(configfile), |
2088 ).format(configfile), |
2097 ) |
2089 ) |
2098 else: |
2090 else: |
2099 EricMessageBox.critical( |
2091 EricMessageBox.critical( |
2100 self.__ui, |
2092 self.__ui, |
2135 |
2127 |
2136 def __showRopeHelp(self): |
2128 def __showRopeHelp(self): |
2137 """ |
2129 """ |
2138 Private slot to show help about the refactorings offered by Rope. |
2130 Private slot to show help about the refactorings offered by Rope. |
2139 """ |
2131 """ |
|
2132 from .HelpDialog import HelpDialog |
|
2133 |
2140 if self.__helpDialog is None: |
2134 if self.__helpDialog is None: |
2141 from .HelpDialog import HelpDialog |
|
2142 |
|
2143 self.__helpDialog = HelpDialog( |
2135 self.__helpDialog = HelpDialog( |
2144 self.tr("Help about rope refactorings"), |
2136 self.tr("Help about rope refactorings"), |
2145 self.__ropeConfig["RopeHelpFile"], |
2137 self.__ropeConfig["RopeHelpFile"], |
2146 ) |
2138 ) |
2147 self.__helpDialog.show() |
2139 self.__helpDialog.show() |