summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-10 07:15:48 (EDT)
committerEike Stepper2007-10-10 07:15:48 (EDT)
commitc3e57965523b95bba0a03d312341bae9369bce43 (patch)
tree1a5938d80419c4230454a643df946479d2ae47e8
parenta32ffcf2988454ab9668fe8e8fae7a13ecc01a97 (diff)
downloadcdo-c3e57965523b95bba0a03d312341bae9369bce43.zip
cdo-c3e57965523b95bba0a03d312341bae9369bce43.tar.gz
cdo-c3e57965523b95bba0a03d312341bae9369bce43.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java10
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java8
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesManager.java17
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java38
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java37
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/ui/IBuddiesManager.java4
6 files changed, 87 insertions, 27 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
index 94cee5e..1a3eae8 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
@@ -1,3 +1,13 @@
+/***************************************************************************
+ * 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.emf.cdo.internal.ui.views;
import org.eclipse.emf.cdo.CDOSession;
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
index 189a855..be12b96 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
@@ -124,15 +124,17 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
Collaboration collaboration = new Collaboration(collaborationID, buddies);
addCollaboration(collaboration);
+
+ Set<IBuddy> invitations = new HashSet<IBuddy>(buddies);
for (IBuddy buddy : buddies)
{
if (buddy != initiator)
{
try
{
- buddies.remove(buddy);
+ invitations.remove(buddy);
IChannel channel = buddy.getSession().getChannel();
- new CollaborationInitiatedNotification(channel, collaborationID, buddies).send();
+ new CollaborationInitiatedNotification(channel, collaborationID, invitations).send();
}
catch (Exception ex)
{
@@ -140,7 +142,7 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
}
finally
{
- buddies.add(buddy);
+ invitations.add(buddy);
}
}
}
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/BuddiesManager.java
index 1707f0b..13bf2d2 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/BuddiesManager.java
@@ -26,7 +26,9 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
private IBuddySession session;
- private State state;
+ private State state = State.DISCONNECTED;
+
+ private boolean connecting;
private boolean flashing;
@@ -54,6 +56,11 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
}
}
+ public boolean isFlashing()
+ {
+ return flashing;
+ }
+
public boolean isConnecting()
{
return state == IBuddiesManager.State.CONNECTING;
@@ -89,7 +96,8 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
try
{
setState(IBuddiesManager.State.CONNECTING);
- while (session == null && isConnecting())
+ connecting = true;
+ while (session == null && connecting)
{
IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, getConnectorDescription());
if (connector == null)
@@ -103,7 +111,7 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
session = BuddiesUtil.openSession(connector, getUserID(), getPassword(), 5000L);
if (session != null)
{
- if (isConnecting())
+ if (connecting)
{
session.addListener(BuddiesManager.this);
setState(IBuddiesManager.State.CONNECTED);
@@ -124,7 +132,7 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
}
finally
{
- setState(IBuddiesManager.State.DISCONNECTED);
+ connecting = false;
}
}
}.start();
@@ -132,6 +140,7 @@ public class BuddiesManager extends Lifecycle implements IBuddiesManager, IListe
public void disconnect()
{
+ connecting = false;
if (session != null)
{
session.removeListener(this);
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 744c1ee..b45d537 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
@@ -1,3 +1,13 @@
+/***************************************************************************
+ * 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;
@@ -67,7 +77,6 @@ public class BuddiesView extends ContainerView implements IListener
if (event instanceof IBuddiesManagerStateChangedEvent)
{
queryBuddiesManager();
- updateState();
}
else if (event instanceof IBuddyStateChangedEvent)
{
@@ -85,7 +94,6 @@ public class BuddiesView extends ContainerView implements IListener
queryBuddiesManager();
IBuddiesManager.INSTANCE.addListener(this);
INSTANCE = this;
- updateState();
return control;
}
@@ -136,21 +144,31 @@ public class BuddiesView extends ContainerView implements IListener
{
IBuddySession oldSession = session;
session = IBuddiesManager.INSTANCE.getSession();
- if (oldSession != null && oldSession != session)
+ if (oldSession != session)
{
- oldSession.removeListener(this);
- oldSession.getSelf().removeListener(this);
- }
+ if (oldSession != null)
+ {
+ oldSession.removeListener(this);
+ oldSession.getSelf().removeListener(this);
+ }
- if (session != null && session != oldSession)
- {
- session.addListener(this);
- session.getSelf().addListener(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());
+
updateState(availableAction, IBuddy.State.AVAILABLE);
updateState(lonesomeAction, IBuddy.State.LONESOME);
updateState(awayAction, IBuddy.State.AWAY);
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 520713f..80c154b 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
@@ -1,3 +1,13 @@
+/***************************************************************************
+ * 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;
@@ -64,7 +74,6 @@ public class CollaborationsView extends ContainerView implements IListener
if (event instanceof IBuddiesManagerStateChangedEvent)
{
queryBuddiesManager();
- updateState();
}
else if (event instanceof IBuddyStateChangedEvent)
{
@@ -124,7 +133,6 @@ public class CollaborationsView extends ContainerView implements IListener
queryBuddiesManager();
IBuddiesManager.INSTANCE.addListener(this);
INSTANCE = this;
- updateState();
return composite;
}
@@ -156,20 +164,29 @@ public class CollaborationsView extends ContainerView implements IListener
{
IBuddySession oldSession = session;
session = IBuddiesManager.INSTANCE.getSession();
- if (oldSession != null && oldSession != session)
+ if (oldSession != session)
{
- oldSession.removeListener(this);
- oldSession.getSelf().removeListener(this);
- }
+ if (oldSession != null)
+ {
+ oldSession.removeListener(this);
+ oldSession.getSelf().removeListener(this);
+ }
- if (session != null && session != oldSession)
- {
- session.addListener(this);
- session.getSelf().addListener(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());
}
} \ 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/IBuddiesManager.java
index c9ca23a..47be7d6 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/IBuddiesManager.java
@@ -25,12 +25,16 @@ public interface IBuddiesManager extends INotifier
public State getState();
+ public boolean isConnecting();
+
public void connect();
public void disconnect();
public void flashMe();
+ public boolean isFlashing();
+
/**
* @author Eike Stepper
*/