Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsuen2008-12-14 04:13:52 -0500
committerrsuen2008-12-14 04:13:52 -0500
commitf2161b9cc18d6d443f23ae70ba284d88e3aecc8f (patch)
tree3b69db72e30cd381e48bb2dad65d6d750fac0811 /examples/bundles/org.eclipse.ecf.example.collab
parent2743d73c5244ef29253c56e31646d4a8004cc260 (diff)
downloadorg.eclipse.ecf-f2161b9cc18d6d443f23ae70ba284d88e3aecc8f.tar.gz
org.eclipse.ecf-f2161b9cc18d6d443f23ae70ba284d88e3aecc8f.tar.xz
org.eclipse.ecf-f2161b9cc18d6d443f23ae70ba284d88e3aecc8f.zip
Reuse the 'Messages' view.
Diffstat (limited to 'examples/bundles/org.eclipse.ecf.example.collab')
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/META-INF/MANIFEST.MF4
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/plugin.xml6
-rw-r--r--examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java74
3 files changed, 55 insertions, 29 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/META-INF/MANIFEST.MF b/examples/bundles/org.eclipse.ecf.example.collab/META-INF/MANIFEST.MF
index b10a3b812..248b3c308 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/META-INF/MANIFEST.MF
+++ b/examples/bundles/org.eclipse.ecf.example.collab/META-INF/MANIFEST.MF
@@ -25,9 +25,9 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ecf,
org.eclipse.ecf.sharedobject,
org.eclipse.ecf.discovery,
- org.eclipse.ecf.discovery.ui,
org.eclipse.ecf.presence,
org.eclipse.ecf.provider,
org.eclipse.ecf.ui,
- org.eclipse.ecf.server.generic
+ org.eclipse.ecf.server.generic,
+ org.eclipse.ecf.presence.ui
Bundle-ActivationPolicy: lazy
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/plugin.xml b/examples/bundles/org.eclipse.ecf.example.collab/plugin.xml
index 5a0f50ef7..7aa697798 100644
--- a/examples/bundles/org.eclipse.ecf.example.collab/plugin.xml
+++ b/examples/bundles/org.eclipse.ecf.example.collab/plugin.xml
@@ -123,12 +123,6 @@
relative="org.eclipse.ui.views.ProblemView"
visible="true">
</view>
- <view
- id="org.eclipse.ecf.example.collab.discoveryview"
- relationship="stack"
- relative="org.eclipse.ui.views.ProblemView"
- visible="true">
- </view>
</perspectiveExtension>
</extension>
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 b00d1f1e5..1b7bc9ea1 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
@@ -26,11 +26,10 @@ import org.eclipse.ecf.internal.example.collab.Messages;
import org.eclipse.ecf.internal.example.collab.presence.PresenceContainer;
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.*;
+import org.eclipse.ecf.presence.im.*;
import org.eclipse.ecf.presence.roster.*;
+import org.eclipse.ecf.presence.ui.MessagesView;
import org.eclipse.ecf.ui.screencapture.*;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
@@ -41,6 +40,7 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.*;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
public class EclipseCollabSharedObject extends GenericSharedObject {
/**
@@ -77,6 +77,7 @@ public class EclipseCollabSharedObject extends GenericSharedObject {
private IUser localUser = null;
private String localVersion = ""; //$NON-NLS-1$
private ID serverID = null;
+ private ID containerID;
private SharedObjectEventListener sharedObjectEventListener = null;
private PresenceContainer presenceContainer;
@@ -88,12 +89,59 @@ public class EclipseCollabSharedObject extends GenericSharedObject {
this.localResource = proj;
this.localUser = user;
this.downloadDirectory = downloaddir;
+
+ containerID = container.getID();
presenceContainer = new PresenceContainer(this, container, localUser);
+ presenceContainer.addMessageListener(new IIMMessageListener() {
+ public void handleMessageEvent(IIMMessageEvent messageEvent) {
+ if (messageEvent instanceof IChatMessageEvent) {
+ handleChatMessageEvent((IChatMessageEvent) messageEvent);
+ }
+ }
+ });
createOutputView();
Assert.isNotNull(localGUI, "Local GUI cannot be created...exiting"); //$NON-NLS-1$
}
+ void handleChatMessageEvent(final IChatMessageEvent event) {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ workbench.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ appendMessage(presenceContainer.getChatMessageSender(), presenceContainer.getTypingMessageSender(), event.getChatMessage());
+ }
+ });
+ }
+
+ void appendMessage(IChatMessageSender chatMessageSender, ITypingMessageSender typingMessageSender, IChatMessage message) {
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (int i = 0; i < windows.length; i++) {
+ IWorkbenchPage page = windows[i].getActivePage();
+ if (page != null) {
+ MessagesView view = (MessagesView) page.findView(MessagesView.VIEW_ID);
+ if (view == null) {
+ try {
+ view = (MessagesView) page.showView(MessagesView.VIEW_ID, null, IWorkbenchPage.VIEW_CREATE);
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return;
+ }
+ }
+
+ view.openTab(chatMessageSender, typingMessageSender, containerID, message.getFromID());
+ view.showMessage(message);
+
+ if (!page.isPartVisible(view)) {
+ IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) view.getSite().getService(IWorkbenchSiteProgressService.class);
+ if (service != null) {
+ service.warnOfContentChange();
+ }
+ }
+ }
+ }
+ }
+
public IPresenceContainerAdapter getPresenceContainer() {
return presenceContainer;
}
@@ -270,25 +318,9 @@ public class EclipseCollabSharedObject extends GenericSharedObject {
sendUserUpdate(requestor);
}
- protected void handleShowPrivateTextMsg(final IUser remote, final String aString) {
+ protected void handleShowPrivateTextMsg(IUser remote, 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() {
- try {
- if (localGUI != null) {
- final ChatLine line = new ChatLine(aString);
- line.setOriginator(remote);
- line.setPrivate(true);
- localGUI.showLine(line);
- localGUI.toFront();
- }
- } catch (final Exception e) {
- log("Exception in showLineOnGUI", e); //$NON-NLS-1$
- }
- }
- });
}
protected void handleShowTextMsg(ID remote, String aString) {

Back to the top