summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-11-12 05:41:48 (EST)
committerEike Stepper2007-11-12 05:41:48 (EST)
commit7a158500c5f872a917db5ae2f36350e70e2e068e (patch)
tree1a214223534bb6b622176360c77e1302fd1ca6c9
parenta9ffe7bc90d2e6eef51aa220024275d8b2c1fee7 (diff)
downloadcdo-7a158500c5f872a917db5ae2f36350e70e2e068e.zip
cdo-7a158500c5f872a917db5ae2f36350e70e2e068e.tar.gz
cdo-7a158500c5f872a917db5ae2f36350e70e2e068e.tar.bz2
[209380] Add invitation capability for multi buddy collaborations
https://bugs.eclipse.org/bugs/show_bug.cgi?id=209380 [!] DO NOT COMMIT
-rw-r--r--features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml8
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java35
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java62
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsItemProvider.java25
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java8
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java46
6 files changed, 110 insertions, 74 deletions
diff --git a/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml b/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
index 611662f..d30019e 100644
--- a/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
+++ b/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
@@ -37,17 +37,17 @@
databaseName="/temp/cdodb1"
createDatabase="create"/> -->
- <dbAdapter name="derby"/>
+ <!--<dbAdapter name="derby"/>
<dataSource
driverClass="org.apache.derby.jdbc.ClientDataSource"
databaseName="cdodb1"
- createDatabase="create"/>
+ createDatabase="create"/>-->
- <!--<dbAdapter name="hsqldb"/>
+ <dbAdapter name="hsqldb"/>
<dataSource
driverClass="org.eclipse.net4j.db.hsqldb.HSQLDBDataSource"
database="jdbc:hsqldb:mem:cdodb1"
- user="sa"/>-->
+ user="sa"/>
<!--<dbAdapter name="mysql"/>
<dataSource
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
index 4396569..25431d8 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
@@ -57,29 +57,32 @@ public class InstallFacilityIndication extends IndicationWithResponse
IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, facilityType, description);
Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
- facility.setCollaboration(collaboration);
- collaboration.addFacility(facility, true);
+ if (collaboration != null)
+ {
+ facility.setCollaboration(collaboration);
+ collaboration.addFacility(facility, true);
- ISession session = (ISession)getProtocol().getInfraStructure();
- IBuddy initiator = session.getSelf();
+ ISession session = (ISession)getProtocol().getInfraStructure();
+ IBuddy initiator = session.getSelf();
- for (IBuddy buddy : collaboration.getBuddies())
- {
- if (buddy != initiator)
+ for (IBuddy buddy : collaboration.getBuddies())
{
- try
- {
- IChannel channel = buddy.getSession().getChannel();
- new FacilityInstalledNotification(channel, collaborationID, facilityType).send();
- }
- catch (Exception ex)
+ if (buddy != initiator)
{
- OM.LOG.error(ex);
+ try
+ {
+ IChannel channel = buddy.getSession().getChannel();
+ new FacilityInstalledNotification(channel, collaborationID, facilityType).send();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
}
}
- }
- success = true;
+ success = true;
+ }
}
catch (RuntimeException ex)
{
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
index 25a5bed..50e7e4d 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
@@ -49,44 +49,46 @@ public class InviteBuddiesIndication extends Indication
String[] userIDs = ProtocolUtil.readUserIDs(in);
Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
- Set<IBuddy> added = new HashSet<IBuddy>();
-
- for (String userID : userIDs)
+ if (collaboration != null)
{
- IBuddy buddy = BuddyAdmin.INSTANCE.getBuddy(userID);
- if (buddy != null && collaboration.getMembership(buddy) == null)
+ Set<IBuddy> added = new HashSet<IBuddy>();
+ for (String userID : userIDs)
{
- Membership.create(buddy, collaboration);
- added.add(buddy);
- }
- }
-
- List<IBuddy> buddies = Arrays.asList(collaboration.getBuddies());
- for (IBuddy buddy : buddies)
- {
- IChannel channel = buddy.getSession().getChannel();
- String[] facilityTypes = null;
- Set<IBuddy> set = new HashSet<IBuddy>();
- if (added.contains(buddy))
- {
- set.addAll(buddies);
- set.remove(buddy);
- facilityTypes = collaboration.getFacilityTypes();
- }
- else
- {
- set.addAll(added);
+ IBuddy buddy = BuddyAdmin.INSTANCE.getBuddy(userID);
+ if (buddy != null && collaboration.getMembership(buddy) == null)
+ {
+ Membership.create(buddy, collaboration);
+ added.add(buddy);
+ }
}
- if (!set.isEmpty())
+ List<IBuddy> buddies = Arrays.asList(collaboration.getBuddies());
+ for (IBuddy buddy : buddies)
{
- try
+ IChannel channel = buddy.getSession().getChannel();
+ String[] facilityTypes = null;
+ Set<IBuddy> set = new HashSet<IBuddy>();
+ if (added.contains(buddy))
{
- new CollaborationInitiatedNotification(channel, collaborationID, set, facilityTypes).send();
+ set.addAll(buddies);
+ set.remove(buddy);
+ facilityTypes = collaboration.getFacilityTypes();
}
- catch (Exception ex)
+ else
+ {
+ set.addAll(added);
+ }
+
+ if (!set.isEmpty())
{
- throw WrappedException.wrap(ex);
+ try
+ {
+ new CollaborationInitiatedNotification(channel, collaborationID, set, facilityTypes).send();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
}
}
}
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsItemProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsItemProvider.java
index 099579a..d5135d4 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsItemProvider.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsItemProvider.java
@@ -10,9 +10,11 @@
**************************************************************************/
package org.eclipse.net4j.buddies.internal.ui;
-import org.eclipse.net4j.buddies.protocol.ICollaboration;
import org.eclipse.net4j.buddies.protocol.IMembership;
import org.eclipse.net4j.internal.buddies.Self;
+import org.eclipse.net4j.internal.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
import org.eclipse.net4j.util.ui.views.IElementFilter;
import org.eclipse.swt.graphics.Image;
@@ -71,6 +73,12 @@ public class CollaborationsItemProvider extends AbstractItemProvider
return getImage(membership.getBuddy());
}
+ @Override
+ protected void refreshElement(Object element, boolean updateLabels)
+ {
+ super.refreshElement(null, updateLabels);
+ }
+
/**
* @author Eike Stepper
*/
@@ -78,6 +86,16 @@ public class CollaborationsItemProvider extends AbstractItemProvider
{
private Self self;
+ private IListener membershipListener = new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ IMembership membership = (IMembership)lifecycle;
+ // onRemoved(self, membership.getCollaboration());
+ }
+ };
+
public SelfNode(Self self)
{
super(null);
@@ -102,8 +120,9 @@ public class CollaborationsItemProvider extends AbstractItemProvider
@Override
protected Node addChild(Collection<Node> children, Object element)
{
- ICollaboration collaboration = ((IMembership)element).getCollaboration();
- return super.addChild(children, collaboration);
+ IMembership membership = (IMembership)element;
+ // membership.addListener(membershipListener);
+ return super.addChild(children, membership.getCollaboration());
}
}
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java
index a75e0c9..0609327 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java
@@ -44,8 +44,10 @@ public class FacilityInstalledIndication extends Indication
IBuddySession session = (IBuddySession)getProtocol().getInfraStructure();
Self self = (Self)session.getSelf();
BuddyCollaboration collaboration = (BuddyCollaboration)self.getCollaboration(collaborationID);
-
- IFacility facility = collaboration.createFacility(facilityType);
- collaboration.addFacility(facility, true);
+ if (collaboration != null)
+ {
+ IFacility facility = collaboration.createFacility(facilityType);
+ collaboration.addFacility(facility, true);
+ }
}
}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java
index b799768..d66edf6 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java
@@ -326,29 +326,13 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
@Override
protected void onAdded(IContainer<Object> container, Object element)
{
- Node node = addChild(getChildren(), element);
- if (node != null)
- {
- refreshElement(container, true);
- revealElement(element);
- elementAdded(element, container);
- }
+ AbstractContainerNode.this.onAdded(container, element);
}
@Override
protected void onRemoved(IContainer<Object> container, Object element)
{
- Node node = removeNode(element);
- if (node != null)
- {
- getChildren().remove(node);
- elementRemoved(element, container);
-
- Object rootElement = root.getElement();
- Object refreshElement = container == rootElement ? null : container;
- refreshElement(refreshElement, true);
- node.dispose();
- }
+ AbstractContainerNode.this.onRemoved(container, element);
}
@Override
@@ -414,6 +398,32 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
getContainer().addListener(containerListener);
return children;
}
+
+ protected void onAdded(IContainer<Object> container, Object element)
+ {
+ Node node = addChild(getChildren(), element);
+ if (node != null)
+ {
+ refreshElement(container, true);
+ revealElement(element);
+ elementAdded(element, container);
+ }
+ }
+
+ protected void onRemoved(IContainer<Object> container, Object element)
+ {
+ Node node = removeNode(element);
+ if (node != null)
+ {
+ getChildren().remove(node);
+ elementRemoved(element, container);
+
+ Object rootElement = root.getElement();
+ Object refreshElement = container == rootElement ? null : container;
+ refreshElement(refreshElement, true);
+ node.dispose();
+ }
+ }
}
/**