Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsuen2007-04-17 03:52:56 +0000
committerrsuen2007-04-17 03:52:56 +0000
commitfe81638fc0da7f52b74e3d6b0c3b72505d03250b (patch)
treeca4d21741b11eacd3e6c9ae84d76709a48b7ac58
parentd770397a43cc333da3402c1655b2ac5b6357f39f (diff)
downloadorg.eclipse.ecf-fe81638fc0da7f52b74e3d6b0c3b72505d03250b.tar.gz
org.eclipse.ecf-fe81638fc0da7f52b74e3d6b0c3b72505d03250b.tar.xz
org.eclipse.ecf-fe81638fc0da7f52b74e3d6b0c3b72505d03250b.zip
Track IPresenceServices and add them to the MultiRosterView upon creation if applicable.
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Activator.java21
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java15
2 files changed, 36 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Activator.java b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Activator.java
index e5ec08406..e3c267a7b 100644
--- a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Activator.java
+++ b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/internal/presence/ui/Activator.java
@@ -10,8 +10,11 @@
*****************************************************************************/
package org.eclipse.ecf.internal.presence.ui;
+import org.eclipse.ecf.presence.service.IPresenceService;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
/**
* The activator class controls the plug-in life cycle
@@ -24,12 +27,27 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
+ private ServiceTracker tracker;
+
/**
* The constructor
*/
public Activator() {
}
+ public IPresenceService[] getPresenceServices() {
+ ServiceReference[] references = tracker.getServiceReferences();
+ if (references == null) {
+ return new IPresenceService[0];
+ }
+ int length = references.length;
+ IPresenceService[] services = new IPresenceService[length];
+ for (int i = 0; i < length; i++) {
+ services[i] = (IPresenceService) tracker.getService(references[i]);
+ }
+ return services;
+ }
+
/*
* (non-Javadoc)
*
@@ -38,6 +56,9 @@ public class Activator extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ tracker = new ServiceTracker(context, IPresenceService.class.getName(),
+ null);
+ tracker.open();
}
/*
diff --git a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java
index a872c43b9..0de8e8501 100644
--- a/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java
+++ b/framework/bundles/org.eclipse.ecf.presence.ui/src/org/eclipse/ecf/presence/ui/MultiRosterView.java
@@ -56,6 +56,7 @@ import org.eclipse.ecf.presence.roster.IRosterGroup;
import org.eclipse.ecf.presence.roster.IRosterManager;
import org.eclipse.ecf.presence.roster.IRosterSubscriptionListener;
import org.eclipse.ecf.presence.roster.IRosterSubscriptionSender;
+import org.eclipse.ecf.presence.service.IPresenceService;
import org.eclipse.ecf.ui.SharedImages;
import org.eclipse.ecf.ui.dialogs.ChatRoomSelectionDialog;
import org.eclipse.ecf.ui.views.ChatRoomView;
@@ -227,6 +228,20 @@ public class MultiRosterView extends ViewPart implements
makeActions();
hookContextMenu();
contributeToActionBars();
+ retrieveServices();
+ treeViewer.expandToLevel(DEFAULT_EXPAND_LEVEL);
+ }
+
+ private void retrieveServices() {
+ IPresenceService[] services = Activator.getDefault()
+ .getPresenceServices();
+ for (int i = 0; i < services.length; i++) {
+ IContainer container = (IContainer) services[i]
+ .getAdapter(IContainer.class);
+ if (container != null) {
+ addContainer(container);
+ }
+ }
}
private String getChatRoomSecondaryID(ID roomID) {

Back to the top