Search in sources :

Example 1 with IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry 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 2 with IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry in project ecf by eclipse.

the class BrowseHandler method execute.

/**
 * the command has been executed, so extract extract the needed information
 * from the application context.
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    IContainerManager containerManager = Activator.getDefault().getContainerManager();
    IContainer[] containers = containerManager.getAllContainers();
    BrowseDialog dialog = new BrowseDialog(window.getShell(), containers);
    int status = dialog.open();
    if (status == Window.OK) {
        Object[] object = dialog.getResult();
        IRosterEntry entry = (IRosterEntry) object[0];
        IRoster roster = entry.getRoster();
        if (roster != null) {
            IChatManager manager = roster.getPresenceContainerAdapter().getChatManager();
            IChatMessageSender icms = manager.getChatMessageSender();
            ITypingMessageSender itms = manager.getTypingMessageSender();
            try {
                MessagesView view = (MessagesView) window.getActivePage().showView(MessagesView.VIEW_ID);
                view.selectTab(icms, itms, roster.getUser().getID(), entry.getUser().getID(), entry.getUser().getName());
            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IContainerManager(org.eclipse.ecf.core.IContainerManager) IRoster(org.eclipse.ecf.presence.roster.IRoster) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) PartInitException(org.eclipse.ui.PartInitException) IContainer(org.eclipse.ecf.core.IContainer) MessagesView(org.eclipse.ecf.presence.ui.MessagesView)

Example 3 with IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry in project ecf by eclipse.

the class ScreenCaptureShareRosterEntryContributionItem method makeActions.

protected IAction[] makeActions() {
    // Else check for Roster entry
    final IRosterEntry entry = getSelectedRosterEntry();
    final IContainer c = getContainerForRosterEntry(entry);
    // If roster entry is selected and it has a container
    if (entry != null && c != null) {
        final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c.getAdapter(IChannelContainerAdapter.class);
        // If the container has channel container adapter and is online/available
        if (channelAdapter != null && isAvailable(entry)) {
            final ScreenCaptureShare tmp = ScreenCaptureShare.getScreenCaptureShare(c.getID());
            // If there is an URL share associated with this container
            if (tmp != null) {
                final ScreenCaptureShare screencaptureshare = tmp;
                final IAction action = new Action() {

                    public void run() {
                        MessageDialog dialog = new MessageDialog(null, Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MESSAGEBOX_TITLE, Window.getDefaultImage(), Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MESSAGEBOX_MESSAGE, MessageDialog.QUESTION, new String[] { NLS.bind(Messages.ScreenCaptureShareRosterEntryContributionItem_VERIFY_SEND_BUTTON_TEXT, entry.getName()), Messages.ScreenCaptureShareRosterEntryContributionItem_VERIFY_CANCEL_BUTTON_TEXT }, 0);
                        if (dialog.open() == Window.OK) {
                            ScreenCaptureJob screenCaptureJob = new ScreenCaptureJob(Display.getCurrent(), entry.getUser().getID(), entry.getUser().getName(), new IImageSender() {

                                public void sendImage(ID targetID, ImageData imageData) {
                                    screencaptureshare.sendImage(entry.getRoster().getUser().getID(), entry.getRoster().getUser().getName(), targetID, imageData);
                                }
                            });
                            screenCaptureJob.schedule(SCREEN_CAPTURE_DELAY);
                        }
                    }
                };
                action.setText(Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MENU);
                action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW));
                return new IAction[] { action };
            }
        }
    }
    return null;
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IImageSender(org.eclipse.ecf.ui.screencapture.IImageSender) IAction(org.eclipse.jface.action.IAction) ImageData(org.eclipse.swt.graphics.ImageData) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer) ScreenCaptureJob(org.eclipse.ecf.ui.screencapture.ScreenCaptureJob)

Example 4 with IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry in project ecf by eclipse.

the class XMPPContainerPresenceHelper method updatePresence.

private void updatePresence(XMPPID fromID, IPresence newPresence) {
    final Collection rosterItems = roster.getItems();
    List newEntrys = new ArrayList();
    synchronized (rosterItems) {
        for (final Iterator i = roster.getItems().iterator(); i.hasNext(); ) {
            final IRosterItem item = (IRosterItem) i.next();
            if (item instanceof IRosterGroup) {
                AdditionalClientRosterEntry[] es = updatePresenceInGroup((IRosterGroup) item, fromID, newPresence);
                for (int j = 0; j < es.length; j++) {
                    newEntrys.add(es[j]);
                }
            } else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
                AdditionalClientRosterEntry entry = updatePresenceForMatchingEntry((org.eclipse.ecf.presence.roster.RosterEntry) item, fromID, newPresence);
                if (entry != null)
                    newEntrys.add(entry);
            }
        }
    }
    AdditionalClientRosterEntry[] entrys = (AdditionalClientRosterEntry[]) newEntrys.toArray(new AdditionalClientRosterEntry[] {});
    if (entrys.length > 0) {
        for (int i = 0; i < entrys.length; i++) {
            if (entrys[i].add) {
                IRosterEntry entry = new org.eclipse.ecf.presence.roster.RosterEntry(entrys[i].parent, entrys[i].user, entrys[i].presence);
                addUniqueToRoster(new IRosterItem[] { entry });
                fireSetRosterEntry(false, entry);
            } else {
                removeItemFromRoster(rosterItems, fromID);
            }
        }
    }
}
Also used : IRosterItem(org.eclipse.ecf.presence.roster.IRosterItem) ArrayList(java.util.ArrayList) IRosterGroup(org.eclipse.ecf.presence.roster.IRosterGroup) Iterator(java.util.Iterator) Collection(java.util.Collection) List(java.util.List) ArrayList(java.util.ArrayList) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) RosterEntry(org.jivesoftware.smack.RosterEntry) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry)

Example 5 with IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry in project ecf by eclipse.

the class XMPPContainerPresenceHelper method replace.

private boolean replace(IRosterItem i1, IRosterItem i2) {
    if (i1 instanceof IRosterEntry) {
        IRosterEntry re1 = (IRosterEntry) i1;
        if (!(i2 instanceof IRosterEntry))
            return false;
        IRosterEntry re2 = (IRosterEntry) i2;
        XMPPID id1 = (XMPPID) re1.getUser().getID();
        XMPPID id2 = (XMPPID) re2.getUser().getID();
        String jid1 = id1.getUsernameAtHost();
        String jid2 = id2.getUsernameAtHost();
        if (jid1.equals(jid2)) {
            String r1 = id1.getResourceName();
            String r2 = id2.getResourceName();
            if (r1 == null && r2 != null)
                return true;
        }
    }
    return false;
}
Also used : IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID)

Aggregations

IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)15 IContainer (org.eclipse.ecf.core.IContainer)9 Action (org.eclipse.jface.action.Action)6 IAction (org.eclipse.jface.action.IAction)6 IUser (org.eclipse.ecf.core.user.IUser)5 IRoster (org.eclipse.ecf.presence.roster.IRoster)5 ID (org.eclipse.ecf.core.identity.ID)4 IChannelContainerAdapter (org.eclipse.ecf.datashare.IChannelContainerAdapter)4 IResource (org.eclipse.core.resources.IResource)3 IRosterGroup (org.eclipse.ecf.presence.roster.IRosterGroup)3 RemoteShare (org.eclipse.team.internal.ecf.core.RemoteShare)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 List (java.util.List)2 IRosterItem (org.eclipse.ecf.presence.roster.IRosterItem)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Job (org.eclipse.core.runtime.jobs.Job)1 IContainerManager (org.eclipse.ecf.core.IContainerManager)1 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)1