summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-08 04:09:11 (EDT)
committerEike Stepper2007-10-08 04:09:11 (EDT)
commita1bdd3c6bea3be3cdb7d43e4b1570a0d2d3765bf (patch)
tree4719f1df58838efc20bdccdbc3774c209e541996
parent814e122440c2d100e3a44f7ea090f2e97ca5c0b5 (diff)
downloadcdo-a1bdd3c6bea3be3cdb7d43e4b1570a0d2d3765bf.zip
cdo-a1bdd3c6bea3be3cdb7d43e4b1570a0d2d3765bf.tar.gz
cdo-a1bdd3c6bea3be3cdb7d43e4b1570a0d2d3765bf.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.java76
1 files changed, 56 insertions, 20 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 5488927..6ef0d27 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
@@ -14,10 +14,14 @@ 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.IToolBarManager;
+import org.eclipse.jface.action.IMenuManager;
public class BuddiesView extends ContainerView implements IListener
{
+ private ConnectAction connectAction = new ConnectAction();
+
+ private DisconnectAction disconnectAction = new DisconnectAction();
+
private IBuddySession session;
private boolean connecting;
@@ -45,7 +49,7 @@ public class BuddiesView extends ContainerView implements IListener
try
{
connecting = true;
- while (session == null && connecting && isAutoConnect())
+ while (session == null && connecting)
{
String connectorDescription = OM.PREF_CONNECTOR_DESCRIPTION.getValue();
IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, connectorDescription);
@@ -148,31 +152,63 @@ public class BuddiesView extends ContainerView implements IListener
}
@Override
- protected void fillLocalToolBar(IToolBarManager manager)
+ protected void fillLocalPullDown(IMenuManager manager)
{
+ manager.add(connectAction);
+ manager.add(disconnectAction);
if (session == null && !connecting)
{
- manager.add(new SafeAction("Connect", "Connect to buddies server")
- {
- @Override
- protected void safeRun() throws Exception
- {
- connect();
- }
- });
}
else
{
- manager.add(new SafeAction("Disonnect", "Disconnect from buddies server")
- {
- @Override
- protected void safeRun() throws Exception
- {
- disconnect();
- }
- });
}
- super.fillLocalToolBar(manager);
+ super.fillLocalPullDown(manager);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class ConnectAction extends SafeAction
+ {
+ private ConnectAction()
+ {
+ super("Connect", "Connect to buddies server");
+ }
+
+ @Override
+ public boolean isEnabled()
+ {
+ return session == null && !connecting;
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ connect();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class DisconnectAction extends SafeAction
+ {
+ private DisconnectAction()
+ {
+ super("Disonnect", "Disconnect from buddies server");
+ }
+
+ @Override
+ public boolean isEnabled()
+ {
+ return session != null || connecting;
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ disconnect();
+ }
}
} \ No newline at end of file