summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-08 08:41:09 (EDT)
committerEike Stepper2007-10-08 08:41:09 (EDT)
commitba710a318756d18be5f219ce9977d986b4cb5d3b (patch)
tree6543e24c49a9107bcfa96de94e63590fc84136c9
parent05342ed8d0b12893bb0d9f70d363841707510fc7 (diff)
downloadcdo-ba710a318756d18be5f219ce9977d986b4cb5d3b.zip
cdo-ba710a318756d18be5f219ce9977d986b4cb5d3b.tar.gz
cdo-ba710a318756d18be5f219ce9977d986b4cb5d3b.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.java42
1 files changed, 27 insertions, 15 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 21ab08f..b67a454 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
@@ -7,6 +7,7 @@ import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.ui.SharedIcons;
import org.eclipse.net4j.buddies.internal.ui.bundle.OM;
import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.IBuddyStateChangedEvent;
import org.eclipse.net4j.buddies.protocol.IBuddy.State;
import org.eclipse.net4j.internal.buddies.Self;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
@@ -96,15 +97,10 @@ public class BuddiesView extends ContainerView implements IListener
resetInput();
connectAction.setEnabled(false);
disconnectAction.setEnabled(true);
- availableAction.setEnabled(true);
- availableAction.setChecked(session.getSelf().getState() == IBuddy.State.AVAILABLE);
- lonesomeAction.setEnabled(true);
- lonesomeAction.setChecked(session.getSelf().getState() == IBuddy.State.LONESOME);
- awayAction.setEnabled(true);
- awayAction.setChecked(session.getSelf().getState() == IBuddy.State.AWAY);
- doNotDisturbAction.setEnabled(true);
- doNotDisturbAction.setChecked(session.getSelf().getState() == IBuddy.State.DO_NOT_DISTURB);
+ flashAction.setEnabled(true);
+ updateState();
session.addListener(BuddiesView.this);
+ session.getSelf().addListener(BuddiesView.this);
}
else
{
@@ -130,6 +126,7 @@ public class BuddiesView extends ContainerView implements IListener
protected void disconnect()
{
connecting = false;
+ session.getSelf().removeListener(BuddiesView.this);
session.removeListener(this);
session.close();
session = null;
@@ -137,6 +134,7 @@ public class BuddiesView extends ContainerView implements IListener
connectAction.setEnabled(true);
disconnectAction.setEnabled(false);
+ flashAction.setEnabled(false);
availableAction.setEnabled(false);
availableAction.setChecked(false);
lonesomeAction.setEnabled(false);
@@ -182,11 +180,13 @@ public class BuddiesView extends ContainerView implements IListener
}
}
}
- // else if (event instanceof IBuddyStateChangedEvent)
- // {
- // IBuddyStateChangedEvent e = (IBuddyStateChangedEvent)event;
- // updateLabels(e.getBuddy());
- // }
+ else if (event instanceof IBuddyStateChangedEvent)
+ {
+ if (session != null && event.getSource() == session.getSelf())
+ {
+ updateState();
+ }
+ }
}
protected void closeView()
@@ -245,6 +245,18 @@ public class BuddiesView extends ContainerView implements IListener
super.fillLocalPullDown(manager);
}
+ protected void updateState()
+ {
+ availableAction.setEnabled(true);
+ availableAction.setChecked(session.getSelf().getState() == IBuddy.State.AVAILABLE);
+ lonesomeAction.setEnabled(true);
+ lonesomeAction.setChecked(session.getSelf().getState() == IBuddy.State.LONESOME);
+ awayAction.setEnabled(true);
+ awayAction.setChecked(session.getSelf().getState() == IBuddy.State.AWAY);
+ doNotDisturbAction.setEnabled(true);
+ doNotDisturbAction.setChecked(session.getSelf().getState() == IBuddy.State.DO_NOT_DISTURB);
+ }
+
/**
* @author Eike Stepper
*/
@@ -329,10 +341,10 @@ public class BuddiesView extends ContainerView implements IListener
{
flashing = true;
IBuddy.State state = original == IBuddy.State.AVAILABLE ? IBuddy.State.LONESOME : IBuddy.State.AVAILABLE;
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i < 15; i++)
{
self.setState(state);
- ConcurrencyUtil.sleep(400);
+ ConcurrencyUtil.sleep(200);
state = state == IBuddy.State.AVAILABLE ? IBuddy.State.LONESOME : IBuddy.State.AVAILABLE;
}