Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-07-24 15:19:23 -0400
committerslewis2007-07-24 15:19:23 -0400
commitde610107980f0260b76f4fd3fa1eb1cc0c24328d (patch)
treeae8cd2f746382b1b5a7d7626ace4744c65f9ca09 /examples/bundles
parent22fe895434029ae433f5830be5baba8d02f5e783 (diff)
downloadorg.eclipse.ecf-de610107980f0260b76f4fd3fa1eb1cc0c24328d.tar.gz
org.eclipse.ecf-de610107980f0260b76f4fd3fa1eb1cc0c24328d.tar.xz
org.eclipse.ecf-de610107980f0260b76f4fd3fa1eb1cc0c24328d.zip
Initial checkin or org.eclipse.ecf.examples.webinar
Diffstat (limited to 'examples/bundles')
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/.classpath7
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/.project28
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/META-INF/MANIFEST.MF15
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/build.properties5
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/plugin.xml32
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/Activator.java50
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterEntryContributionItem1.java34
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterEntryContributionItem2.java161
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterViewerDropTarget1.java34
9 files changed, 366 insertions, 0 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/.classpath b/examples/bundles/org.eclipse.ecf.examples.webinar/.classpath
new file mode 100644
index 000000000..751c8f2e5
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/.project b/examples/bundles/org.eclipse.ecf.examples.webinar/.project
new file mode 100644
index 000000000..38f52137e
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.internal.examples.webinar</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/META-INF/MANIFEST.MF b/examples/bundles/org.eclipse.ecf.examples.webinar/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..d459a08cd
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ECF Webinar Plug-in
+Bundle-SymbolicName: org.eclipse.ecf.examples.webinar;singleton:=true
+Bundle-Version: 0.0.1.qualifier
+Bundle-Activator: org.eclipse.ecf.internal.examples.webinar.Activator
+Bundle-Vendor: Eclipse.org
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ecf,
+ org.eclipse.ecf.datashare,
+ org.eclipse.ecf.remoteservice,
+ org.eclipse.ecf.presence,
+ org.eclipse.ecf.presence.ui
+Eclipse-LazyStart: true
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/build.properties b/examples/bundles/org.eclipse.ecf.examples.webinar/build.properties
new file mode 100644
index 000000000..e9863e281
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/plugin.xml b/examples/bundles/org.eclipse.ecf.examples.webinar/plugin.xml
new file mode 100644
index 000000000..add8b12bf
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/plugin.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.ecf.presence.ui.MultiRosterView?before=additions">
+ <dynamic
+ class="org.eclipse.ecf.internal.examples.webinar.RosterEntryContributionItem1"
+ id="org.eclipse.ecf.examples.webinar.dynamic1">
+ </dynamic>
+ </menuContribution>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.ecf.presence.ui.MultiRosterView?before=additions">
+ <dynamic
+ class="org.eclipse.ecf.internal.examples.webinar.RosterEntryContributionItem2"
+ id="org.eclipse.ecf.examples.webinar.dynamic2">
+ </dynamic>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ecf.presence.ui.rosterViewerDropTarget">
+ <dropTarget
+ class="org.eclipse.ecf.internal.examples.webinar.RosterViewerDropTarget1">
+ </dropTarget>
+ </extension>
+
+</plugin>
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/Activator.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/Activator.java
new file mode 100644
index 000000000..64df2b6bf
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/Activator.java
@@ -0,0 +1,50 @@
+package org.eclipse.ecf.internal.examples.webinar;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.ecf.internal.examples.webinar";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterEntryContributionItem1.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterEntryContributionItem1.java
new file mode 100644
index 000000000..8e9a76bf0
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterEntryContributionItem1.java
@@ -0,0 +1,34 @@
+package org.eclipse.ecf.internal.examples.webinar;
+
+import org.eclipse.ecf.presence.roster.IRosterEntry;
+import org.eclipse.ecf.presence.ui.roster.AbstractRosterEntryContributionItem;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+public class RosterEntryContributionItem1 extends AbstractRosterEntryContributionItem {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.presence.ui.roster.AbstractPresenceContributionItem#makeActions()
+ */
+ protected IAction[] makeActions() {
+ IAction action = null;
+ IRosterEntry entry = getSelectedRosterEntry();
+ if (entry != null) {
+ action = new Action() {
+ public void run() {
+ IRosterEntry rosterEntry = getSelectedRosterEntry();
+ System.out.println("running action for roster entry "+rosterEntry.getName());
+ }
+ };
+ action.setText("Send info to "+getSelectedRosterEntry().getName());
+ action.setImageDescriptor(PlatformUI.getWorkbench()
+ .getSharedImages().getImageDescriptor(
+ ISharedImages.IMG_DEF_VIEW));
+ return new IAction[] { action };
+ }
+ return null;
+ }
+
+}
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterEntryContributionItem2.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterEntryContributionItem2.java
new file mode 100644
index 000000000..e1f6e98ff
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterEntryContributionItem2.java
@@ -0,0 +1,161 @@
+package org.eclipse.ecf.internal.examples.webinar;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.datashare.IChannel;
+import org.eclipse.ecf.datashare.IChannelContainerAdapter;
+import org.eclipse.ecf.datashare.IChannelListener;
+import org.eclipse.ecf.datashare.events.IChannelEvent;
+import org.eclipse.ecf.datashare.events.IChannelMessageEvent;
+import org.eclipse.ecf.presence.roster.IRosterEntry;
+import org.eclipse.ecf.presence.ui.roster.AbstractRosterEntryContributionItem;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+
+public class RosterEntryContributionItem2 extends
+ AbstractRosterEntryContributionItem {
+
+ private static Map channels = new HashMap();
+
+ public RosterEntryContributionItem2() {
+ super();
+ }
+
+ private IChannel initializeChannelFor(IContainer container) {
+ if (container == null) return null;
+ ID containerID = container.getID();
+ IChannel chan = (IChannel) channels.get(containerID);
+ if (chan == null) {
+ IChannelContainerAdapter adapter = (IChannelContainerAdapter) container
+ .getAdapter(IChannelContainerAdapter.class);
+ if (adapter != null) {
+ chan = createChannel(adapter);
+ channels.put(containerID,chan);
+ }
+ }
+ return chan;
+ }
+
+ public void dispose() {
+ super.dispose();
+ for(Iterator i=channels.keySet().iterator(); i.hasNext(); ) {
+ IChannel chan = (IChannel) channels.get(i.next());
+ chan.dispose();
+ }
+ channels.clear();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.presence.ui.roster.AbstractPresenceContributionItem#makeActions()
+ */
+ protected IAction[] makeActions() {
+ IAction action = null;
+ IRosterEntry rosterEntry = getSelectedRosterEntry();
+ if (rosterEntry != null) {
+ if (initializeChannelFor(getContainerForRosterEntry(rosterEntry)) != null) {
+ action = new Action() {
+ public void run() {
+ sendDataToChannel(getSelectedRosterEntry());
+ }
+
+ };
+ action
+ .setText("Send Object Array");
+ action.setImageDescriptor(PlatformUI.getWorkbench()
+ .getSharedImages().getImageDescriptor(
+ ISharedImages.IMG_DEF_VIEW));
+ return new IAction[] { action };
+ }
+ }
+ return null;
+ }
+
+ private void sendDataToChannel(IRosterEntry rosterEntry) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeObject(new String[] { "Hi " + rosterEntry.getName(),
+ "http://www.eclipse.org/ecf" });
+ IChannel channel = initializeChannelFor(getContainerForRosterEntry(rosterEntry));
+ channel.sendMessage(rosterEntry.getUser().getID(), bos
+ .toByteArray());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ private void receiveDataFromChannel(byte[] data) {
+ try {
+ ByteArrayInputStream bins = new ByteArrayInputStream(data);
+ ObjectInputStream oos = new ObjectInputStream(bins);
+ String[] received = (String[]) oos.readObject();
+ show(received[0], received[1]);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ private IChannel createChannel(IChannelContainerAdapter adapter) {
+ try {
+ return adapter.createChannel(IDFactory.getDefault().createStringID(
+ "mychannel"), new IChannelListener() {
+ public void handleChannelEvent(IChannelEvent event) {
+ if (event instanceof IChannelMessageEvent) {
+ receiveDataFromChannel(((IChannelMessageEvent) event)
+ .getData());
+ }
+ }
+
+ }, null);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private void show(final String string, final String url) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (MessageDialog.openConfirm(null, "Received message", string
+ + ". Show URL?"))
+ showURL(url);
+ }
+ });
+ }
+
+ private void showURL(String string) {
+ IWorkbenchBrowserSupport support = PlatformUI.getWorkbench()
+ .getBrowserSupport();
+ IWebBrowser browser;
+ try {
+ browser = support.createBrowser(null);
+ browser.openURL(new URL(string));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterViewerDropTarget1.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterViewerDropTarget1.java
new file mode 100644
index 000000000..4631cb592
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/RosterViewerDropTarget1.java
@@ -0,0 +1,34 @@
+package org.eclipse.ecf.internal.examples.webinar;
+
+import org.eclipse.ecf.presence.roster.IRosterEntry;
+import org.eclipse.ecf.presence.roster.IRosterItem;
+import org.eclipse.ecf.presence.ui.dnd.IRosterViewerDropTarget;
+import org.eclipse.swt.dnd.TransferData;
+public class RosterViewerDropTarget1 implements IRosterViewerDropTarget {
+
+ protected TransferData transferData = null;
+ protected IRosterEntry rosterEntry = null;
+
+ public boolean performDrop(Object data) {
+ if (data instanceof String) {
+ System.out.println("performDrop("+data+") to "+rosterEntry.getName());
+ // Right here, send data to channel
+ // sendString(rosterEntry.getUser().getID(),(String) data);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean validateDrop(IRosterItem rosterItem, int operation,
+ TransferData transferType) {
+ if (rosterItem instanceof IRosterEntry) {
+ transferData = transferType;
+ return true;
+ } else {
+ transferData = null;
+ rosterEntry = null;
+ }
+ return false;
+ }
+
+}

Back to the top