summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-16 14:05:37 (EDT)
committerEike Stepper2007-10-16 14:05:37 (EDT)
commitc1dad986d4271fd5d74ff9098170e0d91304f3ff (patch)
tree84689886324be08fe922fec8e8c21d7beabe5455
parent27edab21a9abb87f033c444739338fb0ed3fc0dd (diff)
downloadcdo-c1dad986d4271fd5d74ff9098170e0d91304f3ff.zip
cdo-c1dad986d4271fd5d74ff9098170e0d91304f3ff.tar.gz
cdo-c1dad986d4271fd5d74ff9098170e0d91304f3ff.tar.bz2
[206224] Provide chat example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206224
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerProtocol.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java16
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java14
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java4
5 files changed, 37 insertions, 5 deletions
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 ec4bf54..f3e5fe7 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
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.buddies.internal.server.protocol;
+import org.eclipse.net4j.buddies.internal.protocol.CollaborationLeftIndication;
import org.eclipse.net4j.buddies.internal.protocol.MessageIndication;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;
@@ -47,6 +48,9 @@ public class ServerProtocol extends SignalProtocol
case ProtocolConstants.SIGNAL_INITIATE_COLLABORATION:
return new InitiateCollaborationIndication();
+ case ProtocolConstants.SIGNAL_COLLABORATION_LEFT:
+ return new CollaborationLeftIndication(IBuddyAdmin.INSTANCE);
+
case ProtocolConstants.SIGNAL_MESSAGE:
return new MessageIndication(IBuddyAdmin.INSTANCE);
}
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 a16da52..a89cb31 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
@@ -24,6 +24,7 @@ import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.ui.actions.SafeAction;
+import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
@@ -139,11 +140,12 @@ public class CollaborationsPane extends Composite implements IListener
public void fillActionBars(IActionBars bars)
{
+ IToolBarManager manager = bars.getToolBarManager();
for (IFacilityPaneCreator c : collaborationsView.getFacilityPaneCreators().values())
{
ActivateFacilityAction action = new ActivateFacilityAction(c.getType(), c.getImageDescriptor());
activateFacilityActions.add(action);
- bars.getToolBarManager().add(action);
+ manager.add(action);
}
}
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
index ddae433..fb1b992 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
@@ -113,10 +113,9 @@ public class CollaborationsView extends SessionManagerView
super.fillContextMenu(manager, selection);
if (selection.size() == 1)
{
- Object firstElement = selection.getFirstElement();
- if (firstElement instanceof IBuddyCollaboration)
+ final IBuddyCollaboration collaboration = (IBuddyCollaboration)selection.getFirstElement();
+ if (collaboration != null)
{
- IBuddyCollaboration collaboration = (IBuddyCollaboration)firstElement;
manager.add(new Separator());
for (IFacilityPaneCreator c : facilityPaneCreators.values())
{
@@ -127,6 +126,17 @@ public class CollaborationsView extends SessionManagerView
manager.add(action);
}
}
+
+ manager.add(new Separator());
+ manager.add(new SafeAction("Leave", "Leave this collaboration")
+ {
+ @Override
+ protected void safeRun() throws Exception
+ {
+ collaboration.leave();
+ }
+ });
+
}
}
}
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 7ae269c..8e2f023 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
@@ -15,6 +15,7 @@ import org.eclipse.net4j.buddies.IBuddyCollaboration;
import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.protocol.ClientFacilityFactory;
import org.eclipse.net4j.buddies.internal.protocol.Collaboration;
+import org.eclipse.net4j.buddies.internal.protocol.CollaborationLeftNotification;
import org.eclipse.net4j.buddies.internal.protocol.Message;
import org.eclipse.net4j.buddies.internal.protocol.MessageNotification;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
@@ -95,11 +96,22 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
public IBuddy invite(String userID)
{
- return null;
+ // TODO Implement method BuddyCollaboration.invite()
+ throw new UnsupportedOperationException("Not yet implemented");
}
public void leave()
{
+ try
+ {
+ new CollaborationLeftNotification(session.getChannel(), getID(), session.getSelf().getUserID()).send();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ deactivate();
}
protected IPluginContainer getContainer()
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 97d4a7f..aaded8e 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
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.internal.buddies.protocol;
+import org.eclipse.net4j.buddies.internal.protocol.CollaborationLeftIndication;
import org.eclipse.net4j.buddies.internal.protocol.MessageIndication;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.IBuddy;
@@ -48,6 +49,9 @@ public class ClientProtocol extends SignalProtocol
case ProtocolConstants.SIGNAL_COLLABORATION_INITIATED:
return new CollaborationInitiatedIndication();
+ case ProtocolConstants.SIGNAL_COLLABORATION_LEFT:
+ return new CollaborationLeftIndication(getSelf());
+
case ProtocolConstants.SIGNAL_FACILITY_INSTALLED:
return new FacilityInstalledIndication();