summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-17 05:39:30 (EDT)
committerEike Stepper2007-10-17 05:39:30 (EDT)
commit0e387ca27e2110cf18da08c00d354ac4820b6306 (patch)
treed73ac6ba8ba2a99ca225ce9609f3da4415b76970
parentbb0da9583a86903c54c8e86246c4b038e442dc84 (diff)
downloadcdo-0e387ca27e2110cf18da08c00d354ac4820b6306.zip
cdo-0e387ca27e2110cf18da08c00d354ac4820b6306.tar.gz
cdo-0e387ca27e2110cf18da08c00d354ac4820b6306.tar.bz2
[206224] Provide chat example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206224
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java12
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java81
2 files changed, 77 insertions, 16 deletions
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 fb1b992..229e151 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
@@ -13,6 +13,7 @@ package org.eclipse.net4j.buddies.internal.ui.views;
import org.eclipse.net4j.buddies.IBuddyCollaboration;
import org.eclipse.net4j.buddies.internal.ui.bundle.OM;
import org.eclipse.net4j.buddies.ui.IFacilityPaneCreator;
+import org.eclipse.net4j.internal.buddies.ClientBuddy;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IContainer;
@@ -163,6 +164,17 @@ public class CollaborationsView extends SessionManagerView
return new BuddiesItemProvider()
{
@Override
+ protected Node createNode(Node parent, Object element)
+ {
+ if (element instanceof ClientBuddy)
+ {
+ return new LeafNode(parent, element);
+ }
+
+ return super.createNode(parent, element);
+ }
+
+ @Override
public Font getFont(Object obj)
{
if (obj instanceof IBuddyCollaboration)
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java
index bfadcbc..8cc46ad 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java
@@ -116,6 +116,12 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
}
@Override
+ public void dispose()
+ {
+ super.dispose();
+ }
+
+ @Override
protected void connectInput(CONTAINER input)
{
root = (ContainerNode)createNode(null, input);
@@ -218,19 +224,23 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
public void dispose()
{
- parent = null;
- if (children != null)
+ if (!disposed)
{
- for (Node child : children)
+ nodes.remove(getElement());
+ parent = null;
+ if (children != null)
{
- child.dispose();
+ for (Node child : children)
+ {
+ child.dispose();
+ }
+
+ children.clear();
+ children = null;
}
- children.clear();
- children = null;
+ disposed = true;
}
-
- disposed = true;
}
public boolean isDisposed()
@@ -246,11 +256,13 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
public final Node getParent()
{
+ checkNotDisposed();
return parent;
}
public final List<Node> getChildren()
{
+ checkNotDisposed();
if (children == null)
{
children = createChildren();
@@ -259,6 +271,14 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
return children;
}
+ protected void checkNotDisposed()
+ {
+ if (disposed)
+ {
+ throw new IllegalStateException("Node is already disposed of");
+ }
+ }
+
protected abstract List<Node> createChildren();
}
@@ -295,9 +315,12 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
if (node != null)
{
getChildren().remove(node);
- node.dispose();
- refreshElement(container, true);
elementRemoved(element, container);
+
+ Object rootElement = root.getElement();
+ Object refreshElement = container == rootElement ? null : container;
+ refreshElement(refreshElement, true);
+ node.dispose();
}
}
}
@@ -313,23 +336,33 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
{
super(parent);
this.container = container;
+ if (container == null)
+ {
+ throw new IllegalArgumentException("container == null");
+ }
}
@Override
public void dispose()
{
- container.removeListener(containerListener);
- container = null;
- super.dispose();
+ if (!isDisposed())
+ {
+ container.removeListener(containerListener);
+ containerListener = null;
+ container = null;
+ super.dispose();
+ }
}
public IContainer<Object> getContainer()
{
+ checkNotDisposed();
return container;
}
public Object getElement()
{
+ checkNotDisposed();
return container;
}
@@ -342,6 +375,7 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
@Override
protected List<Node> createChildren()
{
+ checkNotDisposed();
Object[] elements = container.getElements();
List<Node> children = new ArrayList<Node>(elements.length);
for (int i = 0; i < elements.length; i++)
@@ -391,9 +425,13 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
public void dispose()
{
- EventUtil.removeListener(element, this);
- element = null;
- parent = null;
+ if (!isDisposed())
+ {
+ nodes.remove(element);
+ EventUtil.removeListener(element, this);
+ element = null;
+ parent = null;
+ }
}
public boolean isDisposed()
@@ -403,16 +441,19 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
public Node getParent()
{
+ checkNotDisposed();
return parent;
}
public Object getElement()
{
+ checkNotDisposed();
return element;
}
public List<Node> getChildren()
{
+ checkNotDisposed();
return Collections.emptyList();
}
@@ -426,5 +467,13 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
{
return element == null ? super.toString() : element.toString();
}
+
+ protected void checkNotDisposed()
+ {
+ if (isDisposed())
+ {
+ throw new IllegalStateException("Node is already disposed of");
+ }
+ }
}
}