summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-11-12 05:17:27 (EST)
committerEike Stepper2007-11-12 05:17:27 (EST)
commitd1336876753ab1632fecbb728aaae36c39341cb0 (patch)
tree756cedd783db97bd94aff0d681fd1468bcc5f81a
parentbbb340455411f643c7d95f6eed8a8e722ec0015d (diff)
downloadcdo-d1336876753ab1632fecbb728aaae36c39341cb0.zip
cdo-d1336876753ab1632fecbb728aaae36c39341cb0.tar.gz
cdo-d1336876753ab1632fecbb728aaae36c39341cb0.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.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/AbstractItemProvider.java229
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesContentProvider.java41
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesItemProvider.java (renamed from plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesItemProvider.java)2
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/ChatInstaller.java (renamed from plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/ChatInstaller.java)2
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsContentProvider.java41
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsItemProvider.java107
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java1
7 files changed, 421 insertions, 2 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/AbstractItemProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/AbstractItemProvider.java
new file mode 100644
index 0000000..44cdd8b
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/AbstractItemProvider.java
@@ -0,0 +1,229 @@
+/***************************************************************************
+ * 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;
+
+import org.eclipse.net4j.buddies.IBuddyCollaboration;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ICollaboration;
+import org.eclipse.net4j.buddies.protocol.IMembership;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.ui.UIUtil;
+import org.eclipse.net4j.util.ui.actions.LongRunningAction;
+import org.eclipse.net4j.util.ui.actions.SafeAction;
+import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
+import org.eclipse.net4j.util.ui.views.ContainerView;
+import org.eclipse.net4j.util.ui.views.IElementFilter;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractItemProvider extends ContainerItemProvider<IContainer<Object>>
+{
+ public static final Color GRAY = UIUtil.getDisplay().getSystemColor(SWT.COLOR_GRAY);
+
+ private Font bold;
+
+ public AbstractItemProvider()
+ {
+ }
+
+ public AbstractItemProvider(IElementFilter rootElementFilter)
+ {
+ super(rootElementFilter);
+ }
+
+ @Override
+ public void dispose()
+ {
+ UIUtil.dispose(bold);
+ super.dispose();
+ }
+
+ public Font getBold()
+ {
+ return bold;
+ }
+
+ @Override
+ protected Node createNode(Node parent, Object element)
+ {
+ if (element instanceof IMembership)
+ {
+ IMembership membership = (IMembership)element;
+ return createMembershipNode(parent, membership);
+ }
+
+ return super.createNode(parent, element);
+ }
+
+ protected abstract Node createMembershipNode(Node parent, IMembership membership);
+
+ @Override
+ public String getText(Object obj)
+ {
+ if (obj instanceof IBuddy)
+ {
+ IBuddy buddy = (IBuddy)obj;
+ return buddy.getUserID();
+ }
+
+ if (obj instanceof ICollaboration)
+ {
+ ICollaboration collaboration = (ICollaboration)obj;
+ return collaboration.getTitle();
+ }
+
+ if (obj instanceof IMembership)
+ {
+ IMembership membership = (IMembership)obj;
+ return getText(membership);
+ }
+
+ return super.getText(obj);
+ }
+
+ protected abstract String getText(IMembership membership);
+
+ @Override
+ public Image getImage(Object obj)
+ {
+ if (obj instanceof IBuddy)
+ {
+ IBuddy buddy = (IBuddy)obj;
+ switch (buddy.getState())
+ {
+ case AVAILABLE:
+ return SharedIcons.getImage(SharedIcons.OBJ_BUDDY);
+
+ case LONESOME:
+ return SharedIcons.getImage(SharedIcons.OBJ_BUDDY_LONESOME);
+
+ case AWAY:
+ return SharedIcons.getImage(SharedIcons.OBJ_BUDDY_AWAY);
+
+ case DO_NOT_DISTURB:
+ return SharedIcons.getImage(SharedIcons.OBJ_BUDDY_DO_NOT_DISTURB);
+ }
+ }
+
+ if (obj instanceof ICollaboration)
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_COLLABORATION);
+ }
+
+ if (obj instanceof IMembership)
+ {
+ IMembership membership = (IMembership)obj;
+ return getImage(membership);
+ }
+
+ return super.getImage(obj);
+ }
+
+ protected abstract Image getImage(IMembership membership);
+
+ @Override
+ public Color getForeground(Object obj)
+ {
+ if (obj instanceof IBuddy)
+ {
+ IBuddy buddy = (IBuddy)obj;
+ switch (buddy.getState())
+ {
+ case AWAY:
+ case DO_NOT_DISTURB:
+ return GRAY;
+ }
+ }
+
+ return super.getForeground(obj);
+ }
+
+ @Override
+ public Font getFont(Object obj)
+ {
+ if (obj instanceof IBuddy)
+ {
+ IBuddy buddy = (IBuddy)obj;
+ switch (buddy.getState())
+ {
+ case LONESOME:
+ return bold;
+ }
+ }
+
+ return super.getFont(obj);
+ }
+
+ @Override
+ protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
+ {
+ manager.add(new Separator());
+ if (selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj instanceof IBuddy)
+ {
+ manager.add(new RemoveAction(obj));
+ }
+ else if (obj instanceof IBuddyCollaboration)
+ {
+ final IBuddyCollaboration collaboration = (IBuddyCollaboration)obj;
+ manager.add(new SafeAction("Leave", "Leave this collaboration")
+ {
+ @Override
+ protected void safeRun() throws Exception
+ {
+ collaboration.leave();
+ }
+ });
+ }
+ }
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ UIUtil.dispose(bold);
+ super.inputChanged(viewer, oldInput, newInput);
+ bold = UIUtil.getBoldFont(getViewer().getControl());
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class RemoveAction extends LongRunningAction
+ {
+ private Object object;
+
+ public RemoveAction(Object object)
+ {
+ super("Remove", "Remove", ContainerView.getDeleteImageDescriptor());
+ this.object = object;
+ }
+
+ @Override
+ protected void doRun() throws Exception
+ {
+ LifecycleUtil.deactivateNoisy(object);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesContentProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesContentProvider.java
new file mode 100644
index 0000000..7c80e2d
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesContentProvider.java
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * 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;
+
+import org.eclipse.net4j.buddies.protocol.IBuddyContainer;
+import org.eclipse.net4j.util.ui.StructuredContentProvider;
+
+/**
+ * @author Eike Stepper
+ */
+public class BuddiesContentProvider extends StructuredContentProvider<IBuddyContainer>
+{
+ public BuddiesContentProvider()
+ {
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ return getInput().getElements();
+ }
+
+ @Override
+ protected void connectInput(IBuddyContainer input)
+ {
+ input.addListener(this);
+ }
+
+ @Override
+ protected void disconnectInput(IBuddyContainer input)
+ {
+ input.removeListener(this);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesItemProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesItemProvider.java
index 9848cca..731d66b 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesItemProvider.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesItemProvider.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.buddies.internal.ui.views;
+package org.eclipse.net4j.buddies.internal.ui;
import org.eclipse.net4j.buddies.protocol.IMembership;
import org.eclipse.net4j.util.ui.views.IElementFilter;
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/ChatInstaller.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/ChatInstaller.java
index 7af82a7..f1b6866 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/ChatInstaller.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/ChatInstaller.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.buddies.internal.ui.views;
+package org.eclipse.net4j.buddies.internal.ui;
import org.eclipse.net4j.buddies.IBuddyCollaboration;
import org.eclipse.net4j.chat.IChat;
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsContentProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsContentProvider.java
new file mode 100644
index 0000000..fbac343
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsContentProvider.java
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * 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;
+
+import org.eclipse.net4j.buddies.protocol.ICollaborationContainer;
+import org.eclipse.net4j.util.ui.StructuredContentProvider;
+
+/**
+ * @author Eike Stepper
+ */
+public class CollaborationsContentProvider extends StructuredContentProvider<ICollaborationContainer>
+{
+ public CollaborationsContentProvider()
+ {
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ return getInput().getElements();
+ }
+
+ @Override
+ protected void connectInput(ICollaborationContainer input)
+ {
+ input.addListener(this);
+ }
+
+ @Override
+ protected void disconnectInput(ICollaborationContainer input)
+ {
+ input.removeListener(this);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsItemProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsItemProvider.java
new file mode 100644
index 0000000..aa0779c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/CollaborationsItemProvider.java
@@ -0,0 +1,107 @@
+/***************************************************************************
+ * 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;
+
+import org.eclipse.net4j.buddies.protocol.IMembership;
+import org.eclipse.net4j.internal.buddies.Self;
+import org.eclipse.net4j.util.ui.views.IElementFilter;
+
+import org.eclipse.swt.graphics.Image;
+
+import java.util.Collection;
+
+/**
+ * @author Eike Stepper
+ */
+public class CollaborationsItemProvider extends AbstractItemProvider
+{
+ public CollaborationsItemProvider()
+ {
+ }
+
+ public CollaborationsItemProvider(IElementFilter rootElementFilter)
+ {
+ super(rootElementFilter);
+ }
+
+ @Override
+ protected Node createNode(Node parent, Object element)
+ {
+ if (element instanceof Self)
+ {
+ return new SelfNode((Self)element);
+ }
+
+ if (element instanceof IMembership)
+ {
+ IMembership membership = (IMembership)element;
+ if (membership.getBuddy() instanceof Self)
+ {
+ return null;
+ }
+ }
+
+ return super.createNode(parent, element);
+ }
+
+ @Override
+ protected Node createMembershipNode(Node parent, IMembership membership)
+ {
+ return createLeafNode(parent, membership);
+ }
+
+ @Override
+ protected String getText(IMembership membership)
+ {
+ return getText(membership.getBuddy());
+ }
+
+ @Override
+ protected Image getImage(IMembership membership)
+ {
+ return getImage(membership.getBuddy());
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private class SelfNode extends AbstractContainerNode
+ {
+ private Self self;
+
+ public SelfNode(Self self)
+ {
+ super(null);
+ this.self = self;
+ }
+
+ @Override
+ public void dispose()
+ {
+ if (!isDisposed())
+ {
+ self.removeListener(containerListener);
+ super.dispose();
+ }
+ }
+
+ public Self getElement()
+ {
+ return self;
+ }
+
+ @Override
+ protected Node addChild(Collection<Node> children, Object element)
+ {
+ return super.addChild(children, ((IMembership)element).getCollaboration());
+ }
+ }
+}
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 0a031bc..b68c9fb 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,6 +11,7 @@
package org.eclipse.net4j.buddies.internal.ui.views;
import org.eclipse.net4j.buddies.IBuddyCollaboration;
+import org.eclipse.net4j.buddies.internal.ui.CollaborationsItemProvider;
import org.eclipse.net4j.buddies.internal.ui.bundle.OM;
import org.eclipse.net4j.buddies.ui.IFacilityPaneCreator;
import org.eclipse.net4j.util.StringUtil;