Saros
Distributed Collaborative Editing and Distributed Party Programming
de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager Class Reference

List of all members.

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< SPathconnectedUserWithWriteAccessFiles = new HashSet<SPath>()
ISarosSession sarosSession
ISharedProjectListener sharedProjectListener
IActivityReceiver activityReceiver

Detailed Description

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.


Constructor & Destructor Documentation

de.fu_berlin.inf.dpp.core.editor.RemoteWriteAccessManager.RemoteWriteAccessManager ( final ISarosSession  sarosSession)

Creates a new RemoteWriteAccessManager and adds the sharedProjectListener to the session.

Parameters:
sarosSession

Member Function Documentation

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

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


Member Data Documentation

Initial value:
 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);
        }

    }

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)

Initial value:
 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());
            }
        }
    }
 All Classes Namespaces Files Functions Variables Enumerations