--- a/src/eric7/RemoteServerInterface/EricServerInterface.py Tue Jun 11 16:42:56 2024 +0200 +++ b/src/eric7/RemoteServerInterface/EricServerInterface.py Tue Jun 11 17:12:23 2024 +0200 @@ -91,6 +91,13 @@ EricRequestCategory.Project: self.remoteProjectReply, EricRequestCategory.Server: self.remoteServerReply, } + self.__serviceFactory = { + # key: lower case service name; value method to create the service interface + "coverage": self.__createCoverageInterface, + "debugger": self.__createDebuggerInterface, + "editorconfig": self.__createEditorConfigInterface, + "filesystem": self.__createFilesystemInterface, + } self.__serviceInterfaces = {} # no specific service interfaces have been created yet @@ -117,41 +124,50 @@ try: return self.__serviceInterfaces[lname] except KeyError: - if lname not in ("coverage", "debugger", "editorconfig", "filesystem"): - raise ValueError(f"no such service supported ({name})") - else: + try: # instantiate the service interface - if lname == "filesystem": - from .EricServerFileSystemInterface import ( # noqa: I101 - EricServerFileSystemInterface, - ) - - self.__serviceInterfaces[lname] = EricServerFileSystemInterface( - self - ) - elif lname == "debugger": - from .EricServerDebuggerInterface import ( # noqa: I101 - EricServerDebuggerInterface, - ) - - self.__serviceInterfaces[lname] = EricServerDebuggerInterface(self) - elif lname == "coverage": - from .EricServerCoverageInterface import ( # noqa: I101 - EricServerCoverageInterface, - ) - - self.__serviceInterfaces[lname] = EricServerCoverageInterface(self) - elif lname == "editorconfig": - from .EricServerEditorConfigInterface import ( # noqa: I101 - EricServerEditorConfigInterface - ) - - self.__serviceInterfaces[lname] = EricServerEditorConfigInterface( - self - ) + self.__serviceFactory[lname]() + except KeyError: + raise ValueError(f"no such service supported ({name})") return self.__serviceInterfaces[lname] + def __createCoverageInterface(self): + """ + Private method to create and register the 'Coverage' eric-ide server interface. + """ + from .EricServerCoverageInterface import EricServerCoverageInterface + + self.__serviceInterfaces["coverage"] = EricServerCoverageInterface(self) + + def __createDebuggerInterface(self): + """ + Private method to create and register the 'Debugger' eric-ide server interface. + """ + from .EricServerDebuggerInterface import EricServerDebuggerInterface + + self.__serviceInterfaces["debugger"] = EricServerDebuggerInterface(self) + + def __createEditorConfigInterface(self): + """ + Private method to create and register the 'EditorConfig' eric-ide server + interface. + """ + from .EricServerEditorConfigInterface import EricServerEditorConfigInterface + + self.__serviceInterfaces["editorconfig"] = EricServerEditorConfigInterface( + self + ) + + def __createFilesystemInterface(self): + """ + Private method to create and register the 'Filesystem' eric-ide server + interface. + """ + from .EricServerFileSystemInterface import EricServerFileSystemInterface + + self.__serviceInterfaces["filesystem"] = EricServerFileSystemInterface(self) + ####################################################################### ## Methods for handling the server connection. ####################################################################### @@ -641,7 +657,7 @@ self.__menus = { "Main": menu, - ##"Recent": self.recentMenu, + "ServerProfiles": self.__serverProfilesMenu, } return menu @@ -715,6 +731,8 @@ self.tr("Manage Server Connections"), self.__manageServerProfiles ) + self.showMenu.emit("ServerProfiles", self.__menus["ServerProfiles"]) + @pyqtSlot(bool) def __connectionStateChanged(self, connected): """