Skip to content

Commit

Permalink
[578422] Extend subscriber retrieval through extension points
Browse files Browse the repository at this point in the history
- Manage providers in registry and expose registry through UI plugin
- Providers can map from comparison input data to Team subscriber
- Providers may be ranked to allow for easier execution control
- Use previous subscriber retrieval behavior in new subscriber provider

Bug: 578422
Change-Id: Ifd1dc9e7d5dbc19cdd2f9c1d6899ea1049475845
Signed-off-by: Martin Fleck <mfleck@eclipsesource.com>
  • Loading branch information
martin-fleck-at committed Jan 28, 2022
1 parent e739909 commit cdf1917
Show file tree
Hide file tree
Showing 9 changed files with 623 additions and 82 deletions.
8 changes: 8 additions & 0 deletions plugins/org.eclipse.emf.compare.ide.ui/plugin.xml
Expand Up @@ -23,6 +23,7 @@
<extension-point id="modelMinimizers" name="Logical Model Minimizers" schema="schema/modelMinimizers.exsd"/>
<extension-point id="modelDependencyProvider" name="Model Dependency Provider" schema="schema/modelDependencyProvider.exsd"/>
<extension-point id="mergeResolutionListener" name="Merge Resolution Listener" schema="schema/mergeResolutionListener.exsd"/>
<extension-point id="subscriberProvider" name="Subscriber Provider" schema="schema/subscriberProvider.exsd"/>

<extension
point="org.eclipse.compare.structureMergeViewers">
Expand Down Expand Up @@ -602,4 +603,11 @@
contextId="org.eclipse.compare.compareEditorScope">
</key>
</extension>
<extension
point="org.eclipse.emf.compare.ide.ui.subscriberProvider">
<provider
class="org.eclipse.emf.compare.ide.ui.subscriber.TeamSubscriberProvider"
ranking="0">
</provider>
</extension>
</plugin>
122 changes: 122 additions & 0 deletions plugins/org.eclipse.emf.compare.ide.ui/schema/subscriberProvider.exsd
@@ -0,0 +1,122 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.emf.compare.ide.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.eclipse.emf.compare.ide.ui" id="subscriberProvider" name="Subscriber Provider"/>
</appinfo>
<documentation>
The extension point can be used to support the mapping from a comparison input to a Team Subscriber that manages the mapping between local resources and a remote resources.
</documentation>
</annotation>

<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence>
<element ref="provider" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>

</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="provider">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
The fully qualified name of a class that implements org.eclipse.emf.compare.ide.ui.subscriber.ISubscriberProvider
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.eclipse.emf.compare.ide.ui.subscriber.ISubscriberProvider"/>
</appinfo>
</annotation>
</attribute>
<attribute name="ranking" type="string" use="default" value="0">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
</complexType>
</element>

<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
4.4.3
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
&lt;extension
point=&quot;org.eclipse.emf.compare.ide.ui.subscriberProvider&quot;&gt;
&lt;provider
class=&quot;org.eclipse.emf.compare.ide.ui.subscriber.TeamSubscriberProvider&quot;
ranking=&quot;0&quot;&gt;
&lt;/provider&gt;
&lt;/extension&gt;
</documentation>
</annotation>


<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
See org.eclipse.emf.compare.ide.ui/plugin.xml for existing contributions.
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="copyright"/>
</appinfo>
<documentation>
Copyright (c) 2022 EclipseSource and others.
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:
Martin Fleck - initial API and implementation
</documentation>
</annotation>

</schema>
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2017 Obeo and others.
* Copyright (c) 2012, 2022 Obeo and others.
* 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
Expand All @@ -10,6 +10,7 @@
* Stefan Dirix - Bug 456699
* Michael Borkowski - Bug 462863
* Martin Fleck - Bug 512562
* Martin Fleck - Bug 578422
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal;

Expand All @@ -33,7 +34,9 @@
import org.eclipse.emf.compare.ide.ui.internal.logical.view.registry.LogicalModelViewHandlerRegistryListener;
import org.eclipse.emf.compare.ide.ui.internal.mergeresolution.MergeResolutionListenerRegistry;
import org.eclipse.emf.compare.ide.ui.internal.mergeresolution.MergeResolutionListenerRegistryListener;
import org.eclipse.emf.compare.ide.ui.internal.subscriber.SubscriberProviderRegistryListener;
import org.eclipse.emf.compare.ide.ui.logical.IModelMinimizer;
import org.eclipse.emf.compare.ide.ui.subscriber.SubscriberProviderRegistry;
import org.eclipse.emf.compare.rcp.extension.AbstractRegistryEventListener;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
Expand All @@ -45,6 +48,7 @@
*
* @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
*/
@SuppressWarnings("restriction")
public class EMFCompareIDEUIPlugin extends AbstractUIPlugin {
/** The plugin ID. */
public static final String PLUGIN_ID = "org.eclipse.emf.compare.ide.ui"; //$NON-NLS-1$
Expand All @@ -67,6 +71,9 @@ public class EMFCompareIDEUIPlugin extends AbstractUIPlugin {
/** Merge resolution listener extension point. */
private static final String MERGE_RESOLUTION_PPID = "mergeResolutionListener"; //$NON-NLS-1$

/** Subscriber provider extension point. */
private static final String SUBSCRIBER_PROVIDER_PPID = "subscriberProvider"; //$NON-NLS-1$

/** keep track of resources that should be freed when exiting. */
private static Map<String, Image> resourcesMapper = new HashMap<String, Image>();

Expand Down Expand Up @@ -100,6 +107,12 @@ public class EMFCompareIDEUIPlugin extends AbstractUIPlugin {
/** Registry for the merge resolution listener extension point. */
private MergeResolutionListenerRegistry mergeResolutionListenerRegistry;

/** Registry for the subscriber provider extension point. */
private SubscriberProviderRegistry subscriberProviderRegistry;

/** Listener for the subscriber provider extension point. */
private SubscriberProviderRegistryListener subscriberProviderRegistryListener;

/** Default constructor. */
public EMFCompareIDEUIPlugin() {
// Empty constructor
Expand All @@ -120,6 +133,7 @@ public void start(BundleContext context) throws Exception {
logicalModelViewHandlerRegistry = new LogicalModelViewHandlerRegistry();
modelMinimizerRegistry = new ModelMinimizerRegistry();
mergeResolutionListenerRegistry = new MergeResolutionListenerRegistry();
subscriberProviderRegistry = new SubscriberProviderRegistry();

final IExtensionRegistry globalRegistry = Platform.getExtensionRegistry();

Expand Down Expand Up @@ -148,6 +162,11 @@ public void start(BundleContext context) throws Exception {
globalRegistry.addListener(modelMinimizerRegistryListener);
modelMinimizerRegistryListener.readRegistry(globalRegistry);

subscriberProviderRegistryListener = new SubscriberProviderRegistryListener(PLUGIN_ID,
SUBSCRIBER_PROVIDER_PPID, getLog(), subscriberProviderRegistry);
globalRegistry.addListener(subscriberProviderRegistryListener);
subscriberProviderRegistryListener.readRegistry(globalRegistry);

Platform.getAdapterManager().registerAdapters(new PropertySheetAdapterFactory(), CompareEditor.class);
}

Expand All @@ -165,6 +184,8 @@ public void stop(BundleContext context) throws Exception {
modelResolverRegistry.clear();
globalRegistry.removeListener(modelDependencyProviderRegistryListener);
modelDependencyProviderRegistry.clear();
globalRegistry.removeListener(subscriberProviderRegistryListener);
subscriberProviderRegistry.clear();
plugin = null;
super.stop(context);
}
Expand Down Expand Up @@ -279,6 +300,15 @@ public MergeResolutionListenerRegistry getMergeResolutionListenerRegistry() {
return mergeResolutionListenerRegistry;
}

/**
* Returns the registry containing all known subscriber providers.
*
* @return The registry containing all known subscriber providers.
*/
public SubscriberProviderRegistry getSubscriberProviderRegistry() {
return subscriberProviderRegistry;
}

/**
* Log an {@link Exception} in the {@link #getLog() current logger}.
*
Expand Down

0 comments on commit cdf1917

Please sign in to comment.