Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Dirix2016-08-10 07:57:57 +0000
committerStefan Dirix2017-01-13 11:40:44 +0000
commit5aeefe6e825a9d7b529202b48fd3dc64501c0021 (patch)
treed1c08b8f91052a44e7006f9b01e0c3f22b3f6ddc /plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare
parenta6cb5f1bd528d972fc41cc14907375aeb5ea13dc (diff)
downloadorg.eclipse.emf.compare-5aeefe6e825a9d7b529202b48fd3dc64501c0021.tar.gz
org.eclipse.emf.compare-5aeefe6e825a9d7b529202b48fd3dc64501c0021.tar.xz
org.eclipse.emf.compare-5aeefe6e825a9d7b529202b48fd3dc64501c0021.zip
Introduce ContentProviders for TreeContentMergeViewer
This refactoring has two distinct goals: Clear separation of concerns in the code and allowing the user to customize the TreeContentMergeViewer. Currently the MergeViewerItem serves the dual use of wrapping the displayed model but is also responsible to determine its parents, children and stub elements. The later tasks are now separated to different ContentProviders. The content of the TreeContentMergeViewer is now determined by 'IMergeViewerItemContentProvider's which can be registered at the new extension point 'contentMergeViewerCustomization'. The default implementation uses the existing EMFCompare adapterFactory mechanism to determine the 'real' and 'stub' content of the TreeContentMergeViewer. Additionally the new 'ImergeViewerItemProvider's are used to determine the root elements of the tree, currently provided by the 'ICompareAccessors'. The new customizations are extensively used within the Papyrus customizations for EMFCompare. Change-Id: I5f3cc5143b71ed3f517e427868395a5e14638fea Signed-off-by: Alexandra Buzila <abuzila@eclipsesource.com> Signed-off-by: Stefan Dirix <sdirix@eclipsesource.com>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare')
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/EMFCompareRCPUIPlugin.java29
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationDescriptor.java171
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationRegistry.java159
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationRegistryListener.java158
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/emfcomparercpuimessages.properties5
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java5
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/item/impl/MergeViewerItem.java13
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/item/impl/ResourceAttachmentChangeProvider.java53
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/IMergeViewerItem.java4
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemContentProvider.java56
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemProvider.java48
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemProviderConfiguration.java63
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IOptionalProvider.java28
13 files changed, 786 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/EMFCompareRCPUIPlugin.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/EMFCompareRCPUIPlugin.java
index c0fe60a61..807904c6a 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/EMFCompareRCPUIPlugin.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/EMFCompareRCPUIPlugin.java
@@ -31,6 +31,8 @@ import org.eclipse.emf.compare.rcp.ui.internal.configuration.ui.ConfigurationUIR
import org.eclipse.emf.compare.rcp.ui.internal.configuration.ui.IConfigurationUIFactory;
import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.factory.impl.AccessorFactoryExtensionRegistryListener;
import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.factory.impl.AccessorFactoryRegistryImpl;
+import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.customization.ContentMergeViewerCustomizationRegistry;
+import org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.customization.ContentMergeViewerCustomizationRegistryListener;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.DifferenceFilterExtensionRegistryListener;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.DifferenceFilterManager;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.DifferenceFilterRegistryImpl;
@@ -87,6 +89,11 @@ public class EMFCompareRCPUIPlugin extends AbstractUIPlugin {
private static final String MATCH_ENGINE_FACTORY_CONFIGURATION_UI_PPID = "matchEngineFactoryConfigurationUI";//$NON-NLS-1$
/**
+ * @since 4.4
+ */
+ private static final String CONTENT_CUSTOMIZATION_PPID = "contentMergeViewerCustomization"; //$NON-NLS-1$
+
+ /**
* the shared instance.
*/
private static EMFCompareRCPUIPlugin plugin;
@@ -118,6 +125,10 @@ public class EMFCompareRCPUIPlugin extends AbstractUIPlugin {
private ConfigurationUIRegistryEventListener matchEngineConfiguratorRegistryListener;
+ private AbstractRegistryEventListener contentMergeViewerCustomizationRegistryListener;
+
+ private ContentMergeViewerCustomizationRegistry contentMergeViewerCustomizationRegistry;
+
@Deprecated
private IEMFCompareConfiguration compareConfiguration;
@@ -188,6 +199,13 @@ public class EMFCompareRCPUIPlugin extends AbstractUIPlugin {
extensionRegistry.addListener(matchEngineConfiguratorRegistryListener,
PLUGIN_ID + '.' + MATCH_ENGINE_FACTORY_CONFIGURATION_UI_PPID);
matchEngineConfiguratorRegistryListener.readRegistry(extensionRegistry);
+
+ contentMergeViewerCustomizationRegistry = new ContentMergeViewerCustomizationRegistry();
+ contentMergeViewerCustomizationRegistryListener = new ContentMergeViewerCustomizationRegistryListener(
+ PLUGIN_ID, CONTENT_CUSTOMIZATION_PPID, getLog(), contentMergeViewerCustomizationRegistry);
+ extensionRegistry.addListener(contentMergeViewerCustomizationRegistryListener,
+ PLUGIN_ID + '.' + CONTENT_CUSTOMIZATION_PPID);
+ contentMergeViewerCustomizationRegistryListener.readRegistry(extensionRegistry);
}
/*
@@ -304,6 +322,17 @@ public class EMFCompareRCPUIPlugin extends AbstractUIPlugin {
}
/**
+ * Returns the registry containing all known content merge viewer customizations.
+ *
+ * @return the {@link ContentMergeViewerCustomizationRegistry} containing all known content merge viewer
+ * customizations.
+ * @since 4.4
+ */
+ public ContentMergeViewerCustomizationRegistry getContentMergeViewerCustomizationRegistry() {
+ return contentMergeViewerCustomizationRegistry;
+ }
+
+ /**
* <p>
* returns a plugin image. The returned image does not need to be explicitly disposed.
* </p>
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationDescriptor.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationDescriptor.java
new file mode 100644
index 000000000..fd2812bdb
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationDescriptor.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Muenchen GmbH 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:
+ * Stefan Dirix - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.customization;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.compare.adapterfactory.context.IContextTester;
+import org.eclipse.emf.compare.rcp.ui.EMFCompareRCPUIPlugin;
+import org.eclipse.emf.compare.rcp.ui.internal.EMFCompareRCPUIMessages;
+
+/**
+ * The generic descriptor for content merge viewer customizations.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ * @param <T>
+ * the type of object produced by the descriptor.
+ */
+public class ContentMergeViewerCustomizationDescriptor<T> {
+
+ /**
+ * Underlying {@link IConfigurationElement} describing this customization.
+ */
+ private final IConfigurationElement configurationElement;
+
+ /**
+ * Ranking of this handler.
+ */
+ private final int ranking;
+
+ /**
+ * Qualified class name of the provider from this {@link #configurationElement}. Will be used as
+ * identifier.
+ */
+ private final String providerClassName;
+
+ private final String providerAttributeName;
+
+ /**
+ * Qualified class name of the context class
+ */
+ private final String contextClassName;
+
+ private final String contextAttributeName;
+
+ /**
+ * Don't log the same error multiple times.
+ */
+ private boolean logOnce;
+
+ /**
+ * Don't log the same error multiple times.
+ */
+ private boolean logOnceContext;
+
+ /**
+ * The provider provided by this descriptor.
+ */
+ private T provider;
+
+ /**
+ * The context tester provided by this descriptor.
+ */
+ private IContextTester contextTester;
+
+ /**
+ * Default constructor.
+ *
+ * @param configurationElement
+ * Configuration element that served to populate this descriptor.
+ * @param contentProviderClass
+ * The contentProvider which
+ * @param mergeViewerItemProviderClass
+ * @param contextClass
+ * @param ranking
+ * Ranking of this handler. High-priority handlers take precedence over low-priority ones.
+ */
+ ContentMergeViewerCustomizationDescriptor(IConfigurationElement configurationElement,
+ String providerClass, String providerAttributeName, String contextClass,
+ String contextAttributeName, int ranking) {
+ this.configurationElement = checkNotNull(configurationElement);
+ this.providerClassName = checkNotNull(providerClass);
+ this.contextClassName = contextClass;
+ this.ranking = ranking;
+ this.providerAttributeName = providerAttributeName;
+ this.contextAttributeName = contextAttributeName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.ide.ui.internal.logical.view.ILogicalModelViewHandler#getRanking()
+ */
+ public int getRanking() {
+ return ranking;
+ }
+
+ /**
+ * Get the qualified class name of the described provider.
+ *
+ * @return the qualified class name of the described provider.
+ */
+ public String getProviderClassName() {
+ return providerClassName;
+ }
+
+ /**
+ * Create an instance of this provider.
+ *
+ * @return a new instance of this provider
+ */
+ @SuppressWarnings("unchecked")
+ T getProvider() {
+ if (provider == null) {
+ try {
+ provider = (T)configurationElement.createExecutableExtension(providerAttributeName);
+ } catch (CoreException e) {
+ // Shouldn't happen since the registry listener should have checked that.
+ // log anyway.
+ if (!logOnce) {
+ logOnce = true;
+ final String message = EMFCompareRCPUIMessages
+ .getString("ContentCustomizationRegistry.invalidProvider", providerClassName); //$NON-NLS-1$
+ final IStatus status = new Status(IStatus.ERROR,
+ configurationElement.getDeclaringExtension().getContributor().getName(), message,
+ e);
+ EMFCompareRCPUIPlugin.getDefault().getLog().log(status);
+ }
+ }
+ }
+ return provider;
+ }
+
+ /**
+ * Create an instance of this tester.
+ *
+ * @return a new instance of this tester.
+ */
+ IContextTester getContextTester() {
+ if (contextClassName != null && contextTester == null) {
+ try {
+ contextTester = (IContextTester)configurationElement
+ .createExecutableExtension(contextAttributeName);
+ } catch (CoreException e) {
+ // Shouldn't happen since the registry listener should have checked that.
+ // log anyway.
+ if (!logOnceContext) {
+ logOnceContext = true;
+ final String message = EMFCompareRCPUIMessages
+ .getString("ContentCustomizationRegistry.invalidContextTester", contextClassName); //$NON-NLS-1$
+ final IStatus status = new Status(IStatus.ERROR,
+ configurationElement.getDeclaringExtension().getContributor().getName(), message,
+ e);
+ EMFCompareRCPUIPlugin.getDefault().getLog().log(status);
+ }
+ }
+ }
+ return contextTester;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationRegistry.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationRegistry.java
new file mode 100644
index 000000000..1ae18bbf0
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationRegistry.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Muenchen GmbH 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:
+ * Stefan Dirix - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.customization;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.adapterfactory.context.IContextTester;
+import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider.IMergeViewerItemContentProvider;
+import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider.IMergeViewerItemProvider;
+import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider.IOptionalProvider;
+
+/**
+ * The registry responsible for managing the content merge viewer customizations.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ */
+public class ContentMergeViewerCustomizationRegistry {
+ /** Keeps track of the extensions providing {@link IMergeViewerItemProvider}s. */
+ private final Map<String, ContentMergeViewerCustomizationDescriptor<IMergeViewerItemProvider>> registeredDescriptors;
+
+ /** Keeps track of the extensions providing {@link IMergeViewerItemContentProvider}s. */
+ private final Map<String, ContentMergeViewerCustomizationDescriptor<IMergeViewerItemContentProvider>> registeredTreeDescriptors;
+
+ /**
+ * Constructs and initialized this registry.
+ */
+ public ContentMergeViewerCustomizationRegistry() {
+ registeredDescriptors = new LinkedHashMap<String, ContentMergeViewerCustomizationDescriptor<IMergeViewerItemProvider>>();
+ registeredTreeDescriptors = new LinkedHashMap<String, ContentMergeViewerCustomizationDescriptor<IMergeViewerItemContentProvider>>();
+ }
+
+ /**
+ * Adds the given {@link ContentMergeViewerCustomizationDescriptor} to this registry, using the given
+ * {@code className} as the identifier.
+ *
+ * @param className
+ * The identifier for the given {@link ContentMergeViewerCustomizationDescriptor}.
+ * @param descriptor
+ * The {@link ContentMergeViewerCustomizationDescriptor} which is to be added to this registry.
+ */
+ public void addCustomization(String className,
+ ContentMergeViewerCustomizationDescriptor<IMergeViewerItemProvider> descriptor) {
+ registeredDescriptors.put(className, descriptor);
+ }
+
+ /**
+ * Adds the given {@link ContentMergeViewerCustomizationDescriptor} to this registry, using the given
+ * {@code className} as the identifier.
+ *
+ * @param className
+ * The identifier for the given {@link ContentMergeViewerCustomizationDescriptor}.
+ * @param descriptor
+ * The {@link ContentMergeViewerCustomizationDescriptor} which is to be added to this registry.
+ */
+ public void addTreeCustomization(String className,
+ ContentMergeViewerCustomizationDescriptor<IMergeViewerItemContentProvider> descriptor) {
+ registeredTreeDescriptors.put(className, descriptor);
+ }
+
+ /**
+ * Removes the {@link ContentMergeViewerCustomizationDescriptor} and its managed
+ * {@link IDependencyProvider} identified by the given {@code className} from this registry.
+ *
+ * @param className
+ * Identifier of the provider we are to remove from this registry.
+ */
+ public void removeDescriptor(String className) {
+ registeredDescriptors.remove(className);
+ registeredTreeDescriptors.remove(className);
+ }
+
+ /** Clears out all registered listeners from this registry. */
+ public void clear() {
+ registeredDescriptors.clear();
+ registeredTreeDescriptors.clear();
+ }
+
+ private <T extends IOptionalProvider> T getBestFittingProvider(
+ Collection<ContentMergeViewerCustomizationDescriptor<T>> descriptors, Comparison comparison,
+ Object object) {
+ ContentMergeViewerCustomizationDescriptor<T> bestDescriptor = null;
+ final Map<Object, Object> context = createContext(comparison);
+
+ for (ContentMergeViewerCustomizationDescriptor<T> descriptor : descriptors) {
+ IContextTester contextTester = descriptor.getContextTester();
+ // check context
+ if (contextTester != null && !contextTester.apply(context)) {
+ continue;
+ }
+ // check ranking
+ if (bestDescriptor != null && bestDescriptor.getRanking() > descriptor.getRanking()) {
+ continue;
+ }
+ // check provider
+ if (descriptor.getProvider().canHandle(object)) {
+ bestDescriptor = descriptor;
+ }
+ }
+
+ if (bestDescriptor != null) {
+ return bestDescriptor.getProvider();
+ }
+
+ return null;
+ }
+
+ /**
+ * Creates the context for the {@link IContextTester}s.
+ *
+ * @param comparison
+ * the {@link Comparison}.
+ * @return the created context.
+ */
+ private Map<Object, Object> createContext(Comparison comparison) {
+ final Map<Object, Object> context = new HashMap<Object, Object>();
+ context.put(IContextTester.CTX_COMPARISON, comparison);
+ return context;
+ }
+
+ /**
+ * Returns the best fitting {@link IMergeViewerItemProvider}.
+ *
+ * @param comparison
+ * the {@link Comparison} is used to check the context.
+ * @param object
+ * the {@link Object} for which the {@link IMergeViewerItemProvider} is responsible.
+ * @return the determined {@link IMergeViewerItemProvider} if one exists, {@code null} otherwise.
+ */
+ public IMergeViewerItemProvider getBestFittingMergeViewerItemProvider(Comparison comparison,
+ Object object) {
+ return getBestFittingProvider(registeredDescriptors.values(), comparison, object);
+ }
+
+ /**
+ * Returns the best fitting {@link IMergeViewerItemContentProvider}.
+ *
+ * @param comparison
+ * the {@link Comparison} is used to check the context.
+ * @param object
+ * the {@link Object} for which the {@link IMergeViewerItemContentProvider} is responsible.
+ * @return the determined {@link IMergeViewerItemContentProvider} if one exists, {@code null} otherwise.
+ */
+ public IMergeViewerItemContentProvider getBestFittingMergeViewerItemContentProvider(Comparison comparison,
+ Object object) {
+ return getBestFittingProvider(registeredTreeDescriptors.values(), comparison, object);
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationRegistryListener.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationRegistryListener.java
new file mode 100644
index 000000000..3e27edd34
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/customization/ContentMergeViewerCustomizationRegistryListener.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Muenchen GmbH 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:
+ * Stefan Dirix - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.customization;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.compare.rcp.extension.AbstractRegistryEventListener;
+import org.eclipse.emf.compare.rcp.ui.internal.EMFCompareRCPUIMessages;
+import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider.IMergeViewerItemContentProvider;
+import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider.IMergeViewerItemProvider;
+
+/**
+ * The listener responsible for handling registration events regarding content merge viewer customizations.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ */
+public class ContentMergeViewerCustomizationRegistryListener extends AbstractRegistryEventListener {
+
+ /** The content customization tag of our extension point. */
+ private static final String TAG_CONTENT_CUSTOMIZATION = "contentCustomization"; //$NON-NLS-1$
+
+ /** The tree content customization tag of our extension point. */
+ private static final String TAG_TREE_CONTENT_CUSTOMIZATION = "treeContentCustomization"; //$NON-NLS-1$
+
+ /** The "contentProvider" attribute of the tree content customization tag. */
+ private static final String ATTRIBUTE_CONTENTPROVIDER = "contentProvider"; //$NON-NLS-1$
+
+ /** The "mergeViewerItemProvider" attribute of the tree content customization tag. */
+ private static final String ATTRIBUTE_MERGEVIEWERITEMPROVIDER = "mergeViewerItemProvider"; //$NON-NLS-1$
+
+ /** The "context" attribute of the tree content customization tag. */
+ private static final String ATTRIBUTE_CONTEXT = "context"; //$NON-NLS-1$
+
+ /** The "ranking" attribute of the tree content customization tag. */
+ private static final String ATTRIBUTE_RANKING = "ranking"; //$NON-NLS-1$
+
+ /** The actual registry this listener will alter. */
+ private final ContentMergeViewerCustomizationRegistry registry;
+
+ /**
+ * Initialize a registry event listener for our handlers.
+ *
+ * @param pluginID
+ * ID of the plugin contributing the extension point to monitor.
+ * @param extensionPointID
+ * Actual id of the extension point to monitor.
+ * @param log
+ * Log in which errors/warning should be logged.
+ * @param contentMergeViewerCustomizationRegistry
+ * The actual store of handlers this registry will alter.
+ */
+ public ContentMergeViewerCustomizationRegistryListener(String pluginID, String extensionPointID, ILog log,
+ ContentMergeViewerCustomizationRegistry contentMergeViewerCustomizationRegistry) {
+ super(pluginID, extensionPointID, log);
+ this.registry = contentMergeViewerCustomizationRegistry;
+ }
+
+ @Override
+ protected boolean addedValid(IConfigurationElement element) {
+ if (element.getName().equals(TAG_CONTENT_CUSTOMIZATION)) {
+ final String mergeViewerItemProvider = element.getAttribute(ATTRIBUTE_MERGEVIEWERITEMPROVIDER);
+
+ final String context = element.getAttribute(ATTRIBUTE_CONTEXT);
+
+ final String rankingStr = element.getAttribute(ATTRIBUTE_RANKING);
+ int ranking = -1;
+ try {
+ ranking = Integer.parseInt(rankingStr);
+ } catch (NumberFormatException e) {
+ log(IStatus.ERROR, element, EMFCompareRCPUIMessages.getString(
+ "ContentCustomizationRegistry.invalidRanking", mergeViewerItemProvider, rankingStr)); //$NON-NLS-1$
+ }
+
+ final ContentMergeViewerCustomizationDescriptor<IMergeViewerItemProvider> descriptor = new ContentMergeViewerCustomizationDescriptor<IMergeViewerItemProvider>(
+ element, mergeViewerItemProvider, ATTRIBUTE_MERGEVIEWERITEMPROVIDER, context,
+ ATTRIBUTE_CONTEXT, ranking);
+ registry.addCustomization(mergeViewerItemProvider, descriptor);
+ return true;
+ }
+ if (element.getName().equals(TAG_TREE_CONTENT_CUSTOMIZATION)) {
+ final String contentProvider = element.getAttribute(ATTRIBUTE_CONTENTPROVIDER);
+
+ final String context = element.getAttribute(ATTRIBUTE_CONTEXT);
+
+ final String rankingStr = element.getAttribute(ATTRIBUTE_RANKING);
+ int ranking = -1;
+ try {
+ ranking = Integer.parseInt(rankingStr);
+ } catch (NumberFormatException e) {
+ log(IStatus.ERROR, element, EMFCompareRCPUIMessages.getString(
+ "ContentCustomizationRegistry.invalidRanking", contentProvider, rankingStr)); //$NON-NLS-1$
+ }
+
+ final ContentMergeViewerCustomizationDescriptor<IMergeViewerItemContentProvider> descriptor = new ContentMergeViewerCustomizationDescriptor<IMergeViewerItemContentProvider>(
+ element, contentProvider, ATTRIBUTE_CONTENTPROVIDER, context, ATTRIBUTE_CONTEXT, ranking);
+ registry.addTreeCustomization(contentProvider, descriptor);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the attribute with the {@code attributeName} from the given {@code element}.
+ *
+ * @param element
+ * the {@link IConfigurationElement}.
+ * @param attributeName
+ * the name of the attribute which's value is to be determined.
+ * @param defaultResult
+ * the result of this method if the attribute does not exist.
+ * @return The determined value of the attribute if it exists, {@code defaultResult} otherwise.
+ */
+ protected String getAttribute(IConfigurationElement element, String attributeName, String defaultResult) {
+ String attribute = element.getAttribute(attributeName);
+ if (attribute != null) {
+ return attribute;
+ }
+ return defaultResult;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.rcp.extension.AbstractRegistryEventListener#removedValid(org.eclipse.core.runtime.IConfigurationElement)
+ */
+ @Override
+ protected boolean removedValid(IConfigurationElement element) {
+ final String className;
+ if (element.getName().equals(TAG_CONTENT_CUSTOMIZATION)) {
+ className = element.getAttribute(ATTRIBUTE_MERGEVIEWERITEMPROVIDER);
+ } else {
+ className = element.getAttribute(ATTRIBUTE_CONTENTPROVIDER);
+ }
+ registry.removeDescriptor(className);
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.rcp.extension.AbstractRegistryEventListener#validateExtensionElement(org.eclipse.core.runtime.IConfigurationElement)
+ */
+ @Override
+ protected boolean validateExtensionElement(IConfigurationElement element) {
+ // Don't work twice as much, validate as we add.
+ // Removing cannot fail.
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/emfcomparercpuimessages.properties b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/emfcomparercpuimessages.properties
index fd77e3408..e552d8194 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/emfcomparercpuimessages.properties
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/emfcomparercpuimessages.properties
@@ -103,3 +103,8 @@ DefaultMatchEngineConfiguratorUI.useIdentifier.label = Select if identifiers sh
DefaultMatchEngineConfiguratorUI.whenAvailable.label = When available: The engine will use some heuristics when identifiers are missing
DefaultMatchEngineConfiguratorUI.only.label = Only: Objects without identifiers will never be matched.
DefaultMatchEngineConfiguratorUI.never.label = Never: Objects will be matched with some heuristics regardless of having identifiers.
+
+ContentCustomizationRegistry.invalidRanking = Ranking of resolver ''{0}'' is not a valid integer : ''{1}''.
+ContentCustomizationRegistry.invalidContextTester = IContextTester named ''{0}'' could not be instantiated.
+ContentCustomizationRegistry.invalidProvider = Provider named ''{0}'' could not be instantiated.
+
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java
index 4f5ba6157..084034863 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java
@@ -148,10 +148,7 @@ public abstract class AbstractTableOrTreeMergeViewer extends AbstractStructuredM
IMergeViewerItem mergeViewerItem = ((IMergeViewerItem)data);
Diff diff = mergeViewerItem.getDiff();
if (diff != null) {
- if (MergeViewerUtil.isVisibleInMergeViewer(diff, getDifferenceGroupProvider(),
- getDifferenceFilter())
- && !MergeViewerUtil.isMarkAsMerged(diff, mergeViewerItem,
- getCompareConfiguration())) {
+ if (!MergeViewerUtil.isMarkAsMerged(diff, mergeViewerItem, getCompareConfiguration())) {
if (mergeViewerItem.isInsertionPoint()) {
paintItemDiffBox(event, itemWrapper, diff,
getBoundsForInsertionPoint(event, itemWrapper));
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/item/impl/MergeViewerItem.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/item/impl/MergeViewerItem.java
index 1e790a75f..4d9e3ff11 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/item/impl/MergeViewerItem.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/item/impl/MergeViewerItem.java
@@ -193,7 +193,6 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
ret = createBasicContainer((EObject)parent);
}
}
-
return ret;
}
@@ -255,7 +254,7 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
/**
* @return the fComparison
*/
- protected final Comparison getComparison() {
+ public final Comparison getComparison() {
return fComparison;
}
@@ -266,6 +265,7 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
return fAdapterFactory;
}
+ @Deprecated
protected final IMergeViewerItem.Container createBasicContainer(EObject eObject) {
IMergeViewerItem.Container ret = null;
Match parentMatch = fComparison.getMatch(eObject);
@@ -337,6 +337,7 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
* the given {@link ResourceAttachmentChange}.
* @return an IMergeViewerItem.
*/
+ @Deprecated
protected final IMergeViewerItem.Container createBasicContainer(ResourceAttachmentChange diff) {
final Comparison comparison = getComparison();
Resource left = MergeViewerUtil.getResource(comparison, MergeViewerSide.LEFT, diff);
@@ -347,6 +348,7 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
return ret;
}
+ @Deprecated
protected final List<IMergeViewerItem> createInsertionPoints(Comparison comparison,
EStructuralFeature eStructuralFeature, final List<? extends IMergeViewerItem> values,
List<? extends Diff> differences) {
@@ -487,6 +489,7 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
return insertionPoint;
}
+ @Deprecated
protected final List<IMergeViewerItem> createMergeViewerItemFrom(Collection<?> values) {
List<IMergeViewerItem> ret = newArrayListWithCapacity(values.size());
for (EObject value : filter(values, EObject.class)) {
@@ -501,6 +504,7 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
return ret;
}
+ @Deprecated
protected boolean yieldsMergeViewerItem(Collection<?> values) {
Iterable<EObject> elements = filter(values, EObject.class);
if (fDiff != null && !Iterables.isEmpty(elements)) {
@@ -517,6 +521,7 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
return false;
}
+ @Deprecated
protected boolean yieldsInsertionPoint(Iterable<Diff> diffs) {
return Iterables.any(diffs, new Predicate<Diff>() {
public boolean apply(Diff diff) {
@@ -572,6 +577,7 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
* the given eObject.
* @return an IMergeViewerItem.
*/
+ @Deprecated
protected IMergeViewerItem createMergeViewerItemFrom(EObject eObject) {
Match match = getComparison().getMatch(eObject);
@@ -610,11 +616,13 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
* the active group provider
* @return a list of the filtered diffs
*/
+ @Deprecated
protected List<? extends Diff> filteredDiffs(Iterable<? extends Diff> unfilteredDiffs,
Predicate<? super EObject> predicate, IDifferenceGroupProvider groupProvider) {
return Lists.newArrayList(filter(unfilteredDiffs, visibleInMergeViewer(predicate, groupProvider)));
}
+ @Deprecated
protected Predicate<Diff> visibleInMergeViewer(final Predicate<? super EObject> predicate,
final IDifferenceGroupProvider groupProvider) {
if (predicate == null) {
@@ -628,6 +636,7 @@ public class MergeViewerItem extends AdapterImpl implements IMergeViewerItem {
};
}
+ @Deprecated
public static class Container extends MergeViewerItem implements IMergeViewerItem.Container {
/**
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/item/impl/ResourceAttachmentChangeProvider.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/item/impl/ResourceAttachmentChangeProvider.java
new file mode 100644
index 000000000..c1b3c1b7c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/item/impl/ResourceAttachmentChangeProvider.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Muenchen GmbH 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:
+ * Stefan Dirix - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item.impl;
+
+import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider.IMergeViewerItemContentProvider;
+import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider.IMergeViewerItemProviderConfiguration;
+
+/**
+ * Legacy Provider to keep backward compatibility with {@link ResourceAttachmentChangeMergeViewerItem}.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ */
+public class ResourceAttachmentChangeProvider implements IMergeViewerItemContentProvider {
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getParent(Object object, IMergeViewerItemProviderConfiguration configuration) {
+ return ((ResourceAttachmentChangeMergeViewerItem)object).getParent();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getChildren(Object object, IMergeViewerItemProviderConfiguration configuration) {
+ return ((ResourceAttachmentChangeMergeViewerItem)object).getChildren(
+ configuration.getDifferenceGroupProvider(), configuration.getDifferenceFilterPredicate());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasChildren(Object object, IMergeViewerItemProviderConfiguration configuration) {
+ return ((ResourceAttachmentChangeMergeViewerItem)object).hasChildren(
+ configuration.getDifferenceGroupProvider(), configuration.getDifferenceFilterPredicate());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canHandle(Object object) {
+ return object instanceof ResourceAttachmentChangeMergeViewerItem;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/IMergeViewerItem.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/IMergeViewerItem.java
index 03c10bed6..350a1305b 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/IMergeViewerItem.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/IMergeViewerItem.java
@@ -100,7 +100,11 @@ public interface IMergeViewerItem extends Adapter {
*
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
* @since 4.0
+ * @deprecated IMergeViewerItem.Container is no longer needed since its functionality is now provided by
+ * {@link org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider.IMergeViewerItemContentProvider
+ * IMergeViewerItemContentProvider}. Use an {@link IMergeViewerItem} instead.
*/
+ @Deprecated
interface Container extends IMergeViewerItem {
/**
* Returns whether this container has at least one child. In some cases this methods avoids having to
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemContentProvider.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemContentProvider.java
new file mode 100644
index 000000000..4e2475a3f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemContentProvider.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Muenchen GmbH 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:
+ * Alexandra Buzila - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+
+/**
+ * Interface for specialized {@link ITreeContentProvider tree content providers} for the comparison content
+ * merge viewer.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ * @since 4.4
+ */
+public interface IMergeViewerItemContentProvider extends IOptionalProvider {
+
+ /**
+ * Determine the parent of the given {@code object}.
+ *
+ * @param object
+ * the {@link Object} for which the parent is to be determined.
+ * @param configuration
+ * the {@link IMergeViewerItemProviderConfiguration}.
+ * @return the determined parent object, {@code null} if there is none.
+ */
+ public Object getParent(Object object, IMergeViewerItemProviderConfiguration configuration);
+
+ /**
+ * Determine the children of the given {@code object}
+ *
+ * @param object
+ * the {@link Object} for which the children are to be determined.
+ * @param configuration
+ * the {@link IMergeViewerItemProviderConfiguration}.
+ * @return an array with the determined children, an empty array if there are none.
+ */
+ public Object[] getChildren(Object object, IMergeViewerItemProviderConfiguration configuration);
+
+ /**
+ * Indicates whether the given {@code object} has children.
+ *
+ * @param object
+ * the {@link Object} for which it is indicated whether it has children.
+ * @param configuration
+ * the {@link IMergeViewerItemProviderConfiguration}.
+ * @return {@code true} if the given object has children, {@code false} otherwise.
+ */
+ public boolean hasChildren(Object object, IMergeViewerItemProviderConfiguration configuration);
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemProvider.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemProvider.java
new file mode 100644
index 000000000..694b136fd
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemProvider.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Muenchen GmbH 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:
+ * Stefan Dirix - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider;
+
+import java.util.List;
+
+import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.IMergeViewerItem;
+
+/**
+ * The contract for providers responsible for determining root elements in merge viewers. Typically these are
+ * {@link IMergeViewerItem}s but they not necessarily have to be.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ * @since 4.4
+ */
+public interface IMergeViewerItemProvider extends IOptionalProvider {
+
+ /**
+ * Determine the root merge viewer items for the given {@code object}.
+ *
+ * @param object
+ * the {@link Object} for which the root merge viewer items are to be determined.
+ * @param configuration
+ * the {@link IMergeViewerItemProviderConfiguration}.
+ * @return a list of the root elements.
+ */
+ public List<Object> getMergeViewerItems(Object object,
+ IMergeViewerItemProviderConfiguration configuration);
+
+ /**
+ * Determine the merge viewer item which shall be selected.
+ *
+ * @param object
+ * the {@link Object} for which the selected merge viewer item is to be determined.
+ * @param configuration
+ * the {@link IMergeViewerItemProviderConfiguration}.
+ * @return the merge viewer item to select.
+ */
+ public Object getItemToSelect(Object object, IMergeViewerItemProviderConfiguration configuration);
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemProviderConfiguration.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemProviderConfiguration.java
new file mode 100644
index 000000000..313a1602f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IMergeViewerItemProviderConfiguration.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Muenchen GmbH 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:
+ * Stefan Dirix - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider;
+
+import com.google.common.base.Predicate;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide;
+import org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups.IDifferenceGroupProvider;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * The configuration used by {@link IMergeViewerItemContentProvider}s.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ * @since 4.4
+ */
+public interface IMergeViewerItemProviderConfiguration {
+
+ /**
+ * Get the {@link AdapterFactory}.
+ *
+ * @return the {@link AdapterFactory},
+ */
+ public AdapterFactory getAdapterFactory();
+
+ /**
+ * Get the {@link IDifferenceGroupProvider}.
+ *
+ * @return the {@link IDifferenceGroupProvider}.
+ */
+ public IDifferenceGroupProvider getDifferenceGroupProvider();
+
+ /**
+ * Get the difference filter {@link Predicate}.
+ *
+ * @return the difference filter {@link Predicate}.
+ */
+ public Predicate<? super EObject> getDifferenceFilterPredicate();
+
+ /**
+ * Get the {@link Comparison}.
+ *
+ * @return the {@link Comparison}.
+ */
+ public Comparison getComparison();
+
+ /**
+ * Get the {@link MergeViewerSide}.
+ *
+ * @return the {@link MergeViewerSide}.
+ */
+ public MergeViewerSide getSide();
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IOptionalProvider.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IOptionalProvider.java
new file mode 100644
index 000000000..31c2d9884
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/mergeviewer/item/provider/IOptionalProvider.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Muenchen GmbH 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:
+ * Stefan Dirix - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider;
+
+/**
+ * A contract for a provider which can indicate whether it wants to handle a certain object.
+ *
+ * @author Stefan Dirix <sdirix@eclipsesource.com>
+ * @since 4.4
+ */
+public interface IOptionalProvider {
+ /**
+ * Indicates whether this provider wants to handle the given {@code object}.
+ *
+ * @param object
+ * the {@link Object}.
+ * @return {@code true} if the provider wants to handle the given {@code object}, {@code false} otherwise.
+ */
+ boolean canHandle(Object object);
+}

Back to the top