Search in sources :

Example 1 with XMPPContainer

use of org.eclipse.ecf.provider.xmpp.XMPPContainer in project ecf by eclipse.

the class XMPPHyperlink method getContainers.

protected IContainer[] getContainers() {
    final IContainerManager manager = Activator.getDefault().getContainerManager();
    if (manager == null)
        return EMPTY;
    final List results = new ArrayList();
    final IContainer[] containers = manager.getAllContainers();
    for (int i = 0; i < containers.length; i++) {
        final ID connectedID = containers[i].getConnectedID();
        // Must be connected and ID of correct type
        if (connectedID != null && ((isXMPPS && containers[i] instanceof XMPPSContainer) || (!isXMPPS && containers[i] instanceof XMPPContainer)))
            results.add(containers[i]);
    }
    return (IContainer[]) results.toArray(EMPTY);
}
Also used : XMPPSContainer(org.eclipse.ecf.provider.xmpp.XMPPSContainer) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID) ID(org.eclipse.ecf.core.identity.ID) XMPPSID(org.eclipse.ecf.provider.xmpp.identity.XMPPSID) XMPPContainer(org.eclipse.ecf.provider.xmpp.XMPPContainer)

Example 2 with XMPPContainer

use of org.eclipse.ecf.provider.xmpp.XMPPContainer in project ecf by eclipse.

the class XMPPContainerInstantiator method createInstance.

/*
	 * (non-Javadoc)
	 * 
	 * @seeorg.eclipse.ecf.core.provider.IContainerInstantiator#createInstance(
	 * ContainerDescription, java.lang.Object[])
	 */
public IContainer createInstance(ContainerTypeDescription description, Object[] args) throws ContainerCreateException {
    try {
        Integer ka = new Integer(XMPPContainer.DEFAULT_KEEPALIVE);
        String name = null;
        if (args != null) {
            if (args.length > 0) {
                name = (String) args[0];
                if (args.length > 1) {
                    ka = getIntegerFromArg(args[1]);
                }
            }
        }
        if (name == null) {
            if (ka == null) {
                return new XMPPContainer();
            } else {
                return new XMPPContainer(ka.intValue());
            }
        } else {
            if (ka == null) {
                ka = new Integer(XMPPContainer.DEFAULT_KEEPALIVE);
            }
            return new XMPPContainer(name, ka.intValue());
        }
    } catch (Exception e) {
        throw new ContainerCreateException("Exception creating generic container", e);
    }
}
Also used : ContainerCreateException(org.eclipse.ecf.core.ContainerCreateException) XMPPContainer(org.eclipse.ecf.provider.xmpp.XMPPContainer) ContainerCreateException(org.eclipse.ecf.core.ContainerCreateException)

Example 3 with XMPPContainer

use of org.eclipse.ecf.provider.xmpp.XMPPContainer 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)

Aggregations

XMPPContainer (org.eclipse.ecf.provider.xmpp.XMPPContainer)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ContainerCreateException (org.eclipse.ecf.core.ContainerCreateException)1 IContainer (org.eclipse.ecf.core.IContainer)1 ID (org.eclipse.ecf.core.identity.ID)1 ISendFileTransferContainerAdapter (org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter)1 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)1 XMPPSContainer (org.eclipse.ecf.provider.xmpp.XMPPSContainer)1 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)1 XMPPSID (org.eclipse.ecf.provider.xmpp.identity.XMPPSID)1 Action (org.eclipse.jface.action.Action)1 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 IAction (org.eclipse.jface.action.IAction)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1