Package de.fu_berlin.inf.dpp.project

Examples of de.fu_berlin.inf.dpp.project.ISarosSession


    public boolean test(Object receiver, String property, Object[] args,
        Object expectedValue) {
        if (receiver instanceof IResource) {
            IResource resource = (IResource) receiver;
            if ("isInSarosSession".equals(property)) {
                ISarosSession sarosSession = sarosSessionManager
                    .getSarosSession();
                if (sarosSession != null) {
                    if (resource instanceof IProject)
                        return sarosSession
                            .isCompletelyShared((IProject) resource);
                    return sarosSession.isShared(resource);
                }
            }
        }
        return false;
    }
View Full Code Here


public class SarosSessionPropertyTester extends PropertyTester {

    public boolean test(Object receiver, String property, Object[] args,
        Object expectedValue) {
        if (receiver instanceof ISarosSession) {
            ISarosSession sarosSession = (ISarosSession) receiver;
            if ("isHost".equals(property)) {
                return sarosSession.isHost();
            }
        }
        return false;
    }
View Full Code Here

     * @sarosThread must be called from the Dispatch Thread
     */
    public void receiveActivities(JID fromJID,
        List<TimedActivityDataObject> timedActivities) {

        final ISarosSession session = sarosSessionObservable.getValue();

        if (session == null || session.getUser(fromJID) == null) {
            log.warn("Rcvd (" + String.format("%03d", timedActivities.size())
                + ") " + Utils.prefix(fromJID)
                + " but buddy is no participant: " + timedActivities);
            return;
        } else {
            String msg = "Rcvd ("
                + String.format("%03d", timedActivities.size()) + ") "
                + Utils.prefix(fromJID) + ": " + timedActivities;

            // only log on debug level if there is more than a checksum
            if (ActivityUtils.containsChecksumsOnly(timedActivities))
                log.trace(msg);
            else
                log.debug(msg);
        }

        for (TimedActivityDataObject timedActivity : timedActivities) {

            IActivityDataObject activityDataObject = timedActivity
                .getActivity();

            /*
             * Some activityDataObjects save space in the message by not setting
             * the source and the XML parser needs to provide the source
             */
            assert activityDataObject.getSource() != null : "Received activityDataObject without source:"
                + activityDataObject;

            try {
                // Ask sequencer to execute or queue until missing
                // activityDataObjects
                // arrive
                session.getSequencer().exec(timedActivity);
            } catch (Exception e) {
                log.error("Internal error", e);
            }
        }
    }
View Full Code Here

    public boolean test(Object receiver, String property, Object[] args,
        Object expectedValue) {
        if (receiver instanceof JID) {
            JID jid = (JID) receiver;
            if ("isInSarosSession".equals(property)) {
                ISarosSession sarosSession = sarosSessionManager
                    .getSarosSession();
                if (sarosSession != null) {
                    Collection<User> users = sarosSession.getParticipants();
                    for (User user : users) {
                        if (user.getJID().equals(jid)) {
                            return true;
                        }
                    }
View Full Code Here

     * @nonSWT This method should not be called from the SWT Thread!
     */
    protected void recoverFiles(ChecksumErrorActivity checksumError,
        SubMonitor progress) {

        ISarosSession sarosSession = this.sarosSession;

        progress
            .beginTask("Sending files", checksumError.getPaths().size() + 1);

        try {
            for (SPath path : checksumError.getPaths()) {
                progress.subTask("Recovering file: "
                    + path.getProjectRelativePath().lastSegment());
                recoverFile(checksumError.getSource(), sarosSession, path,
                    progress.newChild(1));
            }

            // Tell the user that we sent all files
            sarosSession.sendActivity(checksumError.getSource(),
                new ChecksumErrorActivity(sarosSession.getLocalUser(), null,
                    checksumError.getRecoveryID()));
        } finally {
            progress.done();
        }
    }
View Full Code Here

                /*
                 * If more than one person is in the session, it should not be
                 * closed because we are adding to an existing session not
                 * abandoning our attempt to set one up.
                 */
                ISarosSession s = sessionManager.getSarosSession();
                if (s != null && s.getParticipants().size() <= 1) {
                    sessionManager.stopSarosSession();
                }
            }
        });

View Full Code Here

        }

        @Override
        public void leaveReceived(JID fromJID) {

            final ISarosSession sarosSession = sessionManager.getSarosSession();

            if (sarosSession == null) {
                log.warn("Received leave message but shared"
                    + " project has already ended: " + fromJID);
                return;
            }

            final User user = sarosSession.getUser(fromJID);
            if (user == null) {
                log.warn("Received leave message from buddy who"
                    + " is not part of our shared project session: " + fromJID);
                return;
            }

            // FIXME LeaveEvents need to be Activities, otherwise
            // RaceConditions can occur when two users leave a the "same" time

            if (user.isHost()) {
                sessionManager.stopSarosSession();

                SarosView.showNotification(
                    "Closing the session",
                    "Session was closed by inviter "
                        + user.getHumanReadableName() + ".");
            } else {
                // Client
                Utils.runSafeSWTSync(log, new Runnable() {
                    public void run() {
                        // FIXME see above...
                        sarosSession.removeUser(user);
                    }
                });
            }
        }
View Full Code Here

        @Override
        public void requestForResendingActivitiesReceived(JID fromJID,
            int sequenceNumber, boolean andUp) {

            ISarosSession sarosSession = sessionManager.getSarosSession();

            if (sarosSession.getUser(fromJID) == null) {
                log.warn("Received Request for activityDataObject from buddy who"
                    + " is not part of our shared project session: " + fromJID);
                return;
            }

            List<TimedActivityDataObject> activities = sarosSession
                .getSequencer().getActivityHistory(fromJID, sequenceNumber,
                    andUp);

            log.info(String.format(
                "Received request for resending of timestamp%s %d%s.",
View Full Code Here

                        + ": The received userList packet's"
                        + " payload is null.");
                    return;
                }

                ISarosSession sarosSession = sessionManager.getSarosSession();
                assert sarosSession != null;

                User fromUser = sarosSession.getUser(fromJID);

                if (fromUser == null || !fromUser.isHost()) {
                    log.error("Received userList from buddy who "
                        + "is not part of our session or is not host: "
                        + Utils.prefix(fromJID));
                    return;
                }

                // Adding new users
                User newUser;
                for (UserListEntry userEntry : userListInfo.userList) {

                    // Check if we already know this user
                    User user = sarosSession.getUser(userEntry.jid);

                    if (user == null) {
                        // This user is not part of our project
                        newUser = new User(sarosSession, userEntry.jid,
                            userEntry.colorID);
                        newUser.setPermission(userEntry.permission);
                        if (userEntry.invitationComplete)
                            newUser.invitationCompleted();

                        // Add him and send him a message, and tell him our
                        // colour
                        sarosSession.addUser(newUser);
                    } else {
                        // User already exists

                        // Check if the existing user has the colour that we
                        // expect
                        if (user.getColorID() != userEntry.colorID) {
                            log.warn("Received color id doesn't"
                                + " match known color id");
                        }

                        // Update his permission
                        user.setPermission(userEntry.permission);

                        // Update invitation status
                        if (userEntry.invitationComplete
                            && !user.isInvitationComplete()) {
                            sarosSession.userInvitationCompleted(user);
                        }
                    }
                }
                transmitter.sendUserListConfirmation(fromJID);
            }
View Full Code Here

        if (!(element instanceof FileEditorInput))
            return;

        final IFile file = ((FileEditorInput) element).getFile();
        final ISarosSession sarosSession = editorManager.sarosSession;

        if (sarosSession == null || !sarosSession.isShared(file.getProject())) {
            return;
        }

        Utils.runSafeSWTSync(log, new Runnable() {
View Full Code Here

TOP

Related Classes of de.fu_berlin.inf.dpp.project.ISarosSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.