summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-11 14:14:11 (EDT)
committerEike Stepper2007-10-11 14:14:11 (EDT)
commit5b85336ac1d70cf0131425df881fdf72ab6adecf (patch)
tree71b9f59c8889f4fc205781df438ca497acc6189e
parent2c3b751c168cd1f1553d6b1087eeb379460d8082 (diff)
downloadcdo-5b85336ac1d70cf0131425df881fdf72ab6adecf.zip
cdo-5b85336ac1d70cf0131425df881fdf72ab6adecf.tar.gz
cdo-5b85336ac1d70cf0131425df881fdf72ab6adecf.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeManyToOneMapping.gifbin0 -> 204 bytes
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeOneToManyMapping.gifbin0 -> 200 bytes
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeOneToOneMapping.gifbin0 -> 192 bytes
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/plugin.xml15
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/schema/facilityPaneCreators.exsd15
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java47
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java68
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java14
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java8
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java2
12 files changed, 144 insertions, 29 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
index 32162f5..a903b08 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
@@ -54,7 +54,7 @@ public class InstallFacilityIndication extends IndicationWithResponse
IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, facilityType, description);
Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
facility.setCollaboration(collaboration);
- collaboration.addFacility(facility);
+ collaboration.addFacility(facility, true);
success = true;
}
catch (RuntimeException ex)
diff --git a/plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeManyToOneMapping.gif b/plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeManyToOneMapping.gif
new file mode 100644
index 0000000..6743955
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeManyToOneMapping.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeOneToManyMapping.gif b/plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeOneToManyMapping.gif
new file mode 100644
index 0000000..c19520b
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeOneToManyMapping.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeOneToOneMapping.gif b/plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeOneToOneMapping.gif
new file mode 100644
index 0000000..4703360
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/icons/full/TypeOneToOneMapping.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.buddies.ui/plugin.xml b/plugins/org.eclipse.net4j.buddies.ui/plugin.xml
index d18612f..48018f7 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/plugin.xml
+++ b/plugins/org.eclipse.net4j.buddies.ui/plugin.xml
@@ -22,14 +22,17 @@
<extension
point="org.eclipse.net4j.buddies.ui.facilityPaneCreators">
<facilityPaneCreator
- class="org.eclipse.net4j.buddies.internal.ui.Test1PaneCreator"
- type="Test1Facility"/>
+ class="org.eclipse.net4j.buddies.internal.ui.Test1PaneCreator"
+ icon="icons/full/TypeManyToOneMapping.gif"
+ type="Test1Facility"/>
<facilityPaneCreator
- class="org.eclipse.net4j.buddies.internal.ui.Test2PaneCreator"
- type="Test2Facility"/>
+ class="org.eclipse.net4j.buddies.internal.ui.Test2PaneCreator"
+ icon="icons/full/TypeOneToManyMapping.gif"
+ type="Test2Facility"/>
<facilityPaneCreator
- class="org.eclipse.net4j.buddies.internal.ui.Test3PaneCreator"
- type="Test3Facility"/>
+ class="org.eclipse.net4j.buddies.internal.ui.Test3PaneCreator"
+ icon="icons/full/TypeOneToOneMapping.gif"
+ type="Test3Facility"/>
</extension>
<extension
diff --git a/plugins/org.eclipse.net4j.buddies.ui/schema/facilityPaneCreators.exsd b/plugins/org.eclipse.net4j.buddies.ui/schema/facilityPaneCreators.exsd
index 9be9ac3..3cee15e 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/schema/facilityPaneCreators.exsd
+++ b/plugins/org.eclipse.net4j.buddies.ui/schema/facilityPaneCreators.exsd
@@ -43,6 +43,11 @@
</element>
<element name="facilityPaneCreator">
+ <annotation>
+ <appInfo>
+ <meta.element labelAttribute="type" icon="icon"/>
+ </appInfo>
+ </annotation>
<complexType>
<attribute name="type" type="string" use="required">
<annotation>
@@ -61,6 +66,16 @@
</appInfo>
</annotation>
</attribute>
+ <attribute name="icon" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java
index 9bc3e65..384c61b 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/bundle/OM.java
@@ -26,6 +26,8 @@ public abstract class OM
{
public static final String BUNDLE_ID = "org.eclipse.net4j.buddies.ui"; //$NON-NLS-1$
+ public static final String EXT_POINT = "facilityPaneCreators";
+
public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
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 19469a5..e1201a1 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
@@ -10,13 +10,12 @@
**************************************************************************/
package org.eclipse.net4j.buddies.internal.ui.views;
-import org.eclipse.net4j.buddies.BuddiesUtil;
import org.eclipse.net4j.buddies.IBuddyCollaboration;
import org.eclipse.net4j.buddies.IBuddySession;
-import org.eclipse.net4j.buddies.internal.ui.SharedIcons;
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;
@@ -32,26 +31,25 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
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;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* @author Eike Stepper
*/
public class CollaborationsPane extends Composite implements IListener
{
- public static final String EXT_POINT = "facilityPaneCreators";
-
private CollaborationsView collaborationsView;
private ISelectionChangedListener collaborationsViewerListener = new ISelectionChangedListener()
@@ -158,16 +156,25 @@ public class CollaborationsPane extends Composite implements IListener
public void fillActionBars(IActionBars bars)
{
- for (String type : BuddiesUtil.getFacilityTypes())
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, OM.EXT_POINT);
+ for (final IConfigurationElement element : elements)
{
- IAction action = new ActivateFacilityAction(type);
- activateFacilityActions.add(action);
- bars.getToolBarManager().add(action);
+ if ("facilityPaneCreator".equals(element.getName()))
+ {
+ String type = element.getAttribute("type");
+ String icon = element.getAttribute("icon");
+ ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(OM.BUNDLE_ID, icon);
+ IAction action = new ActivateFacilityAction(type, descriptor);
+ activateFacilityActions.add(action);
+ bars.getToolBarManager().add(action);
+ }
}
}
public void notifyEvent(IEvent event)
{
+ System.out.println("EVENT: " + event);
if (session != null && event.getSource() == session.getSelf() && event instanceof IContainerEvent)
{
IContainerEvent<ICollaboration> e = (IContainerEvent<ICollaboration>)event;
@@ -184,9 +191,10 @@ public class CollaborationsPane extends Composite implements IListener
}
});
}
- else
+ else if (event instanceof IFacilityInstalledEvent)
{
- System.out.println("EVENT: " + event);
+ IFacilityInstalledEvent e = (IFacilityInstalledEvent)event;
+ facilityInstalled(e.getFacility(), e.fromRemote());
}
}
@@ -213,6 +221,17 @@ public class CollaborationsPane extends Composite implements IListener
{
}
+ protected void facilityInstalled(IFacility facility, boolean fromRemote)
+ {
+ addFacilityPane(facility);
+ if (!fromRemote)
+ {
+ IBuddyCollaboration collaboration = (IBuddyCollaboration)facility.getCollaboration();
+ setActiveCollaboration(collaboration);
+ setActiveFacility(collaboration, facility);
+ }
+ }
+
protected FacilityPane addFacilityPane(IFacility facility)
{
IFacilityPaneCreator creator = getFacilityPaneCreator(facility.getType());
@@ -224,7 +243,7 @@ public class CollaborationsPane extends Composite implements IListener
protected IFacilityPaneCreator getFacilityPaneCreator(String type)
{
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, EXT_POINT);
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, OM.EXT_POINT);
for (final IConfigurationElement element : elements)
{
if ("facilityPaneCreator".equals(element.getName()))
@@ -253,11 +272,11 @@ public class CollaborationsPane extends Composite implements IListener
{
private final String type;
- private ActivateFacilityAction(String type)
+ private ActivateFacilityAction(String type, ImageDescriptor descriptor)
{
super(StringUtil.cap(type), AS_RADIO_BUTTON);
setToolTipText("Activate " + type + " facility");
- setImageDescriptor(SharedIcons.getDescriptor(SharedIcons.OBJ_COLLABORATION));
+ setImageDescriptor(descriptor);
this.type = type;
}
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 035ec94..01fec70 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
@@ -10,16 +10,27 @@
**************************************************************************/
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.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.ui.actions.SafeAction;
import org.eclipse.net4j.util.ui.widgets.SashComposite;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
public class CollaborationsView extends SessionManagerView
{
@@ -74,8 +85,65 @@ public class CollaborationsView extends SessionManagerView
}
@Override
+ protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
+ {
+ super.fillContextMenu(manager, selection);
+ if (selection.size() == 1)
+ {
+ Object firstElement = selection.getFirstElement();
+ if (firstElement instanceof IBuddyCollaboration)
+ {
+ 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)
+ {
+ if ("facilityPaneCreator".equals(element.getName()))
+ {
+ 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);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
protected IContainer<?> getContainer()
{
return getSession() != null ? getSession().getSelf() : ContainerUtil.emptyContainer();
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class InstallFacilityAction extends SafeAction
+ {
+ private final String type;
+
+ private IBuddyCollaboration collaboration;
+
+ private InstallFacilityAction(IBuddyCollaboration collaboration, String type, ImageDescriptor descriptor)
+ {
+ super("Install " + type, AS_RADIO_BUTTON);
+ setToolTipText("Install " + type + " facility");
+ setImageDescriptor(descriptor);
+ this.collaboration = collaboration;
+ this.type = type;
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ collaboration.installFacility(type);
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
index ba2c6ce..be65709 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.internal.buddies;
+import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.IBuddyCollaboration;
import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.protocol.ClientFacilityFactory;
@@ -35,9 +36,10 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
private IBuddySession session;
- public BuddyCollaboration(long id, Set<IBuddy> buddies)
+ public BuddyCollaboration(IBuddySession session, long id, Set<IBuddy> buddies)
{
super(id, buddies);
+ this.session = session;
}
public IBuddySession getSession()
@@ -49,13 +51,15 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
{
try
{
- String description = String.valueOf(getID());
- IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, type, description);
+ IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, type, String
+ .valueOf(getID()));
facility.setCollaboration(this);
- boolean success = new InstallFacilityRequest(session.getChannel(), getID(), type).send(ProtocolConstants.TIMEOUT);
+
+ IChannel channel = session.getChannel();
+ boolean success = new InstallFacilityRequest(channel, getID(), type).send(ProtocolConstants.TIMEOUT);
if (success)
{
- addFacility(facility);
+ addFacility(facility, false);
return facility;
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java
index 178fd66..6c37cd6 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.internal.buddies;
+import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.internal.protocol.Buddy;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.IAccount;
@@ -54,8 +55,11 @@ public class Self extends Buddy
{
try
{
- long id = new InitiateCollaborationRequest(getSession().getChannel(), buddies).send(ProtocolConstants.TIMEOUT);
- BuddyCollaboration collaboration = new BuddyCollaboration(id, buddies);
+ ClientSession session = getSession();
+ IChannel channel = session.getChannel();
+ long id = new InitiateCollaborationRequest(channel, buddies).send(ProtocolConstants.TIMEOUT);
+
+ BuddyCollaboration collaboration = new BuddyCollaboration(session, id, buddies);
LifecycleUtil.activate(collaboration);
addCollaboration(collaboration);
return collaboration;
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java
index 9ef2337..60aa4db 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java
@@ -58,7 +58,7 @@ public class CollaborationInitiatedIndication extends Indication
}
}
- BuddyCollaboration collaboration = new BuddyCollaboration(collaborationID, buddies);
+ BuddyCollaboration collaboration = new BuddyCollaboration(session, collaborationID, buddies);
LifecycleUtil.activate(collaboration);
self.addCollaboration(collaboration);
for (IBuddy buddy : buddies)