summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-11 03:15:18 (EDT)
committerEike Stepper2007-10-11 03:15:18 (EDT)
commit341b755fc3b2a29d257f99ad1451a67fbca29b52 (patch)
tree2bcf958e0db6edeb2b6d6e9029db862919f7a672
parent376c2b00ec96dd0c7ec3c806414d5896e150135b (diff)
downloadcdo-341b755fc3b2a29d257f99ad1451a67fbca29b52.zip
cdo-341b755fc3b2a29d257f99ad1451a67fbca29b52.tar.gz
cdo-341b755fc3b2a29d257f99ad1451a67fbca29b52.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/SessionManager.java (renamed from plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesManager.java)26
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/ConnectAction.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/DisconnectAction.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/FlashAction.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/actions/StateAction.java8
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java109
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java92
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/SessionManagerView.java147
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/ISessionManager.java (renamed from plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/IBuddiesManager.java)6
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/ISessionManagerEvent.java (renamed from plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/IBuddiesManagerStateChangedEvent.java)6
11 files changed, 189 insertions, 223 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesManager.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/SessionManager.java
index 13bf2d2..01ee8b9 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesManager.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/SessionManager.java
@@ -6,8 +6,8 @@ import org.eclipse.net4j.buddies.BuddiesUtil;
import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.ui.bundle.OM;
import org.eclipse.net4j.buddies.protocol.IBuddy;
-import org.eclipse.net4j.buddies.ui.IBuddiesManager;
-import org.eclipse.net4j.buddies.ui.IBuddiesManagerStateChangedEvent;
+import org.eclipse.net4j.buddies.ui.ISessionManager;
+import org.eclipse.net4j.buddies.ui.ISessionManagerEvent;
import org.eclipse.net4j.internal.buddies.Self;
import org.eclipse.net4j.internal.util.event.Event;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
@@ -20,9 +20,9 @@ import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListener
+public class SessionManager extends Lifecycle implements ISessionManager, IListener
{
- public static final BuddiesManager INSTANCE = new BuddiesManager();
+ public static final SessionManager INSTANCE = new SessionManager();
private IBuddySession session;
@@ -32,7 +32,7 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
private boolean flashing;
- private BuddiesManager()
+ private SessionManager()
{
}
@@ -63,7 +63,7 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
public boolean isConnecting()
{
- return state == IBuddiesManager.State.CONNECTING;
+ return state == ISessionManager.State.CONNECTING;
}
public String getConnectorDescription()
@@ -95,7 +95,7 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
{
try
{
- setState(IBuddiesManager.State.CONNECTING);
+ setState(ISessionManager.State.CONNECTING);
connecting = true;
while (session == null && connecting)
{
@@ -113,14 +113,14 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
{
if (connecting)
{
- session.addListener(BuddiesManager.this);
- setState(IBuddiesManager.State.CONNECTED);
+ session.addListener(SessionManager.this);
+ setState(ISessionManager.State.CONNECTED);
}
else
{
session.close();
session = null;
- setState(IBuddiesManager.State.DISCONNECTED);
+ setState(ISessionManager.State.DISCONNECTED);
}
}
}
@@ -148,7 +148,7 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
session = null;
}
- setState(IBuddiesManager.State.DISCONNECTED);
+ setState(ISessionManager.State.DISCONNECTED);
}
public void flashMe()
@@ -228,7 +228,7 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
/**
* @author Eike Stepper
*/
- private final class StateChangedEvent extends Event implements IBuddiesManagerStateChangedEvent
+ private final class StateChangedEvent extends Event implements ISessionManagerEvent
{
private static final long serialVersionUID = 1L;
@@ -240,7 +240,7 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
public StateChangedEvent(State oldState, State newState, IBuddySession session)
{
- super(BuddiesManager.this);
+ super(SessionManager.this);
this.oldState = oldState;
this.newState = newState;
this.session = session;
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
index d53b671..0eca122 100644
--- 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
@@ -1,6 +1,6 @@
package org.eclipse.net4j.buddies.internal.ui.actions;
-import org.eclipse.net4j.buddies.ui.IBuddiesManager;
+import org.eclipse.net4j.buddies.ui.ISessionManager;
import org.eclipse.net4j.util.ui.actions.SafeAction;
/**
@@ -16,6 +16,6 @@ public final class ConnectAction extends SafeAction
@Override
protected void safeRun() throws Exception
{
- IBuddiesManager.INSTANCE.connect();
+ ISessionManager.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
index 1831a15..054a256 100644
--- 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
@@ -1,6 +1,6 @@
package org.eclipse.net4j.buddies.internal.ui.actions;
-import org.eclipse.net4j.buddies.ui.IBuddiesManager;
+import org.eclipse.net4j.buddies.ui.ISessionManager;
import org.eclipse.net4j.util.ui.actions.SafeAction;
/**
@@ -16,6 +16,6 @@ public final class DisconnectAction extends SafeAction
@Override
protected void safeRun() throws Exception
{
- IBuddiesManager.INSTANCE.disconnect();
+ ISessionManager.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
index db6f28a..f98e411 100644
--- 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
@@ -1,6 +1,6 @@
package org.eclipse.net4j.buddies.internal.ui.actions;
-import org.eclipse.net4j.buddies.ui.IBuddiesManager;
+import org.eclipse.net4j.buddies.ui.ISessionManager;
import org.eclipse.net4j.util.ui.actions.SafeAction;
/**
@@ -16,6 +16,6 @@ public final class FlashAction extends SafeAction
@Override
protected void safeRun() throws Exception
{
- IBuddiesManager.INSTANCE.flashMe();
+ ISessionManager.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
index 3b792f2..5153ee1 100644
--- 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
@@ -3,7 +3,7 @@ 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.buddies.ui.ISessionManager;
import org.eclipse.net4j.internal.buddies.Self;
import org.eclipse.net4j.util.ui.actions.SafeAction;
@@ -30,7 +30,7 @@ public class StateAction extends SafeAction
public void updateState()
{
- IBuddySession session = IBuddiesManager.INSTANCE.getSession();
+ IBuddySession session = ISessionManager.INSTANCE.getSession();
setEnabled(session != null);
setChecked(session != null && session.getSelf().getState() == state);
}
@@ -38,7 +38,7 @@ public class StateAction extends SafeAction
@Override
protected void safeRun() throws Exception
{
- IBuddySession session = IBuddiesManager.INSTANCE.getSession();
+ IBuddySession session = ISessionManager.INSTANCE.getSession();
if (session != null && isChecked())
{
Self self = (Self)session.getSelf();
@@ -80,7 +80,7 @@ public class StateAction extends SafeAction
awayAction.updateState();
doNotDisturbAction.updateState();
- IBuddySession session = IBuddiesManager.INSTANCE.getSession();
+ IBuddySession session = ISessionManager.INSTANCE.getSession();
if (session != null)
{
setEnabled(true);
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java
index d64f925..9bc3e65 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.buddies.internal.ui.bundle;
-import org.eclipse.net4j.buddies.internal.ui.BuddiesManager;
+import org.eclipse.net4j.buddies.internal.ui.SessionManager;
import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.log.OMLogger;
@@ -48,12 +48,12 @@ public abstract class OM
static void start() throws Exception
{
- BuddiesManager.INSTANCE.activate();
+ SessionManager.INSTANCE.activate();
}
static void stop() throws Exception
{
- BuddiesManager.INSTANCE.deactivate();
+ SessionManager.INSTANCE.deactivate();
}
/**
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 5a630a7..b0569e5 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
@@ -10,42 +10,17 @@
**************************************************************************/
package org.eclipse.net4j.buddies.internal.ui.views;
-import org.eclipse.net4j.buddies.IBuddySession;
-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.DropDownAction;
import org.eclipse.net4j.buddies.protocol.IBuddy;
-import org.eclipse.net4j.buddies.protocol.IBuddyStateChangedEvent;
-import org.eclipse.net4j.buddies.ui.IBuddiesManager;
-import org.eclipse.net4j.buddies.ui.IBuddiesManagerStateChangedEvent;
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.views.ContainerItemProvider;
-import org.eclipse.net4j.util.ui.views.ContainerView;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-public class BuddiesView extends ContainerView implements IListener
+public class BuddiesView extends SessionManagerView
{
private static BuddiesView INSTANCE;
- private IBuddySession session;
-
- private ConnectAction connectAction = new ConnectAction();
-
- private DisconnectAction disconnectAction = new DisconnectAction();
-
- private FlashAction flashAction = new FlashAction();
-
- private DropDownAction dropDownAction = new DropDownAction();
-
public BuddiesView()
{
}
@@ -59,32 +34,13 @@ public class BuddiesView extends ContainerView implements IListener
public synchronized void dispose()
{
INSTANCE = null;
- IBuddiesManager.INSTANCE.removeListener(this);
- session = null;
super.dispose();
}
- public void notifyEvent(IEvent event)
- {
- if (event instanceof IBuddiesManagerStateChangedEvent)
- {
- queryBuddiesManager();
- }
- else if (event instanceof IBuddyStateChangedEvent)
- {
- if (session != null && event.getSource() == session.getSelf())
- {
- updateState();
- }
- }
- }
-
@Override
- protected Control createUI(Composite parent)
+ protected Control createControl(Composite parent)
{
- Control control = super.createUI(parent);
- queryBuddiesManager();
- IBuddiesManager.INSTANCE.addListener(this);
+ Control control = super.createControl(parent);
INSTANCE = this;
return control;
}
@@ -92,71 +48,18 @@ public class BuddiesView extends ContainerView implements IListener
@Override
protected IContainer<?> getContainer()
{
- return session != null ? session : ContainerUtil.emptyContainer();
- }
-
- @Override
- protected ContainerItemProvider<IContainer<Object>> createContainerItemProvider()
- {
- return new BuddiesItemProvider();
+ return getSession() != null ? getSession() : ContainerUtil.emptyContainer();
}
@Override
protected void doubleClicked(Object object)
{
- if (session != null && object instanceof IBuddy)
+ if (getSession() != null && object instanceof IBuddy)
{
IBuddy buddy = (IBuddy)object;
- IBuddy self = session.getSelf();
+ IBuddy self = getSession().getSelf();
self.initiate(buddy);
}
}
- @Override
- protected void fillLocalToolBar(IToolBarManager manager)
- {
- manager.add(dropDownAction);
- super.fillLocalToolBar(manager);
- }
-
- @Override
- protected void fillLocalPullDown(IMenuManager manager)
- {
- manager.add(connectAction);
- manager.add(disconnectAction);
- manager.add(new Separator());
- manager.add(flashAction);
- super.fillLocalPullDown(manager);
- }
-
- protected void queryBuddiesManager()
- {
- IBuddySession oldSession = session;
- session = IBuddiesManager.INSTANCE.getSession();
- if (oldSession != session)
- {
- if (oldSession != null)
- {
- oldSession.removeListener(this);
- oldSession.getSelf().removeListener(this);
- }
-
- if (session != null)
- {
- session.addListener(this);
- session.getSelf().addListener(this);
- }
- }
-
- resetInput();
- updateState();
- }
-
- protected void updateState()
- {
- connectAction.setEnabled(session == null);
- disconnectAction.setEnabled(session != null);
- flashAction.setEnabled(session != null && !IBuddiesManager.INSTANCE.isFlashing());
- dropDownAction.updateState();
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
index 16c47e5..574366f 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
@@ -11,19 +11,9 @@
package org.eclipse.net4j.buddies.internal.ui.views;
import org.eclipse.net4j.buddies.BuddiesUtil;
-import org.eclipse.net4j.buddies.IBuddySession;
-import org.eclipse.net4j.buddies.protocol.IBuddyStateChangedEvent;
-import org.eclipse.net4j.buddies.ui.IBuddiesManager;
-import org.eclipse.net4j.buddies.ui.IBuddiesManagerStateChangedEvent;
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.views.ContainerItemProvider;
-import org.eclipse.net4j.util.ui.views.ContainerView;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
@@ -36,7 +26,7 @@ import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Sash;
-public class CollaborationsView extends ContainerView implements IListener
+public class CollaborationsView extends SessionManagerView
{
private static final int LIMIT = 10;
@@ -44,8 +34,6 @@ public class CollaborationsView extends ContainerView implements IListener
private static CollaborationsView INSTANCE;
- private IBuddySession session;
-
private Sash sash;
private Control leftControl;
@@ -65,34 +53,17 @@ public class CollaborationsView extends ContainerView implements IListener
public synchronized void dispose()
{
INSTANCE = null;
- IBuddiesManager.INSTANCE.removeListener(this);
- session = null;
super.dispose();
}
- public void notifyEvent(IEvent event)
- {
- if (event instanceof IBuddiesManagerStateChangedEvent)
- {
- queryBuddiesManager();
- }
- else if (event instanceof IBuddyStateChangedEvent)
- {
- if (session != null && event.getSource() == session.getSelf())
- {
- updateState();
- }
- }
- }
-
@Override
- protected synchronized Control createUI(final Composite parent)
+ protected Control createControl(Composite parent)
{
final FormLayout form = new FormLayout();
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(form);
- leftControl = super.createUI(composite);
+ leftControl = super.createControl(composite);
sash = new Sash(composite, SWT.VERTICAL);
rightControl = createPane(composite);
@@ -131,8 +102,6 @@ public class CollaborationsView extends ContainerView implements IListener
rightControlData.bottom = new FormAttachment(100, 0);
rightControl.setLayoutData(rightControlData);
- queryBuddiesManager();
- IBuddiesManager.INSTANCE.addListener(this);
INSTANCE = this;
return composite;
}
@@ -151,59 +120,6 @@ public class CollaborationsView extends ContainerView implements IListener
@Override
protected IContainer<?> getContainer()
{
- return session != null ? session.getSelf() : ContainerUtil.emptyContainer();
- }
-
- @Override
- protected ContainerItemProvider<IContainer<Object>> createContainerItemProvider()
- {
- return new BuddiesItemProvider();
- }
-
- @Override
- protected void fillLocalToolBar(IToolBarManager manager)
- {
- super.fillLocalToolBar(manager);
- }
-
- @Override
- protected void fillLocalPullDown(IMenuManager manager)
- {
- super.fillLocalPullDown(manager);
- }
-
- protected void queryBuddiesManager()
- {
- IBuddySession oldSession = session;
- session = IBuddiesManager.INSTANCE.getSession();
- if (oldSession != session)
- {
- if (oldSession != null)
- {
- oldSession.removeListener(this);
- oldSession.getSelf().removeListener(this);
- }
-
- if (session != null)
- {
- session.addListener(this);
- session.getSelf().addListener(this);
- }
- }
-
- resetInput();
- updateState();
- }
-
- protected void updateState()
- {
- // connectAction.setEnabled(session == null);
- // disconnectAction.setEnabled(session != null);
- // flashAction.setEnabled(session != null && !IBuddiesManager.INSTANCE.isFlashing());
-
- // availableAction.updateState();
- // lonesomeAction.updateState();
- // awayAction.updateState();
- // doNotDisturbAction.updateState();
+ return getSession() != null ? getSession().getSelf() : ContainerUtil.emptyContainer();
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/SessionManagerView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/SessionManagerView.java
new file mode 100644
index 0000000..9a0fc5d
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/SessionManagerView.java
@@ -0,0 +1,147 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.buddies.internal.ui.views;
+
+import org.eclipse.net4j.buddies.IBuddySession;
+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.DropDownAction;
+import org.eclipse.net4j.buddies.protocol.IBuddyStateChangedEvent;
+import org.eclipse.net4j.buddies.ui.ISessionManager;
+import org.eclipse.net4j.buddies.ui.ISessionManagerEvent;
+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.views.ContainerItemProvider;
+import org.eclipse.net4j.util.ui.views.ContainerView;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public abstract class SessionManagerView extends ContainerView implements IListener
+{
+ private IBuddySession session;
+
+ private ConnectAction connectAction = new ConnectAction();
+
+ private DisconnectAction disconnectAction = new DisconnectAction();
+
+ private FlashAction flashAction = new FlashAction();
+
+ private DropDownAction dropDownAction = new DropDownAction();
+
+ private Control control;
+
+ public SessionManagerView()
+ {
+ }
+
+ public IBuddySession getSession()
+ {
+ return session;
+ }
+
+ @Override
+ public void dispose()
+ {
+ ISessionManager.INSTANCE.removeListener(this);
+ session = null;
+ super.dispose();
+ }
+
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof ISessionManagerEvent)
+ {
+ queryBuddiesManager();
+ }
+ else if (event instanceof IBuddyStateChangedEvent)
+ {
+ if (session != null && event.getSource() == session.getSelf())
+ {
+ updateState();
+ }
+ }
+ }
+
+ @Override
+ protected final Control createUI(Composite parent)
+ {
+ control = createControl(parent);
+ queryBuddiesManager();
+ ISessionManager.INSTANCE.addListener(this);
+ return control;
+ }
+
+ protected Control createControl(Composite parent)
+ {
+ return super.createUI(parent);
+ }
+
+ @Override
+ protected ContainerItemProvider<IContainer<Object>> createContainerItemProvider()
+ {
+ return new BuddiesItemProvider();
+ }
+
+ @Override
+ protected void fillLocalToolBar(IToolBarManager manager)
+ {
+ manager.add(dropDownAction);
+ super.fillLocalToolBar(manager);
+ }
+
+ @Override
+ protected void fillLocalPullDown(IMenuManager manager)
+ {
+ manager.add(connectAction);
+ manager.add(disconnectAction);
+ manager.add(new Separator());
+ manager.add(flashAction);
+ super.fillLocalPullDown(manager);
+ }
+
+ protected void queryBuddiesManager()
+ {
+ IBuddySession oldSession = session;
+ session = ISessionManager.INSTANCE.getSession();
+ if (oldSession != session)
+ {
+ if (oldSession != null)
+ {
+ oldSession.removeListener(this);
+ oldSession.getSelf().removeListener(this);
+ }
+
+ if (session != null)
+ {
+ session.addListener(this);
+ session.getSelf().addListener(this);
+ }
+ }
+
+ resetInput();
+ updateState();
+ }
+
+ protected void updateState()
+ {
+ connectAction.setEnabled(session == null);
+ disconnectAction.setEnabled(session != null);
+ flashAction.setEnabled(session != null && !ISessionManager.INSTANCE.isFlashing());
+ dropDownAction.updateState();
+ // control.setEnabled(session != null);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/IBuddiesManager.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/ISessionManager.java
index 47be7d6..46e1329 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/IBuddiesManager.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/ISessionManager.java
@@ -11,15 +11,15 @@
package org.eclipse.net4j.buddies.ui;
import org.eclipse.net4j.buddies.IBuddySession;
-import org.eclipse.net4j.buddies.internal.ui.BuddiesManager;
+import org.eclipse.net4j.buddies.internal.ui.SessionManager;
import org.eclipse.net4j.util.event.INotifier;
/**
* @author Eike Stepper
*/
-public interface IBuddiesManager extends INotifier
+public interface ISessionManager extends INotifier
{
- public static final IBuddiesManager INSTANCE = BuddiesManager.INSTANCE;
+ public static final ISessionManager INSTANCE = SessionManager.INSTANCE;
public IBuddySession getSession();
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/IBuddiesManagerStateChangedEvent.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/ISessionManagerEvent.java
index 9a2a4d1..7dc7382 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/IBuddiesManagerStateChangedEvent.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/ISessionManagerEvent.java
@@ -16,11 +16,11 @@ import org.eclipse.net4j.util.event.IEvent;
/**
* @author Eike Stepper
*/
-public interface IBuddiesManagerStateChangedEvent extends IEvent
+public interface ISessionManagerEvent extends IEvent
{
- public IBuddiesManager.State getOldState();
+ public ISessionManager.State getOldState();
- public IBuddiesManager.State getNewState();
+ public ISessionManager.State getNewState();
public IBuddySession getSession();
}