Saros
Distributed Collaborative Editing and Distributed Party Programming
de.fu_berlin.inf.dpp.editor.EditorManager Class Reference
Inheritance diagram for de.fu_berlin.inf.dpp.editor.EditorManager:
de.fu_berlin.inf.dpp.session.AbstractActivityProducer de.fu_berlin.inf.dpp.editor.IEditorManager de.fu_berlin.inf.dpp.session.IActivityProducer

List of all members.

Public Member Functions

 EditorManager (ISarosSessionManager sessionManager, EditorAPI editorAPI, IPreferenceStore preferenceStore)
boolean isManaged (IFile file)
Set< SPathgetLocallyOpenEditors ()
Set< SPathgetRemotelyOpenEditors ()
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< SPathgetRemoteOpenEditors (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

Detailed Description

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)

Author:
rdjemili

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,...


Constructor & Destructor Documentation

de.fu_berlin.inf.dpp.editor.EditorManager.EditorManager ( ISarosSessionManager  sessionManager,
EditorAPI  editorAPI,
IPreferenceStore  preferenceStore 
)

Member Function Documentation

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.

Parameters:
listenereditor 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.

Parameters:
pathPath 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.

Parameters:
paththe 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.

Parameters:
partThe IEditorPart for which to generate a TextSelectionActivity
newSelectionThe 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.

Parameters:
partThe IEditorPart for which to generate a ViewportActivity.
viewportThe 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.

Returns:
paths of locally open shared files

Implements de.fu_berlin.inf.dpp.editor.IEditorManager.

RemoteEditorManager de.fu_berlin.inf.dpp.editor.EditorManager.getRemoteEditorManager ( )
Deprecated:
Returns:
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.

Returns:
paths of remotely open shared files

Implements de.fu_berlin.inf.dpp.editor.IEditorManager.

Set<SPath> de.fu_berlin.inf.dpp.editor.EditorManager.getRemoteOpenEditors ( User  user)

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 ( )

Checks if the local currently active editor is part of the running Saros session.

Returns:
true, if active editor is part of the Saros session, false otherwise.
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.

Parameters:
paththe project-relative path to the resource.
Returns:
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.

Parameters:
pathpath of the file to check
Returns:
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.

Parameters:
pathPath 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).

Parameters:
listenereditor 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.

Parameters:
paththe 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.

Parameters:
paththe 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.

Parameters:
offsetThe index into the given document where the text change started.
textThe text that has been inserted (is "" if no text was inserted but just characters were removed)
replaceLengthThe number of characters which have been replaced by this edit (is 0 if no character has been removed)
documentThe 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!


Member Data Documentation

 All Classes Namespaces Files Functions Variables Enumerations