src/eric7/RemoteServerInterface/EricServerInterface.py

branch
server
changeset 10775
fd8b7692c03d
parent 10774
7f7ff7456904
child 10776
ec110553c5ab
equal deleted inserted replaced
10774:7f7ff7456904 10775:fd8b7692c03d
89 EricRequestCategory.EditorConfig: self.remoteEditorConfig, 89 EricRequestCategory.EditorConfig: self.remoteEditorConfig,
90 EricRequestCategory.FileSystem: self.remoteFileSystemReply, 90 EricRequestCategory.FileSystem: self.remoteFileSystemReply,
91 EricRequestCategory.Project: self.remoteProjectReply, 91 EricRequestCategory.Project: self.remoteProjectReply,
92 EricRequestCategory.Server: self.remoteServerReply, 92 EricRequestCategory.Server: self.remoteServerReply,
93 } 93 }
94 self.__serviceFactory = {
95 # key: lower case service name; value method to create the service interface
96 "coverage": self.__createCoverageInterface,
97 "debugger": self.__createDebuggerInterface,
98 "editorconfig": self.__createEditorConfigInterface,
99 "filesystem": self.__createFilesystemInterface,
100 }
94 self.__serviceInterfaces = {} 101 self.__serviceInterfaces = {}
95 # no specific service interfaces have been created yet 102 # no specific service interfaces have been created yet
96 103
97 self.__connection = None 104 self.__connection = None
98 self.__callbacks = {} # callback references indexed by UUID 105 self.__callbacks = {} # callback references indexed by UUID
115 """ 122 """
116 lname = name.lower() 123 lname = name.lower()
117 try: 124 try:
118 return self.__serviceInterfaces[lname] 125 return self.__serviceInterfaces[lname]
119 except KeyError: 126 except KeyError:
120 if lname not in ("coverage", "debugger", "editorconfig", "filesystem"): 127 try:
128 # instantiate the service interface
129 self.__serviceFactory[lname]()
130 except KeyError:
121 raise ValueError(f"no such service supported ({name})") 131 raise ValueError(f"no such service supported ({name})")
122 else:
123 # instantiate the service interface
124 if lname == "filesystem":
125 from .EricServerFileSystemInterface import ( # noqa: I101
126 EricServerFileSystemInterface,
127 )
128
129 self.__serviceInterfaces[lname] = EricServerFileSystemInterface(
130 self
131 )
132 elif lname == "debugger":
133 from .EricServerDebuggerInterface import ( # noqa: I101
134 EricServerDebuggerInterface,
135 )
136
137 self.__serviceInterfaces[lname] = EricServerDebuggerInterface(self)
138 elif lname == "coverage":
139 from .EricServerCoverageInterface import ( # noqa: I101
140 EricServerCoverageInterface,
141 )
142
143 self.__serviceInterfaces[lname] = EricServerCoverageInterface(self)
144 elif lname == "editorconfig":
145 from .EricServerEditorConfigInterface import ( # noqa: I101
146 EricServerEditorConfigInterface
147 )
148
149 self.__serviceInterfaces[lname] = EricServerEditorConfigInterface(
150 self
151 )
152 132
153 return self.__serviceInterfaces[lname] 133 return self.__serviceInterfaces[lname]
134
135 def __createCoverageInterface(self):
136 """
137 Private method to create and register the 'Coverage' eric-ide server interface.
138 """
139 from .EricServerCoverageInterface import EricServerCoverageInterface
140
141 self.__serviceInterfaces["coverage"] = EricServerCoverageInterface(self)
142
143 def __createDebuggerInterface(self):
144 """
145 Private method to create and register the 'Debugger' eric-ide server interface.
146 """
147 from .EricServerDebuggerInterface import EricServerDebuggerInterface
148
149 self.__serviceInterfaces["debugger"] = EricServerDebuggerInterface(self)
150
151 def __createEditorConfigInterface(self):
152 """
153 Private method to create and register the 'EditorConfig' eric-ide server
154 interface.
155 """
156 from .EricServerEditorConfigInterface import EricServerEditorConfigInterface
157
158 self.__serviceInterfaces["editorconfig"] = EricServerEditorConfigInterface(
159 self
160 )
161
162 def __createFilesystemInterface(self):
163 """
164 Private method to create and register the 'Filesystem' eric-ide server
165 interface.
166 """
167 from .EricServerFileSystemInterface import EricServerFileSystemInterface
168
169 self.__serviceInterfaces["filesystem"] = EricServerFileSystemInterface(self)
154 170
155 ####################################################################### 171 #######################################################################
156 ## Methods for handling the server connection. 172 ## Methods for handling the server connection.
157 ####################################################################### 173 #######################################################################
158 174
639 menu.addSeparator() 655 menu.addSeparator()
640 menu.addAction(self.serverVersionsAct) 656 menu.addAction(self.serverVersionsAct)
641 657
642 self.__menus = { 658 self.__menus = {
643 "Main": menu, 659 "Main": menu,
644 ##"Recent": self.recentMenu, 660 "ServerProfiles": self.__serverProfilesMenu,
645 } 661 }
646 662
647 return menu 663 return menu
648 664
649 def initToolbar(self, toolbarManager): 665 def initToolbar(self, toolbarManager):
712 self.__serverProfilesMenu.addSeparator() 728 self.__serverProfilesMenu.addSeparator()
713 729
714 self.__serverProfilesMenu.addAction( 730 self.__serverProfilesMenu.addAction(
715 self.tr("Manage Server Connections"), self.__manageServerProfiles 731 self.tr("Manage Server Connections"), self.__manageServerProfiles
716 ) 732 )
733
734 self.showMenu.emit("ServerProfiles", self.__menus["ServerProfiles"])
717 735
718 @pyqtSlot(bool) 736 @pyqtSlot(bool)
719 def __connectionStateChanged(self, connected): 737 def __connectionStateChanged(self, connected):
720 """ 738 """
721 Private slot to handle the connection state change. 739 Private slot to handle the connection state change.

eric ide

mercurial