Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2005-03-31 12:40:30 +0000
committerslewis2005-03-31 12:40:30 +0000
commit6e278ceff4d875ffb1c5bdb41a577a866cf0e077 (patch)
tree4dbb4c168f6d4e7ba7bc3629fa735e2294c1cae0
parentf7858d16a8de8e4241feded763171559f9c047fa (diff)
downloadorg.eclipse.ecf-6e278ceff4d875ffb1c5bdb41a577a866cf0e077.tar.gz
org.eclipse.ecf-6e278ceff4d875ffb1c5bdb41a577a866cf0e077.tar.xz
org.eclipse.ecf-6e278ceff4d875ffb1c5bdb41a577a866cf0e077.zip
Added suppport for groups in the roster view. Also cleaned up IPresenceContainer config in Client.java
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java13
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/IConfigViewer.java22
-rw-r--r--framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java85
3 files changed, 68 insertions, 52 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java
index 66833e6de..3e4f32199 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java
+++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java
@@ -21,7 +21,9 @@ import java.util.Vector;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.ISharedObjectContainer;
import org.eclipse.ecf.core.ISharedObjectContainerListener;
import org.eclipse.ecf.core.SharedObjectContainerFactory;
@@ -288,7 +290,7 @@ public class Client {
// Check for IPresenceContainer....if it is, setup
IPresenceContainer pc = (IPresenceContainer) client.getAdapter(IPresenceContainer.class);
- if (pc != null) setupPresenceContainer(pc,groupID,username);
+ if (pc != null) setupPresenceContainer(client,pc,groupID,username);
try {
client.joinGroup(groupID, data);
@@ -308,7 +310,7 @@ public class Client {
protected RosterView rosterView = null;
protected IMessageSender messageSender = null;
- protected void setupPresenceContainer(IPresenceContainer pc, final ID localUser, final String nick) {
+ protected void setupPresenceContainer(final ISharedObjectContainer container, IPresenceContainer pc, final ID localUser, final String nick) {
messageSender = pc.getMessageSender();
@@ -338,13 +340,13 @@ public class Client {
}
public void disconnect() {
- System.out.println("disconnect()");
+ container.leaveGroup();
}
});
} catch (Exception e) {
- System.err.println("Exception showing view");
- e.printStackTrace(System.err);
+ IStatus status = new Status(IStatus.ERROR,ClientPlugin.PLUGIN_ID,IStatus.OK,"Excetion showing presence view",e);
+ ClientPlugin.getDefault().getLog().log(status);
}
}
});
@@ -391,6 +393,7 @@ public class Client {
}
});
messageSender = null;
+ rosterView = null;
}
});
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/IConfigViewer.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/IConfigViewer.java
deleted file mode 100644
index 58f5b9930..000000000
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/IConfigViewer.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/****************************************************************************
-* Copyright (c) 2004 Composent, Inc. and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* Composent, Inc. - initial API and implementation
-*****************************************************************************/
-
-package org.eclipse.ecf.ui.views;
-
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.user.IUser;
-
-public interface IConfigViewer {
-
- public void setLocalUser(IUser user, ITextInputHandler inputHandler);
- public void setGroup(ID groupManager);
- public void memberDeparted(ID member);
-}
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java
index 396270650..73ebb28ac 100644
--- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java
+++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java
@@ -62,8 +62,7 @@ import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
-public class RosterView extends ViewPart implements IConfigViewer,
- IPresenceListener, IMessageListener {
+public class RosterView extends ViewPart implements IPresenceListener, IMessageListener {
public static final String DISCONNECT_ICON_DISABLED = "icons/disabled/terminate_co.gif";
public static final String DISCONNECT_ICON_ENABLED = "icons/enabled/terminate_co.gif";
@@ -253,8 +252,8 @@ public class RosterView extends ViewPart implements IConfigViewer,
return fillPresence(obj, entry.getPresenceState());
}
- public void addEntry(TreeParent parent, IRosterEntry entry) {
- TreeObject[] objs = parent.getChildren();
+ public void addGroupEntry(TreeParent group, String groupName, IRosterEntry entry) {
+ TreeObject[] objs = group.getChildren();
TreeParent found = null;
if (objs != null) {
for (int i = 0; i < objs.length; i++) {
@@ -264,6 +263,46 @@ public class RosterView extends ViewPart implements IConfigViewer,
}
}
}
+
+ if (found == null) {
+ found = new TreeParent(entry.getUserID().getName(), entry
+ .getUserID());
+ found = fillWithEntry(found, entry);
+ group.addChild(found);
+ } else {
+ group.removeChild(found);
+ group.addChild(found);
+ }
+ }
+
+ public TreeParent findGroup(TreeParent parent, IRosterEntry entry) {
+ TreeObject [] objs = parent.getChildren();
+ Iterator groups = entry.getGroups();
+ for( ; groups.hasNext(); ) {
+ IRosterGroup grp = (IRosterGroup) groups.next();
+ String groupName = grp.getName();
+ if (objs != null) {
+ for(int i = 0; i < objs.length; i++) {
+ if (objs[i].getName().equals(groupName)) {
+ return (TreeParent) objs[i];
+ }
+ }
+ }
+ }
+ return null;
+ }
+ public void findAndReplaceEntry(TreeParent parent, IRosterEntry entry) {
+ TreeObject [] objs = parent.getChildren();
+ TreeParent found = null;
+ if (objs != null) {
+ for (int i = 0; i < objs.length; i++) {
+ if (objs[i].getName().equals(entry.getUserID().getName())) {
+ // Found it...replace values with new
+ found = fillWithEntry((TreeParent) objs[i], entry);
+ }
+ }
+
+ }
if (found == null) {
found = new TreeParent(entry.getUserID().getName(), entry
.getUserID());
@@ -274,31 +313,29 @@ public class RosterView extends ViewPart implements IConfigViewer,
parent.addChild(found);
}
}
-
- public TreeParent addEntriesToGroup(TreeParent grp, IRosterGroup group) {
- Iterator i = group.getRosterEntries();
- for (; i.hasNext();) {
- IRosterEntry entry = (IRosterEntry) i.next();
- if (entry != null) {
- addEntry(grp, entry);
+ public void addEntry(TreeParent parent, IRosterEntry entry) {
+ TreeParent group = findGroup(parent,entry);
+ if (group != null) {
+ findAndReplaceEntry(group,entry);
+ } else {
+ // Existing group not found, so see if entry has a group associated with it
+ Iterator groups = entry.getGroups();
+ if (groups.hasNext()) {
+ // There's a group associated with entry...so add with group name
+ String groupName = ((IRosterGroup) groups.next()).getName();
+ TreeParent newgrp = new TreeParent(groupName);
+ findAndReplaceEntry(newgrp,entry);
+ parent.addChild(newgrp);
+ } else {
+ // No group for entry...just add to parent
+ findAndReplaceEntry(parent,entry);
}
}
- return grp;
}
-
public void addEntry(IRosterEntry entry) {
addEntry(root, entry);
}
- public void addGroup(IRosterGroup group) {
- TreeParent grp = hasGroup(group);
- if (grp == null) {
- // Need to add it
- grp = new TreeParent(group.getName());
- }
- grp = addEntriesToGroup(grp, group);
- root.addChild(grp);
- }
public void removeAllEntries() {
root = null;
}
@@ -576,8 +613,6 @@ public class RosterView extends ViewPart implements IConfigViewer,
System.out.println("disconnect()");
}
};
- } else if (clazz.equals(IConfigViewer.class)) {
- return this;
} else if (clazz.equals(IPresenceListener.class)) {
return this;
} else if (clazz.equals(IMessageListener.class)) {
@@ -626,7 +661,7 @@ public class RosterView extends ViewPart implements IConfigViewer,
}
}
public void handleContainerJoined(ID containerID) {
- // XXX
+ // do nothing on this notification for now
}
public void handleContainerDeparted(ID containerID) {
handleGroupManagerDeparted();

Back to the top