summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-11 02:32:15 (EDT)
committerEike Stepper2007-10-11 02:32:15 (EDT)
commita092037c944b894b40a32878a343a44531f9423a (patch)
tree329a4ea30dcb7af3acf8f3f9c283b537adcf092f
parentfeb875377d73d2f89d9feae7666f1c2ce73475f8 (diff)
downloadcdo-a092037c944b894b40a32878a343a44531f9423a.zip
cdo-a092037c944b894b40a32878a343a44531f9423a.tar.gz
cdo-a092037c944b894b40a32878a343a44531f9423a.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/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/ConnectAction.java21
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/DisconnectAction.java21
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/FlashAction.java21
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/StateAction.java69
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java84
6 files changed, 137 insertions, 80 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.buddies.ui/META-INF/MANIFEST.MF
index de91d06..f3e83f2 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.buddies.ui/META-INF/MANIFEST.MF
@@ -15,6 +15,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.net4j.util.ui;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
org.eclipse.net4j.buddies;bundle-version="[0.8.0,0.9.0)";visibility:=reexport
Export-Package: org.eclipse.net4j.buddies.internal.ui;version="0.8.0",
+ org.eclipse.net4j.buddies.internal.ui.actions;version="0.8.0",
org.eclipse.net4j.buddies.internal.ui.preferences;version="0.8.0",
org.eclipse.net4j.buddies.internal.ui.views;version="0.8.0",
org.eclipse.net4j.buddies.ui;version="0.8.0"
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/ConnectAction.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/ConnectAction.java
new file mode 100644
index 0000000..d53b671
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/ConnectAction.java
@@ -0,0 +1,21 @@
+package org.eclipse.net4j.buddies.internal.ui.actions;
+
+import org.eclipse.net4j.buddies.ui.IBuddiesManager;
+import org.eclipse.net4j.util.ui.actions.SafeAction;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ConnectAction extends SafeAction
+{
+ public ConnectAction()
+ {
+ super("Connect", "Connect to buddies server");
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ IBuddiesManager.INSTANCE.connect();
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/DisconnectAction.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/DisconnectAction.java
new file mode 100644
index 0000000..1831a15
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/DisconnectAction.java
@@ -0,0 +1,21 @@
+package org.eclipse.net4j.buddies.internal.ui.actions;
+
+import org.eclipse.net4j.buddies.ui.IBuddiesManager;
+import org.eclipse.net4j.util.ui.actions.SafeAction;
+
+/**
+ * @author Eike Stepper
+ */
+public final class DisconnectAction extends SafeAction
+{
+ public DisconnectAction()
+ {
+ super("Disonnect", "Disconnect from buddies server");
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ IBuddiesManager.INSTANCE.disconnect();
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/FlashAction.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/FlashAction.java
new file mode 100644
index 0000000..db6f28a
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/FlashAction.java
@@ -0,0 +1,21 @@
+package org.eclipse.net4j.buddies.internal.ui.actions;
+
+import org.eclipse.net4j.buddies.ui.IBuddiesManager;
+import org.eclipse.net4j.util.ui.actions.SafeAction;
+
+/**
+ * @author Eike Stepper
+ */
+public final class FlashAction extends SafeAction
+{
+ public FlashAction()
+ {
+ super("Flash Me", "Flash Me");
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ IBuddiesManager.INSTANCE.flashMe();
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/StateAction.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/StateAction.java
new file mode 100644
index 0000000..ebdd0bf
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/StateAction.java
@@ -0,0 +1,69 @@
+package org.eclipse.net4j.buddies.internal.ui.actions;
+
+import org.eclipse.net4j.buddies.IBuddySession;
+import org.eclipse.net4j.buddies.internal.ui.SharedIcons;
+import org.eclipse.net4j.buddies.protocol.IBuddy.State;
+import org.eclipse.net4j.buddies.ui.IBuddiesManager;
+import org.eclipse.net4j.internal.buddies.Self;
+import org.eclipse.net4j.util.ui.actions.SafeAction;
+
+import org.eclipse.jface.action.Action;
+
+/**
+ * @author Eike Stepper
+ */
+public class StateAction extends SafeAction
+{
+ private State state;
+
+ public StateAction(String text, State state, String key)
+ {
+ super(text, Action.AS_RADIO_BUTTON);
+ setToolTipText("Set own state to '" + text.toLowerCase() + "'");
+ setImageDescriptor(SharedIcons.getDescriptor(key));
+ this.state = state;
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ IBuddySession session = IBuddiesManager.INSTANCE.getSession();
+ if (session != null && isChecked())
+ {
+ Self self = (Self)session.getSelf();
+ self.setState(state);
+ }
+ }
+
+ public static final class AvailableAction extends StateAction
+ {
+ public AvailableAction()
+ {
+ super("Available", State.AVAILABLE, SharedIcons.OBJ_BUDDY);
+ }
+ }
+
+ public static final class LonesomeAction extends StateAction
+ {
+ public LonesomeAction()
+ {
+ super("Lonesome", State.LONESOME, SharedIcons.OBJ_BUDDY_LONESOME);
+ }
+ }
+
+ public static final class AwayAction extends StateAction
+ {
+ public AwayAction()
+ {
+ super("Away", State.AWAY, SharedIcons.OBJ_BUDDY_AWAY);
+ }
+ }
+
+ public static final class DoNotDisturbAction extends StateAction
+ {
+ public DoNotDisturbAction()
+ {
+ super("Do Not Disturb", State.DO_NOT_DISTURB, SharedIcons.OBJ_BUDDY_DO_NOT_DISTURB);
+ }
+ }
+} \ No newline at end of file
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 b45d537..94ba5da 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
@@ -12,21 +12,22 @@ package org.eclipse.net4j.buddies.internal.ui.views;
import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.ui.SharedIcons;
+import org.eclipse.net4j.buddies.internal.ui.actions.ConnectAction;
+import org.eclipse.net4j.buddies.internal.ui.actions.DisconnectAction;
+import org.eclipse.net4j.buddies.internal.ui.actions.FlashAction;
+import org.eclipse.net4j.buddies.internal.ui.actions.StateAction;
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.buddies.ui.IBuddiesManager;
import org.eclipse.net4j.buddies.ui.IBuddiesManagerStateChangedEvent;
-import org.eclipse.net4j.internal.buddies.Self;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.ui.actions.SafeAction;
import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
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;
@@ -180,81 +181,4 @@ public class BuddiesView extends ContainerView implements IListener
action.setEnabled(session != null);
action.setChecked(session != null && session.getSelf().getState() == state);
}
-
- /**
- * @author Eike Stepper
- */
- private final class ConnectAction extends SafeAction
- {
- private ConnectAction()
- {
- super("Connect", "Connect to buddies server");
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- IBuddiesManager.INSTANCE.connect();
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private final class DisconnectAction extends SafeAction
- {
- private DisconnectAction()
- {
- super("Disonnect", "Disconnect from buddies server");
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- IBuddiesManager.INSTANCE.disconnect();
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private final class StateAction extends SafeAction
- {
- private State state;
-
- private StateAction(String text, State state, String key)
- {
- super(text, Action.AS_RADIO_BUTTON);
- setToolTipText("Set own state to '" + text.toLowerCase() + "'");
- setImageDescriptor(SharedIcons.getDescriptor(key));
- this.state = state;
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- if (session != null && isChecked())
- {
- Self self = (Self)session.getSelf();
- self.setState(state);
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private final class FlashAction extends SafeAction
- {
- private FlashAction()
- {
- super("Flash Me", "Flash Me");
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- IBuddiesManager.INSTANCE.flashMe();
- }
- }
} \ No newline at end of file