summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-11-10 05:47:41 (EST)
committerEike Stepper2007-11-10 05:47:41 (EST)
commit4fbe5ddbb62e439ad7708520674c3f03ebb512c6 (patch)
tree490f76a334bd59b6a404ddf23bd799a59093093b
parent1f56c2e90579798c8a922db1a3d7cacd26348fd3 (diff)
downloadcdo-4fbe5ddbb62e439ad7708520674c3f03ebb512c6.zip
cdo-4fbe5ddbb62e439ad7708520674c3f03ebb512c6.tar.gz
cdo-4fbe5ddbb62e439ad7708520674c3f03ebb512c6.tar.bz2
[209380] Add invitation capability for multi buddy collaborations
https://bugs.eclipse.org/bugs/show_bug.cgi?id=209380
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/BuddiesServer.launch4
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java20
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java9
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java96
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerProtocol.java3
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/BuddiesClient1.launch4
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/BuddiesClient2.launch4
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/BuddiesClient3.launch4
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java43
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java16
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java30
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java20
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InviteBuddiesNotification.java51
-rw-r--r--plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/actions/IntrospectAction.java25
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jIntrospectorView.java32
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StructuredContentProvider.java4
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProviderTest.java47
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java3
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java3
20 files changed, 298 insertions, 121 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/BuddiesServer.launch b/plugins/org.eclipse.net4j.buddies.server/BuddiesServer.launch
index 2c0bd1f..c0bbdf5 100644
--- a/plugins/org.eclipse.net4j.buddies.server/BuddiesServer.launch
+++ b/plugins/org.eclipse.net4j.buddies.server/BuddiesServer.launch
@@ -15,6 +15,10 @@
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../buddies.server"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}&#13;&#10;-debug&#13;&#10;-console&#13;&#10;--launcher.XXMaxPermSize&#13;&#10;128M"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Ddebug=true&#13;&#10;-Dnet4j.config=${resource_loc:/org.eclipse.net4j.buddies.server/config}"/>
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java
index bc50e84..5117c71 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java
@@ -13,11 +13,12 @@ package org.eclipse.net4j.buddies.internal.server.protocol;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import java.io.IOException;
-import java.util.Set;
+import java.util.Collection;
/**
* @author Eike Stepper
@@ -26,9 +27,9 @@ public class CollaborationInitiatedNotification extends Request
{
private long collaborationID;
- private Set<IBuddy> buddies;
+ private Collection<IBuddy> buddies;
- public CollaborationInitiatedNotification(IChannel channel, long collaborationID, Set<IBuddy> buddies)
+ public CollaborationInitiatedNotification(IChannel channel, long collaborationID, Collection<IBuddy> buddies)
{
super(channel);
this.collaborationID = collaborationID;
@@ -45,17 +46,6 @@ public class CollaborationInitiatedNotification extends Request
protected void requesting(ExtendedDataOutputStream out) throws IOException
{
out.writeLong(collaborationID);
- if (buddies == null)
- {
- out.writeInt(0);
- }
- else
- {
- out.writeInt(buddies.size());
- for (IBuddy buddy : buddies)
- {
- out.writeString(buddy.getUserID());
- }
- }
+ ProtocolUtil.writeBuddies(out, buddies);
}
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java
index b98aea5..cf0e94a 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java
@@ -14,6 +14,7 @@ import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.IBuddy;
import org.eclipse.net4j.buddies.protocol.ICollaboration;
import org.eclipse.net4j.buddies.protocol.ISession;
+import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;
import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -41,13 +42,7 @@ public class InitiateCollaborationIndication extends IndicationWithResponse
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
- int size = in.readInt();
- String[] userIDs = new String[size];
- for (int i = 0; i < size; i++)
- {
- userIDs[i] = in.readString();
- }
-
+ String[] userIDs = ProtocolUtil.readUserIDs(in);
ISession session = (ISession)getProtocol().getInfraStructure();
IBuddy initiator = session.getSelf();
collaboration = IBuddyAdmin.INSTANCE.initiateCollaboration(initiator, userIDs);
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
new file mode 100644
index 0000000..21e0cea
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
@@ -0,0 +1,96 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.buddies.internal.server.protocol;
+
+import org.eclipse.net4j.IChannel;
+import org.eclipse.net4j.buddies.internal.protocol.Buddy;
+import org.eclipse.net4j.buddies.internal.protocol.Collaboration;
+import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ISession;
+import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
+import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class InviteBuddiesIndication extends Indication
+{
+ public InviteBuddiesIndication()
+ {
+ }
+
+ @Override
+ protected short getSignalID()
+ {
+ return ProtocolConstants.SIGNAL_INVITE_BUDDIES;
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws IOException
+ {
+ long collaborationID = in.readLong();
+ String[] userIDs = ProtocolUtil.readUserIDs(in);
+
+ Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
+ Map<String, ISession> sessions = BuddyAdmin.INSTANCE.getSessions();
+ Set<IBuddy> added = new HashSet<IBuddy>();
+
+ for (String userID : userIDs)
+ {
+ ISession session = sessions.get(userID);
+ IBuddy buddy = session.getSelf();
+ if (collaboration.addBuddy(buddy))
+ {
+ ((Buddy)buddy).addCollaboration(collaboration);
+ added.add(buddy);
+ }
+ }
+
+ List<IBuddy> buddies = Arrays.asList(collaboration.getBuddies());
+ for (IBuddy buddy : buddies)
+ {
+ IChannel channel = buddy.getSession().getChannel();
+ Set<IBuddy> set = new HashSet<IBuddy>();
+ if (added.contains(buddy))
+ {
+ set.addAll(buddies);
+ set.remove(buddy);
+ }
+ else
+ {
+ set.addAll(added);
+ }
+
+ if (!set.isEmpty())
+ {
+ try
+ {
+ new CollaborationInitiatedNotification(channel, collaborationID, set).send();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerProtocol.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerProtocol.java
index 64e53e2..5628ca1 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerProtocol.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerProtocol.java
@@ -47,6 +47,9 @@ public class ServerProtocol extends SignalProtocol
case ProtocolConstants.SIGNAL_INITIATE_COLLABORATION:
return new InitiateCollaborationIndication();
+ case ProtocolConstants.SIGNAL_INVITE_BUDDIES:
+ return new InviteBuddiesIndication();
+
case ProtocolConstants.SIGNAL_COLLABORATION_LEFT:
return new ServerCollaborationLeftIndication();
diff --git a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient1.launch b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient1.launch
index 0762c6a..f090bcb 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient1.launch
+++ b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient1.launch
@@ -13,6 +13,10 @@
<booleanAttribute key="includeOptional" value="false"/>
<stringAttribute key="location" value="${workspace_loc}/../buddies.client1"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-nosplash&#13;&#10;-console"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.aspectj.tracing.debug=false&#13;&#10;-Xms40m&#13;&#10;-Xmx512m"/>
diff --git a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient2.launch b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient2.launch
index 3400f21..f20cbba 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient2.launch
+++ b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient2.launch
@@ -13,6 +13,10 @@
<booleanAttribute key="includeOptional" value="false"/>
<stringAttribute key="location" value="${workspace_loc}/../buddies.client2"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-nosplash&#13;&#10;-console"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.aspectj.tracing.debug=false&#13;&#10;-Xms40m&#13;&#10;-Xmx512m"/>
diff --git a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient3.launch b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient3.launch
index 9066ba5..55b227f 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient3.launch
+++ b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient3.launch
@@ -13,6 +13,10 @@
<booleanAttribute key="includeOptional" value="false"/>
<stringAttribute key="location" value="${workspace_loc}/../buddies.client3"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-nosplash&#13;&#10;-console"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.aspectj.tracing.debug=false&#13;&#10;-Xms40m&#13;&#10;-Xmx512m"/>
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java
index 5ed67ca..87c4d63 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java
@@ -29,6 +29,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
import java.util.ArrayList;
@@ -243,30 +244,40 @@ public class CollaborationsPane extends Composite implements IListener
final IBuddyCollaboration collaboration = (IBuddyCollaboration)facility.getCollaboration();
if (fromRemote)
{
- try
+ Runnable runnable = new Runnable()
{
- getDisplay().asyncExec(new Runnable()
+ public void run()
{
- public void run()
+ try
{
- try
+ addFacilityPane(facility);
+ IFacility activeFacility = activeFacilities.get(collaboration);
+ if (activeFacility == null)
{
- addFacilityPane(facility);
- IFacility activeFacility = activeFacilities.get(collaboration);
- if (activeFacility == null)
- {
- setActiveFacility(collaboration, facility);
- }
- else
- {
- updateState();
- }
+ setActiveFacility(collaboration, facility);
}
- catch (RuntimeException ignore)
+ else
{
+ updateState();
}
}
- });
+ catch (RuntimeException ignore)
+ {
+ }
+ }
+ };
+
+ try
+ {
+ Display display = getDisplay();
+ if (display.getThread() == Thread.currentThread())
+ {
+ runnable.run();
+ }
+ else
+ {
+ display.asyncExec(runnable);
+ }
}
catch (RuntimeException ignore)
{
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
index c81a30a..5dfc69f 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
@@ -23,6 +23,7 @@ import org.eclipse.net4j.buddies.protocol.IBuddy;
import org.eclipse.net4j.buddies.protocol.IFacility;
import org.eclipse.net4j.buddies.protocol.IMessage;
import org.eclipse.net4j.internal.buddies.protocol.InstallFacilityRequest;
+import org.eclipse.net4j.internal.buddies.protocol.InviteBuddiesNotification;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.IPluginContainer;
@@ -112,11 +113,24 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
public void invite(IBuddy... buddies)
{
+ List<IBuddy> toBeInvited = new ArrayList<IBuddy>();
for (IBuddy buddy : buddies)
{
if (getBuddy(buddy.getUserID()) == null)
{
- System.out.println("INVITING: " + buddy);
+ toBeInvited.add(buddy);
+ }
+ }
+
+ if (!toBeInvited.isEmpty())
+ {
+ try
+ {
+ new InviteBuddiesNotification(session.getChannel(), getID(), toBeInvited).send();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
}
}
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java
index 60aa4db..bb4d142 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java
@@ -13,6 +13,7 @@ package org.eclipse.net4j.internal.buddies.protocol;
import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
import org.eclipse.net4j.internal.buddies.BuddyCollaboration;
import org.eclipse.net4j.internal.buddies.ClientBuddy;
import org.eclipse.net4j.internal.buddies.Self;
@@ -21,7 +22,6 @@ import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import java.io.IOException;
-import java.util.HashSet;
import java.util.Set;
/**
@@ -46,24 +46,26 @@ public class CollaborationInitiatedIndication extends Indication
Self self = (Self)session.getSelf();
long collaborationID = in.readLong();
- int size = in.readInt();
- Set<IBuddy> buddies = new HashSet<IBuddy>();
- for (int i = 0; i < size; i++)
+ Set<IBuddy> buddies = ProtocolUtil.readBuddies(in, session);
+
+ BuddyCollaboration collaboration = (BuddyCollaboration)self.getCollaboration(collaborationID);
+ if (collaboration == null)
{
- String userID = in.readString();
- IBuddy buddy = session.getBuddy(userID);
- if (buddy != null)
+ collaboration = new BuddyCollaboration(session, collaborationID, buddies);
+ LifecycleUtil.activate(collaboration);
+ self.addCollaboration(collaboration);
+ for (IBuddy buddy : buddies)
{
- buddies.add(buddy);
+ ((ClientBuddy)buddy).addCollaboration(collaboration);
}
}
-
- BuddyCollaboration collaboration = new BuddyCollaboration(session, collaborationID, buddies);
- LifecycleUtil.activate(collaboration);
- self.addCollaboration(collaboration);
- for (IBuddy buddy : buddies)
+ else
{
- ((ClientBuddy)buddy).addCollaboration(collaboration);
+ for (IBuddy buddy : buddies)
+ {
+ collaboration.addBuddy(buddy);
+ ((ClientBuddy)buddy).addCollaboration(collaboration);
+ }
}
}
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java
index d8ff8dd..0a8e92a 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java
@@ -13,21 +13,22 @@ package org.eclipse.net4j.internal.buddies.protocol;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import java.io.IOException;
-import java.util.Set;
+import java.util.Collection;
/**
* @author Eike Stepper
*/
public class InitiateCollaborationRequest extends RequestWithConfirmation<Long>
{
- private Set<IBuddy> buddies;
+ private Collection<IBuddy> buddies;
- public InitiateCollaborationRequest(IChannel channel, Set<IBuddy> buddies)
+ public InitiateCollaborationRequest(IChannel channel, Collection<IBuddy> buddies)
{
super(channel);
this.buddies = buddies;
@@ -42,18 +43,7 @@ public class InitiateCollaborationRequest extends RequestWithConfirmation<Long>
@Override
protected void requesting(ExtendedDataOutputStream out) throws IOException
{
- if (buddies == null)
- {
- out.writeInt(0);
- }
- else
- {
- out.writeInt(buddies.size());
- for (IBuddy buddy : buddies)
- {
- out.writeString(buddy.getUserID());
- }
- }
+ ProtocolUtil.writeBuddies(out, buddies);
}
@Override
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InviteBuddiesNotification.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InviteBuddiesNotification.java
new file mode 100644
index 0000000..4c7375d
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InviteBuddiesNotification.java
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.internal.buddies.protocol;
+
+import org.eclipse.net4j.IChannel;
+import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ * @author Eike Stepper
+ */
+public class InviteBuddiesNotification extends Request
+{
+ private long collaborationID;
+
+ private Collection<IBuddy> buddies;
+
+ public InviteBuddiesNotification(IChannel channel, long collaborationID, Collection<IBuddy> buddies)
+ {
+ super(channel);
+ this.buddies = buddies;
+ this.collaborationID = collaborationID;
+ }
+
+ @Override
+ protected short getSignalID()
+ {
+ return ProtocolConstants.SIGNAL_INVITE_BUDDIES;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws IOException
+ {
+ out.writeLong(collaborationID);
+ ProtocolUtil.writeBuddies(out, buddies);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
index 4212d41..25bdc65 100644
--- a/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.3.0,4.0.0)";visibility:=reexport,
org.eclipse.net4j.util;bundle-version="[0.8.0,0.9.0)";visibility:=reexport
Export-Package: org.eclipse.net4j.util.internal.ui;version="0.8.0",
+ org.eclipse.net4j.util.internal.ui.actions;version="0.8.0",
org.eclipse.net4j.util.internal.ui.security;version="0.8.0",
org.eclipse.net4j.util.internal.ui.views;version="0.8.0",
org.eclipse.net4j.util.ui;version="0.8.0",
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/actions/IntrospectAction.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/actions/IntrospectAction.java
new file mode 100644
index 0000000..2aed14f
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/actions/IntrospectAction.java
@@ -0,0 +1,25 @@
+package org.eclipse.net4j.util.internal.ui.actions;
+
+import org.eclipse.net4j.util.internal.ui.views.Net4jIntrospectorView;
+import org.eclipse.net4j.util.ui.actions.SafeAction;
+
+/**
+ * @author Eike Stepper
+ */
+public class IntrospectAction extends SafeAction
+{
+ private Object object;
+
+ public IntrospectAction(Object object)
+ {
+ super("Introspect");
+ this.object = object;
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ Net4jIntrospectorView introspector = Net4jIntrospectorView.getInstance(true);
+ introspector.setObject(object);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jIntrospectorView.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jIntrospectorView.java
index c012660..ce81830 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jIntrospectorView.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/views/Net4jIntrospectorView.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.util.internal.ui.views;
import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.event.EventUtil;
@@ -45,6 +46,7 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
@@ -60,8 +62,12 @@ import java.util.Stack;
*/
public class Net4jIntrospectorView extends ViewPart implements ISelectionListener, IDoubleClickListener, IListener
{
+ public static final String VIEW_ID = "org.eclipse.net4j.util.Net4jIntrospectorView";
+
private static final Object[] NO_ELEMENTS = {};
+ private static Net4jIntrospectorView instance;
+
private TableViewer currentViewer;
private TableViewer objectViewer;
@@ -95,6 +101,29 @@ public class Net4jIntrospectorView extends ViewPart implements ISelectionListene
super.dispose();
}
+ public static Net4jIntrospectorView getInstance()
+ {
+ return instance;
+ }
+
+ public static synchronized Net4jIntrospectorView getInstance(boolean show)
+ {
+ if (instance == null)
+ {
+ try
+ {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.showView(VIEW_ID);
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ return instance;
+ }
+
@Override
public void createPartControl(Composite parent)
{
@@ -150,6 +179,7 @@ public class Net4jIntrospectorView extends ViewPart implements ISelectionListene
fillLocalToolBar(bars.getToolBarManager());
getSite().getPage().addSelectionListener(this);
setCurrentViewer(objectViewer);
+ instance = this;
}
private void setCurrentViewer(TableViewer viewer)
@@ -258,7 +288,7 @@ public class Net4jIntrospectorView extends ViewPart implements ISelectionListene
refreshViewer();
}
- private void setObject(Object object)
+ public void setObject(Object object)
{
EventUtil.removeListener(object, this);
if (object != null)
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StructuredContentProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StructuredContentProvider.java
index 44ecca4..26e12d3 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StructuredContentProvider.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/StructuredContentProvider.java
@@ -123,7 +123,7 @@ public abstract class StructuredContentProvider<INPUT> implements IStructuredCon
{
try
{
- getDisplay().asyncExec(new Runnable()
+ getDisplay().syncExec(new Runnable()
{
public void run()
{
@@ -146,7 +146,7 @@ public abstract class StructuredContentProvider<INPUT> implements IStructuredCon
{
try
{
- getDisplay().asyncExec(new Runnable()
+ getDisplay().syncExec(new Runnable()
{
public void run()
{
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProviderTest.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProviderTest.java
deleted file mode 100644
index 44d506d..0000000
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProviderTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
- * 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:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.net4j.util.ui.views;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @author Eike Stepper
- */
-public class ContainerItemProviderTest
-{
- public static void main(String[] args)
- {
- Display display = new Display();
- Shell shell = new Shell(display);
- createUI(shell);
- shell.open();
- while (!shell.isDisposed())
- {
- if (!display.readAndDispatch())
- {
- display.sleep();
- }
- }
-
- display.dispose();
- }
-
- private static void createUI(Composite parent)
- {
- Label label = new Label(parent, SWT.CENTER);
- label.setText("Hello World");
- label.setBounds(parent.getClientArea());
- }
-}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java
index 7e0cd1e..f2e0e06 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java
@@ -76,7 +76,7 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar
{
try
{
- getDisplay().asyncExec(new Runnable()
+ getDisplay().syncExec(new Runnable()
{
public void run()
{
@@ -216,6 +216,7 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar
{
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
manager.add(refreshAction);
+ // manager.add(new IntrospectAction(getViewer()));
}
protected void fillLocalToolBar(IToolBarManager manager)
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java
index f2e8a91..941e32e 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java
@@ -11,7 +11,6 @@
package org.eclipse.net4j.util;
import org.eclipse.net4j.internal.util.bundle.OM;
-import org.eclipse.net4j.internal.util.event.Notifier;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.net4j.util.io.IOUtil;
@@ -135,7 +134,7 @@ public final class ReflectUtil
public static void collectFields(Class<?> c, List<Field> fields)
{
- if (c == ROOT_CLASS || c == Notifier.class)
+ if (c == ROOT_CLASS)
{
return;
}