Search in sources :

Example 1 with IUser

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

the class ChatComposite method appendText.

public void appendText(ChatLine text) {
    if (text == null || textoutput == null || textoutput.isDisposed()) {
        return;
    }
    final IUser user = text.getOriginator();
    final StyleRange range = new StyleRange();
    range.start = textoutput.getText().length();
    if (user != null) {
        // $NON-NLS-1$
        String prefix = user.getNickname() + ": ";
        final String date = text.getDate();
        if (date != null && !date.equals("")) {
            // $NON-NLS-1$
            prefix = date + ' ' + prefix;
        }
        range.length = prefix.length();
        range.foreground = user.equals(view.userdata) ? meColor : otherColor;
        textoutput.append(prefix);
        textoutput.setStyleRange(range);
        textoutput.append(text.getText());
    } else {
        String content = text.getText();
        final String date = text.getDate();
        if (date != null && !date.equals("")) {
            // $NON-NLS-1$
            content = date + ' ' + content;
        }
        range.length = content.length();
        range.foreground = otherColor;
        textoutput.append(content);
    }
    if (!text.isNoCRLF()) {
        textoutput.append(Text.DELIMITER);
    }
    // scroll to end
    final String t = textoutput.getText();
    if (t != null) {
        textoutput.setSelection(t.length());
    }
}
Also used : StyleRange(org.eclipse.swt.custom.StyleRange) IUser(org.eclipse.ecf.core.user.IUser)

Example 2 with IUser

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

the class LineChatClientView method removeUserFromTree.

protected void removeUserFromTree(ID id) {
    if (id == null) {
        return;
    } else {
        for (int i = 0; i < users.size(); i++) {
            final IUser user = (IUser) users.get(i);
            if (user.getID().equals(id)) {
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        if (!teamChat.isDisposed())
                            teamChat.getTableViewer().remove(user);
                    }
                });
                users.remove(i);
                break;
            }
        }
    }
}
Also used : IUser(org.eclipse.ecf.core.user.IUser) Point(org.eclipse.swt.graphics.Point)

Example 3 with IUser

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

the class CompareWithHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IRosterEntry selectedEntry = getRosterEntry();
    IRoster roster = selectedEntry.getRoster();
    final IUser remoteUser = roster.getUser();
    ID localId = remoteUser.getID();
    ID remoteId = selectedEntry.getUser().getID();
    IContainer container = (IContainer) roster.getPresenceContainerAdapter().getAdapter(IContainer.class);
    final IResource resource = getResource(event);
    if (resource == null) {
        MessageDialog.openInformation(HandlerUtil.getActiveShell(event), null, Messages.CompareWithHandler_FileNotSelectedError);
        return null;
    }
    RemoteShare share = TeamSynchronization.getShare(container.getID());
    final RemoteResourceVariantTreeSubscriber subscriber = new RemoteResourceVariantTreeSubscriber(share, localId, remoteId);
    Job job = new Job(Messages.CompareWithHandler_ResourceComparisonJobTitle) {

        protected IStatus run(IProgressMonitor monitor) {
            try {
                openCompareEditor(subscriber.getSyncInfo(resource, monitor), remoteUser);
                return Status.OK_STATUS;
            } catch (TeamException e) {
                return e.getStatus();
            }
        }
    };
    job.setUser(true);
    job.schedule();
    return null;
}
Also used : TeamException(org.eclipse.team.core.TeamException) IRoster(org.eclipse.ecf.presence.roster.IRoster) RemoteShare(org.eclipse.team.internal.ecf.core.RemoteShare) RemoteResourceVariantTreeSubscriber(org.eclipse.team.internal.ecf.core.variants.RemoteResourceVariantTreeSubscriber) IUser(org.eclipse.ecf.core.user.IUser) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) Job(org.eclipse.core.runtime.jobs.Job) IResource(org.eclipse.core.resources.IResource)

Example 4 with IUser

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

the class XMPPUserSearchManager method createResultList.

/**
 * Create a result list from ReportedData. Identify dynamically columns and
 * rows and create users adding it to a {@link IResultList}
 *
 * @param data
 *            ReportedData
 * @return {@link IResultList} a list of users
 * @throws
 */
protected IResultList createResultList(ReportedData data) {
    ResultList result = new ResultList();
    Iterator rows = data.getRows();
    while (rows.hasNext()) {
        Row row = (Row) rows.next();
        Iterator jids = row.getValues(JID);
        Iterator names = row.getValues(NAME);
        String jid = null;
        String name = null;
        // XMPP server returns the same length for both
        while (jids.hasNext() && names.hasNext()) {
            try {
                jid = (String) jids.next();
                name = (String) names.next();
                IUser user = new User(new XMPPID(connectNamespace, jid), name);
                result.add(new XMPPResultItem(user));
            } catch (URISyntaxException e) {
                throw new RuntimeException(// $NON-NLS-1$
                "cannot create connect id for client " + jid + " , name = " + name, // $NON-NLS-1$
                e);
            }
        }
    }
    return result;
}
Also used : IResultList(org.eclipse.ecf.presence.search.IResultList) ResultList(org.eclipse.ecf.presence.search.ResultList) User(org.eclipse.ecf.core.user.User) IUser(org.eclipse.ecf.core.user.IUser) Iterator(java.util.Iterator) IUser(org.eclipse.ecf.core.user.IUser) Row(org.jivesoftware.smackx.ReportedData.Row) URISyntaxException(java.net.URISyntaxException) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID)

Example 5 with IUser

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

the class ChatRoomManagerView method doJoinRoom.

protected void doJoinRoom(final IChatRoomInfo roomInfo, final String password) {
    final ID targetRoomID = roomInfo.getRoomID();
    final String targetRoomName = targetRoomID.getName();
    // first, check to see if we already have it open. If so just activate
    ChatRoom room = (ChatRoom) chatRooms.get(targetRoomName);
    if (room != null && room.isConnected()) {
        room.setSelected();
        return;
    }
    // Then we create a new chatRoomContainer from the roomInfo
    try {
        final IChatRoomContainer chatRoomContainer = roomInfo.createChatRoomContainer();
        // Setup new user interface (new tab)
        final ChatRoom chatroom = new ChatRoom(chatRoomContainer, new ChatRoomTab(rootTabFolder, targetRoomName));
        // setup message listener
        chatRoomContainer.addMessageListener(new IIMMessageListener() {

            public void handleMessageEvent(IIMMessageEvent messageEvent) {
                if (messageEvent instanceof IChatRoomMessageEvent) {
                    IChatRoomMessage m = ((IChatRoomMessageEvent) messageEvent).getChatRoomMessage();
                    chatroom.handleMessage(m.getFromID(), m.getMessage());
                }
            }
        });
        // setup participant listener
        chatRoomContainer.addChatRoomParticipantListener(new IChatRoomParticipantListener() {

            public void handlePresenceUpdated(ID fromID, IPresence presence) {
                chatroom.handlePresence(fromID, presence);
            }

            public void handleArrived(IUser participant) {
            // do nothing
            }

            public void handleUpdated(IUser updatedParticipant) {
            // do nothing
            }

            public void handleDeparted(IUser participant) {
            // do nothing
            }
        });
        chatRoomContainer.addListener(new IContainerListener() {

            public void handleEvent(IContainerEvent evt) {
                if (evt instanceof IContainerDisconnectedEvent || evt instanceof IContainerEjectedEvent) {
                    chatroom.disconnected();
                }
            }
        });
        // Now connect/join
        Display.getDefault().asyncExec(new Runnable() {

            public void run() {
                try {
                    chatRoomContainer.connect(targetRoomID, ConnectContextFactory.createPasswordConnectContext(password));
                    chatRooms.put(targetRoomName, chatroom);
                } catch (Exception e) {
                    // $NON-NLS-1$
                    MessageDialog.openError(// $NON-NLS-1$
                    getSite().getShell(), // $NON-NLS-1$
                    "Connect Error", // $NON-NLS-1$
                    NLS.bind(// $NON-NLS-1$
                    "Could not connect to {0}.\n\nError is {1}.", targetRoomName, e.getLocalizedMessage()));
                }
            }
        });
    } catch (Exception e) {
        // $NON-NLS-1$
        MessageDialog.openError(// $NON-NLS-1$
        getSite().getShell(), // $NON-NLS-1$
        "Container Create Error", // $NON-NLS-1$
        NLS.bind(// $NON-NLS-1$
        "Could not create chatRoomContainer for {0}.\n\nError is {1}.", targetRoomName, e.getLocalizedMessage()));
    }
}
Also used : IContainerListener(org.eclipse.ecf.core.IContainerListener) ECFException(org.eclipse.ecf.core.util.ECFException) URISyntaxException(java.net.URISyntaxException) IUser(org.eclipse.ecf.core.user.IUser) IChatID(org.eclipse.ecf.presence.im.IChatID)

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