Search in sources :

Example 16 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class PHPBBParser method parseRequestedMessage.

public ThreadMessage parseRequestedMessage(final ThreadMessageID id, final CharSequence seq) throws BBException {
    final ThreadMessageFactory tmf = new ThreadMessageFactory();
    // lastRead = -1 the one we want
    ThreadMessageID lastReadId = null;
    try {
        lastReadId = (ThreadMessageID) tmf.createBBObjectId(namespace, baseURL, String.valueOf(id.getLongValue() - 1));
    } catch (final IDCreateException e) {
        e.printStackTrace();
    }
    final List<ThreadMessage> msgs = parseMessages2(seq, lastReadId, true);
    if (msgs.size() > 0) {
        return msgs.get(0);
    }
    return null;
}
Also used : ThreadMessageID(org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException)

Example 17 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class PHPBBParser method parseMemberGroup.

public MemberGroup parseMemberGroup(CharSequence seq) {
    final Matcher m = PAT_GROUP.matcher(seq);
    if (m.find()) {
        final MemberGroupFactory mgf = new MemberGroupFactory();
        final String idStr = m.group(1);
        final String name = StringUtil.stripHTMLTrim(m.group(2));
        final String desc = StringUtil.stripHTMLTrim(m.group(3));
        ID id = null;
        try {
            id = mgf.createBBObjectId(namespace, baseURL, idStr);
        } catch (final IDCreateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        final MemberGroup grp = (MemberGroup) mgf.createBBObject(id, name, null);
        grp.setDescription(desc);
        return grp;
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ID(org.eclipse.ecf.core.identity.ID) ThreadMessageID(org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID)

Example 18 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class SendContextContributionItem method createRosterEntryHandler.

protected AbstractRosterMenuHandler createRosterEntryHandler(final IRosterEntry rosterEntry) {
    return new AbstractRosterMenuHandler(rosterEntry) {

        public Object execute(ExecutionEvent event) throws ExecutionException {
            IWorkbenchPart part = HandlerUtil.getActivePart(event);
            if (part == null) {
                return null;
            }
            IWorkbenchSite site = part.getSite();
            if (site == null) {
                return null;
            }
            ISelectionProvider provider = site.getSelectionProvider();
            if (provider == null) {
                return null;
            }
            ISelection selection = provider.getSelection();
            if (selection instanceof IStructuredSelection) {
                IChannelContainerAdapter icca = (IChannelContainerAdapter) rosterEntry.getRoster().getPresenceContainerAdapter().getAdapter(IChannelContainerAdapter.class);
                ID channelID;
                try {
                    channelID = icca.getChannelNamespace().createInstance(new Object[] { Activator.PLUGIN_ID });
                } catch (IDCreateException e1) {
                    return null;
                }
                final IChannel channel = icca.getChannel(channelID);
                if (channel == null) {
                    return null;
                }
                Object element = ((IStructuredSelection) selection).getFirstElement();
                if (element instanceof ITask) {
                    final ITask task = (ITask) element;
                    Job job = new Job("Send Task") {

                        protected IStatus run(IProgressMonitor monitor) {
                            monitor.beginTask("Sending task...", 5);
                            ByteArrayOutputStream stream = new ByteArrayOutputStream();
                            TasksUiPlugin.getTaskListManager().getTaskListWriter().writeTask((AbstractTask) task, stream);
                            monitor.worked(2);
                            try {
                                channel.sendMessage(getRosterEntry().getUser().getID(), stream.toByteArray());
                                monitor.worked(3);
                            } catch (Exception e) {
                                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "An error occurred while sending the task.", e);
                            } finally {
                                monitor.done();
                            }
                            return Status.OK_STATUS;
                        }
                    };
                    job.schedule();
                }
            }
            return null;
        }
    };
}
Also used : IWorkbenchSite(org.eclipse.ui.IWorkbenchSite) ITask(org.eclipse.mylyn.tasks.core.ITask) IChannel(org.eclipse.ecf.datashare.IChannel) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ExecutionException(org.eclipse.core.commands.ExecutionException) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) AbstractRosterMenuHandler(org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuHandler) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) ID(org.eclipse.ecf.core.identity.ID) Job(org.eclipse.core.runtime.jobs.Job)

Example 19 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class GenericParser method parseIdNamePairs.

private Object parseIdNamePairs(IPatternDescriptor pattern, CharSequence sequence, IBBObjectFactory factory, boolean expectMultipleMatches, boolean preserveOrder) {
    final Matcher m = pattern.getPattern().matcher(sequence);
    Map<ID, IBBObject> objectMap = null;
    if (expectMultipleMatches) {
        if (preserveOrder) {
            objectMap = new LinkedHashMap<ID, IBBObject>();
        } else {
            objectMap = new HashMap<ID, IBBObject>();
        }
    }
    while (m.find()) {
        final Map<String, Object> values = pattern.getValueMap(m);
        ID id = null;
        try {
            id = factory.createBBObjectId(namespace, baseURL, (String) values.get(IPatternDescriptor.ID_PARAM));
        } catch (final IDCreateException e) {
            // TODO autogen e
            e.printStackTrace();
        }
        final String name = StringUtil.stripHTMLTrim((String) values.get(IPatternDescriptor.NAME_PARAM));
        final IBBObject obj = factory.createBBObject(id, new String(name), values);
        if (expectMultipleMatches) {
            objectMap.put(id, obj);
        } else {
            return obj;
        }
    }
    if (expectMultipleMatches) {
        return objectMap;
    } else {
        return null;
    }
}
Also used : Matcher(java.util.regex.Matcher) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) ID(org.eclipse.ecf.core.identity.ID)

Example 20 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class MSNConnectWizard method performFinish.

public boolean performFinish() {
    final String connectID = page.getEmail();
    final String password = page.getPassword();
    // Save combo text even if we don't successfully login
    page.saveComboText();
    connectContext = ConnectContextFactory.createPasswordConnectContext(password);
    try {
        targetID = container.getConnectNamespace().createInstance(new Object[] { connectID });
    } catch (final IDCreateException e) {
        new IDCreateErrorDialog(null, connectID, e).open();
        return false;
    }
    page.saveComboItems();
    final IPresenceContainerAdapter adapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
    container.addListener(new IContainerListener() {

        public void handleEvent(IContainerEvent event) {
            if (event instanceof IContainerConnectedEvent) {
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        openView();
                    }
                });
            }
        }
    });
    final IChatManager icm = adapter.getChatManager();
    icms = icm.getChatMessageSender();
    itms = icm.getTypingMessageSender();
    icm.addMessageListener(new IIMMessageListener() {

        public void handleMessageEvent(IIMMessageEvent e) {
            if (e instanceof IChatMessageEvent) {
                displayMessage((IChatMessageEvent) e);
            } else if (e instanceof ITypingMessageEvent) {
                displayTypingNotification((ITypingMessageEvent) e);
            }
        }
    });
    new AsynchContainerConnectAction(container, targetID, connectContext, null, new Runnable() {

        public void run() {
            cachePassword(connectID, password);
        }
    }).run();
    return true;
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) IContainerListener(org.eclipse.ecf.core.IContainerListener) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent) IDCreateErrorDialog(org.eclipse.ecf.ui.dialogs.IDCreateErrorDialog) IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) ITypingMessageEvent(org.eclipse.ecf.presence.im.ITypingMessageEvent) AsynchContainerConnectAction(org.eclipse.ecf.ui.actions.AsynchContainerConnectAction) IChatManager(org.eclipse.ecf.presence.im.IChatManager)

Aggregations

IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)34 ID (org.eclipse.ecf.core.identity.ID)16 Matcher (java.util.regex.Matcher)11 Namespace (org.eclipse.ecf.core.identity.Namespace)8 ThreadMessageID (org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID)5 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)4 ExecutionException (org.eclipse.core.commands.ExecutionException)4 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)4 UnknownHostException (java.net.UnknownHostException)3 ContainerConnectedEvent (org.eclipse.ecf.core.events.ContainerConnectedEvent)3 ContainerConnectingEvent (org.eclipse.ecf.core.events.ContainerConnectingEvent)3 ThreadMessageFactory (org.eclipse.ecf.internal.provider.vbulletin.internal.ThreadMessageFactory)3 URI (java.net.URI)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 NameValuePair (org.apache.commons.httpclient.NameValuePair)2 Job (org.eclipse.core.runtime.jobs.Job)2 IBBObject (org.eclipse.ecf.bulletinboard.IBBObject)2 IThreadMessage (org.eclipse.ecf.bulletinboard.IThreadMessage)2