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