Saros
Distributed Collaborative Editing and Distributed Party Programming
|
Public Member Functions | |
EditorManager (ISarosSessionManager sessionManager, EditorAPI editorAPI, IPreferenceStore preferenceStore) | |
boolean | isManaged (IFile file) |
Set< SPath > | getLocallyOpenEditors () |
Set< SPath > | getRemotelyOpenEditors () |
void | addSharedEditorListener (ISharedEditorListener editorListener) |
void | removeSharedEditorListener (ISharedEditorListener editorListener) |
boolean | isOpened (SPath path) |
boolean | isActiveEditorShared () |
void | saveLazy (final SPath path) |
void | saveEditor (SPath path) |
boolean | isFollowing () |
User | getFollowedUser () |
void | setFollowing (User newFollowedUser) |
void | refreshAnnotations () |
void | colorChanged () |
RemoteEditorManager | getRemoteEditorManager () |
void | jumpToUser (User jumpTo) |
Set< SPath > | getRemoteOpenEditors (User user) |
boolean | isOpenEditor (SPath path) |
void | openEditor (SPath path) |
void | closeEditor (SPath path) |
void | saveEditors (final IProject project) |
Package Functions | |
void | connect (final IFile file) |
void | disconnect (final IFile file) |
void | generateEditorActivated (SPath path) |
void | generateViewport (IEditorPart part, ILineRange viewport) |
void | generateSelection (IEditorPart part, ITextSelection newSelection) |
void | textAboutToBeChanged (int offset, String text, int replaceLength, IDocument document) |
void | partOpened (IEditorPart editorPart) |
void | partActivated (IEditorPart editorPart) |
void | partInputChanged (IEditorPart editorPart) |
void | partClosed (IEditorPart editorPart) |
void | sendEditorActivitySaved (SPath path) |
Package Attributes | |
boolean | hasWriteAccess |
boolean | isLocked |
The EditorManager is responsible for handling all editors in a DPP-session. This includes the functionality of listening for user inputs in an editor, locking the editors of the users with Permission#READONLY_ACCESS. It both produces and consumes activities.
The EditorManager contains the testable logic. All untestable logic should only appear in a class of the IEditorAPI type. (CO: This is the theory at least)
TODO CO Since it was forgotten to reset the Editors of users with Permission#WRITE_ACCESS after a session closed, it is highly likely that this whole class needs to be reviewed for restarting issues
TODO CO This class contains too many different concerns: TextEdits, Editor opening and closing, Parsing of activities, executing of activities, dirty state management,...
de.fu_berlin.inf.dpp.editor.EditorManager.EditorManager | ( | ISarosSessionManager | sessionManager, |
EditorAPI | editorAPI, | ||
IPreferenceStore | preferenceStore | ||
) |
void de.fu_berlin.inf.dpp.editor.EditorManager.addSharedEditorListener | ( | ISharedEditorListener | listener | ) |
Adds an ISharedEditorListener to listen for changes such as editors getting opened, closed or their content changed.
listener | editor listener to add |
Implements de.fu_berlin.inf.dpp.editor.IEditorManager.
void de.fu_berlin.inf.dpp.editor.EditorManager.closeEditor | ( | SPath | path | ) |
Close the editor of given SPath.
path | Path of the file of which the editor should be closed |
void de.fu_berlin.inf.dpp.editor.EditorManager.colorChanged | ( | ) |
void de.fu_berlin.inf.dpp.editor.EditorManager.connect | ( | final IFile | file | ) | [package] |
Tries to add the given IFile to a set of locally opened files. The file gets connected to its IDocumentProvider (e.g. CompilationUnitDocumentProvider for Java-Files) This Method also converts the line delimiters of the document. Already connected files will not be connected twice.
void de.fu_berlin.inf.dpp.editor.EditorManager.disconnect | ( | final IFile | file | ) | [package] |
void de.fu_berlin.inf.dpp.editor.EditorManager.generateEditorActivated | ( | SPath | path | ) | [package] |
Sets the local editor 'opened' and fires an EditorActivity of type Type#ACTIVATED.
path | the project-relative path to the resource that the editor is currently editing or null if the local user has no editor open. |
void de.fu_berlin.inf.dpp.editor.EditorManager.generateSelection | ( | IEditorPart | part, |
ITextSelection | newSelection | ||
) | [package] |
Fires an update of the given ITextSelection for the given IEditorPart so that all remote parties know that the user selected some text in the given part.
part | The IEditorPart for which to generate a TextSelectionActivity |
newSelection | The ITextSelection in the given part which represents the currently selected text in editor. |
void de.fu_berlin.inf.dpp.editor.EditorManager.generateViewport | ( | IEditorPart | part, |
ILineRange | viewport | ||
) | [package] |
Fires an update of the given viewport for the given IEditorPart so that all remote parties know that the user is now positioned at the given viewport in the given part.
A ViewportActivity not necessarily indicates that the given IEditorPart is currently active. If it is (the given IEditorPart matches the locallyActiveEditor) then the localViewport is updated to reflect this.
part | The IEditorPart for which to generate a ViewportActivity. |
viewport | The ILineRange in the given part which represents the currently visible portion of the editor. (again visible does not mean that this editor is actually the active one) |
User de.fu_berlin.inf.dpp.editor.EditorManager.getFollowedUser | ( | ) |
Returns the followed User or null
if currently no user is followed.
Set<SPath> de.fu_berlin.inf.dpp.editor.EditorManager.getLocallyOpenEditors | ( | ) |
Returns the paths of all shared files for which an editor is currently open locally.
Implements de.fu_berlin.inf.dpp.editor.IEditorManager.
RemoteEditorManager de.fu_berlin.inf.dpp.editor.EditorManager.getRemoteEditorManager | ( | ) |
Set<SPath> de.fu_berlin.inf.dpp.editor.EditorManager.getRemotelyOpenEditors | ( | ) |
Returns the paths of all shared files for which an editor is currently open at a remote site.
Implements de.fu_berlin.inf.dpp.editor.IEditorManager.
Returns a snap shot copy of the paths representing the editors that the given user has currently opened (one of them being the active editor).
Returns an empty set if the user has no editors open.
boolean de.fu_berlin.inf.dpp.editor.EditorManager.isActiveEditorShared | ( | ) |
boolean de.fu_berlin.inf.dpp.editor.EditorManager.isFollowing | ( | ) |
Returns true
if there is currently a User followed, otherwise false
.
boolean de.fu_berlin.inf.dpp.editor.EditorManager.isManaged | ( | IFile | file | ) |
boolean de.fu_berlin.inf.dpp.editor.EditorManager.isOpened | ( | SPath | path | ) |
Checks whether given resource is currently opened.
path | the project-relative path to the resource. |
true
if the given resource is opened according to the editor pool. boolean de.fu_berlin.inf.dpp.editor.EditorManager.isOpenEditor | ( | SPath | path | ) |
Convenience method for determining whether a file is currently open in an editor.
path | path of the file to check |
true
if there is an open editor for this file, false
otherwise void de.fu_berlin.inf.dpp.editor.EditorManager.jumpToUser | ( | User | jumpTo | ) |
void de.fu_berlin.inf.dpp.editor.EditorManager.openEditor | ( | SPath | path | ) |
Open the editor window of given SPath.
path | Path of the Editor to open. |
void de.fu_berlin.inf.dpp.editor.EditorManager.partActivated | ( | IEditorPart | editorPart | ) | [package] |
Called when the local user activated a shared editor.
This can be called twice for a single IEditorPart, because it is called from partActivated and from partBroughtToTop.
We do not filter duplicate events, because it would be bad to miss events and is not too bad have duplicate one's. In particular we use IPath as an identifier to the IEditorPart which might not work for multiple editors based on the same file. (called by EditorPartListener)
void de.fu_berlin.inf.dpp.editor.EditorManager.partClosed | ( | IEditorPart | editorPart | ) | [package] |
Called if the local user closed a part (called by EditorPartListener)
void de.fu_berlin.inf.dpp.editor.EditorManager.partInputChanged | ( | IEditorPart | editorPart | ) | [package] |
Called if the IEditorInput of the IEditorPart is now something different than before! Probably when renaming. (called by EditorPartListener)
void de.fu_berlin.inf.dpp.editor.EditorManager.partOpened | ( | IEditorPart | editorPart | ) | [package] |
Called when the local user opened an editor part. (called by EditorPartListener)
void de.fu_berlin.inf.dpp.editor.EditorManager.refreshAnnotations | ( | ) |
void de.fu_berlin.inf.dpp.editor.EditorManager.removeSharedEditorListener | ( | ISharedEditorListener | listener | ) |
Removes an ISharedEditorListener that was previously added with addSharedEditorListener(ISharedEditorListener).
listener | editor listener to remove |
Implements de.fu_berlin.inf.dpp.editor.IEditorManager.
void de.fu_berlin.inf.dpp.editor.EditorManager.saveEditor | ( | SPath | path | ) |
Programmatically saves the given editor IF and only if the file is registered as a connected file.
Calling this method will trigger a call to all registered SharedEditorListeners (independent of the success of this method) BEFORE the file is actually saved.
Calling this method will NOT trigger a EditorActivity of type Save to be sent to the other clients.
path | the project relative path to the file that is supposed to be saved to disk. |
This method must be called from the SWT thread
This method cannot be called twice at the same time.
void de.fu_berlin.inf.dpp.editor.EditorManager.saveEditors | ( | final IProject | project | ) |
void de.fu_berlin.inf.dpp.editor.EditorManager.saveLazy | ( | final SPath | path | ) |
Save file denoted by the given project relative path if necessary according to isDirty(IPath) and call saveText(IPath) if necessary in the SWT thread.
This method returns after the file has been saved in the SWT Thread.
void de.fu_berlin.inf.dpp.editor.EditorManager.sendEditorActivitySaved | ( | SPath | path | ) | [package] |
Sends an Activity for clients to save the editor of given path.
path | the project relative path to the resource that the user with Permission#WRITE_ACCESS was editing. |
void de.fu_berlin.inf.dpp.editor.EditorManager.setFollowing | ( | User | newFollowedUser | ) |
Sets the User to follow or null
if no user should be followed.
void de.fu_berlin.inf.dpp.editor.EditorManager.textAboutToBeChanged | ( | int | offset, |
String | text, | ||
int | replaceLength, | ||
IDocument | document | ||
) | [package] |
This method is called from Eclipse (via the StoppableDocumentListener) whenever the local user has changed some text in an editor.
offset | The index into the given document where the text change started. |
text | The text that has been inserted (is "" if no text was inserted but just characters were removed) |
replaceLength | The number of characters which have been replaced by this edit (is 0 if no character has been removed) |
document | The document which was changed. |
TODO If we don't have User.Permission#WRITE_ACCESS, then receiving this event might indicate that the user somehow achieved to change his document. We should run a consistency check.
But watch out for changes because of a consistency check!
boolean de.fu_berlin.inf.dpp.editor.EditorManager.hasWriteAccess [package] |
boolean de.fu_berlin.inf.dpp.editor.EditorManager.isLocked [package] |