summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-11-10 14:03:18 (EST)
committerEike Stepper2007-11-10 14:03:18 (EST)
commite8cc466cd37d0200b41628f10949cd9d5998acdb (patch)
treeb7fb8e301233239cec08ee34459ddf0058bc39f7
parent4fbe5ddbb62e439ad7708520674c3f03ebb512c6 (diff)
downloadcdo-e8cc466cd37d0200b41628f10949cd9d5998acdb.zip
cdo-e8cc466cd37d0200b41628f10949cd9d5998acdb.tar.gz
cdo-e8cc466cd37d0200b41628f10949cd9d5998acdb.tar.bz2
[209380] Add invitation capability for multi buddy collaborations
https://bugs.eclipse.org/bugs/show_bug.cgi?id=209380
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerItemProvider.java39
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerPathItemProvider.java102
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java3
3 files changed, 137 insertions, 7 deletions
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 c85ef2a..11b7545 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
@@ -18,6 +18,8 @@ import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleState;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.jface.viewers.TreePath;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -127,7 +129,7 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
protected void connectInput(CONTAINER input)
{
root = (ContainerNode)createNode(null, input);
- nodes.put(input, root);
+ addNode(input, root);
}
@Override
@@ -182,6 +184,16 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
return new LeafNode(parent, element);
}
+ protected void addNode(Object element, Node node)
+ {
+ nodes.put(element, node);
+ }
+
+ protected Node removeNode(Object element)
+ {
+ return nodes.remove(element);
+ }
+
protected boolean filterRootElement(Object element)
{
if (rootElementFilter != null)
@@ -206,6 +218,8 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
public Node getParent();
public List<Node> getChildren();
+
+ public TreePath getTreePath();
}
/**
@@ -228,7 +242,7 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
{
if (!disposed)
{
- nodes.remove(getElement());
+ removeNode(getElement());
parent = null;
if (children != null)
{
@@ -253,7 +267,8 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
@Override
public String toString()
{
- return getElement().toString();
+ Object element = getElement();
+ return element == null ? "null" : element.toString();
}
public final Node getParent()
@@ -273,6 +288,12 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
return children;
}
+ public TreePath getTreePath()
+ {
+ TreePath parentPath = parent == null ? TreePath.EMPTY : parent.getTreePath();
+ return parentPath.createChildPath(getElement());
+ }
+
protected void checkNotDisposed()
{
if (disposed)
@@ -313,7 +334,7 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
{
if (container == ContainerNode.this.container)
{
- Node node = nodes.remove(element);
+ Node node = removeNode(element);
if (node != null)
{
getChildren().remove(node);
@@ -400,7 +421,7 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
if (this != root || filterRootElement(element))
{
Node node = createNode(this, element);
- nodes.put(element, node);
+ addNode(element, node);
children.add(node);
return node;
}
@@ -429,7 +450,7 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
{
if (!isDisposed())
{
- nodes.remove(element);
+ removeNode(element);
EventUtil.removeListener(element, this);
element = null;
parent = null;
@@ -459,6 +480,12 @@ public class ContainerItemProvider<CONTAINER extends IContainer<Object>> extends
return Collections.emptyList();
}
+ public TreePath getTreePath()
+ {
+ TreePath parentPath = parent == null ? TreePath.EMPTY : parent.getTreePath();
+ return parentPath.createChildPath(element);
+ }
+
public void notifyEvent(IEvent event)
{
updateLabels(event.getSource());
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerPathItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerPathItemProvider.java
new file mode 100644
index 0000000..f9ecddc
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerPathItemProvider.java
@@ -0,0 +1,102 @@
+/***************************************************************************
+ * 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.util.ui.views;
+
+import org.eclipse.net4j.util.container.IContainer;
+
+import org.eclipse.jface.viewers.ITreePathContentProvider;
+import org.eclipse.jface.viewers.TreePath;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+@Deprecated
+public class ContainerPathItemProvider<CONTAINER extends IContainer<Object>> extends ContainerItemProvider<CONTAINER>
+ implements ITreePathContentProvider
+{
+ private Map<Object, List<TreePath>> parents = new HashMap<Object, List<TreePath>>();
+
+ public ContainerPathItemProvider()
+ {
+ }
+
+ public ContainerPathItemProvider(IElementFilter rootElementFilter)
+ {
+ super(rootElementFilter);
+ }
+
+ public boolean hasChildren(TreePath path)
+ {
+ return hasChildren((Object)path);
+ }
+
+ public Object[] getChildren(TreePath path)
+ {
+ return getChildren((Object)path);
+ }
+
+ public TreePath[] getParents(Object element)
+ {
+ List<TreePath> paths = parents.get(element);
+ if (paths != null)
+ {
+ return paths.toArray(new TreePath[paths.size()]);
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void addNode(Object element, Node node)
+ {
+ super.addNode(node.getTreePath(), node);
+ TreePath path = getParentPath(node);
+ List<TreePath> paths = parents.get(element);
+ if (paths == null)
+ {
+ paths = new ArrayList<TreePath>();
+ parents.put(element, paths);
+ }
+
+ paths.add(path);
+ }
+
+ @Override
+ protected Node removeNode(Object element)
+ {
+ Node node = super.removeNode(element);
+ TreePath path = getParentPath(node);
+ List<TreePath> paths = parents.get(element);
+ if (paths != null)
+ {
+ paths.remove(path);
+ }
+
+ return node;
+ }
+
+ @Override
+ protected void disconnectInput(CONTAINER input)
+ {
+ super.disconnectInput(input);
+ }
+
+ protected TreePath getParentPath(Node node)
+ {
+ Node parent = node.getParent();
+ return parent == null ? TreePath.EMPTY : parent.getTreePath();
+ }
+}
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 f2e0e06..267bff0 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
@@ -2,6 +2,7 @@ package org.eclipse.net4j.util.ui.views;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.internal.ui.SharedIcons;
+import org.eclipse.net4j.util.internal.ui.actions.IntrospectAction;
import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.net4j.util.ui.actions.SafeAction;
@@ -216,7 +217,7 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar
{
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
manager.add(refreshAction);
- // manager.add(new IntrospectAction(getViewer()));
+ manager.add(new IntrospectAction(getViewer()));
}
protected void fillLocalToolBar(IToolBarManager manager)