Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp')
-rw-r--r--plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/EMFCompareRCPPlugin.java42
-rw-r--r--plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/graph/IGraphConsumer.java46
-rw-r--r--plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/emfcomparercpmessages.properties6
3 files changed, 92 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/EMFCompareRCPPlugin.java b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/EMFCompareRCPPlugin.java
index 055b2f2f3..65f589a1b 100644
--- a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/EMFCompareRCPPlugin.java
+++ b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/EMFCompareRCPPlugin.java
@@ -27,7 +27,9 @@ import com.google.common.collect.Multimaps;
import java.io.IOException;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
@@ -42,11 +44,14 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.conflict.IConflictDetector;
import org.eclipse.emf.compare.diff.IDiffEngine;
import org.eclipse.emf.compare.equi.IEquiEngine;
+import org.eclipse.emf.compare.graph.IGraphView;
import org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor;
import org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptorRegistryImpl;
+import org.eclipse.emf.compare.internal.utils.Graph;
import org.eclipse.emf.compare.match.IMatchEngine;
import org.eclipse.emf.compare.match.eobject.WeightProvider;
import org.eclipse.emf.compare.match.eobject.WeightProviderDescriptorRegistryImpl;
@@ -54,6 +59,7 @@ import org.eclipse.emf.compare.merge.IMerger;
import org.eclipse.emf.compare.postprocessor.IPostProcessor;
import org.eclipse.emf.compare.provider.EMFCompareEditPlugin;
import org.eclipse.emf.compare.rcp.extension.AbstractRegistryEventListener;
+import org.eclipse.emf.compare.rcp.graph.IGraphConsumer;
import org.eclipse.emf.compare.rcp.internal.EMFCompareRCPMessages;
import org.eclipse.emf.compare.rcp.internal.adapterfactory.AdapterFactoryDescriptorRegistryListener;
import org.eclipse.emf.compare.rcp.internal.extension.IItemRegistry;
@@ -197,6 +203,11 @@ public class EMFCompareRCPPlugin extends Plugin {
private IPreferenceChangeListener preferenceChangeListener;
/**
+ * Keep all resources graphs identified by their id.
+ */
+ private Map<String, IGraphView<URI>> graphsById = new HashMap<String, IGraphView<URI>>();
+
+ /**
* Instance scope for preferences.
* <p>
* Do not use singleton to respect Helios compatibility
@@ -813,4 +824,35 @@ public class EMFCompareRCPPlugin extends Plugin {
}
}
+ /**
+ * This method creates a new Graph of URI, passes it to the given consumer and then keeps track of the
+ * given graph to be able to provide a read only view of it on demand.
+ *
+ * @param consumer
+ * An instance of graph consumer, for instance the ThreadedModelResolver instance.
+ * @throws IllegalArgumentException
+ * if the consumer uses an ID that is already registered.
+ * @since 2.4
+ */
+ public void register(IGraphConsumer consumer) {
+ consumer.setGraph(new Graph<URI>());
+ String id = consumer.getId();
+ if (graphsById.containsKey(id)) {
+ throw new IllegalArgumentException(EMFCompareRCPMessages.getString("duplicate.graph.id.msg", id)); //$NON-NLS-1$
+ }
+ graphsById.put(id, consumer.getGraphView());
+ }
+
+ /**
+ * Return the graph view associated with the given id, or null if it does not exist.
+ *
+ * @param id
+ * The id of the graph
+ * @return The graph view registered for the given ID, which can be null.
+ * @since 2.4
+ */
+ public IGraphView<URI> getGraphView(String id) {
+ return graphsById.get(id);
+ }
+
}
diff --git a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/graph/IGraphConsumer.java b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/graph/IGraphConsumer.java
new file mode 100644
index 000000000..4c1da13db
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/graph/IGraphConsumer.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.rcp.graph;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.compare.graph.IGraph;
+import org.eclipse.emf.compare.graph.IGraphView;
+
+/**
+ * Graph consumer, that maintains the state of a graph created by a third party.
+ *
+ * @author <a href="mailto:mathieu.cartaud@obeo.fr">Mathieu Cartaud</a>
+ * @since 2.4
+ */
+public interface IGraphConsumer {
+
+ /**
+ * Set the graph to be used by this consumer.
+ *
+ * @param graph
+ * The graph to use
+ */
+ void setGraph(IGraph<URI> graph);
+
+ /**
+ * Return the ID used to identify this specific consumer.
+ *
+ * @return the consumer id
+ */
+ String getId();
+
+ /**
+ * Provide a read-only view of the graph used by this consumer.
+ *
+ * @return A read-only view of the graph used by this consumer.
+ */
+ IGraphView<URI> getGraphView();
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/emfcomparercpmessages.properties b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/emfcomparercpmessages.properties
index 5c5605a9b..c17e9c04e 100644
--- a/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/emfcomparercpmessages.properties
+++ b/plugins/org.eclipse.emf.compare.rcp/src/org/eclipse/emf/compare/rcp/internal/emfcomparercpmessages.properties
@@ -1,5 +1,5 @@
################################################################################
-# Copyright (c) 2011, 2012 Obeo.
+# Copyright (c) 2011, 2015 Obeo.
# 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
@@ -15,4 +15,6 @@ duplicate.extension = The extension {0} is registered twice
RCPMatchEngineFactory.INCORECT_USE_IDENTIFIER_ATTRIBUTE = Incorrect value of UseIdentifier stored in preferences
-logging.appender.error = Impossible to log to file {0}.\nException message is: {1} \ No newline at end of file
+logging.appender.error = Impossible to log to file {0}.\nException message is: {1}
+
+duplicate.graph.id.msg = A graph consumer is already registered for the given ID "{0}". Only one graph consumer can be registered for a given ID.

Back to the top