summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-13 05:18:08 (EDT)
committerEike Stepper2007-10-13 05:18:08 (EDT)
commitcd323ea531e87aa2f4459182779106361c660529 (patch)
tree135197ebf51a3ef254bb026e92b2cd43ce1758c6
parentf8eb99dd533b77b3a7804f488c5a15f5f3a394db (diff)
downloadcdo-cd323ea531e87aa2f4459182779106361c660529.zip
cdo-cd323ea531e87aa2f4459182779106361c660529.tar.gz
cdo-cd323ea531e87aa2f4459182779106361c660529.tar.bz2
[206223] Provide collaborations example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206223
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java86
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java52
2 files changed, 61 insertions, 77 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 5c461ff..817a099 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,24 +12,18 @@ 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.protocol.IFacilityInstalledEvent;
import org.eclipse.net4j.buddies.ui.IFacilityPaneCreator;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.StringUtil;
-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.net4j.util.ui.actions.SafeAction;
-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.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -37,7 +31,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
import java.util.ArrayList;
import java.util.HashMap;
@@ -164,18 +157,29 @@ public class CollaborationsPane extends Composite implements IListener
public void fillActionBars(IActionBars bars)
{
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, OM.EXT_POINT);
- for (final IConfigurationElement element : elements)
+ for (IFacilityPaneCreator c : collaborationsView.getFacilityPaneCreators().values())
{
- if ("facilityPaneCreator".equals(element.getName()))
+ ActivateFacilityAction action = new ActivateFacilityAction(c.getType(), c.getImageDescriptor());
+ activateFacilityActions.add(action);
+ bars.getToolBarManager().add(action);
+ }
+ }
+
+ public void updateState()
+ {
+ for (ActivateFacilityAction action : activateFacilityActions)
+ {
+ if (activeCollaboration == null)
{
- String type = element.getAttribute("type");
- String icon = element.getAttribute("icon");
- ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(OM.BUNDLE_ID, icon);
- ActivateFacilityAction action = new ActivateFacilityAction(type, descriptor);
- activateFacilityActions.add(action);
- bars.getToolBarManager().add(action);
+ action.setEnabled(false);
+ }
+ else
+ {
+ String type = action.getType();
+ action.setEnabled(activeCollaboration.getFacility(type) != null);
+
+ IFacility activeFacility = activeFacilities.get(activeCollaboration);
+ action.setChecked(activeFacility != null && ObjectUtil.equals(activeFacility.getType(), type));
}
}
}
@@ -276,56 +280,12 @@ public class CollaborationsPane extends Composite implements IListener
protected FacilityPane addFacilityPane(IFacility facility)
{
- IFacilityPaneCreator creator = getFacilityPaneCreator(facility.getType());
- FacilityPane pane = creator.createFacilityPane(this, SWT.NONE);
+ IFacilityPaneCreator creator = collaborationsView.getFacilityPaneCreators().get(facility.getType());
+ FacilityPane pane = creator.createPane(this, SWT.NONE);
facilityPanes.put(facility, pane);
return pane;
}
- protected IFacilityPaneCreator getFacilityPaneCreator(String type)
- {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, OM.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);
- }
-
- public void updateState()
- {
- for (ActivateFacilityAction action : activateFacilityActions)
- {
- if (activeCollaboration == null)
- {
- action.setEnabled(false);
- }
- else
- {
- String type = action.getType();
- action.setEnabled(activeCollaboration.getFacility(type) != null);
-
- IFacility activeFacility = activeFacilities.get(activeCollaboration);
- action.setChecked(activeFacility != null && ObjectUtil.equals(activeFacility.getType(), type));
- }
- }
- }
-
/**
* @author Eike Stepper
*/
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 7d700e2..0de91c2 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
@@ -12,6 +12,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.util.StringUtil;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IContainer;
@@ -34,14 +35,19 @@ import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import java.util.HashMap;
+import java.util.Map;
public class CollaborationsView extends SessionManagerView
{
private SashComposite sashComposite;
+ private Map<String, IFacilityPaneCreator> facilityPaneCreators = new HashMap<String, IFacilityPaneCreator>();
+
public CollaborationsView()
{
+ initFacilityPaneCreators();
}
public CollaborationsPane getCollaborationsPane()
@@ -49,6 +55,11 @@ public class CollaborationsView extends SessionManagerView
return (CollaborationsPane)sashComposite.getControl2();
}
+ public Map<String, IFacilityPaneCreator> getFacilityPaneCreators()
+ {
+ return facilityPaneCreators;
+ }
+
@Override
protected Control createControl(Composite parent)
{
@@ -107,21 +118,13 @@ public class CollaborationsView extends SessionManagerView
{
IBuddyCollaboration collaboration = (IBuddyCollaboration)firstElement;
manager.add(new Separator());
-
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, OM.EXT_POINT);
- for (final IConfigurationElement element : elements)
+ for (IFacilityPaneCreator c : facilityPaneCreators.values())
{
- if ("facilityPaneCreator".equals(element.getName()))
+ String type = c.getType();
+ if (collaboration.getFacility(type) == null)
{
- String type = element.getAttribute("type");
- if (collaboration.getFacility(type) == null)
- {
- String icon = element.getAttribute("icon");
- ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(OM.BUNDLE_ID, icon);
- IAction action = new InstallFacilityAction(collaboration, type, descriptor);
- manager.add(action);
- }
+ IAction action = new InstallFacilityAction(collaboration, type, c.getImageDescriptor());
+ manager.add(action);
}
}
}
@@ -165,6 +168,27 @@ public class CollaborationsView extends SessionManagerView
};
}
+ protected void initFacilityPaneCreators()
+ {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, OM.EXT_POINT);
+ for (final IConfigurationElement element : elements)
+ {
+ if ("facilityPaneCreator".equals(element.getName()))
+ {
+ try
+ {
+ IFacilityPaneCreator creator = (IFacilityPaneCreator)element.createExecutableExtension("class");
+ facilityPaneCreators.put(creator.getType(), creator);
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+ }
+
/**
* @author Eike Stepper
*/