RefactoringRope/Refactoring.py

branch
server_client_variant
changeset 173
2cdb7c48b719
parent 172
c8890f852917
child 174
04583cac110f
equal deleted inserted replaced
172:c8890f852917 173:2cdb7c48b719
83 "HistoryResult": self.__processHistoryResult, 83 "HistoryResult": self.__processHistoryResult,
84 84
85 "Changes": self.__processChanges, 85 "Changes": self.__processChanges,
86 } 86 }
87 87
88 def getMainWindow(self):
89 """
90 Public method to get a reference to the IDE main window.
91
92 @return reference to the IDE main window
93 @rtype UserInterface
94 """
95 return self.__ui
96
88 def initActions(self): 97 def initActions(self):
89 """ 98 """
90 Public method to define the refactoring actions. 99 Public method to define the refactoring actions.
91 """ 100 """
92 self.actions = [] 101 self.actions = []
784 @rtype bool 793 @rtype bool
785 """ 794 """
786 if "Error" not in result: 795 if "Error" not in result:
787 return True 796 return True
788 797
798 if "Title" in result:
799 title = result["Title"]
800 else:
801 title = self.tr("Rope Error")
802
789 if result["Error"] == 'ModuleSyntaxError': 803 if result["Error"] == 'ModuleSyntaxError':
790 res = E5MessageBox.warning( 804 res = E5MessageBox.warning(
791 self.__ui, result["Title"], 805 self.__ui, title,
792 self.tr("Rope error: {0}").format( 806 self.tr("Rope error: {0}").format(
793 result["ErrorString"]), 807 result["ErrorString"]),
794 E5MessageBox.Ok | E5MessageBox.Open) 808 E5MessageBox.Ok | E5MessageBox.Open)
795 if res == E5MessageBox.Open: 809 if res == E5MessageBox.Open:
796 e5App().getObject("ViewManager").openSourceFile( 810 e5App().getObject("ViewManager").openSourceFile(
799 result["ErrorLine"]) 813 result["ErrorLine"])
800 elif result["Error"] == "InterruptedTaskError": 814 elif result["Error"] == "InterruptedTaskError":
801 return True 815 return True
802 else: 816 else:
803 E5MessageBox.warning( 817 E5MessageBox.warning(
804 self.__ui, result["Title"], 818 self.__ui, title,
805 self.tr("Rope error: {0}").format( 819 self.tr("Rope error: {0}").format(
806 result["ErrorString"]) 820 result["ErrorString"])
807 ) 821 )
808 822
809 return False 823 return False
839 @type dict 853 @type dict
840 """ 854 """
841 if self.handleRopeError(result): 855 if self.handleRopeError(result):
842 changeGroup = result["ChangeGroup"] 856 changeGroup = result["ChangeGroup"]
843 try: 857 try:
844 self.__refactoringDialogs[changeGroup].processChangeData(result) 858 self.__refactoringDialogs[changeGroup]\
859 .processChangeData(result)
845 except KeyError: 860 except KeyError:
846 # ignore data for non-existing dialogs 861 # ignore data for non-existing dialogs
847 pass 862 pass
848 863
849 def __refactoringDialogClosed(self): 864 def __refactoringDialogClosed(self, changeGroup):
850 """ 865 """
851 Private slot handling the closing of a refactoring dialog. 866 Private slot handling the closing of a refactoring dialog.
852 """ 867
853 dlg = self.sender() 868 @param changeGroup name of the refactoring change group the dialog
854 changeGroup = dlg.getChangeGroupName() 869 belonged to
855 del self.__refactoringDialogs[changeGroup] 870 @type str
871 """
872 try:
873 del self.__refactoringDialogs[changeGroup]
874 except KeyError:
875 # it's gone already; ignore it
876 pass
856 877
857 ##################################################### 878 #####################################################
858 ## Rename refactorings 879 ## Rename refactorings
859 ##################################################### 880 #####################################################
860 881
923 index = int(index + (index1 - index) / 2) 944 index = int(index + (index1 - index) / 2)
924 # keep it inside the object 945 # keep it inside the object
925 offset = self.__getOffset(aw, line, index) 946 offset = self.__getOffset(aw, line, index)
926 selectedText = aw.selectedText() 947 selectedText = aw.selectedText()
927 948
928 ## import rope.refactor.rename
929 ## resource = rope.base.libutils.path_to_resource(
930 ## self.__project, filename)
931 ## try:
932 ## renamer = rope.refactor.rename.Rename(
933 ## self.__project, resource, offset)
934 ## except Exception as err:
935 ## self.handleRopeError(err, title)
936 ## return
937 ##
938 ## if isLocal:
939 ## localResource = resource
940 ## else:
941 ## localResource = None
942 ##
943 from RenameDialog import RenameDialog 949 from RenameDialog import RenameDialog
944 dlg = RenameDialog( 950 dlg = RenameDialog(
945 self, title, filename, offset, isLocal, 951 self, title, filename, offset, isLocal,
946 selectedText=selectedText, parent=self.__ui) 952 selectedText=selectedText, parent=self.__ui)
947 changeGroup = dlg.getChangeGroupName() 953 changeGroup = dlg.getChangeGroupName()
948 self.__refactoringDialogs[changeGroup] = dlg 954 self.__refactoringDialogs[changeGroup] = dlg
949 dlg.finished.connect(self.__refactoringDialogClosed) 955 dlg.finished.connect(
956 lambda: self.__refactoringDialogClosed(changeGroup))
950 dlg.show() 957 dlg.show()
951 958
959 # TODO: continue from here
952 def __changeOccurrences(self): 960 def __changeOccurrences(self):
953 """ 961 """
954 Private slot to perform the Change Occurrences refactoring. 962 Private slot to perform the Change Occurrences refactoring.
955 """ 963 """
956 aw = e5App().getObject("ViewManager").activeWindow() 964 aw = e5App().getObject("ViewManager").activeWindow()
2025 if subcommand == "Init": 2033 if subcommand == "Init":
2026 if self.__progressDialog is not None: 2034 if self.__progressDialog is not None:
2027 self.__progressDialog.reset() 2035 self.__progressDialog.reset()
2028 2036
2029 progressDialog = RopeProgressDialog( 2037 progressDialog = RopeProgressDialog(
2030 self, params["Title"], params["Interruptable"], self.__ui) 2038 self, params["Title"], params["Interruptable"])
2031 progressDialog.show() 2039 progressDialog.show()
2040 progressDialog.raise_()
2032 self.__progressDialog = progressDialog 2041 self.__progressDialog = progressDialog
2033 QApplication.processEvents() 2042 QApplication.processEvents()
2034 2043
2035 elif subcommand == "Progress": 2044 elif subcommand == "Progress":
2036 if self.__progressDialog is not None: 2045 if self.__progressDialog is not None:
2037 self.__progressDialog.updateProgress(params) 2046 self.__progressDialog.updateProgress(params)
2047 self.__progressDialog.raise_()
2038 2048
2039 elif subcommand == "Reset": 2049 elif subcommand == "Reset":
2040 if self.__progressDialog is not None: 2050 if self.__progressDialog is not None:
2041 self.__progressDialog.reset() 2051 self.__progressDialog.reset()
2042 2052
2047 @param params dictionary containing the configuration data 2057 @param params dictionary containing the configuration data
2048 @type dict 2058 @type dict
2049 """ 2059 """
2050 self.__ropeConfig = params 2060 self.__ropeConfig = params
2051 # keys: RopeFolderName, DefaultConfig, RopeHelpFile, 2061 # keys: RopeFolderName, DefaultConfig, RopeHelpFile,
2052 # RopeInfo, RopeVersion, RopeCopyright 2062 # RopeInfo, RopeVersion, RopeCopyright
2053 2063
2054 def __ropeConfigFile(self): 2064 def __ropeConfigFile(self):
2055 """ 2065 """
2056 Private method to get the name of the rope configuration file. 2066 Private method to get the name of the rope configuration file.
2057 2067

eric ide

mercurial