Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-05-04 06:18:53 +0000
committerslewis2007-05-04 06:18:53 +0000
commitfc9f693c7454fd7d9490b0c573d1fdceffa9c6e1 (patch)
tree2893e4772415fdc5dbe38af1fef695c6e9b382a1
parentda0350dc381b6cf01a1ebd05a2032e479dfed0b5 (diff)
downloadorg.eclipse.ecf-20070504-0834.tar.gz
org.eclipse.ecf-20070504-0834.tar.xz
org.eclipse.ecf-20070504-0834.zip
Small additions for url sharing. Also added synchronization primitives for xmpp providerv20070504-0834
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java2
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties2
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShare.java58
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShareRosterEntryContributionItem.java2
4 files changed, 49 insertions, 15 deletions
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java
index 9cb7fcd20..c7cb1ddfe 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java
@@ -21,6 +21,8 @@ public class Messages extends NLS {
public static String URLShare_ENTER_URL_DEFAULT_URL;
public static String URLShare_ENTER_URL_DIALOG_TEXT;
public static String URLShare_INPUT_URL_DIALOG_TITLE;
+ public static String URLShare_RECEIVED_URL_MESSAGE;
+ public static String URLShare_RECEIVED_URL_TITLE;
public static String URLShareRosterContributionItem_ADD_URL_SHARE_MENU_TEXT;
public static String URLShareRosterContributionItem_BROWSER_ICON;
public static String URLShareRosterContributionItem_REMOVE_URL_SHARE_MENU_TEXT;
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties
index eade3274f..9ae01ff82 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties
@@ -5,3 +5,5 @@ URLShareRosterContributionItem_REMOVE_URL_SHARE_MENU_TEXT=Remove URL Listener
URLShare_INPUT_URL_DIALOG_TITLE=Enter URL to Send
URLShare_ENTER_URL_DIALOG_TEXT=URL
URLShare_ENTER_URL_DEFAULT_URL=http://www.eclipse.org/ecf
+URLShare_RECEIVED_URL_TITLE=Received URL
+URLShare_RECEIVED_URL_MESSAGE=Received URL from {0}\n\nDo you want to display?
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShare.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShare.java
index 1cc84fbbd..9ae0d0e93 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShare.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShare.java
@@ -11,6 +11,10 @@
package org.eclipse.ecf.presence.collab.ui;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.net.URL;
import org.eclipse.core.runtime.Assert;
@@ -20,6 +24,8 @@ import org.eclipse.ecf.datashare.AbstractShare;
import org.eclipse.ecf.datashare.IChannelContainerAdapter;
import org.eclipse.ecf.internal.presence.collab.ui.Messages;
import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
@@ -44,24 +50,28 @@ public class URLShare extends AbstractShare {
return containerID;
}
- private void showURL(final String url) {
+ private void showURL(final String user, final String url) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- IWorkbenchBrowserSupport support = PlatformUI.getWorkbench()
- .getBrowserSupport();
- IWebBrowser browser;
- try {
- browser = support.createBrowser(null);
- browser.openURL(new URL(url));
- } catch (Exception e) {
- // TODO display error to user
- e.printStackTrace();
+ if (MessageDialog.openQuestion(null, Messages.URLShare_RECEIVED_URL_TITLE, NLS.bind(
+ Messages.URLShare_RECEIVED_URL_MESSAGE,
+ user))) {
+ IWorkbenchBrowserSupport support = PlatformUI.getWorkbench()
+ .getBrowserSupport();
+ IWebBrowser browser;
+ try {
+ browser = support.createBrowser(null);
+ browser.openURL(new URL(url));
+ } catch (Exception e) {
+ // TODO display error to user
+ e.printStackTrace();
+ }
}
}
});
}
- public void sendURL(final ID toID) {
+ public void sendURL(final String senderuser, final ID toID) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
InputDialog input = new InputDialog(null,
@@ -74,7 +84,8 @@ public class URLShare extends AbstractShare {
String send = input.getValue();
if (send != null && !send.equals("")) { //$NON-NLS-1$
try {
- sendMessage(toID, send.getBytes());
+ sendMessage(toID, serialize(new Object[] {
+ senderuser, send }));
} catch (Exception e) {
// TODO display error to user
}
@@ -89,11 +100,30 @@ public class URLShare extends AbstractShare {
URLShareRosterContributionItem.removeURLShare(containerID);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ecf.datashare.AbstractShare#handleChannelData(byte[])
*/
protected void handleMessage(ID fromContainerID, byte[] data) {
- showURL(new String(data));
+ try {
+ Object[] msg = (Object[]) deserialize(data);
+ showURL((String) msg[0], (String) msg[1]);
+ } catch (Exception e) {
+ // XXX show and/or log error
+ }
+ }
+
+ protected byte[] serialize(Object o) throws Exception {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeObject(o);
+ return bos.toByteArray();
}
+ protected Object deserialize(byte[] bytes) throws Exception {
+ ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
+ ObjectInputStream oins = new ObjectInputStream(bins);
+ return oins.readObject();
+ }
}
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShareRosterEntryContributionItem.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShareRosterEntryContributionItem.java
index ef6edad9d..4e9426bb3 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShareRosterEntryContributionItem.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/URLShareRosterEntryContributionItem.java
@@ -36,7 +36,7 @@ public class URLShareRosterEntryContributionItem extends
final URLShare urlshare = tmp;
IAction action = new Action() {
public void run() {
- urlshare.sendURL(entry.getUser().getID());
+ urlshare.sendURL(entry.getRoster().getUser().getName(),entry.getUser().getID());
}
};
action

Back to the top