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;
}
}
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 };
}
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);
}
}
}
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);
}
}
}
}
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();
}
}
Aggregations