summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-11 06:18:05 (EDT)
committerEike Stepper2007-10-11 06:18:05 (EDT)
commitc6a5b042dfd501c05662ea690aa01a58723529b0 (patch)
tree3bf79621cc3f9202879cf68aa19bdfae1c07c17a
parentd4efae0b5518fcdd92afed8832e2bd237214f1d9 (diff)
downloadcdo-c6a5b042dfd501c05662ea690aa01a58723529b0.zip
cdo-c6a5b042dfd501c05662ea690aa01a58723529b0.tar.gz
cdo-c6a5b042dfd501c05662ea690aa01a58723529b0.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/CollaborationsPane.java50
1 files changed, 47 insertions, 3 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java
index 4ee8e86..8f0a54d 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java
@@ -12,13 +12,21 @@ package org.eclipse.net4j.buddies.internal.ui.views;
import org.eclipse.net4j.buddies.IBuddyCollaboration;
import org.eclipse.net4j.buddies.IBuddySession;
+import org.eclipse.net4j.buddies.internal.ui.bundle.OM;
import org.eclipse.net4j.buddies.protocol.ICollaboration;
import org.eclipse.net4j.buddies.protocol.IFacility;
+import org.eclipse.net4j.buddies.ui.IFacilityPaneCreator;
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.IContainerEvent;
import org.eclipse.net4j.util.container.IContainerEventVisitor;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
@@ -33,6 +41,8 @@ import java.util.Map;
*/
public class CollaborationsPane extends Composite implements IListener
{
+ public static final String EXT_POINT = "facilityPaneCreators";
+
private CollaborationsView collaborationsView;
private ISelectionChangedListener collaborationsViewerListener = new ISelectionChangedListener()
@@ -44,6 +54,8 @@ public class CollaborationsPane extends Composite implements IListener
private IBuddySession session;
+ private IBuddyCollaboration activeCollaboration;
+
private Map<IBuddyCollaboration, IFacility> activeFacilities = new HashMap<IBuddyCollaboration, IFacility>();
private Map<IFacility, FacilityPane> facilityPanes = new HashMap<IFacility, FacilityPane>();
@@ -81,6 +93,17 @@ public class CollaborationsPane extends Composite implements IListener
this.session = session;
}
+ public void setActiveFacility(IBuddyCollaboration collaboration, IFacility facility)
+ {
+ activeFacilities.put(collaboration, facility);
+ if (collaboration == activeCollaboration)
+ {
+ FacilityPane facilityPane = facilityPanes.get(facility);
+ paneStack.topControl = facilityPane;
+ layout();
+ }
+ }
+
public void notifyEvent(IEvent event)
{
if (session != null && event.getSource() == session.getSelf() && event instanceof IContainerEvent)
@@ -115,13 +138,34 @@ public class CollaborationsPane extends Composite implements IListener
protected FacilityPane addFacilityPane(IFacility facility)
{
- FacilityPane pane = createFacilityPane(facility.getType());
+ IFacilityPaneCreator creator = getFacilityPaneCreator(facility.getType());
+ FacilityPane pane = creator.createFacilityPane(this, SWT.NONE);
facilityPanes.put(facility, pane);
return pane;
}
- protected FacilityPane createFacilityPane(String type)
+ protected IFacilityPaneCreator getFacilityPaneCreator(String type)
{
- return null;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, EXT_POINT);
+ for (final IConfigurationElement element : elements)
+ {
+ if ("facilityPaneCreator".equals(element.getName()))
+ {
+ if (ObjectUtil.equals(element.getAttribute("type"), type))
+ {
+ try
+ {
+ return (IFacilityPaneCreator)element.createExecutableExtension("class");
+ }
+ catch (CoreException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+ }
+ }
+
+ throw new IllegalStateException("No facility pane creator for type " + type);
}
}