Search in sources :

Example 11 with IUser

use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.

the class AbstractActionDelegate method run.

public void run(IAction action) {
    if ((chatRoomContainer == null) || (selection == null)) {
        return;
    }
    try {
        Iterator iterator = selection.iterator();
        while (iterator.hasNext()) {
            IUser user = (IUser) iterator.next();
            String message = getMessage(getUsername(user));
            chatRoomContainer.getChatRoomMessageSender().sendMessage(message);
        }
    } catch (ECFException e) {
        StatusManager.getManager().handle(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ECFException(org.eclipse.ecf.core.util.ECFException) Iterator(java.util.Iterator) IUser(org.eclipse.ecf.core.user.IUser)

Example 12 with IUser

use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.

the class DocShareRosterMenuHandler method execute.

/**
 * @throws ExecutionException
 */
public Object execute(ExecutionEvent arg0) throws ExecutionException {
    IRosterEntry rosterEntry = getRosterEntry();
    if (rosterEntry != null) {
        IRoster roster = rosterEntry.getRoster();
        final IContainer container = (IContainer) roster.getPresenceContainerAdapter().getAdapter(IContainer.class);
        if (container.getConnectedID() == null)
            showErrorMessage(Messages.DocShareRosterMenuHandler_ERROR_NOT_CONNECTED);
        final DocShare sender = Activator.getDefault().getDocShare(container.getID());
        if (sender == null)
            showErrorMessage(Messages.DocShareRosterMenuHandler_ERROR_NO_SENDER);
        if (sender.isSharing())
            showErrorMessage(Messages.DocShareRosterMenuHandler_ERROR_EDITOR_ALREADY_SHARING);
        final ITextEditor textEditor = getTextEditor();
        if (textEditor == null)
            showErrorMessage(Messages.DocShareRosterMenuHandler_EXCEPTION_EDITOR_NOT_TEXT);
        final String inputName = getInputName(textEditor);
        if (inputName == null)
            showErrorMessage(Messages.DocShareRosterMenuHandler_NO_FILENAME_WITH_CONTENT);
        final IUser user = roster.getUser();
        sender.startShare(user.getID(), user.getName(), rosterEntry.getUser().getID(), inputName, textEditor);
    }
    return null;
}
Also used : IRoster(org.eclipse.ecf.presence.roster.IRoster) DocShare(org.eclipse.ecf.docshare.DocShare) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IUser(org.eclipse.ecf.core.user.IUser) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) IContainer(org.eclipse.ecf.core.IContainer)

Example 13 with IUser

use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.

the class SharedObjectContainerUI method getUserData.

protected IUser getUserData(String containerType, ID clientID, String usernick, IResource project) {
    final Map topElements = new HashMap();
    topElements.put(Messages.SharedObjectContainerUI_PROJECT_LABEL, CollabClient.getNameForResource(project));
    final SimpleDateFormat sdf = new SimpleDateFormat(JOIN_TIME_FORMAT);
    topElements.put(Messages.SharedObjectContainerUI_TIME_LABEL, sdf.format(new Date()));
    try {
        // $NON-NLS-1$
        topElements.put(Messages.SharedObjectContainerUI_LANGUAGE_LABEL, System.getProperty("user.language"));
    } catch (final Exception e) {
    }
    try {
        // $NON-NLS-1$
        topElements.put(Messages.SharedObjectContainerUI_TIME_ZONE_LABEL, System.getProperty("user.timezone"));
    } catch (final Exception e) {
    }
    try {
        topElements.put(Messages.SharedObjectContainerUI_OS_LABEL, Platform.getOS());
    } catch (final Exception e) {
    }
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        topElements.put("Username", System.getProperty("user.name"));
    } catch (final Exception e) {
    }
    try {
        // $NON-NLS-1$
        topElements.put("Hostname/IP", InetAddress.getLocalHost().toString());
    } catch (final Exception e) {
    }
    return new User(clientID, usernick, usernick, topElements);
}
Also used : User(org.eclipse.ecf.core.user.User) IUser(org.eclipse.ecf.core.user.IUser) SimpleDateFormat(java.text.SimpleDateFormat)

Example 14 with IUser

use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.

the class SharedObjectContainerUI method addObjectToClient.

void addObjectToClient(ISharedObjectContainer soContainer, ClientEntry client, String username, IResource proj) throws Exception {
    final IResource project = (proj == null) ? CollabClient.getWorkspace() : proj;
    final IUser user = getUserData(client.getClass().getName(), client.getContainer().getID(), username, proj);
    createAndAddSharedObject(soContainer, client, project, user, getSharedFileDirectoryForProject(project));
}
Also used : IUser(org.eclipse.ecf.core.user.IUser) IResource(org.eclipse.core.resources.IResource)

Example 15 with IUser

use of org.eclipse.ecf.core.user.IUser in project ecf by eclipse.

the class XMPPContainerPresenceHelper method updatePresenceForMatchingEntry.

private AdditionalClientRosterEntry updatePresenceForMatchingEntry(org.eclipse.ecf.presence.roster.RosterEntry entry, XMPPID fromID, IPresence newPresence) {
    final IUser user = entry.getUser();
    XMPPID oldID = (XMPPID) user.getID();
    // the resource, or create a new client
    if (oldID.equals(fromID)) {
        if (newPresence.getType() == IPresence.Type.UNAVAILABLE) {
            return removeEntryFromRoster(oldID, entry, newPresence, user);
        } else {
            // set the new presence state
            entry.setPresence(newPresence);
            // and notify with roster update
            rosterManager.notifyRosterUpdate(entry);
        }
    } else if (oldID.getUsernameAtHost().equals(fromID.getUsernameAtHost())) {
        if (oldID.getResourceName() == null) {
            oldID.setResourceName(fromID.getResourceName());
            // set the new presence state
            entry.setPresence(newPresence);
            // and notify with roster update
            rosterManager.notifyRosterUpdate(entry);
        } else if (fromID.getResourceName() != null && !newPresence.getType().equals(IPresence.Type.UNAVAILABLE)) {
            return new AdditionalClientRosterEntry(entry.getParent(), new User(fromID, user.getName()), newPresence);
        }
    }
    return null;
}
Also used : User(org.eclipse.ecf.core.user.User) IUser(org.eclipse.ecf.core.user.IUser) IUser(org.eclipse.ecf.core.user.IUser) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID)

Aggregations

IUser (org.eclipse.ecf.core.user.IUser)16 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)5 IResource (org.eclipse.core.resources.IResource)4 ID (org.eclipse.ecf.core.identity.ID)4 User (org.eclipse.ecf.core.user.User)4 IContainer (org.eclipse.ecf.core.IContainer)3 ECFException (org.eclipse.ecf.core.util.ECFException)3 IRoster (org.eclipse.ecf.presence.roster.IRoster)3 RemoteShare (org.eclipse.team.internal.ecf.core.RemoteShare)3 URISyntaxException (java.net.URISyntaxException)2 Iterator (java.util.Iterator)2 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Job (org.eclipse.core.runtime.jobs.Job)1 IContainerListener (org.eclipse.ecf.core.IContainerListener)1