4926 |
4926 |
4927 ####################################################################### |
4927 ####################################################################### |
4928 ## Cooperation related methods |
4928 ## Cooperation related methods |
4929 ####################################################################### |
4929 ####################################################################### |
4930 |
4930 |
4931 def __getCooperationClient(self): |
4931 def setCooperationClient(self, client): |
4932 """ |
4932 """ |
4933 Private method to initialize and get a reference to the cooperation |
4933 Public method to set a reference to the cooperation client. |
4934 client. |
4934 |
4935 |
4935 @param client reference to the cooperation client (CooperationClient) |
4936 @return reference to the cooperation client (CooperationClient) |
4936 """ |
4937 """ |
4937 self.__cooperationClient = client |
4938 if self.__cooperationClient is None: |
|
4939 self.__cooperationClient = e5App().getObject("Cooperation").getClient() |
|
4940 self.__cooperationClient.editorCommand.connect(self.__receive) |
|
4941 return self.__cooperationClient |
|
4942 |
4938 |
4943 def isConnected(self): |
4939 def isConnected(self): |
4944 """ |
4940 """ |
4945 Public method to check the connection status of the IDE. |
4941 Public method to check the connection status of the IDE. |
4946 |
4942 |
4947 @return flag indicating the connection status (boolean) |
4943 @return flag indicating the connection status (boolean) |
4948 """ |
4944 """ |
4949 return self.__getCooperationClient().hasConnections() |
4945 return self.__cooperationClient.hasConnections() |
4950 |
4946 |
4951 def send(self, fileName, message): |
4947 def send(self, fileName, message): |
4952 """ |
4948 """ |
4953 Public method to send an editor command to remote editors. |
4949 Public method to send an editor command to remote editors. |
4954 |
4950 |
4955 @param fileName file name of the editor (string) |
4951 @param fileName file name of the editor (string) |
4956 @param message command message to be sent (string) |
4952 @param message command message to be sent (string) |
4957 """ |
4953 """ |
4958 project = e5App().getObject("Project") |
4954 project = e5App().getObject("Project") |
4959 if project.isProjectFile(fileName): |
4955 if project.isProjectFile(fileName): |
4960 self.__getCooperationClient().sendEditorCommand( |
4956 self.__cooperationClient.sendEditorCommand( |
4961 project.getHash(), |
4957 project.getHash(), |
4962 project.getRelativeUniversalPath(fileName), |
4958 project.getRelativeUniversalPath(fileName), |
4963 message |
4959 message |
4964 ) |
4960 ) |
4965 |
4961 |
4966 def __receive(self, hash, fileName, command): |
4962 def receive(self, hash, fileName, command): |
4967 """ |
4963 """ |
4968 Private slot to handle received editor commands. |
4964 Public slot to handle received editor commands. |
4969 |
4965 |
4970 @param hash hash of the project (string) |
4966 @param hash hash of the project (string) |
4971 @param fileName project relative file name of the editor (string) |
4967 @param fileName project relative file name of the editor (string) |
4972 @param command command string (string) |
4968 @param command command string (string) |
4973 """ |
4969 """ |
4975 if hash == project.getHash(): |
4971 if hash == project.getHash(): |
4976 fn = project.getAbsoluteUniversalPath(fileName) |
4972 fn = project.getAbsoluteUniversalPath(fileName) |
4977 editor = self.getOpenEditor(fn) |
4973 editor = self.getOpenEditor(fn) |
4978 if editor: |
4974 if editor: |
4979 editor.receive(command) |
4975 editor.receive(command) |
|
4976 |
|
4977 def shareConnected(self, connected): |
|
4978 """ |
|
4979 Public slot to handle a change of the connected state. |
|
4980 |
|
4981 @param connected flag indicating the connected state (boolean) |
|
4982 """ |
|
4983 for editor in self.getOpenEditors(): |
|
4984 editor.shareConnected(connected) |
|
4985 |
|
4986 def shareEditor(self, share): |
|
4987 """ |
|
4988 Public slot to set the shared status of the current editor. |
|
4989 |
|
4990 @param share flag indicating the share status (boolean) |
|
4991 """ |
|
4992 aw = self.activeWindow() |
|
4993 if aw is not None: |
|
4994 fn = aw.getFileName() |
|
4995 if e5App().getObject("Project").isProjectFile(fn): |
|
4996 aw.shareEditor(share) |
|
4997 |
|
4998 def startSharedEdit(self): |
|
4999 """ |
|
5000 Public slot to start a shared edit session for the current editor. |
|
5001 """ |
|
5002 aw = self.activeWindow() |
|
5003 if aw is not None: |
|
5004 fn = aw.getFileName() |
|
5005 if e5App().getObject("Project").isProjectFile(fn): |
|
5006 aw.startSharedEdit() |
|
5007 |
|
5008 def sendSharedEdit(self): |
|
5009 """ |
|
5010 Public slot to end a shared edit session for the current editor and |
|
5011 send the changes. |
|
5012 """ |
|
5013 aw = self.activeWindow() |
|
5014 if aw is not None: |
|
5015 fn = aw.getFileName() |
|
5016 if e5App().getObject("Project").isProjectFile(fn): |
|
5017 aw.sendSharedEdit() |
|
5018 |
|
5019 def cancelSharedEdit(self): |
|
5020 """ |
|
5021 Public slot to cancel a shared edit session for the current editor. |
|
5022 """ |
|
5023 aw = self.activeWindow() |
|
5024 if aw is not None: |
|
5025 fn = aw.getFileName() |
|
5026 if e5App().getObject("Project").isProjectFile(fn): |
|
5027 aw.cancelSharedEdit() |