61 |
61 |
62 self.__mainMenu = None |
62 self.__mainMenu = None |
63 self.__progressDialog = None |
63 self.__progressDialog = None |
64 self.__helpDialog = None |
64 self.__helpDialog = None |
65 self.__historyDialog = None |
65 self.__historyDialog = None |
|
66 self.__refactoringDialogs = {} |
66 |
67 |
67 from FileSystemCommands import E5FileSystemCommands |
68 from FileSystemCommands import E5FileSystemCommands |
68 self.__fsCommands = E5FileSystemCommands(self.__e5project) |
69 self.__fsCommands = E5FileSystemCommands(self.__e5project) |
69 |
70 |
70 self.__methodMapping = { |
71 self.__methodMapping = { |
78 "FileSystemCommand": self.__fsCommands.processFileSystemCommand, |
79 "FileSystemCommand": self.__fsCommands.processFileSystemCommand, |
79 |
80 |
80 "ClientException": self.__processClientException, |
81 "ClientException": self.__processClientException, |
81 |
82 |
82 "HistoryResult": self.__processHistoryResult, |
83 "HistoryResult": self.__processHistoryResult, |
|
84 |
|
85 "Changes": self.__processChanges, |
83 } |
86 } |
84 |
87 |
85 def initActions(self): |
88 def initActions(self): |
86 """ |
89 """ |
87 Public method to define the refactoring actions. |
90 Public method to define the refactoring actions. |
825 |
828 |
826 ################################################################## |
829 ################################################################## |
827 ## slots below implement the various refactorings |
830 ## slots below implement the various refactorings |
828 ################################################################## |
831 ################################################################## |
829 |
832 |
|
833 def __processChanges(self, result): |
|
834 """ |
|
835 Private method to process the changes data sent by the refactoring |
|
836 client. |
|
837 |
|
838 @param result dictionary containing the changes data |
|
839 @type dict |
|
840 """ |
|
841 if self.handleRopeError(result): |
|
842 changeGroup = result["ChangeGroup"] |
|
843 try: |
|
844 self.__refactoringDialogs[changeGroup].processChangeData(result) |
|
845 except KeyError: |
|
846 # ignore data for non-existing dialogs |
|
847 pass |
|
848 |
|
849 def __refactoringDialogClosed(self): |
|
850 """ |
|
851 Private slot handling the closing of a refactoring dialog. |
|
852 """ |
|
853 dlg = self.sender() |
|
854 changeGroup = dlg.getChangeGroupName() |
|
855 del self.__refactoringDialogs[changeGroup] |
|
856 |
830 ##################################################### |
857 ##################################################### |
831 ## Rename refactorings |
858 ## Rename refactorings |
832 ##################################################### |
859 ##################################################### |
833 |
860 |
834 def __rename(self): |
861 def __rename(self): |
896 index = int(index + (index1 - index) / 2) |
923 index = int(index + (index1 - index) / 2) |
897 # keep it inside the object |
924 # keep it inside the object |
898 offset = self.__getOffset(aw, line, index) |
925 offset = self.__getOffset(aw, line, index) |
899 selectedText = aw.selectedText() |
926 selectedText = aw.selectedText() |
900 |
927 |
901 import rope.refactor.rename |
928 ## import rope.refactor.rename |
902 resource = rope.base.libutils.path_to_resource( |
929 ## resource = rope.base.libutils.path_to_resource( |
903 self.__project, filename) |
930 ## self.__project, filename) |
904 try: |
931 ## try: |
905 renamer = rope.refactor.rename.Rename( |
932 ## renamer = rope.refactor.rename.Rename( |
906 self.__project, resource, offset) |
933 ## self.__project, resource, offset) |
907 except Exception as err: |
934 ## except Exception as err: |
908 self.handleRopeError(err, title) |
935 ## self.handleRopeError(err, title) |
909 return |
936 ## return |
910 |
937 ## |
911 if isLocal: |
938 ## if isLocal: |
912 localResource = resource |
939 ## localResource = resource |
913 else: |
940 ## else: |
914 localResource = None |
941 ## localResource = None |
|
942 ## |
915 from RenameDialog import RenameDialog |
943 from RenameDialog import RenameDialog |
916 self.dlg = RenameDialog(self, title, renamer, resource=localResource, |
944 dlg = RenameDialog( |
917 selectedText=selectedText, parent=self.__ui) |
945 self, title, filename, offset, isLocal, |
918 self.dlg.show() |
946 selectedText=selectedText, parent=self.__ui) |
|
947 changeGroup = dlg.getChangeGroupName() |
|
948 self.__refactoringDialogs[changeGroup] = dlg |
|
949 dlg.finished.connect(self.__refactoringDialogClosed) |
|
950 dlg.show() |
919 |
951 |
920 def __changeOccurrences(self): |
952 def __changeOccurrences(self): |
921 """ |
953 """ |
922 Private slot to perform the Change Occurrences refactoring. |
954 Private slot to perform the Change Occurrences refactoring. |
923 """ |
955 """ |
2124 self.__helpDialog.close() |
2156 self.__helpDialog.close() |
2125 self.__helpDialog = None |
2157 self.__helpDialog = None |
2126 if self.__historyDialog is not None: |
2158 if self.__historyDialog is not None: |
2127 self.__historyDialog.close() |
2159 self.__historyDialog.close() |
2128 self.__historyDialog = None |
2160 self.__historyDialog = None |
|
2161 for dlg in self.__refactoringDialogs.values(): |
|
2162 dlg.close() |
|
2163 self.__refactoringDialogs = {} |
2129 |
2164 |
2130 self.sendJson("CloseProject", {}, flush=True) |
2165 self.sendJson("CloseProject", {}, flush=True) |
2131 |
2166 |
2132 self.__projectopen = False |
2167 self.__projectopen = False |
2133 self.__projectpath = '' |
2168 self.__projectpath = '' |