Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2005-06-18 06:03:03 +0000
committerslewis2005-06-18 06:03:03 +0000
commita6f86f4ab4c67c5acfc8047c52900d96ad566026 (patch)
tree8163fa4999c2aa54d7de30063a7dd56ad24b413f
parent4031bc73126cd3f5139ab182c98d184ee28cfe5d (diff)
downloadorg.eclipse.ecf-a6f86f4ab4c67c5acfc8047c52900d96ad566026.tar.gz
org.eclipse.ecf-a6f86f4ab4c67c5acfc8047c52900d96ad566026.tar.xz
org.eclipse.ecf-a6f86f4ab4c67c5acfc8047c52900d96ad566026.zip
Added ability to connect to discovered service
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/DiscoveryStartup.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/DiscoveryStartup.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/DiscoveryStartup.java
index a35729c9d..c675a654f 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/DiscoveryStartup.java
+++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/DiscoveryStartup.java
@@ -2,13 +2,16 @@ package org.eclipse.ecf.example.collab;
import java.net.InetAddress;
import java.net.URI;
+import java.util.Map;
import java.util.Properties;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.ISharedObjectContainer;
import org.eclipse.ecf.core.SharedObjectContainerFactory;
import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.ServiceID;
import org.eclipse.ecf.discovery.IDiscoveryContainer;
import org.eclipse.ecf.discovery.IServiceEvent;
@@ -16,6 +19,7 @@ import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.IServiceListener;
import org.eclipse.ecf.discovery.IServiceTypeListener;
import org.eclipse.ecf.discovery.ServiceInfo;
+import org.eclipse.ecf.example.collab.actions.ClientConnectAction;
import org.eclipse.ecf.ui.views.DiscoveryView;
import org.eclipse.ecf.ui.views.IServiceConnectListener;
import org.eclipse.swt.widgets.Display;
@@ -85,8 +89,28 @@ public class DiscoveryStartup {
}
protected void connectToServiceFromInfo(IServiceInfo svcInfo) {
- // XXX TODO
- System.out.println("connectToService("+svcInfo+"");
+ ClientConnectAction action = new ClientConnectAction();
+ Map props = svcInfo.getProperties();
+ String type = (String) props.get(PROP_CONTAINER_TYPE_NAME);
+ if (type == null || type.equals("")) {
+ action.setContainerType(Client.GENERIC_CONTAINER_CLIENT_NAME);
+ } else {
+ action.setContainerType(type);
+ }
+ String username = System.getProperty("user.name");
+ action.setUsername(username);
+ ID targetID = null;
+ String targetString = null;
+ try {
+ targetString = svcInfo.getServiceURI().toString();
+ targetID = IDFactory.makeStringID(targetString);
+ } catch (Exception e) {
+ ClientPlugin.log("cannot create target id for "+targetString,e);
+ }
+ action.setTargetID(targetID);
+ action.setProject(ResourcesPlugin.getWorkspace().getRoot());
+ // do it
+ action.run(null);
}
protected void setupDiscoveryContainer(final IDiscoveryContainer dc) {

Back to the top