summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-08 08:31:15 (EDT)
committerEike Stepper2007-10-08 08:31:15 (EDT)
commit8fcb2db1feadc46b0a5e99e4b4585b40c4e69e60 (patch)
tree9e51ac43be245aec9d37205f8da7f48ba8884bf3
parent4f8972b433a7a4cba71c7fcd9c9aa92b858880b4 (diff)
downloadcdo-8fcb2db1feadc46b0a5e99e4b4585b40c4e69e60.zip
cdo-8fcb2db1feadc46b0a5e99e4b4585b40c4e69e60.tar.gz
cdo-8fcb2db1feadc46b0a5e99e4b4585b40c4e69e60.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
index 1fc0fa4..0851161 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
@@ -9,6 +9,7 @@ import org.eclipse.net4j.buddies.internal.ui.bundle.OM;
import org.eclipse.net4j.buddies.protocol.IBuddy;
import org.eclipse.net4j.buddies.protocol.IBuddy.State;
import org.eclipse.net4j.internal.buddies.Self;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.container.IContainerDelta;
@@ -25,6 +26,7 @@ import org.eclipse.net4j.util.ui.views.ContainerView;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
public class BuddiesView extends ContainerView implements IListener
{
@@ -32,6 +34,8 @@ public class BuddiesView extends ContainerView implements IListener
private DisconnectAction disconnectAction = new DisconnectAction();
+ private FlashAction flashAction = new FlashAction();
+
private StateAction availableAction = new StateAction("Available", State.AVAILABLE, SharedIcons.OBJ_BUDDY);
private StateAction lonesomeAction = new StateAction("Lonesome", State.LONESOME, SharedIcons.OBJ_BUDDY_LONESOME);
@@ -45,6 +49,8 @@ public class BuddiesView extends ContainerView implements IListener
private boolean connecting;
+ private boolean flashing;
+
public BuddiesView()
{
if (isAutoConnect())
@@ -234,6 +240,8 @@ public class BuddiesView extends ContainerView implements IListener
{
manager.add(connectAction);
manager.add(disconnectAction);
+ manager.add(new Separator());
+ manager.add(flashAction);
super.fillLocalPullDown(manager);
}
@@ -296,4 +304,42 @@ public class BuddiesView extends ContainerView implements IListener
}
}
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class FlashAction extends SafeAction
+ {
+ private FlashAction()
+ {
+ super("Flash Me", "Flash Me");
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ if (session != null && !flashing)
+ {
+ final Self self = (Self)session.getSelf();
+ final State original = self.getState();
+ new Thread("buddies-flasher")
+ {
+ @Override
+ public void run()
+ {
+ flashing = true;
+ IBuddy.State state = original == IBuddy.State.AVAILABLE ? IBuddy.State.LONESOME : IBuddy.State.AVAILABLE;
+ for (int i = 0; i < 10; i++)
+ {
+ self.setState(state);
+ ConcurrencyUtil.sleep(400);
+ }
+
+ self.setState(original);
+ flashing = false;
+ }
+ }.start();
+ }
+ }
+ }
} \ No newline at end of file