Search in sources :

Example 11 with IRosterEntry

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

the class URLShareRosterEntryContributionItem 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 URLShare tmp = URLShare.getURLShare(c.getID());
            // If there is an URL share associated with this container
            if (tmp != null) {
                final URLShare urlshare = tmp;
                final IAction action = new Action() {

                    public void run() {
                        urlshare.showDialogAndSendURL(entry.getRoster().getUser().getName(), entry.getUser().getID());
                    }
                };
                action.setText(Messages.URLShareRosterEntryContributionItem_SEND_URL_MENU_TEXT);
                action.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, Messages.URLShareRosterContributionItem_BROWSER_ICON));
                return new IAction[] { action };
            }
        }
    }
    return null;
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) IContainer(org.eclipse.ecf.core.IContainer)

Example 12 with IRosterEntry

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

the class ViewShareRosterEntryContributionItem 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 ViewShare tmp = ViewShare.getViewShare(c.getID());
            // If there is an URL share associated with this container
            if (tmp != null) {
                final ViewShare viewshare = tmp;
                final IAction action = new Action() {

                    public void run() {
                        viewshare.sendOpenViewRequest(entry.getRoster().getUser().getName(), entry.getUser().getID());
                    }
                };
                action.setText(Messages.ViewShareRosterEntryContributionItem_VIEWSHARE_MENU_TEXT);
                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) IAction(org.eclipse.jface.action.IAction) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) IContainer(org.eclipse.ecf.core.IContainer)

Example 13 with IRosterEntry

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

the class ConsoleShareRosterEntryContributionItem method makeActions.

protected IAction[] makeActions() {
    final TextSelection selection = ConsoleShare.getSelection();
    if (selection == null)
        return null;
    // 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 ConsoleShare tmp = ConsoleShare.getStackShare(c.getID());
            // If there is an URL share associated with this container
            if (tmp != null) {
                final ConsoleShare stackshare = tmp;
                final IAction action = new Action() {

                    public void run() {
                        stackshare.sendShareConsoleSelection(entry.getRoster().getUser().getName(), entry.getUser().getID(), selection.getText());
                    }
                };
                action.setText(Messages.ConsoleShare_RosterEntryMenu);
                action.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, Messages.ConsoleShare_RosterContributionItem_CONSOLE_ICON));
                return new IAction[] { action };
            }
        }
    }
    return null;
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) TextSelection(org.eclipse.jface.text.TextSelection) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) IContainer(org.eclipse.ecf.core.IContainer)

Example 14 with IRosterEntry

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

the class XMPPCompoundContributionItem method getContributionItems.

protected IContributionItem[] getContributionItems() {
    final Object selection = getSelection();
    if (!(selection instanceof IRosterEntry)) {
        return EMPTY_ARRAY;
    }
    final IRosterEntry entry = (IRosterEntry) selection;
    final IContainer container = getContainerForRosterEntry(entry);
    if (container instanceof XMPPContainer) {
        final IContributionItem[] contributions = new IContributionItem[1];
        final ISendFileTransferContainerAdapter ioftca = (ISendFileTransferContainerAdapter) container.getAdapter(ISendFileTransferContainerAdapter.class);
        if (!(ioftca != null && isAvailable(entry)))
            return EMPTY_ARRAY;
        final IAction fileSendAction = new Action() {

            public void run() {
                sendFileToTarget(ioftca, entry.getUser().getID());
            }
        };
        fileSendAction.setText(Messages.XMPPCompoundContributionItem_SEND_FILE);
        fileSendAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE));
        contributions[0] = new ActionContributionItem(fileSendAction);
        return contributions;
    } else {
        return EMPTY_ARRAY;
    }
}
Also used : ISendFileTransferContainerAdapter(org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) IAction(org.eclipse.jface.action.IAction) IContributionItem(org.eclipse.jface.action.IContributionItem) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) XMPPContainer(org.eclipse.ecf.provider.xmpp.XMPPContainer) IContainer(org.eclipse.ecf.core.IContainer)

Example 15 with IRosterEntry

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

the class XMPPContainerPresenceHelper method createRosterEntry.

protected IRosterEntry createRosterEntry(ID userID, String name, Iterator grps) {
    final List groups = new ArrayList();
    for (; grps.hasNext(); ) {
        final Object o = grps.next();
        final String groupName = (o instanceof String) ? (String) o : ((RosterGroup) o).getName();
        final IRosterGroup localGrp = new org.eclipse.ecf.presence.roster.RosterGroup(roster, groupName);
        groups.add(localGrp);
    }
    final IUser user = new User(userID, name);
    IRosterEntry newEntry = null;
    if (groups.size() == 0)
        return new org.eclipse.ecf.presence.roster.RosterEntry(roster, user, new org.eclipse.ecf.presence.Presence(IPresence.Type.UNAVAILABLE, IPresence.Type.UNAVAILABLE.toString(), IPresence.Mode.AWAY));
    else
        for (int i = 0; i < groups.size(); i++) {
            final IRosterGroup grp = (IRosterGroup) groups.get(i);
            if (i == 0)
                newEntry = new org.eclipse.ecf.presence.roster.RosterEntry(grp, user, null);
            else {
                grp.getEntries().add(newEntry);
                newEntry.getGroups().add(grp);
            }
        }
    return newEntry;
}
Also used : User(org.eclipse.ecf.core.user.User) IUser(org.eclipse.ecf.core.user.IUser) ArrayList(java.util.ArrayList) IRosterGroup(org.eclipse.ecf.presence.roster.IRosterGroup) RosterGroup(org.eclipse.ecf.presence.roster.RosterGroup) IRosterGroup(org.eclipse.ecf.presence.roster.IRosterGroup) IUser(org.eclipse.ecf.core.user.IUser) IPresence(org.eclipse.ecf.presence.IPresence) Presence(org.jivesoftware.smack.packet.Presence) List(java.util.List) ArrayList(java.util.ArrayList) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry)

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