Search in sources :

Example 11 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class IMBot method connect.

public synchronized void connect() throws ECFException {
    fireInitBot();
    try {
        Namespace namespace = null;
        if (container == null) {
            container = ContainerFactory.getDefault().createContainer(bot.getContainerFactoryName());
            namespace = container.getConnectNamespace();
        } else
            throw new ContainerConnectException("Already connected");
        targetID = IDFactory.getDefault().createID(namespace, bot.getConnectID());
        firePreConnect();
        IPresenceContainerAdapter presenceAdapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
        presenceAdapter.getChatManager().addMessageListener(this);
        String password = bot.getPassword();
        IConnectContext context = (password == null) ? null : ConnectContextFactory.createPasswordConnectContext(password);
        container.connect(targetID, context);
    } catch (ECFException e) {
        if (container != null) {
            if (container.getConnectedID() != null) {
                container.disconnect();
            }
            container.dispose();
        }
        container = null;
        throw e;
    }
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ECFException(org.eclipse.ecf.core.util.ECFException) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 12 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class ViewShareRosterContributionItem method createActionAdd.

private IAction[] createActionAdd(final ID containerID, final IChannelContainerAdapter channelAdapter) {
    final IAction action = new Action() {

        public void run() {
            try {
                ViewShare.addViewShare(containerID, channelAdapter);
            } catch (ECFException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    };
    action.setText(Messages.ViewShareRosterContributionItem_VIEWSHARE_LISTENER_MENU_ADD_TEXT);
    action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW));
    return new IAction[] { action };
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) ECFException(org.eclipse.ecf.core.util.ECFException)

Example 13 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class XMPPChatClient method setupPresence.

public void setupPresence() throws ECFException {
    if (presence == null) {
        presence = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
        if (presence == null)
            throw new ECFException("adapter is null");
        sender = presence.getChatManager().getChatMessageSender();
        presence.getChatManager().addMessageListener(new IIMMessageListener() {

            public void handleMessageEvent(IIMMessageEvent messageEvent) {
                if (messageEvent instanceof IChatMessageEvent) {
                    IChatMessage m = ((IChatMessageEvent) messageEvent).getChatMessage();
                    if (receiver != null) {
                        receiver.handleMessage(m);
                    }
                }
            }
        });
        if (presenceListener != null) {
            presence.getRosterManager().addPresenceListener(presenceListener);
        }
    }
}
Also used : IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) ECFException(org.eclipse.ecf.core.util.ECFException) IChatMessage(org.eclipse.ecf.presence.im.IChatMessage) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent)

Example 14 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class SyncResourcesUI method startSharing.

private void startSharing(ITextEditor editor, IFile file) {
    String projectName = file.getProject().getName();
    for (Iterator it = SyncResourcesCore.getResourceShares().iterator(); it.hasNext(); ) {
        ResourcesShare share = (ResourcesShare) it.next();
        if (share.isSharing(projectName) && share(file)) {
            DocShare docShare = getDocShare(share.getContainerID());
            try {
                IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
                docShare.startSharing(share.getLocalID(), share.getReceiverID(), file.getFullPath().toString(), annotationModel);
                ISelectionProvider provider = editor.getSelectionProvider();
                if (provider instanceof IPostSelectionProvider) {
                    ISelectionChangedListener listener = new SelectionChangedListener(share.getReceiverID(), file.getFullPath().toString(), docShare);
                    ((IPostSelectionProvider) provider).addPostSelectionChangedListener(listener);
                    sharedEditors.put(editor, listener);
                }
            } catch (ECFException e) {
                IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, // $NON-NLS-1$
                "Could not send initiation request to " + share.getReceiverID(), e);
                log(status);
                StatusManager.getManager().handle(status, StatusManager.SHOW);
            } catch (CoreException e) {
                IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, // $NON-NLS-1$
                "Could not connect to the file buffer of " + file.getFullPath(), e);
                log(status);
                StatusManager.getManager().handle(status, StatusManager.SHOW);
            }
        }
    }
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) DocShare(org.eclipse.ecf.docshare2.DocShare) IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ECFException(org.eclipse.ecf.core.util.ECFException) CoreException(org.eclipse.core.runtime.CoreException) Iterator(java.util.Iterator) ResourcesShare(org.eclipse.ecf.internal.sync.resources.core.ResourcesShare)

Example 15 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class ResourcesShare method sendResourceChangeMessage.

void sendResourceChangeMessage(IResource resource, int kind) {
    try {
        IModelChange change = ResourceChangeMessage.createResourceChange(resource, kind);
        IModelChangeMessage[] messages = ResourcesSynchronizationStrategy.getInstance().registerLocalChange(change);
        for (int i = 0; i < messages.length; i++) {
            send(messages[i].serialize());
        }
    } catch (ECFException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) IModelChange(org.eclipse.ecf.sync.IModelChange) IModelChangeMessage(org.eclipse.ecf.sync.IModelChangeMessage)

Aggregations

ECFException (org.eclipse.ecf.core.util.ECFException)42 IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)9 Iterator (java.util.Iterator)5 IStatus (org.eclipse.core.runtime.IStatus)5 ID (org.eclipse.ecf.core.identity.ID)5 Status (org.eclipse.core.runtime.Status)4 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)4 IOException (java.io.IOException)3 IContainer (org.eclipse.ecf.core.IContainer)3 Action (org.eclipse.jface.action.Action)3 IAction (org.eclipse.jface.action.IAction)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 List (java.util.List)2 TimeoutException (java.util.concurrent.TimeoutException)2 Namespace (org.eclipse.ecf.core.identity.Namespace)2 IConnectContext (org.eclipse.ecf.core.security.IConnectContext)2 IUser (org.eclipse.ecf.core.user.IUser)2 IChatRoomInfo (org.eclipse.ecf.presence.chatroom.IChatRoomInfo)2 IEcho (org.eclipse.ecf.tests.remoteservice.rpc.common.IEcho)2