src/eric7/Cooperation/SharedEditorController.py

Sun, 04 May 2025 16:38:04 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 04 May 2025 16:38:04 +0200
branch
eric7
changeset 11260
67773a953b64
child 11269
ce3bcd9df3b3
permissions
-rw-r--r--

Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.

11260
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2025 Detlev Offenbach <detlev@die-offenbachs.de>
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a controller for shared editing.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import difflib
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt6.QtCore import QCryptographicHash, QObject
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from eric7 import Utilities
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from eric7.EricWidgets.EricApplication import ericApp
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from .SharedEditStatus import SharedEditStatus
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class SharedEditorController(QObject):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Class implementing a controller for shared editing.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Separator = "@@@"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 StartEditToken = "START_EDIT"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 EndEditToken = "END_EDIT"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 CancelEditToken = "CANCEL_EDIT"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 RequestSyncToken = "REQUEST_SYNC"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 SyncToken = "SYNC"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 def __init__(self, cooperationClient, chatWidget):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 Constructor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @param cooperationClient reference to the cooperation client object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @type CooperationClient
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param chatWidget reference to the main cooperation widget
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @type ChatWidget
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 super().__init__(chatWidget)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.__cooperationWidget = chatWidget
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__cooperationClient = cooperationClient
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def __send(self, editor, editToken, args=None):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Private method to send an editor command to remote editors.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 @param editToken edit command token
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @param args arguments for the command
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 if self.__cooperationClient.hasConnections():
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 project = ericApp().getObject("Project")
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 fileName = editor.getFileName()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 if fileName and project.isProjectFile(fileName):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 msg = ""
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 if editToken in (
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 SharedEditorController.StartEditToken,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 SharedEditorController.EndEditToken,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 SharedEditorController.RequestSyncToken,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 SharedEditorController.SyncToken,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 ):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 msg = f"{editToken}{SharedEditorController.Separator}{args}"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 elif editToken == SharedEditorController.CancelEditToken:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 msg = f"{editToken}{SharedEditorController.Separator}c"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.__cooperationClient.sendEditorCommand(
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 project.getHash(), project.getRelativeUniversalPath(fileName), msg
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 )
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def receiveEditorCommand(self, projectHash, fileName, command):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 Public method to handle received editor commands.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @param projectHash hash of the project
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @param fileName project relative file name of the editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 @param command command string
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 project = ericApp().getObject("Project")
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 if projectHash == project.getHash():
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 fn = project.getAbsoluteUniversalPath(fileName)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 # TODO: change this to use local method
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 editor = ericApp().getObject("ViewManager").getOpenEditor(fn)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 if editor:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 if status.isShared:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 if status.isSyncing and not command.startswith(
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 SharedEditorController.SyncToken
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 + SharedEditorController.Separator
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 ):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 status.receivedWhileSyncing.append(command)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 else:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.__dispatchCommand(editor, command)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def shareConnected(self, connected):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Public slot to handle a change of the connected state.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @param connected flag indicating the connected state
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @type bool
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 for editor in ericApp().getObject("ViewManager").getOpenEditors():
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.__shareConnected(editor, connected)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 def shareEditor(self, share):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 Public slot to set the shared status of the current editor.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 @param share flag indicating the share status
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 @type bool
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 aw = ericApp().getObject("ViewManager").activeWindow()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 if aw is not None:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 fn = aw.getFileName()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 if fn and ericApp().getObject("Project").isProjectFile(fn):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.__shareEditor(aw, share)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 def startSharedEdit(self):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 Public slot to start a shared edit session for the current editor.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 aw = ericApp().getObject("ViewManager").activeWindow()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 if aw is not None:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 fn = aw.getFileName()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 if fn and ericApp().getObject("Project").isProjectFile(fn):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.__startSharedEdit(aw)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 def sendSharedEdit(self):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 Public slot to end a shared edit session for the current editor and
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 send the changes.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 aw = ericApp().getObject("ViewManager").activeWindow()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 if aw is not None:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 fn = aw.getFileName()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 if fn and ericApp().getObject("Project").isProjectFile(fn):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 self.__sendSharedEdit(aw)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 def cancelSharedEdit(self):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 Public slot to cancel a shared edit session for the current editor.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 aw = ericApp().getObject("ViewManager").activeWindow()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 if aw is not None:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 fn = aw.getFileName()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 if fn and ericApp().getObject("Project").isProjectFile(fn):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.__cancelSharedEdit(aw)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 ############################################################################
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 ## Shared editor related methods
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 ############################################################################
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 def __getSharedEditStatus(self, editor):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 Private method to get the shared edit status object of a given editor.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 If the editor does not have such an object, a default one is created and
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 set for the editor.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 @return reference to the shared edit status
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 @rtype SharedEditStatus
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 status = editor.getSharedEditStatus()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 if status is None:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 status = SharedEditStatus()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 editor.setSharedEditStatus(status)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 return status
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 def getSharingStatus(self, editor):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 Public method to get some share status info.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 @return tuple indicating, if the editor is sharable, the sharing
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 status, if it is inside a locally initiated shared edit session
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 and if it is inside a remotely initiated shared edit session
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 @rtype tuple of (bool, bool, bool, bool)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 project = ericApp().getObject("Project")
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 fn = editor.getFileName()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 return (
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 bool(fn) and project.isOpen() and project.isProjectFile(fn),
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 False if status is None else status.isShared,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 False if status is None else status.inSharedEdit,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 False if status is None else status.inRemoteSharedEdit,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 )
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 def __shareConnected(self, editor, connected):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 Private method to handle a change of the connected state.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 @param connected flag indicating the connected state
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 @type bool
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 if not connected:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 status.inRemoteSharedEdit = False
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 status.isSyncing = False
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 status.receivedWhileSyncing = []
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 editor.setReadOnly(False)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 editor.updateReadOnly()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 self.__cancelSharedEdit(editor, send=False)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 def __shareEditor(self, editor, share):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 Private method to set the shared status of the editor.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 @param share flag indicating the share status
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 @type bool
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 status.isShared = share
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 if not share:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 self.__shareConnected(editor, False)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 def __startSharedEdit(self, editor):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 Private method to start a shared edit session for the editor.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 status.inSharedEdit = True
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 status.savedText = editor.text()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 hashStr = str(
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 QCryptographicHash.hash(
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 Utilities.encode(status.savedText, editor.getEncoding())[0],
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 QCryptographicHash.Algorithm.Sha1,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 ).toHex(),
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 encoding="utf-8",
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 )
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 self.__send(editor, SharedEditorController.StartEditToken, hashStr)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 def __sendSharedEdit(self, editor):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 Private method to end a shared edit session for the editor and
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 send the changes.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 commands = self.__calculateChanges(status.savedText, editor.text())
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 self.__send(editor, SharedEditorController.EndEditToken, commands)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 status.inSharedEdit = False
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 status.savedText = ""
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 def __cancelSharedEdit(self, editor, send=True):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 Private method to cancel a shared edit session for the editor.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 @param send flag indicating to send the CancelEdit command
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 @type bool
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 status.inSharedEdit = False
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 status.savedText = ""
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 if send:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 self.__send(editor, SharedEditorController.CancelEditToken)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 def __dispatchCommand(self, editor, command):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 Private method to dispatch received commands.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 @param editor reference to the edior object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 @param command command to be processed
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 editToken, argsString = command.split(SharedEditorController.Separator, 1)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 if editToken == SharedEditorController.StartEditToken:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 self.__processStartEditCommand(editor, argsString)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 elif editToken == SharedEditorController.CancelEditToken:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 self.__shareConnected(editor, False)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 elif editToken == SharedEditorController.EndEditToken:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 self.__processEndEditCommand(editor, argsString)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 elif editToken == SharedEditorController.RequestSyncToken:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 self.__processRequestSyncCommand(editor, argsString)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 elif editToken == SharedEditorController.SyncToken:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 self.__processSyncCommand(editor, argsString)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 def __processStartEditCommand(self, editor, argsString):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 Private method to process a remote StartEdit command.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 @param argsString string containing the command parameters
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 if not status.inSharedEdit and not status.inRemoteSharedEdit:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 status.inRemoteSharedEdit = True
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 editor.setReadOnly(True)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 editor.updateReadOnly()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 hashStr = str(
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 QCryptographicHash.hash(
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 Utilities.encode(editor.text(), editor.getEncoding())[0],
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 QCryptographicHash.Algorithm.Sha1,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 ).toHex(),
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 encoding="utf-8",
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 )
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 if hashStr != argsString:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 # text is different to the remote site, request to sync it
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 status.isSyncing = True
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 self.__send(editor, SharedEditorController.RequestSyncToken, argsString)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 def __calculateChanges(self, old, new):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 Private method to determine change commands to convert old text into
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 new text.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 @param old old text
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 @param new new text
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 @return commands to change old into new
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 @rtype str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 oldL = old.splitlines()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 newL = new.splitlines()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 matcher = difflib.SequenceMatcher(None, oldL, newL)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 formatStr = "@@{0} {1} {2} {3}"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 commands = []
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 for diffToken, i1, i2, j1, j2 in matcher.get_opcodes():
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 if diffToken == "insert":
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 commands.append(formatStr.format("i", j1, j2 - j1, -1))
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 commands.extend(newL[j1:j2])
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 elif diffToken == "delete":
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 commands.append(formatStr.format("d", j1, i2 - i1, -1))
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 elif diffToken == "replace":
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 commands.append(formatStr.format("r", j1, i2 - i1, j2 - j1))
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 commands.extend(newL[j1:j2])
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 return "\n".join(commands) + "\n"
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 def __processEndEditCommand(self, editor, argsString):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 Private method to process a remote EndEdit command.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 @param argsString string containing the command parameters
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 commands = argsString.splitlines()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 sep = editor.getLineSeparator()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 cur = editor.getCursorPosition()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 editor.setReadOnly(False)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 editor.beginUndoAction()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 while commands:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 commandLine = commands.pop(0)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 if not commandLine.startswith("@@"):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 continue
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 args = commandLine.split()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 command = args.pop(0)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 pos, l1, l2 = [int(arg) for arg in args]
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 if command == "@@i":
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 txt = sep.join(commands[0:l1]) + sep
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 editor.insertAt(txt, pos, 0)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 del commands[0:l1]
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 elif command == "@@d":
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 editor.setSelection(pos, 0, pos + l1, 0)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 editor.removeSelectedText()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 elif command == "@@r":
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 editor.setSelection(pos, 0, pos + l1, 0)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 editor.removeSelectedText()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 txt = sep.join(commands[0:l2]) + sep
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 editor.insertAt(txt, pos, 0)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 del commands[0:l2]
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 editor.endUndoAction()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 editor.updateReadOnly()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 status.inRemoteSharedEdit = False
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 editor.setCursorPosition(*cur)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 def __processRequestSyncCommand(self, editor, argsString):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 Private method to process a remote RequestSync command.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 @param argsString string containing the command parameters
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 if status.inSharedEdit:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 hashStr = str(
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 QCryptographicHash.hash(
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 Utilities.encode(status.savedText, editor.getEncoding())[0],
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 QCryptographicHash.Algorithm.Sha1,
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 ).toHex(),
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 encoding="utf-8",
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 )
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 if hashStr == argsString:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 self.__send(editor, SharedEditorController.SyncToken, status.savedText)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 def __processSyncCommand(self, editor, argsString):
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 Private method to process a remote Sync command.
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 @param editor reference to the editor object
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 @type Editor
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 @param argsString string containing the command parameters
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 @type str
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 """
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 status = self.__getSharedEditStatus(editor)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 if status.isSyncing:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 cur = editor.getCursorPosition()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 editor.setReadOnly(False)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 editor.beginUndoAction()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 editor.selectAll()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 editor.removeSelectedText()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 editor.insertAt(argsString, 0, 0)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 editor.endUndoAction()
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 editor.setReadOnly(True)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 editor.setCursorPosition(*cur)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 while status.receivedWhileSyncing:
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 command = status.receivedWhileSyncing.pop(0)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 self.__dispatchCommand(editor, command)
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452
67773a953b64 Encapsulated the Cooperation (shared editing) code in the Cooperation package in order to extract it as a plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 status.isSyncing = False

eric ide

mercurial