summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-11 14:41:58 (EDT)
committerEike Stepper2007-10-11 14:41:58 (EDT)
commit82e196ada43372fec0a9c9aa429a73964a5dede5 (patch)
tree5cdc1c5de7a3457634c2ce8bf5354efdd760e872
parent8d55117f4e34215e93c6da180914e79809828543 (diff)
downloadcdo-82e196ada43372fec0a9c9aa429a73964a5dede5.zip
cdo-82e196ada43372fec0a9c9aa429a73964a5dede5.tar.gz
cdo-82e196ada43372fec0a9c9aa429a73964a5dede5.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java23
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/TestPane.java7
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java3
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java3
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java51
5 files changed, 86 insertions, 1 deletions
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 cb8cf76..4396569 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
@@ -10,12 +10,15 @@
**************************************************************************/
package org.eclipse.net4j.buddies.internal.server.protocol;
+import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.internal.protocol.Collaboration;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.internal.protocol.ServerFacilityFactory;
import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
import org.eclipse.net4j.buddies.internal.server.bundle.OM;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
import org.eclipse.net4j.buddies.protocol.IFacility;
+import org.eclipse.net4j.buddies.protocol.ISession;
import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -56,6 +59,26 @@ public class InstallFacilityIndication extends IndicationWithResponse
Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
facility.setCollaboration(collaboration);
collaboration.addFacility(facility, true);
+
+ ISession session = (ISession)getProtocol().getInfraStructure();
+ IBuddy initiator = session.getSelf();
+
+ for (IBuddy buddy : collaboration.getBuddies())
+ {
+ if (buddy != initiator)
+ {
+ try
+ {
+ IChannel channel = buddy.getSession().getChannel();
+ new FacilityInstalledNotification(channel, collaborationID, facilityType).send();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+
success = true;
}
catch (RuntimeException ex)
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/TestPane.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/TestPane.java
index 01a8674..0994928 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/TestPane.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/TestPane.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.buddies.internal.ui;
import org.eclipse.net4j.buddies.internal.ui.views.FacilityPane;
+import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
@@ -24,6 +25,10 @@ public class TestPane extends FacilityPane
public TestPane(Composite parent, int style, String type)
{
super(parent, style);
- new Text(this, SWT.CENTER).setText(type);
+ setLayout(UIUtil.createGridLayout(1));
+
+ Text text = new Text(this, SWT.CENTER);
+ text.setLayoutData(UIUtil.createGridData());
+ text.setText(type);
}
}
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 e1201a1..f47102d 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
@@ -215,10 +215,13 @@ public class CollaborationsPane extends Composite implements IListener
{
setActiveFacility(collaboration, facilities[0]);
}
+
+ collaboration.addListener(this);
}
protected void collaborationRemoved(IBuddyCollaboration collaboration)
{
+ collaboration.removeListener(this);
}
protected void facilityInstalled(IFacility facility, boolean fromRemote)
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java
index 5aef758..2944008 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java
@@ -45,6 +45,9 @@ public class ClientProtocol extends SignalProtocol
case ProtocolConstants.SIGNAL_COLLABORATION_INITIATED:
return new CollaborationInitiatedIndication();
+ case ProtocolConstants.SIGNAL_FACILITY_INSTALLED:
+ return new FacilityInstalledIndication();
+
case ProtocolConstants.SIGNAL_MESSAGE:
return new ClientMessageIndication();
}
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
new file mode 100644
index 0000000..a75e0c9
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.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.buddies.IBuddySession;
+import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.IFacility;
+import org.eclipse.net4j.internal.buddies.BuddyCollaboration;
+import org.eclipse.net4j.internal.buddies.Self;
+import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class FacilityInstalledIndication extends Indication
+{
+ public FacilityInstalledIndication()
+ {
+ }
+
+ @Override
+ protected short getSignalID()
+ {
+ return ProtocolConstants.SIGNAL_FACILITY_INSTALLED;
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws IOException
+ {
+ long collaborationID = in.readLong();
+ String facilityType = in.readString();
+
+ 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);
+ }
+}