summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-08 06:06:00 (EDT)
committerEike Stepper2007-10-08 06:06:00 (EDT)
commit7a31caf7b336b6580fcf81cdcf2e7ffd16e7904f (patch)
tree079234638baebcf7169a5a256d93e08a7afe2d00
parent99f3c75b164889e5d89e867e8f10a5e744ac77d6 (diff)
downloadcdo-7a31caf7b336b6580fcf81cdcf2e7ffd16e7904f.zip
cdo-7a31caf7b336b6580fcf81cdcf2e7ffd16e7904f.tar.gz
cdo-7a31caf7b336b6580fcf81cdcf2e7ffd16e7904f.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.java15
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java25
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java27
3 files changed, 60 insertions, 7 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 261370b..65ae01c 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,6 +10,7 @@ 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.internal.buddies.Self;
+import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.container.IContainerDelta;
import org.eclipse.net4j.util.container.IContainerEvent;
@@ -81,6 +82,7 @@ public class BuddiesView extends ContainerView implements IListener
{
if (connecting)
{
+ resetInput();
connectAction.setEnabled(false);
disconnectAction.setEnabled(true);
availableAction.setEnabled(true);
@@ -113,6 +115,7 @@ public class BuddiesView extends ContainerView implements IListener
session.removeListener(this);
session.close();
session = null;
+ resetInput();
connectAction.setEnabled(true);
disconnectAction.setEnabled(false);
@@ -158,11 +161,11 @@ public class BuddiesView extends ContainerView implements IListener
e.getDeltaElement().removeListener(this);
}
}
- else if (event instanceof IBuddyStateChangedEvent)
- {
- IBuddyStateChangedEvent e = (IBuddyStateChangedEvent)event;
- updateLabels(e.getBuddy());
- }
+ }
+ else if (event instanceof IBuddyStateChangedEvent)
+ {
+ IBuddyStateChangedEvent e = (IBuddyStateChangedEvent)event;
+ updateLabels(e.getBuddy());
}
}
@@ -193,7 +196,7 @@ public class BuddiesView extends ContainerView implements IListener
@Override
protected IContainer<?> getContainer()
{
- return session;
+ return session != null ? session : ContainerUtil.emptyContainer();
}
@Override
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java
index 9120f5b..b2c7a08 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java
@@ -58,6 +58,29 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar
viewer.getControl().setFocus();
}
+ public void resetInput()
+ {
+ try
+ {
+ getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ viewer.setInput(getContainer());
+ }
+ catch (RuntimeException ignore)
+ {
+ }
+ }
+ });
+ }
+ catch (RuntimeException ignore)
+ {
+ }
+ }
+
public void selectReveal(ISelection selection)
{
viewer.setSelection(selection, true);
@@ -71,7 +94,7 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar
viewer.setContentProvider(itemProvider);
viewer.setLabelProvider(itemProvider);
viewer.setSorter(new ContainerNameSorter());
- viewer.setInput(getContainer());
+ resetInput();
viewer.addSelectionChangedListener(selectionListener);
getSite().setSelectionProvider(viewer);
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java
index 2eec9e1..7a562f4 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.util.container;
import org.eclipse.net4j.internal.util.container.ManagedContainer;
+import org.eclipse.net4j.util.event.IListener;
/**
* @author Eike Stepper
@@ -19,10 +20,36 @@ public final class ContainerUtil
{
private static final Object[] NO_ELEMENTS = {};
+ private static final IContainer<Object> EMPTY = new IContainer<Object>()
+ {
+ public Object[] getElements()
+ {
+ return NO_ELEMENTS;
+ }
+
+ public boolean isEmpty()
+ {
+ return true;
+ }
+
+ public void addListener(IListener listener)
+ {
+ }
+
+ public void removeListener(IListener listener)
+ {
+ }
+ };
+
private ContainerUtil()
{
}
+ public static IContainer<Object> emptyContainer()
+ {
+ return EMPTY;
+ }
+
public static IManagedContainer createContainer()
{
return new ManagedContainer();