RefactoringRope/Refactoring.py

changeset 31
0389d4a924cc
parent 26
b02d1f37b55e
child 33
d019d720768c
equal deleted inserted replaced
30:c27f6cc60391 31:0389d4a924cc
30 import rope.refactor.topackage 30 import rope.refactor.topackage
31 from rope.refactor.importutils import ImportOrganizer 31 from rope.refactor.importutils import ImportOrganizer
32 32
33 import rope.contrib.findit 33 import rope.contrib.findit
34 34
35 from PyQt4.QtCore import QObject, SIGNAL 35 from PyQt4.QtCore import QObject
36 from PyQt4.QtGui import QMenu, QApplication, QMessageBox, QDialog 36 from PyQt4.QtGui import QMenu, QApplication, QMessageBox, QDialog
37 37
38 from E5Gui.E5Application import e5App 38 from E5Gui.E5Application import e5App
39 39
40 from E5Gui.E5Action import E5Action 40 from E5Gui.E5Action import E5Action
68 68
69 class Refactoring(QObject): 69 class Refactoring(QObject):
70 """ 70 """
71 Class implementing the refactoring interface to rope. 71 Class implementing the refactoring interface to rope.
72 """ 72 """
73 def __init__(self, plugin, newStyle, parent=None): 73 def __init__(self, plugin, parent=None):
74 """ 74 """
75 Constructor 75 Constructor
76 76
77 @param plugin reference to the plugin object 77 @param plugin reference to the plugin object
78 @param newStyle flag indicating usage of new style signals (bool)
79 @param parent parent (QObject) 78 @param parent parent (QObject)
80 """ 79 """
81 QObject.__init__(self, parent) 80 QObject.__init__(self, parent)
82 81
83 self.__plugin = plugin 82 self.__plugin = plugin
84 self.__newStyle = newStyle
85 self.__ui = parent 83 self.__ui = parent
86 self.__e5project = e5App().getObject("Project") 84 self.__e5project = e5App().getObject("Project")
87 self.__projectpath = '' 85 self.__projectpath = ''
88 self.__projectLanguage = "" 86 self.__projectLanguage = ""
89 self.__projectopen = False 87 self.__projectopen = False
794 smenu.addAction(self.refactoringUndoAct) 792 smenu.addAction(self.refactoringUndoAct)
795 smenu.addAction(self.refactoringRedoAct) 793 smenu.addAction(self.refactoringRedoAct)
796 smenu.addSeparator() 794 smenu.addSeparator()
797 795
798 hmenu = smenu.addMenu(self.trUtf8("History")) 796 hmenu = smenu.addMenu(self.trUtf8("History"))
799 self.connect(hmenu, SIGNAL("aboutToShow()"), 797 hmenu.aboutToShow.connect(self.__showRefactoringHistoryMenu)
800 self.__showRefactoringHistoryMenu)
801 hmenu.addAction(self.refactoringUndoHistoryAct) 798 hmenu.addAction(self.refactoringUndoHistoryAct)
802 hmenu.addAction(self.refactoringUndoFileHistoryAct) 799 hmenu.addAction(self.refactoringUndoFileHistoryAct)
803 hmenu.addSeparator() 800 hmenu.addSeparator()
804 hmenu.addAction(self.refactoringRedoHistoryAct) 801 hmenu.addAction(self.refactoringRedoHistoryAct)
805 hmenu.addAction(self.refactoringRedoFileHistoryAct) 802 hmenu.addAction(self.refactoringRedoFileHistoryAct)
1209 except Exception as err: 1206 except Exception as err:
1210 self.handleRopeError(err, title) 1207 self.handleRopeError(err, title)
1211 return 1208 return
1212 1209
1213 if isinstance(mover, rope.refactor.move.MoveGlobal): 1210 if isinstance(mover, rope.refactor.move.MoveGlobal):
1214 self.dlg = MoveGlobalMethodDialog(self, title, mover, 1211 self.dlg = MoveGlobalMethodDialog(self, title, mover,
1215 self.__project, parent=self.__ui) 1212 self.__project, parent=self.__ui)
1216 else: 1213 else:
1217 self.dlg = MoveMethodDialog(self, title, mover, parent=self.__ui) 1214 self.dlg = MoveMethodDialog(self, title, mover, parent=self.__ui)
1218 self.dlg.show() 1215 self.dlg.show()
1219 1216
1972 if ropedir is not None: 1969 if ropedir is not None:
1973 configfile = os.path.join(ropedir.real_path, "config.py") 1970 configfile = os.path.join(ropedir.real_path, "config.py")
1974 if os.path.exists(configfile): 1971 if os.path.exists(configfile):
1975 self.__editor = MiniEditor(configfile) 1972 self.__editor = MiniEditor(configfile)
1976 self.__editor.show() 1973 self.__editor.show()
1977 if self.__newStyle: 1974 self.__editor.editorSaved.connect(self.__configChanged)
1978 self.__editor.editorSaved.connect(self.__configChanged)
1979 else:
1980 self.connect(self.__editor, SIGNAL("editorSaved"),
1981 self.__configChanged)
1982 else: 1975 else:
1983 QMessageBox.critical(self.__ui, 1976 QMessageBox.critical(self.__ui,
1984 self.trUtf8("Configure Rope"), 1977 self.trUtf8("Configure Rope"),
1985 self.trUtf8("""The Rope configuration file '{0}' does""" 1978 self.trUtf8("""The Rope configuration file '{0}' does"""
1986 """ not exist.""").format(configfile)) 1979 """ not exist.""").format(configfile))

eric ide

mercurial