Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsuen2008-12-14 03:44:18 -0500
committerrsuen2008-12-14 03:44:18 -0500
commit2743d73c5244ef29253c56e31646d4a8004cc260 (patch)
treef027e05285213718946ec39d14b04dbbdb1533c6 /examples/bundles/org.eclipse.ecf.example.collab
parenta4891537880f31847c50c28d247d47b7181b7591 (diff)
downloadorg.eclipse.ecf-2743d73c5244ef29253c56e31646d4a8004cc260.tar.gz
org.eclipse.ecf-2743d73c5244ef29253c56e31646d4a8004cc260.tar.xz
org.eclipse.ecf-2743d73c5244ef29253c56e31646d4a8004cc260.zip
First cut at providing support for handling instant messasges through the Presence API.
Diffstat (limited to 'examples/bundles/org.eclipse.ecf.example.collab')
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java15
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/presence/PresenceContainer.java15
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/SharedObjectContainerUI.java18
3 files changed, 22 insertions, 26 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java
index a0881f2c5..b00d1f1e5 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java
+++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java
@@ -28,6 +28,8 @@ import org.eclipse.ecf.internal.example.collab.ui.*;
import org.eclipse.ecf.internal.example.collab.ui.hyperlink.EclipseCollabHyperlinkDetector;
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
import org.eclipse.ecf.presence.Presence;
+import org.eclipse.ecf.presence.im.ChatMessage;
+import org.eclipse.ecf.presence.im.ChatMessageEvent;
import org.eclipse.ecf.presence.roster.*;
import org.eclipse.ecf.ui.screencapture.*;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -76,16 +78,14 @@ public class EclipseCollabSharedObject extends GenericSharedObject {
private String localVersion = ""; //$NON-NLS-1$
private ID serverID = null;
private SharedObjectEventListener sharedObjectEventListener = null;
- private IWorkbenchWindow workbenchWindow = null;
private PresenceContainer presenceContainer;
public EclipseCollabSharedObject() {
}
- public EclipseCollabSharedObject(IContainer container, IResource proj, IWorkbenchWindow window, IUser user, String downloaddir) {
+ public EclipseCollabSharedObject(IContainer container, IResource proj, IUser user, String downloaddir) {
this.localResource = proj;
- this.workbenchWindow = window;
this.localUser = user;
this.downloadDirectory = downloaddir;
presenceContainer = new PresenceContainer(this, container, localUser);
@@ -128,9 +128,6 @@ public class EclipseCollabSharedObject extends GenericSharedObject {
if (sharedObjectEventListener != null) {
sharedObjectEventListener = null;
}
- if (workbenchWindow != null) {
- workbenchWindow = null;
- }
if (localResource != null) {
localResource = null;
}
@@ -230,10 +227,6 @@ public class EclipseCollabSharedObject extends GenericSharedObject {
return windowTitle;
}
- public IWorkbenchWindow getWorkbenchWindow() {
- return workbenchWindow;
- }
-
// SharedObjectMsg handlers
protected void handleCreateObject(ReplicaSharedObjectDescription cons) {
try {
@@ -278,6 +271,8 @@ public class EclipseCollabSharedObject extends GenericSharedObject {
}
protected void handleShowPrivateTextMsg(final IUser remote, final String aString) {
+ ChatMessageEvent messageEvent = new ChatMessageEvent(remote.getID(), new ChatMessage(remote.getID(), aString));
+ presenceContainer.fireMessageEvent(messageEvent);
// Show line on local interface
Display.getDefault().asyncExec(new Runnable() {
public void run() {
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/presence/PresenceContainer.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/presence/PresenceContainer.java
index 137fc5069..f86a7a0d4 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/presence/PresenceContainer.java
+++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/presence/PresenceContainer.java
@@ -11,6 +11,7 @@
package org.eclipse.ecf.internal.example.collab.presence;
import java.util.Map;
+import org.eclipse.core.runtime.ListenerList;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.user.IUser;
@@ -28,6 +29,8 @@ import org.osgi.framework.ServiceRegistration;
public class PresenceContainer extends AbstractPresenceContainer implements IChatManager, IChatMessageSender, IPresenceSender, IPresenceService {
+ private final ListenerList messageListeners = new ListenerList();
+
private final EclipseCollabSharedObject sharedObject;
private final IContainer container;
private final IRosterManager manager;
@@ -66,12 +69,20 @@ public class PresenceContainer extends AbstractPresenceContainer implements ICha
return super.getAdapter(adapter);
}
+ public void fireMessageEvent(IIMMessageEvent messageEvent) {
+ Object[] listeners = messageListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ IIMMessageListener listener = (IIMMessageListener) listeners[i];
+ listener.handleMessageEvent(messageEvent);
+ }
+ }
+
public void addMessageListener(IIMMessageListener listener) {
- // unimplemented because messages do not currently go through the presence container
+ messageListeners.add(listener);
}
public void removeMessageListener(IIMMessageListener listener) {
- // unimplemented because messages do not currently go through the presence container
+ messageListeners.remove(listener);
}
public void sendPresenceUpdate(ID targetId, IPresence presence) throws ECFException {
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/SharedObjectContainerUI.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/SharedObjectContainerUI.java
index 053388e8b..6c6ed33fe 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/SharedObjectContainerUI.java
+++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/internal/example/collab/ui/SharedObjectContainerUI.java
@@ -12,16 +12,11 @@ package org.eclipse.ecf.internal.example.collab.ui;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
+import java.util.*;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ecf.core.IContainerListener;
-import org.eclipse.ecf.core.events.IContainerDisconnectedEvent;
-import org.eclipse.ecf.core.events.IContainerEjectedEvent;
-import org.eclipse.ecf.core.events.IContainerEvent;
+import org.eclipse.ecf.core.events.*;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer;
@@ -29,11 +24,7 @@ import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.core.user.User;
import org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject;
import org.eclipse.ecf.example.collab.share.SharedObjectEventListener;
-import org.eclipse.ecf.internal.example.collab.ClientEntry;
-import org.eclipse.ecf.internal.example.collab.CollabClient;
-import org.eclipse.ecf.internal.example.collab.Messages;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.ecf.internal.example.collab.*;
public class SharedObjectContainerUI {
public static final String JOIN_TIME_FORMAT = "hh:mm:ss a z"; //$NON-NLS-1$
@@ -108,8 +99,7 @@ public class SharedObjectContainerUI {
}
protected void createAndAddSharedObject(final ISharedObjectContainer soContainer, final ClientEntry client, final IResource proj, IUser user, String fileDir) throws Exception {
- final IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- final EclipseCollabSharedObject sharedObject = new EclipseCollabSharedObject(soContainer, proj, ww, user, fileDir);
+ final EclipseCollabSharedObject sharedObject = new EclipseCollabSharedObject(soContainer, proj, user, fileDir);
sharedObject.setListener(new SharedObjectEventListener() {
public void memberRemoved(ID member) {
final ID groupID = client.getContainer().getConnectedID();

Back to the top