use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class XMPPHyperlink method openContainer.
/**
* @param presenceContainerAdapter
*/
private void openContainer(IContainer container) {
final IPresenceContainerAdapter presenceContainerAdapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
final IChatManager chatManager = presenceContainerAdapter.getChatManager();
final IRosterManager rosterManager = presenceContainerAdapter.getRosterManager();
if (chatManager != null && rosterManager != null) {
try {
// get local ID
final XMPPID localID = (XMPPID) rosterManager.getRoster().getUser().getID();
final Namespace ns = container.getConnectNamespace();
// create target ID
final XMPPID targetID = (isXMPPS) ? new XMPPSID(ns, getURI().getAuthority()) : new XMPPID(ns, getURI().getAuthority());
// If they are same, just tell user and return
if (localID.equals(targetID)) {
MessageDialog.openError(null, Messages.XMPPHyperlink_MESSAGING_ERROR_TITLE, Messages.XMPPHyperlink_MESSAGING_ERROR_MESSAGE);
return;
} else {
final String localHost = localID.getHostname();
final String targetHost = targetID.getHostname();
// it's pretty obvious that we wish to message to them
if (localHost.equals(targetHost)) {
openMessagesView(chatManager, localID, targetID, targetID.getUsername());
} else {
// Otherwise, ask the user whether messaging, or
// connecting is desired
final MessageDialog messageDialog = new MessageDialog(null, Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_TITLE, null, NLS.bind(Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_MESSAGE, new Object[] { targetHost, localHost, targetID.getName(), localID.getName() }), MessageDialog.QUESTION, new String[] { Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_BUTTON_SEND_MESSAGE, Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_BUTTON_CONNECT, Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_BUTTON_CANCEL }, 2);
final int selected = messageDialog.open();
switch(selected) {
case 0:
openMessagesView(chatManager, localID, targetID, targetID.getUsername());
return;
case 1:
super.open();
return;
default:
return;
}
}
}
} catch (final Exception e) {
MessageDialog.openError(null, Messages.XMPPHyperlink_ERROR_OPEN_MESSAGE_VIEW_DIALOG_TITLE, NLS.bind(Messages.XMPPHyperlink_ERROR_OPEN_MESSAGE_VIEW_DIALOG_MESSAGE, e.getLocalizedMessage()));
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.XMPPHyperlink_ERROR_OPEN_MESSAGE_VIEW_LOG_STATUS_MESSAGE, e));
}
}
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class DiscoveryTestsWithoutRegister method testGetServicesNamespace.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IdiscoveryLocatorAdapter#getServicesNamespace()}.
*/
public void testGetServicesNamespace() {
testConnect();
final Namespace namespace = discoveryLocator.getServicesNamespace();
assertNotNull(namespace);
final IServiceTypeID serviceTypeID = ServiceIDFactory.getDefault().createServiceTypeID(namespace, serviceInfo.getServiceID().getServiceTypeID());
assertNotNull("It must be possible to obtain a IServiceTypeID", serviceTypeID);
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class LongIDTest method testEqualNamespaces.
public void testEqualNamespaces() throws Exception {
final ID id1 = createID();
final ID id2 = createID();
final Namespace ns1 = id1.getNamespace();
final Namespace ns2 = id2.getNamespace();
assertTrue(ns1.equals(ns2));
assertTrue(ns2.equals(ns2));
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class NamespaceTest method testNewNamespaceGetSupportedParameterTypesForCreateInstance.
public void testNewNamespaceGetSupportedParameterTypesForCreateInstance() {
Namespace ns = createNamespace();
Class[][] result = ns.getSupportedParameterTypes();
assertTrue(result.length == 1);
assertTrue(result[0][0].equals(String.class));
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class NamespaceTest method testNewNamespaceGetDescription.
public void testNewNamespaceGetDescription() {
Namespace ns = createNamespace();
String desc = ns.getDescription();
assertTrue(desc.equals(DESCRIPTION));
}
Aggregations