Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-07-28 20:37:21 -0400
committerslewis2007-07-28 20:37:21 -0400
commit2f0cf90b7a8c71befc882c3574c6e6c805e9120f (patch)
tree1a001cc7b8f67a0d1a800b691f8afa89b8cb5a50 /examples
parent0c7eed210d996e8636415815e4bee894b0fcbf9c (diff)
downloadorg.eclipse.ecf-2f0cf90b7a8c71befc882c3574c6e6c805e9120f.tar.gz
org.eclipse.ecf-2f0cf90b7a8c71befc882c3574c6e6c805e9120f.tar.xz
org.eclipse.ecf-2f0cf90b7a8c71befc882c3574c6e6c805e9120f.zip
Changes to webinar example code
Diffstat (limited to 'examples')
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/plugin.xml18
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/dnd/RosterEntryDropTarget.java (renamed from examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/dnd/RosterViewerDropTarget1.java)26
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/RosterWriterHelper.java (renamed from examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/RosterWriter.java)6
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/roster/ShowSelectedRosterContribution.java (renamed from examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/roster/RosterContributionItem1.java)8
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterentry/RosterEntryContributionItem1.java32
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterentry/SendMessageRosterEntryContribution.java (renamed from examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterentry/RosterEntryContributionItem2.java)9
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterview/ShowAllRostersContribution.java (renamed from examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterview/RosterViewContributionItem1.java)36
7 files changed, 57 insertions, 78 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/plugin.xml b/examples/bundles/org.eclipse.ecf.examples.webinar/plugin.xml
index a69921d18..c201f7bf9 100644
--- a/examples/bundles/org.eclipse.ecf.examples.webinar/plugin.xml
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/plugin.xml
@@ -1,23 +1,13 @@
<?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.util.rosterentry.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.util.rosterentry.RosterEntryContributionItem2"
+ class="org.eclipse.ecf.internal.examples.webinar.util.rosterentry.SendMessageRosterEntryContribution"
id="org.eclipse.ecf.examples.webinar.dynamic2">
</dynamic>
</menuContribution>
@@ -28,7 +18,7 @@
<menuContribution
locationURI="popup:org.eclipse.ecf.presence.ui.MultiRosterView?before=additions">
<dynamic
- class="org.eclipse.ecf.internal.examples.webinar.util.roster.RosterContributionItem1"
+ class="org.eclipse.ecf.internal.examples.webinar.util.roster.ShowSelectedRosterContribution"
id="org.eclipse.ecf.examples.webinar.dynamic3">
</dynamic>
</menuContribution>
@@ -39,7 +29,7 @@
<menuContribution
locationURI="menu:org.eclipse.ecf.presence.ui.MultiRosterView?after=additions">
<dynamic
- class="org.eclipse.ecf.internal.examples.webinar.util.rosterview.RosterViewContributionItem1"
+ class="org.eclipse.ecf.internal.examples.webinar.util.rosterview.ShowAllRostersContribution"
id="org.eclipse.ecf.examples.webinar.dynamic4">
</dynamic>
</menuContribution>
@@ -48,7 +38,7 @@
<extension
point="org.eclipse.ecf.presence.ui.rosterViewerDropTarget">
<dropTarget
- class="org.eclipse.ecf.internal.examples.webinar.dnd.RosterViewerDropTarget1">
+ class="org.eclipse.ecf.internal.examples.webinar.dnd.RosterEntryDropTarget">
</dropTarget>
</extension>
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/dnd/RosterViewerDropTarget1.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/dnd/RosterEntryDropTarget.java
index 259c6177a..627ab8a74 100644
--- a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/dnd/RosterViewerDropTarget1.java
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/dnd/RosterEntryDropTarget.java
@@ -3,21 +3,13 @@ package org.eclipse.ecf.internal.examples.webinar.dnd;
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.jface.dialogs.MessageDialog;
import org.eclipse.swt.dnd.TransferData;
-public class RosterViewerDropTarget1 implements IRosterViewerDropTarget {
+
+public class RosterEntryDropTarget 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) {
@@ -31,4 +23,16 @@ public class RosterViewerDropTarget1 implements IRosterViewerDropTarget {
return false;
}
+ public boolean performDrop(Object data) {
+ if (data instanceof String) {
+ // Right here, send data to channel
+ // sendString(rosterEntry.getUser().getID(),(String) data);
+ MessageDialog.openInformation(null, "Dropped on Contact",
+ "The following text was dropped on "
+ + rosterEntry.getUser().getName() + ":\n\n" + data);
+ return true;
+ }
+ return false;
+ }
+
}
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/RosterWriter.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/RosterWriterHelper.java
index 931f93537..81ccf314e 100644
--- a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/RosterWriter.java
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/RosterWriterHelper.java
@@ -27,7 +27,7 @@ import org.eclipse.ecf.presence.roster.IRosterItem;
/**
* Chat with me about this at: xmpp://fliwatuet@ecf.eclipse.org
*/
-public class RosterWriter {
+public class RosterWriterHelper {
private IContainer[] getContainers() {
return Activator.getDefault().getContainers();
@@ -46,7 +46,7 @@ public class RosterWriter {
return (Object []) l.toArray();
}
- public void showAllRosters() {
+ public void writeAllRostersToConsole() {
Object [] adapters = getConnectedContainerAdapters(IPresenceContainerAdapter.class);
for(int i=0; i < adapters.length; i++) {
IPresenceContainerAdapter presenceAdapter = (IPresenceContainerAdapter) adapters[i];
@@ -54,7 +54,7 @@ public class RosterWriter {
}
}
- public void showRoster(IRoster roster) {
+ public void writeRosterToConsole(IRoster roster) {
showRosterItems(roster);
}
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/roster/RosterContributionItem1.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/roster/ShowSelectedRosterContribution.java
index 882a103b6..1786cecb5 100644
--- a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/roster/RosterContributionItem1.java
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/roster/ShowSelectedRosterContribution.java
@@ -1,6 +1,6 @@
package org.eclipse.ecf.internal.examples.webinar.util.roster;
-import org.eclipse.ecf.internal.examples.webinar.util.RosterWriter;
+import org.eclipse.ecf.internal.examples.webinar.util.RosterWriterHelper;
import org.eclipse.ecf.presence.roster.IRoster;
import org.eclipse.ecf.presence.ui.roster.AbstractRosterContributionItem;
import org.eclipse.jface.action.Action;
@@ -8,7 +8,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
-public class RosterContributionItem1 extends AbstractRosterContributionItem {
+public class ShowSelectedRosterContribution extends AbstractRosterContributionItem {
/* (non-Javadoc)
* @see org.eclipse.ecf.presence.ui.roster.AbstractPresenceContributionItem#makeActions()
@@ -18,8 +18,8 @@ public class RosterContributionItem1 extends AbstractRosterContributionItem {
if (roster != null) {
IAction action = new Action() {
public void run() {
- RosterWriter accessor = new RosterWriter();
- accessor.showRoster(roster);
+ // Write selected roster to console
+ new RosterWriterHelper().writeRosterToConsole(roster);
}
};
action.setText("Show this roster on console");
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterentry/RosterEntryContributionItem1.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterentry/RosterEntryContributionItem1.java
deleted file mode 100644
index 85e1f7a7a..000000000
--- a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterentry/RosterEntryContributionItem1.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.eclipse.ecf.internal.examples.webinar.util.rosterentry;
-
-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() {
- final IRosterEntry entry = getSelectedRosterEntry();
- if (entry != null) {
- IAction action = new Action() {
- public void run() {
- System.out.println("running action for "+entry.getName());
- }
- };
- action.setText("Super duper addon");
- 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/util/rosterentry/RosterEntryContributionItem2.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterentry/SendMessageRosterEntryContribution.java
index cff764f81..16d0d7843 100644
--- a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterentry/RosterEntryContributionItem2.java
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterentry/SendMessageRosterEntryContribution.java
@@ -28,9 +28,11 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
-public class RosterEntryContributionItem2 extends
+public class SendMessageRosterEntryContribution extends
AbstractRosterEntryContributionItem {
+ private static final String CHANNELID = "mychannel";
+
/*
* (non-Javadoc)
*
@@ -75,8 +77,7 @@ public class RosterEntryContributionItem2 extends
private void receiveDataFromChannel(byte[] data) {
try {
- ByteArrayInputStream bins = new ByteArrayInputStream(data);
- ObjectInputStream oos = new ObjectInputStream(bins);
+ ObjectInputStream oos = new ObjectInputStream(new ByteArrayInputStream(data));
String[] received = (String[]) oos.readObject();
showMessageAndURL(received[0], received[1]);
} catch (Exception e) {
@@ -116,7 +117,7 @@ public class RosterEntryContributionItem2 extends
private IChannel createChannel(IChannelContainerAdapter adapter) {
try {
return adapter.createChannel(IDFactory.getDefault().createStringID(
- "mychannel"), new IChannelListener() {
+ CHANNELID), new IChannelListener() {
public void handleChannelEvent(IChannelEvent event) {
if (event instanceof IChannelMessageEvent) {
receiveDataFromChannel(((IChannelMessageEvent) event)
diff --git a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterview/RosterViewContributionItem1.java b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterview/ShowAllRostersContribution.java
index ed61be289..50244d6bf 100644
--- a/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterview/RosterViewContributionItem1.java
+++ b/examples/bundles/org.eclipse.ecf.examples.webinar/src/org/eclipse/ecf/internal/examples/webinar/util/rosterview/ShowAllRostersContribution.java
@@ -11,7 +11,13 @@
package org.eclipse.ecf.internal.examples.webinar.util.rosterview;
-import org.eclipse.ecf.internal.examples.webinar.util.RosterWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.internal.examples.webinar.Activator;
+import org.eclipse.ecf.internal.examples.webinar.util.RosterWriterHelper;
+import org.eclipse.ecf.presence.IPresenceContainerAdapter;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
@@ -21,24 +27,34 @@ import org.eclipse.ui.actions.CompoundContributionItem;
/**
*
*/
-public class RosterViewContributionItem1 extends CompoundContributionItem {
+public class ShowAllRostersContribution extends CompoundContributionItem {
/* (non-Javadoc)
* @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
*/
protected IContributionItem[] getContributionItems() {
- return new IContributionItem[] { new ActionContributionItem(getAction()) };
- }
-
- private IAction getAction() {
IAction action = new Action() {
public void run() {
- System.out.println("showing rosters on console");
- RosterWriter writer = new RosterWriter();
- writer.showAllRosters();
+ // Get containers from container manager
+ IContainer [] containers = Activator.getDefault().getContainers();
+ List l = new ArrayList();
+ for(int i=0; i < containers.length; i++) {
+ // Make sure the container is connected
+ if (containers[i].getConnectedID() != null) {
+ // Make sure container implements IPresenceContainerAdapter API
+ Object o = containers[i].getAdapter(IPresenceContainerAdapter.class);
+ if (o != null) l.add(o);
+ }
+ }
+ IPresenceContainerAdapter [] adapters = (IPresenceContainerAdapter []) l.toArray(new IPresenceContainerAdapter[] {});
+ for(int i=0; i < adapters.length; i++) {
+ // Show all rosters on console...or do other things with it here.
+ new RosterWriterHelper().writeRosterToConsole(adapters[i].getRosterManager().getRoster());
+ }
}
};
action.setText("show all rosters on console");
- return action;
+ return new IContributionItem[] { new ActionContributionItem(action) };
}
+
}

Back to the top