summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-08 04:43:58 (EDT)
committerEike Stepper2007-10-08 04:43:58 (EDT)
commitce24a6efc8b85f7f3ad0083ea2bd87bf058741df (patch)
treebe9beda3b2133268ce43c916fd494ca1bd87cc9b
parentf820ac2cc3aa2ca04f94a39635c5c180b86726d8 (diff)
downloadcdo-ce24a6efc8b85f7f3ad0083ea2bd87bf058741df.zip
cdo-ce24a6efc8b85f7f3ad0083ea2bd87bf058741df.tar.gz
cdo-ce24a6efc8b85f7f3ad0083ea2bd87bf058741df.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.java56
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Buddy.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddySession.java4
3 files changed, 51 insertions, 13 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 532a6d4..e347461 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
@@ -4,7 +4,11 @@ import org.eclipse.net4j.IConnector;
import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.buddies.BuddiesUtil;
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.IBuddy.State;
+import org.eclipse.net4j.internal.buddies.Self;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.event.IEvent;
@@ -15,6 +19,7 @@ import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
import org.eclipse.net4j.util.ui.views.ContainerView;
import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
public class BuddiesView extends ContainerView implements IListener
{
@@ -22,6 +27,13 @@ public class BuddiesView extends ContainerView implements IListener
private DisconnectAction disconnectAction = new DisconnectAction();
+ private StateAction availableAction = new StateAction("Available", State.AVAILABLE, SharedIcons.OBJ_BUDDY);
+
+ private StateAction awayAction = new StateAction("Away", State.AWAY, SharedIcons.OBJ_BUDDY_AWAY);
+
+ private StateAction doNotDisturbAction = new StateAction("Do Not Disturb", State.DO_NOT_DISTURB,
+ SharedIcons.OBJ_BUDDY_DO_NOT_DISTURB);
+
private IBuddySession session;
private boolean connecting;
@@ -68,6 +80,12 @@ public class BuddiesView extends ContainerView implements IListener
session.addListener(BuddiesView.this);
connectAction.setEnabled(false);
disconnectAction.setEnabled(true);
+ availableAction.setEnabled(true);
+ availableAction.setChecked(session.getSelf().getState() == IBuddy.State.AVAILABLE);
+ awayAction.setEnabled(true);
+ awayAction.setChecked(session.getSelf().getState() == IBuddy.State.AWAY);
+ doNotDisturbAction.setEnabled(true);
+ doNotDisturbAction.setChecked(session.getSelf().getState() == IBuddy.State.DO_NOT_DISTURB);
}
else
{
@@ -93,6 +111,9 @@ public class BuddiesView extends ContainerView implements IListener
connecting = false;
connectAction.setEnabled(true);
disconnectAction.setEnabled(false);
+ availableAction.setEnabled(false);
+ awayAction.setEnabled(false);
+ doNotDisturbAction.setEnabled(false);
}
@Override
@@ -160,13 +181,10 @@ public class BuddiesView extends ContainerView implements IListener
{
manager.add(connectAction);
manager.add(disconnectAction);
- if (session == null && !connecting)
- {
- }
- else
- {
- }
-
+ manager.add(new Separator());
+ manager.add(availableAction);
+ manager.add(awayAction);
+ manager.add(doNotDisturbAction);
super.fillLocalPullDown(manager);
}
@@ -203,4 +221,28 @@ public class BuddiesView extends ContainerView implements IListener
disconnect();
}
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class StateAction extends SafeAction
+ {
+ private State state;
+
+ private StateAction(String text, State state, String key)
+ {
+ super(text, "Set own state to '" + text.toLowerCase() + "'", SharedIcons.getDescriptor(key));
+ this.state = state;
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ if (session != null)
+ {
+ Self self = (Self)session.getSelf();
+ self.setState(state);
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Buddy.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Buddy.java
index 1228c27..aa237d3 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Buddy.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Buddy.java
@@ -30,10 +30,6 @@ public class Buddy extends AbstractBuddy
this.userID = userID;
}
- protected Buddy(BuddySession session, IBuddyAccount account)
- {
- }
-
public BuddySession getSession()
{
return session;
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddySession.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddySession.java
index 9a3c718..45b6d1a 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddySession.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddySession.java
@@ -32,7 +32,7 @@ public class BuddySession extends Lifecycle implements IBuddySession, IListener
{
private IChannel channel;
- private IBuddy self;
+ private Self self;
private Map<String, IBuddy> buddies = new HashMap<String, IBuddy>();
@@ -53,7 +53,7 @@ public class BuddySession extends Lifecycle implements IBuddySession, IListener
public void setSelf(IBuddyAccount account)
{
- this.self = new Buddy(this, account);
+ this.self = new Self(this, account);
}
public IBuddy addBuddy(String userID)