Saros
Distributed Collaborative Editing and Distributed Party Programming
|
Public Member Functions | |
RemoteWriteAccessManager (final ISarosSession sarosSession) | |
void | exec (final IActivity activity) |
void | dispose () |
Protected Member Functions | |
void | updateConnectionState (final SPath path) |
Protected Attributes | |
Map< SPath, Set< User > > | editorStates = AutoHashMap.getSetHashMap() |
Set< SPath > | connectedUserWithWriteAccessFiles = new HashSet<SPath>() |
ISarosSession | sarosSession |
ISharedProjectListener | sharedProjectListener |
IActivityReceiver | activityReceiver |
This class manages state of open editors of all users with Permission#WRITE_ACCESS and connects to/disconnects from the corresponding DocumentProviders to make sure that TextEditActivities can be executed.
The main idea is to connect at the site of user with Permission#READONLY_ACCESS, when a user with Permission#WRITE_ACCESS activates his editor with the document. Disconnect happens, when last user with Permission#WRITE_ACCESS closes the editor.
de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager.RemoteWriteAccessManager | ( | final ISarosSession | sarosSession | ) |
Creates a new RemoteWriteAccessManager and adds the sharedProjectListener to the session.
sarosSession |
void de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager.dispose | ( | ) |
Removes all listener and clears all editorStates.
void de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager.exec | ( | final IActivity | activity | ) |
This method is called from the shared project when a new Activity arrives
activity | activity to dispatch |
void de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager.updateConnectionState | ( | final SPath | path | ) | [protected] |
Updates the state of the document provider of a document under the given path. This method looks if this document is already connected, and whether it needs to get connected/disconnected now.
IActivityReceiver de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager.activityReceiver [protected] |
new AbstractActivityReceiver() { @Override public void receive(final EditorActivity editorActivity) { User sender = editorActivity.getSource(); SPath path = editorActivity.getPath(); if (path == null) { return; } switch (editorActivity.getType()) { case ACTIVATED: editorStates.get(path).add(sender); break; case SAVED: break; case CLOSED: editorStates.get(path).remove(sender); break; default: LOG.warn(".receive() Unknown Activity type"); } updateConnectionState(path); } }
Set<SPath> de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager.connectedUserWithWriteAccessFiles = new HashSet<SPath>() [protected] |
stores files (identified by their path) connected by at least user with Permission#WRITE_ACCESS
Map<SPath, Set<User> > de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager.editorStates = AutoHashMap.getSetHashMap() [protected] |
stores users and their opened files (identified by their path)
ISharedProjectListener de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager.sharedProjectListener [protected] |
new AbstractSharedProjectListener() { @Override public void userLeft(User user) { for (Entry<SPath, Set<User>> entry : editorStates.entrySet()) { if (entry.getValue().remove(user)) updateConnectionState(entry.getKey()); } } @Override public void permissionChanged(User user) { for (Entry<SPath, Set<User>> entry : editorStates.entrySet()) { if (entry.getValue().contains(user)) updateConnectionState(entry.getKey()); } } }