diff -r c8890f852917 -r 2cdb7c48b719 RefactoringRope/Refactoring.py --- a/RefactoringRope/Refactoring.py Mon Sep 18 20:05:28 2017 +0200 +++ b/RefactoringRope/Refactoring.py Tue Sep 19 18:59:14 2017 +0200 @@ -85,6 +85,15 @@ "Changes": self.__processChanges, } + def getMainWindow(self): + """ + Public method to get a reference to the IDE main window. + + @return reference to the IDE main window + @rtype UserInterface + """ + return self.__ui + def initActions(self): """ Public method to define the refactoring actions. @@ -786,9 +795,14 @@ if "Error" not in result: return True + if "Title" in result: + title = result["Title"] + else: + title = self.tr("Rope Error") + if result["Error"] == 'ModuleSyntaxError': res = E5MessageBox.warning( - self.__ui, result["Title"], + self.__ui, title, self.tr("Rope error: {0}").format( result["ErrorString"]), E5MessageBox.Ok | E5MessageBox.Open) @@ -801,7 +815,7 @@ return True else: E5MessageBox.warning( - self.__ui, result["Title"], + self.__ui, title, self.tr("Rope error: {0}").format( result["ErrorString"]) ) @@ -841,18 +855,25 @@ if self.handleRopeError(result): changeGroup = result["ChangeGroup"] try: - self.__refactoringDialogs[changeGroup].processChangeData(result) + self.__refactoringDialogs[changeGroup]\ + .processChangeData(result) except KeyError: # ignore data for non-existing dialogs pass - def __refactoringDialogClosed(self): + def __refactoringDialogClosed(self, changeGroup): """ Private slot handling the closing of a refactoring dialog. + + @param changeGroup name of the refactoring change group the dialog + belonged to + @type str """ - dlg = self.sender() - changeGroup = dlg.getChangeGroupName() - del self.__refactoringDialogs[changeGroup] + try: + del self.__refactoringDialogs[changeGroup] + except KeyError: + # it's gone already; ignore it + pass ##################################################### ## Rename refactorings @@ -925,30 +946,17 @@ offset = self.__getOffset(aw, line, index) selectedText = aw.selectedText() -## import rope.refactor.rename -## resource = rope.base.libutils.path_to_resource( -## self.__project, filename) -## try: -## renamer = rope.refactor.rename.Rename( -## self.__project, resource, offset) -## except Exception as err: -## self.handleRopeError(err, title) -## return -## -## if isLocal: -## localResource = resource -## else: -## localResource = None -## from RenameDialog import RenameDialog dlg = RenameDialog( self, title, filename, offset, isLocal, selectedText=selectedText, parent=self.__ui) changeGroup = dlg.getChangeGroupName() self.__refactoringDialogs[changeGroup] = dlg - dlg.finished.connect(self.__refactoringDialogClosed) + dlg.finished.connect( + lambda: self.__refactoringDialogClosed(changeGroup)) dlg.show() + # TODO: continue from here def __changeOccurrences(self): """ Private slot to perform the Change Occurrences refactoring. @@ -2027,14 +2035,16 @@ self.__progressDialog.reset() progressDialog = RopeProgressDialog( - self, params["Title"], params["Interruptable"], self.__ui) + self, params["Title"], params["Interruptable"]) progressDialog.show() + progressDialog.raise_() self.__progressDialog = progressDialog QApplication.processEvents() elif subcommand == "Progress": if self.__progressDialog is not None: self.__progressDialog.updateProgress(params) + self.__progressDialog.raise_() elif subcommand == "Reset": if self.__progressDialog is not None: @@ -2049,7 +2059,7 @@ """ self.__ropeConfig = params # keys: RopeFolderName, DefaultConfig, RopeHelpFile, - # RopeInfo, RopeVersion, RopeCopyright + # RopeInfo, RopeVersion, RopeCopyright def __ropeConfigFile(self): """