Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Bouchet2015-05-07 10:11:12 +0000
committerStephane Bouchet2015-12-16 13:50:49 +0000
commite846ffb0f21624687ae74bac4a366e95d584416c (patch)
tree9adf9c5c05241aa608bbc0b03753ab0959a46e51 /plugins
parent8dc98e1046a5dc0ec196b3965eb45b9c57cb231d (diff)
downloadorg.eclipse.emf.diffmerge.core-e846ffb0f21624687ae74bac4a366e95d584416c.tar.gz
org.eclipse.emf.diffmerge.core-e846ffb0f21624687ae74bac4a366e95d584416c.tar.xz
org.eclipse.emf.diffmerge.core-e846ffb0f21624687ae74bac4a366e95d584416c.zip
Eclipse Team integration for DiffMerge
[466706] Support Local history [466427] Support Git Scm [482287] Support SVN Scm [482288] Support Perforce Scm Added support for local history, git, svn and perforce. Updated test model. Change-Id: I9b9929bbb5a74220619d4fce55b251efd18f8631 Signed-off-by: Stephane Bouchet <stephane.bouchet@intel.com> Bug: https://bugs.eclipse.org/466706
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/.classpath7
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/.project28
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/META-INF/MANIFEST.MF17
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/about.html26
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/build.properties13
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/plugin.properties9
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/plugin.xml42
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergeCoreConnectorPlugin.java60
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/EMFDiffMergeCompareViewerCreator.java29
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/FileRevisionScopeDefinitionFactory.java140
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalRevisionURIConverter.java70
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScope.java31
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScopeDefinition.java29
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScopeDefinitionFactory.java51
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/StreamScope.java47
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/StreamScopeDefinition.java51
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/.classpath7
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/.project28
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/META-INF/MANIFEST.MF20
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/about.html26
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/build.properties13
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/plugin.properties9
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/plugin.xml32
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergeGitConnectorPlugin.java105
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScope.java58
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScopeDefinition.java38
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScopeDefinitionFactory.java119
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionURIConverter.java71
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitIndexURIConverter.java42
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitRemoteURIConverter.java32
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitSchemeConstants.java25
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitStreamScopeDefinitionFactory.java138
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitURIConverter.java78
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/.classpath7
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/.project28
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/META-INF/MANIFEST.MF24
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/about.html26
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/build.properties13
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/plugin.properties9
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/plugin.xml30
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergePerforceConnectorPlugin.java47
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceRevisionScopeDefinitionFactory.java129
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceStreamScopeDefinitionFactory.java165
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceStreamURIConverter.java143
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/.classpath7
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/.project28
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/META-INF/MANIFEST.MF23
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/about.html26
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/build.properties13
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/plugin.properties9
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/plugin.xml38
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/EMFDiffmergeSVNConnectorPlugin.java47
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNLocalScopeDefinitionFactory.java57
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRemoteScopeDefinitionFactory.java85
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRevisionScopeDefinitionFactory.java91
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNStreamURIConverter.java83
-rw-r--r--plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java96
57 files changed, 2715 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/.classpath b/plugins/org.eclipse.emf.diffmerge.connector.core/.classpath
new file mode 100644
index 00000000..2d1a4302
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/.project b/plugins/org.eclipse.emf.diffmerge.connector.core/.project
new file mode 100644
index 00000000..0ae122b5
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.diffmerge.connector.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.diffmerge.connector.core/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..142fe062
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.emf.diffmerge.connector.core;singleton:=true
+Bundle-Version: 0.5.0.qualifier
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.emf.diffmerge.ui.gmf;bundle-version="0.3.0",
+ org.eclipse.gmf.runtime.emf.core;bundle-version="1.4.1",
+ org.eclipse.team.core;bundle-version="3.6.100",
+ org.eclipse.team.ui;bundle-version="3.6.201",
+ org.eclipse.core.resources;bundle-version="3.8.0",
+ org.eclipse.jface;bundle-version="3.8.0"
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.eclipse.emf.diffmerge.connector.EMFDiffMergeCoreConnectorPlugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.emf.diffmerge.connector.core
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/about.html b/plugins/org.eclipse.emf.diffmerge.connector.core/about.html
new file mode 100644
index 00000000..7e766fe1
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/about.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/build.properties b/plugins/org.eclipse.emf.diffmerge.connector.core/build.properties
new file mode 100644
index 00000000..c592f263
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/build.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2015 Intel Corporation.
+# 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
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/plugin.properties b/plugins/org.eclipse.emf.diffmerge.connector.core/plugin.properties
new file mode 100644
index 00000000..9f4a11d7
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/plugin.properties
@@ -0,0 +1,9 @@
+###############################################################################
+# Copyright (c) 2015 Intel Corporation.
+# 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
+###############################################################################
+pluginName = EMF Diff/Merge Local history and Core Connector Plug-In (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/plugin.xml b/plugins/org.eclipse.emf.diffmerge.connector.core/plugin.xml
new file mode 100644
index 00000000..d1826b3b
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/plugin.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2015 Intel Corporation.
+ 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:
+ Stephane Bouchet (Intel Corporation) - initial API and implementation
+-->
+<plugin>
+ <!-- add a content viewer for diffmerge to be usable with compare editor -->
+ <extension point="org.eclipse.compare.contentMergeViewers">
+ <viewer
+ class="org.eclipse.emf.diffmerge.connector.core.EMFDiffMergeCompareViewerCreator"
+ id="org.eclipse.emf.diffmerge.compareviewer"
+ label="EMF Diff/Merge Viewer">
+ </viewer>
+ <contentTypeBinding
+ contentTypeId="org.eclipse.emf.ecore.xmi" contentMergeViewerId="org.eclipse.emf.diffmerge.compareviewer">
+ </contentTypeBinding>
+ </extension>
+ <!-- Add emf diffmerge support for local resources -->
+ <extension point="org.eclipse.emf.diffmerge.ui.modelComparisonContext">
+ <scopeDefinition
+ factory="org.eclipse.emf.diffmerge.connector.core.LocalScopeDefinitionFactory">
+ </scopeDefinition>
+ <comparisonMethod
+ factory="org.eclipse.emf.diffmerge.ui.specification.ext.ConfigurableComparisonMethodFactory">
+ </comparisonMethod>
+ </extension>
+ <extension point="org.eclipse.emf.diffmerge.ui.modelComparisonContext">
+ <scopeDefinition
+ factory="org.eclipse.emf.diffmerge.connector.core.FileRevisionScopeDefinitionFactory">
+ </scopeDefinition>
+ <comparisonMethod
+ factory="org.eclipse.emf.diffmerge.ui.specification.ext.ConfigurableComparisonMethodFactory">
+ </comparisonMethod>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergeCoreConnectorPlugin.java b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergeCoreConnectorPlugin.java
new file mode 100644
index 00000000..bf44f90b
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergeCoreConnectorPlugin.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class EMFDiffMergeCoreConnectorPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.emf.diffmerge.connector.core"; //$NON-NLS-1$
+
+ // The shared instance
+ private static EMFDiffMergeCoreConnectorPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public EMFDiffMergeCoreConnectorPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static EMFDiffMergeCoreConnectorPlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/EMFDiffMergeCompareViewerCreator.java b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/EMFDiffMergeCompareViewerCreator.java
new file mode 100644
index 00000000..49b10f7d
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/EMFDiffMergeCompareViewerCreator.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.core;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IViewerCreator;
+import org.eclipse.emf.diffmerge.ui.viewers.ComparisonViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Used by compare extension point.
+ */
+public class EMFDiffMergeCompareViewerCreator implements IViewerCreator {
+
+ @Override
+ public Viewer createViewer(Composite parent, CompareConfiguration config) {
+ return new ComparisonViewer(parent);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/FileRevisionScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/FileRevisionScopeDefinitionFactory.java
new file mode 100644
index 00000000..92b59627
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/FileRevisionScopeDefinitionFactory.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.core;
+
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.compare.ISharedDocumentAdapter;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFileState;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergeCoreConnectorPlugin;
+import org.eclipse.emf.diffmerge.ui.gmf.GMFScopeDefinitionFactory;
+import org.eclipse.emf.diffmerge.ui.specification.IModelScopeDefinition;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.ui.IEditorInput;
+
+/**
+ * A Scope Definition Factory for File revisioned resources.
+ */
+public class FileRevisionScopeDefinitionFactory extends GMFScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>>singleton(GMFScopeDefinitionFactory.class);
+ }
+
+ @Override
+ public boolean isApplicableTo(Object entrypoint) {
+ return entrypoint instanceof ITypedElement && getFileRevision((ITypedElement)entrypoint) != null;
+ }
+
+ @Override
+ public IModelScopeDefinition createScopeDefinition(final Object entrypoint, final String label, final boolean editable) {
+ final IFileRevision revision=getFileRevision((ITypedElement)entrypoint);
+ if (revision != null) {
+ try {
+ final IStorage storage=getStorage(revision);
+ final URI uri=getUri(revision);
+ return new StreamScopeDefinition(entrypoint, (label != null) ? label : getLabelFor(entrypoint), uri, storage.getContents(), getURIConverter(revision));
+ }
+ catch (CoreException e) {
+ EMFDiffMergeCoreConnectorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, EMFDiffMergeCoreConnectorPlugin.PLUGIN_ID, e.getMessage(),e));
+ }
+ }
+ return super.createScopeDefinition(entrypoint, label, editable);
+ }
+
+ protected IFileRevision getFileRevision(ITypedElement entrypoint) {
+ // avoid internal API using Adapter
+ if (entrypoint instanceof IAdaptable) {
+ IAdaptable adaptable=(IAdaptable)entrypoint;
+ ISharedDocumentAdapter adapter=(ISharedDocumentAdapter)adaptable.getAdapter(ISharedDocumentAdapter.class);
+ if (adapter != null) {
+ IEditorInput input=adapter.getDocumentKey(entrypoint);
+ if (input != null)
+ return (IFileRevision)input.getAdapter(IFileRevision.class);
+ }
+ }
+ return null;
+ }
+
+ protected URI getUri(IFileRevision revision) throws CoreException {
+ IStorage storage=getStorage(revision);
+ if (storage instanceof IFile) {
+ // local resource
+ return toPlatformURI((IFile)storage);
+ }
+ if (storage instanceof IFileState) {
+ // local fileRevision (local history)
+ IPath fullPath=storage.getFullPath();
+ IResource res=ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath);
+ if (res.exists() && res instanceof IFile)
+ return toPlatformURI((IFile)res);
+ }
+ return toFileUri(storage.getFullPath().toString());
+ }
+
+ protected IStorage getStorage(IFileRevision revision) throws CoreException {
+ return revision.getStorage(new NullProgressMonitor());
+ }
+
+ protected URIConverter getURIConverter(IFileRevision revision) throws CoreException {
+ String fullPath=getUri(revision).trimSegments(1).toString();
+ //local history or current
+ final long timestamp=revision.getTimestamp();
+ if (timestamp != -1) {
+ return new LocalRevisionURIConverter(timestamp, fullPath);
+ }
+ return new ExtensibleURIConverterImpl();
+ }
+
+ protected final IResourceVariant getVariant(IFileRevision revision) {
+ if (revision instanceof IAdaptable && ((IAdaptable)revision).getAdapter(IResourceVariant.class) instanceof IResourceVariant) {
+ return (IResourceVariant)((IAdaptable)revision).getAdapter(IResourceVariant.class);
+ }
+ return null;
+ }
+
+ @Override
+ protected String getLabelFor(Object entrypoint) {
+ IFileRevision revision=getFileRevision((ITypedElement)entrypoint);
+ if (revision != null) {
+ IResourceVariant variant=getVariant(revision);
+ if (variant != null)
+ return variant.getContentIdentifier();
+ if (revision.getTimestamp() != -1) {
+ Calendar fileRevDate=Calendar.getInstance();
+ fileRevDate.setTimeInMillis(revision.getTimestamp());
+ return "Local history: " + revision.getName() + " " + DateFormat.getInstance().format(fileRevDate.getTime());
+ }
+ return revision.getContentIdentifier();
+ }
+ return super.getLabelFor(entrypoint);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalRevisionURIConverter.java b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalRevisionURIConverter.java
new file mode 100644
index 00000000..74b29bdf
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalRevisionURIConverter.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFileState;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergeCoreConnectorPlugin;
+import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+
+/**
+ * An URI Converter for localRevisions.
+ */
+public final class LocalRevisionURIConverter extends ExtensibleURIConverterImpl {
+ private final long timestamp;
+ private final String basePath;
+
+ public LocalRevisionURIConverter(long timestamp, String basePath) {
+ super();
+ this.timestamp=timestamp;
+ this.basePath=basePath;
+ }
+
+ @Override
+ public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
+ IFile targetFile;
+ if (uri.isPlatform()) {
+ targetFile=ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true)));
+ }
+ else {
+ IPath fullPath=new Path(basePath).append(uri.toString());
+ targetFile=ResourcesPlugin.getWorkspace().getRoot().getFile(fullPath);
+ }
+ if (targetFile.exists()) {
+ try {
+ if (targetFile.getLocalTimeStamp() <= timestamp)
+ return targetFile.getContents();
+ IFileState[] states=targetFile.getHistory(new NullProgressMonitor());
+ for (IFileState iFileState: states) {
+ if (iFileState.getModificationTime() <= timestamp)
+ return iFileState.getContents();
+ }
+ }
+ catch (CoreException e) {
+ EMFDiffMergeCoreConnectorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, EMFDiffMergeCoreConnectorPlugin.PLUGIN_ID, e.getMessage(),e));
+ }
+ }
+ return super.createInputStream(uri, options);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScope.java b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScope.java
new file mode 100644
index 00000000..9aec4d78
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScope.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.core;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.gmf.GMFScope;
+import org.eclipse.emf.diffmerge.ui.util.UIUtil;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * A custom scope for local resources.
+ */
+public final class LocalScope extends GMFScope {
+ public LocalScope(URI uri, ResourceSet resourceSet, boolean readOnly) {
+ super(uri, resourceSet, readOnly);
+ }
+
+ @Override
+ public Object getOriginator() {
+ return "Local: " + UIUtil.simplifyURI(getHoldingResource().getURI());
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScopeDefinition.java b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScopeDefinition.java
new file mode 100644
index 00000000..f1b8e55e
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScopeDefinition.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.core;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.api.scopes.IEditableModelScope;
+import org.eclipse.emf.diffmerge.ui.specification.ext.URIScopeDefinition;
+import org.eclipse.emf.edit.domain.EditingDomain;
+
+public final class LocalScopeDefinition extends URIScopeDefinition {
+ public LocalScopeDefinition(URI uri, String label, boolean editable) {
+ super(uri, label, editable);
+ }
+
+ @Override
+ public IEditableModelScope createScope(Object context) {
+ if (context instanceof EditingDomain)
+ return new LocalScope(getEntrypoint(), ((EditingDomain)context).getResourceSet(), !isEditable());
+ return null;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScopeDefinitionFactory.java
new file mode 100644
index 00000000..a6d5f617
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/LocalScopeDefinitionFactory.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.core;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.compare.IResourceProvider;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.ui.gmf.GMFScopeDefinitionFactory;
+import org.eclipse.emf.diffmerge.ui.specification.IModelScopeDefinition;
+
+/**
+ * A Scope Definition Factory for local resources.
+ */
+public class LocalScopeDefinitionFactory extends GMFScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>>singleton(GMFScopeDefinitionFactory.class);
+ }
+
+ @Override
+ public boolean isApplicableTo(Object entrypoint) {
+ return entrypoint instanceof IFile || entrypoint instanceof IResourceProvider;
+ }
+
+ @Override
+ protected URI convertToURI(Object entrypoint) {
+ if (entrypoint instanceof IResourceProvider)
+ return super.convertToURI(((IResourceProvider)entrypoint).getResource());
+ return super.convertToURI(entrypoint);
+ }
+
+ /**
+ * @see org.eclipse.emf.diffmerge.ui.specification.ext.URIScopeDefinitionFactory#createScopeDefinitionFromURI(org.eclipse.emf.common.util.URI, java.lang.String, boolean)
+ */
+ @Override
+ protected IModelScopeDefinition createScopeDefinitionFromURI(URI uri, String label, boolean editable) {
+ return new LocalScopeDefinition(uri, label, editable);
+ }
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/StreamScope.java b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/StreamScope.java
new file mode 100644
index 00000000..ff1ce6b2
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/StreamScope.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.core;
+
+import java.io.InputStream;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.gmf.GMFScope;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * A custom scope for stream resources.
+ */
+public final class StreamScope extends GMFScope {
+ private final InputStream stream;
+ private final String label;
+
+ public StreamScope(URI uri, ResourceSet rs, InputStream stream, String label) {
+ super(uri, rs, true);
+ this.stream=stream;
+ this.label=label;
+ }
+
+ @Override
+ public boolean load() throws Exception {
+ // there is only one resource to be loaded, the graphical one. the semantic is handled by the URIConverter
+ if (!_rootResources.isEmpty() && stream != null) {
+ _rootResources.get(0).load(stream, getLoadOptions(_rootResources.get(0)));
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public Object getOriginator() {
+ return label;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/StreamScopeDefinition.java b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/StreamScopeDefinition.java
new file mode 100644
index 00000000..2fa16220
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.core/src/org/eclipse/emf/diffmerge/connector/core/StreamScopeDefinition.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.core;
+
+import java.io.InputStream;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.api.scopes.IEditableModelScope;
+import org.eclipse.emf.diffmerge.ui.specification.AbstractScopeDefinition;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.edit.domain.EditingDomain;
+
+/**
+ * A custom scope definition for stream resources.
+ */
+public class StreamScopeDefinition extends AbstractScopeDefinition {
+ protected final URI uri;
+ protected final InputStream stream;
+ protected final URIConverter uriConverter;
+
+ public StreamScopeDefinition(Object entrypoint, String label, URI uri, InputStream stream, URIConverter uriConverter) {
+ super(entrypoint, label, false);
+ this.uri=uri;
+ this.stream=stream;
+ this.uriConverter=uriConverter;
+ }
+
+ /**
+ * The resourceSet for StreamScope is independent.
+ * @see org.eclipse.emf.diffmerge.ui.specification.IModelScopeDefinition#createScope(java.lang.Object)
+ */
+ @Override
+ public IEditableModelScope createScope(Object context) {
+ if (context instanceof EditingDomain) {
+ ResourceSet rs= new ResourceSetImpl();
+ rs.setURIConverter(uriConverter);
+ return new StreamScope(uri, rs, stream, getLabel());
+ }
+ return null;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/.classpath b/plugins/org.eclipse.emf.diffmerge.connector.git/.classpath
new file mode 100644
index 00000000..2d1a4302
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/.project b/plugins/org.eclipse.emf.diffmerge.connector.git/.project
new file mode 100644
index 00000000..8d7130ad
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.diffmerge.connector.git</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.diffmerge.connector.git/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..080f4ec9
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.emf.diffmerge.connector.git;singleton:=true
+Bundle-Version: 0.5.0.qualifier
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.egit.ui;bundle-version="3.7.1",
+ org.eclipse.emf.diffmerge.ui.gmf;bundle-version="0.3.0",
+ org.eclipse.team.ui;bundle-version="3.6.201",
+ org.eclipse.egit.core;bundle-version="3.7.1",
+ org.eclipse.team.core;bundle-version="3.6.100",
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
+ org.eclipse.jgit;bundle-version="3.7.1",
+ org.eclipse.core.filesystem;bundle-version="1.3.200",
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.emf.diffmerge.connector.core;bundle-version="0.3.0"
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.eclipse.emf.diffmerge.connector.EMFDiffMergeGitConnectorPlugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/about.html b/plugins/org.eclipse.emf.diffmerge.connector.git/about.html
new file mode 100644
index 00000000..7e766fe1
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/about.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/build.properties b/plugins/org.eclipse.emf.diffmerge.connector.git/build.properties
new file mode 100644
index 00000000..c592f263
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/build.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2015 Intel Corporation.
+# 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
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/plugin.properties b/plugins/org.eclipse.emf.diffmerge.connector.git/plugin.properties
new file mode 100644
index 00000000..6cf4699d
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/plugin.properties
@@ -0,0 +1,9 @@
+###############################################################################
+# Copyright (c) 2015 Intel Corporation.
+# 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
+###############################################################################
+pluginName = EMF Diff/Merge Git Connector Plug-In (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/plugin.xml b/plugins/org.eclipse.emf.diffmerge.connector.git/plugin.xml
new file mode 100644
index 00000000..fddadbcf
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/plugin.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2015 Intel Corporation.
+ 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:
+ Stephane Bouchet (Intel Corporation) - initial API and implementation
+-->
+<plugin>
+ <!-- configure the diffmerge scope definition for remote git resources -->
+ <extension point="org.eclipse.emf.diffmerge.ui.modelComparisonContext">
+ <scopeDefinition
+ factory="org.eclipse.emf.diffmerge.connector.git.GitStreamScopeDefinitionFactory">
+ </scopeDefinition>
+ <comparisonMethod
+ factory="org.eclipse.emf.diffmerge.ui.specification.ext.DefaultComparisonMethodFactory">
+ </comparisonMethod>
+ </extension>
+ <!-- configure the diffmerge scope definition for local git resources -->
+ <extension point="org.eclipse.emf.diffmerge.ui.modelComparisonContext">
+ <scopeDefinition
+ factory="org.eclipse.emf.diffmerge.connector.git.GitEditableRevisionScopeDefinitionFactory">
+ </scopeDefinition>
+ <comparisonMethod
+ factory="org.eclipse.emf.diffmerge.ui.specification.ext.DefaultComparisonMethodFactory">
+ </comparisonMethod>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergeGitConnectorPlugin.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergeGitConnectorPlugin.java
new file mode 100644
index 00000000..eab34be9
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergeGitConnectorPlugin.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.egit.core.Activator;
+import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.egit.ui.internal.revision.LocalFileRevision;
+import org.eclipse.jgit.errors.CorruptObjectException;
+import org.eclipse.jgit.errors.NoWorkTreeException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class EMFDiffMergeGitConnectorPlugin extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID="org.eclipse.emf.diffmerge.connector.git";
+ private static EMFDiffMergeGitConnectorPlugin instance;
+
+ public EMFDiffMergeGitConnectorPlugin() {
+ super();
+ }
+
+ public static EMFDiffMergeGitConnectorPlugin getInstance() {
+ return instance;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ instance=this;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ instance=null;
+ super.stop(context);
+ }
+
+ public Repository getRepo(IPath path) {
+ // first look directly using the repositorymapping for connected projects
+ if (RepositoryMapping.getMapping(path) != null) {
+ return RepositoryMapping.getMapping(path).getRepository();
+ }
+ // then iterate over known repositories.
+ for (Repository repo: Activator.getDefault().getRepositoryCache().getAllRepositories()) {
+ Path fullPath=new Path(repo.getWorkTree().toString().concat(path.makeAbsolute().toString()));
+ if (fullPath.toFile().exists())
+ return repo;
+ }
+ getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Cannot find Git repository for resource at: " + path));
+ return null;
+ }
+
+ public Repository getRepo(IFileRevision revision) {
+ if (revision != null) {
+ IPath revisionPath=new Path(revision.getURI().toString());
+ if (!revisionPath.isAbsolute())
+ return getRepo(revisionPath);
+ else if (revision instanceof LocalFileRevision) {
+ IFile file=((LocalFileRevision)revision).getFile();
+ return getRepo(file.getFullPath());
+ }
+ getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Cannot find Git repository for resource at: " + revisionPath));
+ }
+ return null;
+ }
+
+ public boolean isConflicting(Repository repo, IFileRevision revision) throws NoWorkTreeException, CorruptObjectException, IOException {
+ IPath revisionPath=new Path(revision.getURI().toString());
+ if (!revisionPath.isAbsolute())
+ return isConflicting(repo, revisionPath.toString());
+ else if (revision instanceof LocalFileRevision) {
+ IFile file=((LocalFileRevision)revision).getFile();
+ return isConflicting(repo, file.getFullPath().makeRelative().toString());
+ }
+ getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Cannot find conflict information for resource at: " + revisionPath));
+ return false;
+ }
+
+ public boolean isConflicting(Repository repo, String path) throws NoWorkTreeException, CorruptObjectException, IOException {
+ return repo.readDirCache().getEntry(path).getStage() > 0;
+ }
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScope.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScope.java
new file mode 100644
index 00000000..928b4852
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScope.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.git;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.gmf.GMFScope;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * A custom scope for git editable resources.
+ */
+public final class GitEditableRevisionScope extends GMFScope {
+
+ private final InputStream stream;
+ private final String label;
+
+ public GitEditableRevisionScope(URI uri, ResourceSet rs, InputStream stream, String label, boolean readOnly) {
+ super(uri, rs, readOnly);
+ this.stream = stream;
+ this.label = label;
+ }
+
+ /**
+ * Loading a Git Editable revision via an InputStream. The first one is
+ * loaded, no multi root resource is supported.
+ */
+ @Override
+ public boolean load() throws Exception {
+ if (_state == ScopeState.INITIALIZED || _state == ScopeState.LOADED) {
+ if (!_rootResources.isEmpty() && stream != null) {
+ Resource rootResource = _rootResources.get(0);
+ Map<?, ?> options = getLoadOptions(rootResource);
+ rootResource.load(stream, options);
+ _state = ScopeState.LOADED;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Object getOriginator() {
+ return label;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScopeDefinition.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScopeDefinition.java
new file mode 100644
index 00000000..7e905dcb
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScopeDefinition.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.git;
+
+import java.io.InputStream;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.api.scopes.IEditableModelScope;
+import org.eclipse.emf.diffmerge.connector.core.StreamScopeDefinition;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.edit.domain.EditingDomain;
+
+public class GitEditableRevisionScopeDefinition extends StreamScopeDefinition {
+
+ public GitEditableRevisionScopeDefinition(Object entrypoint, String label, URI uri, InputStream stream, URIConverter uriConverter, boolean editable) {
+ super(entrypoint, label, uri, stream, uriConverter);
+ setEditable(editable);
+ }
+
+ @Override
+ public IEditableModelScope createScope(Object context) {
+ if (context instanceof EditingDomain) {
+ ResourceSet rs=((EditingDomain)context).getResourceSet();
+ rs.setURIConverter(uriConverter);
+ return new GitEditableRevisionScope(uri, rs, stream, getLabel(), !isEditable());
+ }
+ return null;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScopeDefinitionFactory.java
new file mode 100644
index 00000000..53315f17
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionScopeDefinitionFactory.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.git;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.compare.IEditableContent;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.egit.core.internal.storage.IndexFileRevision;
+import org.eclipse.egit.ui.internal.revision.EditableRevision;
+import org.eclipse.egit.ui.internal.revision.LocalFileRevision;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergeGitConnectorPlugin;
+import org.eclipse.emf.diffmerge.connector.core.FileRevisionScopeDefinitionFactory;
+import org.eclipse.emf.diffmerge.connector.core.LocalRevisionURIConverter;
+import org.eclipse.emf.diffmerge.ui.specification.IModelScopeDefinition;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.jgit.errors.NoWorkTreeException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.team.core.history.IFileRevision;
+
+public class GitEditableRevisionScopeDefinitionFactory extends FileRevisionScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>>singleton(FileRevisionScopeDefinitionFactory.class);
+ }
+
+ @Override
+ protected IFileRevision getFileRevision(ITypedElement entrypoint) {
+ if (entrypoint instanceof EditableRevision)
+ return ((EditableRevision)entrypoint).getFileRevision();
+ return null;
+ }
+
+ @Override
+ public IModelScopeDefinition createScopeDefinition(final Object entrypoint, final String label, final boolean editable) {
+ try {
+ ITypedElement typedElement=(ITypedElement)entrypoint;
+ IFileRevision revision=getFileRevision(typedElement);
+ final Repository repo=EMFDiffMergeGitConnectorPlugin.getInstance().getRepo(revision);
+ if (repo != null) {
+ final boolean conflicting=EMFDiffMergeGitConnectorPlugin.getInstance().isConflicting(repo, revision);
+ final IStorage storage=revision.getStorage(new NullProgressMonitor());
+ final String gitLabel=(label != null) ? label : getGitLabel(typedElement);
+ final URI uri=getUri(typedElement, conflicting);
+ final URIConverter uriConverter=getUriConverter(repo, revision);
+ return new GitEditableRevisionScopeDefinition(entrypoint, gitLabel, uri, storage.getContents(), uriConverter, conflicting ? true : editable);
+ }
+ }
+ catch (CoreException | NoWorkTreeException | IOException e) {
+ EMFDiffMergeGitConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, EMFDiffMergeGitConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return super.createScopeDefinition(entrypoint, label, editable);
+ }
+
+ private URIConverter getUriConverter(Repository repo, IFileRevision revision) {
+ if (revision instanceof IndexFileRevision) {
+ return new GitEditableRevisionURIConverter(repo);
+ }
+ if (revision instanceof LocalFileRevision) {
+ String fullPath=getLocalFileRevisionPath((LocalFileRevision)revision);
+ //local history or current
+ final long timestamp=revision.getTimestamp();
+ if (timestamp != -1) {
+ return new LocalRevisionURIConverter(timestamp, fullPath);
+ }
+ }
+ return null;
+ }
+
+ private String getLocalFileRevisionPath(LocalFileRevision revision) {
+ return revision.getFile().getFullPath().toString();
+ }
+
+ private URI getUri(ITypedElement entrypoint, boolean conflicting) {
+ IFileRevision revision=getFileRevision(entrypoint);
+ if (revision instanceof IndexFileRevision) {
+ if (conflicting)
+ return URI.createPlatformResourceURI(revision.getURI().toString(), true);
+ else
+ return URI.createURI(GitSchemeConstants.INDEX_SCHEME + ":/" + revision.getURI().toString());
+ }
+
+ if (revision instanceof LocalFileRevision) {
+ return URI.createPlatformResourceURI(getLocalFileRevisionPath((LocalFileRevision)revision), true);
+ }
+ return null;
+ }
+
+ private String getGitLabel(ITypedElement entrypoint) {
+ IFileRevision revision=getFileRevision(entrypoint);
+ if (revision instanceof IndexFileRevision) {
+ if (entrypoint instanceof IEditableContent)
+ return "Index (editable): " + revision.getName();
+ return "Index: " + revision.getName();
+ }
+ if (revision instanceof LocalFileRevision) {
+ return "Local: " + getLocalFileRevisionPath((LocalFileRevision)revision);
+ }
+ return super.getLabelFor(entrypoint);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionURIConverter.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionURIConverter.java
new file mode 100644
index 00000000..17e62b6f
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitEditableRevisionURIConverter.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.git;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.egit.core.internal.storage.GitFileRevision;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergeGitConnectorPlugin;
+import org.eclipse.emf.ecore.resource.ContentHandler;
+import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.team.core.history.IFileRevision;
+
+public final class GitEditableRevisionURIConverter extends GitURIConverter {
+
+ public GitEditableRevisionURIConverter(Repository repo) {
+ super(repo);
+ }
+
+ @Override
+ protected IFileRevision getGitFileRevision(String gitPath) {
+ // check if the file being loaded is conflicting locally and load the "ours" version from the index.
+ try {
+ if (EMFDiffMergeGitConnectorPlugin.getInstance().isConflicting(getRepository(), gitPath))
+ return GitFileRevision.inIndex(getRepository(), gitPath, DirCacheEntry.STAGE_2);
+ }
+ catch (IOException e) {
+ EMFDiffMergeGitConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, EMFDiffMergeGitConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return GitFileRevision.inIndex(getRepository(), gitPath);
+ }
+
+ @Override
+ public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
+ if (getRepository() != null && uri.isPlatformResource()) {
+ //try to locate the file locally
+ IPath newPath=new Path(getRepository().getWorkTree().getAbsolutePath()).append(uri.toPlatformString(true));
+ File target=newPath.toFile();
+ if (target != null && target.exists()) {
+ try {
+ return getGitFileRevision(uri.toPlatformString(true).substring(1)).getStorage(new NullProgressMonitor()).getContents();
+ }
+ catch (CoreException e) {
+ EMFDiffMergeGitConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, EMFDiffMergeGitConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ }
+ else {
+ EMFDiffMergeGitConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, EMFDiffMergeGitConnectorPlugin.PLUGIN_ID, "Cannot find IResource at: " + newPath));
+ }
+ }
+ return super.createInputStream(uri, options);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitIndexURIConverter.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitIndexURIConverter.java
new file mode 100644
index 00000000..333f389f
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitIndexURIConverter.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.git;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.egit.core.internal.storage.GitFileRevision;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergeGitConnectorPlugin;
+import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.team.core.history.IFileRevision;
+
+public final class GitIndexURIConverter extends GitURIConverter {
+
+ public GitIndexURIConverter(Repository repo) {
+ super(repo);
+ }
+
+ @Override
+ protected IFileRevision getGitFileRevision(String gitPath) {
+ // check if the file being loaded is conflicting locally and load the "theirs" version from the index.
+ try {
+ if (EMFDiffMergeGitConnectorPlugin.getInstance().isConflicting(getRepository(), gitPath))
+ return GitFileRevision.inIndex(getRepository(), gitPath, DirCacheEntry.STAGE_3);
+ }
+ catch (IOException e) {
+ EMFDiffMergeGitConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, EMFDiffMergeGitConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return GitFileRevision.inIndex(getRepository(), gitPath);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitRemoteURIConverter.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitRemoteURIConverter.java
new file mode 100644
index 00000000..941025f1
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitRemoteURIConverter.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.git;
+
+import org.eclipse.egit.core.internal.storage.GitFileRevision;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.team.core.history.IFileRevision;
+
+public final class GitRemoteURIConverter extends GitURIConverter {
+
+ private final RevCommit commitId;
+
+ public GitRemoteURIConverter(RevCommit commitId, Repository repo) {
+ super(repo);
+ this.commitId=commitId;
+ }
+
+ @Override
+ protected IFileRevision getGitFileRevision(String gitPath) {
+ return GitFileRevision.inCommit(getRepository(), commitId, gitPath, null);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitSchemeConstants.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitSchemeConstants.java
new file mode 100644
index 00000000..8fcdafbd
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitSchemeConstants.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.git;
+
+/**
+ * Constants used for loading models using EMF scheme mapping.
+ */
+public final class GitSchemeConstants {
+
+ public static final String REMOTE_SCHEME="remote";
+ public static final String INDEX_SCHEME="index";
+ public static final String COMMIT_SCHEME="commit";
+
+ private GitSchemeConstants() {
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitStreamScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitStreamScopeDefinitionFactory.java
new file mode 100644
index 00000000..e518fb35
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitStreamScopeDefinitionFactory.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.git;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.egit.core.internal.storage.CommitFileRevision;
+import org.eclipse.egit.core.internal.storage.GitFileRevision;
+import org.eclipse.egit.core.internal.storage.IndexFileRevision;
+import org.eclipse.egit.core.synchronize.GitRemoteResource;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergeGitConnectorPlugin;
+import org.eclipse.emf.diffmerge.connector.core.FileRevisionScopeDefinitionFactory;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.jgit.lib.PersonIdent;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.core.variants.IResourceVariant;
+
+public class GitStreamScopeDefinitionFactory extends FileRevisionScopeDefinitionFactory {
+
+ private static final int ABBREVIATE_COMMIT_LABEL_SIZE=7;
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>>singleton(FileRevisionScopeDefinitionFactory.class);
+ }
+
+ @Override
+ protected IFileRevision getFileRevision(ITypedElement entrypoint) {
+ IFileRevision revision=super.getFileRevision(entrypoint);
+ if (getVariant(revision) instanceof GitRemoteResource) {
+ return revision;
+ }
+ if (revision instanceof GitFileRevision) {
+ return revision;
+ }
+ return null;
+ }
+
+ @Override
+ protected URI getUri(IFileRevision revision) throws CoreException {
+ IResourceVariant variant=getVariant(revision);
+ if (variant instanceof GitRemoteResource) {
+ return URI.createURI(GitSchemeConstants.REMOTE_SCHEME + ":/" + ((GitRemoteResource)variant).getPath());
+ }
+ if (revision instanceof IndexFileRevision) {
+ return URI.createURI(GitSchemeConstants.INDEX_SCHEME + ":/" + revision.getURI().toString());
+ }
+ if (revision instanceof CommitFileRevision) {
+ return URI.createURI(GitSchemeConstants.COMMIT_SCHEME + ":/" + revision.getURI().toString());
+ }
+ return super.getUri(revision);
+ }
+
+ @Override
+ protected IStorage getStorage(IFileRevision revision) throws CoreException {
+ IResourceVariant variant=getVariant(revision);
+ if (variant != null) {
+ return variant.getStorage(new NullProgressMonitor());
+ }
+ else
+ return super.getStorage(revision);
+ }
+
+ @Override
+ protected URIConverter getURIConverter(IFileRevision revision) throws CoreException {
+ // git remote
+ IResourceVariant variant=getVariant(revision);
+ if (variant instanceof GitRemoteResource) {
+ IPath path=((GitRemoteResource)variant).getDisplayPath();
+ Repository repo=EMFDiffMergeGitConnectorPlugin.getInstance().getRepo(path);
+ if (repo != null)
+ return new GitRemoteURIConverter(((GitRemoteResource)variant).getCommitId(), repo);
+
+ }
+ Repository repo=EMFDiffMergeGitConnectorPlugin.getInstance().getRepo(revision);
+ if (repo != null) {
+ // git index
+ if (revision instanceof IndexFileRevision) {
+ return new GitIndexURIConverter(repo);
+ }
+ // git commit
+ if (revision instanceof CommitFileRevision) {
+ return new GitRemoteURIConverter(((CommitFileRevision)revision).getRevCommit(), repo);
+ }
+ }
+ return super.getURIConverter(revision);
+ }
+
+ @Override
+ protected String getLabelFor(Object entrypoint) {
+ IFileRevision revision=getFileRevision((ITypedElement)entrypoint);
+ if (revision != null && getVariant(revision) instanceof GitRemoteResource) {
+ return revision.getName() + " " + getVariant(revision).getContentIdentifier();
+ }
+ if (revision instanceof IndexFileRevision) {
+ return "Index: " + revision.getName();
+ }
+ if (revision instanceof CommitFileRevision) {
+ return "Commit: " + revision.getName() + " " + getContentIdentifier(((CommitFileRevision)revision).getRevCommit());
+ }
+ return super.getLabelFor(entrypoint);
+ }
+
+ public String getContentIdentifier(RevCommit commitId) {
+ if (commitId == null)
+ return "";
+
+ StringBuilder s=new StringBuilder();
+ s.append(commitId.abbreviate(ABBREVIATE_COMMIT_LABEL_SIZE).name());
+ s.append("...");
+
+ PersonIdent authorIdent=commitId.getAuthorIdent();
+ if (authorIdent != null) {
+ s.append(" (");
+ s.append(authorIdent.getName());
+ s.append(")");
+ }
+ return s.toString();
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitURIConverter.java b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitURIConverter.java
new file mode 100644
index 00000000..5d315505
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.git/src/org/eclipse/emf/diffmerge/connector/git/GitURIConverter.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.git;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergeGitConnectorPlugin;
+import org.eclipse.emf.ecore.resource.ContentHandler;
+import org.eclipse.emf.ecore.resource.URIHandler;
+import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.team.core.history.IFileRevision;
+
+public abstract class GitURIConverter extends ExtensibleURIConverterImpl {
+
+ private final Repository repo;
+
+
+ public GitURIConverter(Repository repo){
+ super();
+ this.repo = repo;
+ }
+
+ public GitURIConverter(List<URIHandler> uriHandlers, List<ContentHandler> contentHandlers, Repository repo) {
+ super(uriHandlers, contentHandlers);
+ this.repo=repo;
+ }
+
+ protected abstract IFileRevision getGitFileRevision(String gitPath);
+
+ @Override
+ public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
+ if (repo != null
+ && (uri.scheme().equals(GitSchemeConstants.REMOTE_SCHEME) || uri.scheme().equals(GitSchemeConstants.INDEX_SCHEME) || uri.scheme().equals(
+ GitSchemeConstants.COMMIT_SCHEME))) {
+ //try to locate the file locally
+ IPath newPath=new Path(repo.getWorkTree().getAbsolutePath()).append(uri.devicePath());
+ File target=newPath.toFile();
+ if (target != null && target.exists()) {
+ try {
+ String gitPath=uri.devicePath().substring(1);
+ return getGitFileRevision(gitPath).getStorage(new NullProgressMonitor()).getContents();
+ }
+ catch (CoreException e) {
+ EMFDiffMergeGitConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, EMFDiffMergeGitConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ }
+ else {
+ EMFDiffMergeGitConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, EMFDiffMergeGitConnectorPlugin.PLUGIN_ID, "Cannot find IResource at: " + newPath));
+ }
+ }
+ return super.createInputStream(uri, options);
+ }
+
+ protected Repository getRepository() {
+ return repo;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/.classpath b/plugins/org.eclipse.emf.diffmerge.connector.perforce/.classpath
new file mode 100644
index 00000000..2d1a4302
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/.project b/plugins/org.eclipse.emf.diffmerge.connector.perforce/.project
new file mode 100644
index 00000000..0d9e5ff5
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.diffmerge.connector.perforce</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.diffmerge.connector.perforce/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..a9678a97
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.emf.diffmerge.connector.perforce;singleton:=true
+Bundle-Version: 0.5.0.qualifier
+Bundle-Localization: plugin
+Bundle-Vendor: %providerName
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.eclipse.emf.diffmerge.connector.EMFDiffMergePerforceConnectorPlugin
+Require-Bundle: org.eclipse.team.ui;bundle-version="3.6.201",
+ org.eclipse.team.core,
+ org.eclipse.core.filesystem;bundle-version="1.3.200",
+ org.eclipse.osgi,
+ org.eclipse.ui;bundle-version="3.8.2",
+ org.eclipse.core.runtime;bundle-version="3.8.0",
+ org.eclipse.core.resources;bundle-version="3.8.1",
+ org.eclipse.emf.common;bundle-version="2.9.0",
+ org.eclipse.emf.ecore;bundle-version="2.9.1",
+ org.eclipse.emf.diffmerge.ui.gmf;bundle-version="0.3.0",
+ com.perforce.team.core;bundle-version="2013.1.788968",
+ com.perforce.team.ui;bundle-version="2013.1.788968",
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
+ org.eclipse.emf.diffmerge.connector.core;bundle-version="0.5.0"
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/about.html b/plugins/org.eclipse.emf.diffmerge.connector.perforce/about.html
new file mode 100644
index 00000000..7e766fe1
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/about.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/build.properties b/plugins/org.eclipse.emf.diffmerge.connector.perforce/build.properties
new file mode 100644
index 00000000..c592f263
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/build.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2015 Intel Corporation.
+# 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
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/plugin.properties b/plugins/org.eclipse.emf.diffmerge.connector.perforce/plugin.properties
new file mode 100644
index 00000000..bda86685
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/plugin.properties
@@ -0,0 +1,9 @@
+###############################################################################
+# Copyright (c) 2015 Intel Corporation.
+# 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
+###############################################################################
+pluginName = EMF Diff/Merge Perforce Connector Plug-In (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/plugin.xml b/plugins/org.eclipse.emf.diffmerge.connector.perforce/plugin.xml
new file mode 100644
index 00000000..0948bc07
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/plugin.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2015 Intel Corporation.
+ 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:
+ Stephane Bouchet (Intel Corporation) - initial API and implementation
+-->
+<plugin>
+ <extension point="org.eclipse.emf.diffmerge.ui.modelComparisonContext">
+ <scopeDefinition
+ factory="org.eclipse.emf.diffmerge.connector.perforce.PerforceStreamScopeDefinitionFactory">
+ </scopeDefinition>
+ <comparisonMethod
+ factory="org.eclipse.emf.diffmerge.ui.specification.ext.DefaultComparisonMethodFactory">
+ </comparisonMethod>
+ </extension>
+ <extension point="org.eclipse.emf.diffmerge.ui.modelComparisonContext">
+ <scopeDefinition
+ factory="org.eclipse.emf.diffmerge.connector.perforce.PerforceRevisionScopeDefinitionFactory">
+ </scopeDefinition>
+ <comparisonMethod
+ factory="org.eclipse.emf.diffmerge.ui.specification.ext.DefaultComparisonMethodFactory">
+ </comparisonMethod>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergePerforceConnectorPlugin.java b/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergePerforceConnectorPlugin.java
new file mode 100644
index 00000000..0a81f54c
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/EMFDiffMergePerforceConnectorPlugin.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class EMFDiffMergePerforceConnectorPlugin extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.eclipse.emf.diffmerge.connector.perforce";
+ private static EMFDiffMergePerforceConnectorPlugin instance;
+
+ public EMFDiffMergePerforceConnectorPlugin() {
+ super();
+ }
+
+ public static EMFDiffMergePerforceConnectorPlugin getInstance() {
+ return instance;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ instance = this;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ instance = null;
+ super.stop(context);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceRevisionScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceRevisionScopeDefinitionFactory.java
new file mode 100644
index 00000000..c1b3736d
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceRevisionScopeDefinitionFactory.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.perforce;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergePerforceConnectorPlugin;
+import org.eclipse.emf.diffmerge.connector.core.FileRevisionScopeDefinitionFactory;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.core.variants.IResourceVariant;
+
+import com.perforce.p4java.core.IChangelistSummary;
+import com.perforce.p4java.core.file.FileSpecBuilder;
+import com.perforce.p4java.core.file.IFileSpec;
+import com.perforce.p4java.exception.P4JavaException;
+import com.perforce.p4java.impl.mapbased.server.Server;
+import com.perforce.p4java.option.server.GetChangelistsOptions;
+import com.perforce.team.core.ConnectionParameters;
+import com.perforce.team.core.PerforceTeamProvider;
+import com.perforce.team.core.p4java.IP4Connection;
+import com.perforce.team.core.p4java.P4Workspace;
+import com.perforce.team.core.p4java.synchronize.PerforceSyncFile;
+
+public class PerforceRevisionScopeDefinitionFactory extends FileRevisionScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>> singleton(FileRevisionScopeDefinitionFactory.class);
+ }
+
+ @Override
+ protected IFileRevision getFileRevision(ITypedElement entrypoint) {
+ IFileRevision revision = super.getFileRevision(entrypoint);
+ if (getVariant(revision) instanceof PerforceSyncFile) {
+ return revision;
+ }
+ return null;
+ }
+
+ @Override
+ protected URI getUri(IFileRevision revision) throws CoreException {
+ // remote Perforce
+ IResourceVariant variant = getVariant(revision);
+ if (variant instanceof PerforceSyncFile) {
+ return URI.createURI(((PerforceSyncFile) variant).getFile().getRemotePath());
+ }
+ return super.getUri(revision);
+ }
+
+ @Override
+ protected IStorage getStorage(IFileRevision revision) throws CoreException {
+ // remote Perforce
+ IResourceVariant variant = getVariant(revision);
+ if (variant != null) {
+ return variant.getStorage(new NullProgressMonitor());
+ } else
+ return super.getStorage(revision);
+ }
+
+ @Override
+ protected URIConverter getURIConverter(IFileRevision revision) throws CoreException {
+ // remote Perforce
+ IResourceVariant variant = getVariant(revision);
+ if (variant instanceof PerforceSyncFile) {
+ try {
+ String localPath = ((PerforceSyncFile) variant).getFile().getLocalPath();
+ IResource res = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(localPath));
+ ConnectionParameters params = PerforceTeamProvider.getPerforceProvider(res).getProjectProperties(false);
+ IP4Connection connection = P4Workspace.getWorkspace().getConnection(params);
+ String revisionSpec = variant.getContentIdentifier();
+ if (!revisionSpec.startsWith("#") && revisionSpec.lastIndexOf("#") != -1) {
+ revisionSpec = revisionSpec.substring(revisionSpec.lastIndexOf("#"), revisionSpec.length());
+ }
+ List<IFileSpec> fileSpecList = FileSpecBuilder
+ .makeFileSpecList(((PerforceSyncFile) variant).getFile().getRemotePath() + revisionSpec);
+ GetChangelistsOptions opts = new GetChangelistsOptions();
+ opts.setMaxMostRecent(1);
+ if (connection.getServer() instanceof Server
+ && !((Server) connection.getServer()).getChangelists(fileSpecList, opts).isEmpty()) {
+ IChangelistSummary changeList = ((Server) connection.getServer()).getChangelists(fileSpecList, opts)
+ .get(0);
+ return new PerforceStreamURIConverter(res, changeList);
+ } else {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID,
+ "Cannot load changeList for resource: " + res));
+ }
+ } catch (P4JavaException e) {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog().log(
+ new Status(IStatus.ERROR, EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ }
+ return super.getURIConverter(revision);
+ }
+
+ @Override
+ protected String getLabelFor(Object entrypoint) {
+ IFileRevision revision = getFileRevision((ITypedElement) entrypoint);
+ if (revision != null) {
+ IResourceVariant variant = getVariant(revision);
+ if (variant instanceof PerforceSyncFile) {
+ return variant.getName() + " [Remote File " + variant.getContentIdentifier() + "]";
+ }
+ }
+ return super.getLabelFor(entrypoint);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceStreamScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceStreamScopeDefinitionFactory.java
new file mode 100644
index 00000000..c9860de0
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceStreamScopeDefinitionFactory.java
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.perforce;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergePerforceConnectorPlugin;
+import org.eclipse.emf.diffmerge.connector.core.StreamScopeDefinition;
+import org.eclipse.emf.diffmerge.ui.gmf.GMFScopeDefinitionFactory;
+import org.eclipse.emf.diffmerge.ui.specification.IModelScopeDefinition;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.PlatformUI;
+
+import com.perforce.p4java.core.IChangelistSummary;
+import com.perforce.p4java.core.file.FileSpecBuilder;
+import com.perforce.p4java.core.file.IFileSpec;
+import com.perforce.p4java.exception.P4JavaException;
+import com.perforce.p4java.impl.mapbased.server.Server;
+import com.perforce.p4java.option.server.GetChangelistsOptions;
+import com.perforce.team.core.ConnectionParameters;
+import com.perforce.team.core.PerforceTeamProvider;
+import com.perforce.team.core.p4java.IP4Connection;
+import com.perforce.team.core.p4java.IP4Resource;
+import com.perforce.team.core.p4java.P4Workspace;
+import com.perforce.team.ui.editor.P4CompareNode;
+
+/**
+ * Stream-based perforce resource ( distant )
+ */
+public class PerforceStreamScopeDefinitionFactory extends GMFScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>> singleton(GMFScopeDefinitionFactory.class);
+ }
+
+ @Override
+ public boolean isApplicableTo(Object entrypoint) {
+ return entrypoint instanceof P4CompareNode;
+ }
+
+ @Override
+ public IModelScopeDefinition createScopeDefinition(Object entrypoint, String label, boolean editable) {
+ try {
+ final P4CompareNode node = (P4CompareNode) entrypoint;
+ final URI uri = getUri(node);
+ return new StreamScopeDefinition(entrypoint, (label != null) ? label : getLabelFor(entrypoint), uri,
+ node.getContents(), getURIConverter(node));
+ } catch (CoreException e) {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ } catch (NoSuchFieldException e) {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ } catch (SecurityException e) {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ } catch (IllegalArgumentException e) {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ } catch (IllegalAccessException e) {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return null;
+
+ }
+
+ protected URI getUri(P4CompareNode node) {
+ return toFileUri(node.getName());
+ }
+
+ protected URIConverter getURIConverter(P4CompareNode node)
+ throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
+ // cannot have a direct link between the p4CompareNode and the
+ // IResource.
+ // need to parse all known connections and depots
+ String nodeLabel = node.getLabel();
+ if (nodeLabel.indexOf("//") != -1) {
+ for (IP4Connection conn : P4Workspace.getWorkspace().getConnections()) {
+ IP4Resource ip4Resource = conn.getResource(
+ nodeLabel.substring(nodeLabel.indexOf("//"), nodeLabel.length()) + "/" + node.getName());
+ if (ip4Resource.isFile()) {
+ IResource res = ResourcesPlugin.getWorkspace().getRoot()
+ .getFileForLocation(new Path(ip4Resource.getLocalPath()));
+ return new PerforceStreamURIConverter(res,
+ nodeLabel.substring(nodeLabel.indexOf('#'), nodeLabel.indexOf("//") - 3));
+ }
+ }
+ }
+ if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
+ ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
+ .getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object element = ((IStructuredSelection) selection).getFirstElement();
+ if (element instanceof IAdaptable) {
+ IResource res = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
+ if (PerforceStreamURIConverter.DEPOT_FILE_REVISION_LABEL.equals(nodeLabel)) {
+ return new PerforceStreamURIConverter(res,
+ PerforceStreamURIConverter.DEPOT_FILE_REVISION_LABEL);
+ } else if (nodeLabel.indexOf("#") != -1) {
+ try {
+ ConnectionParameters params = PerforceTeamProvider.getPerforceProvider(res)
+ .getProjectProperties(false);
+ IP4Connection connection = P4Workspace.getWorkspace().getConnection(params);
+ String revision = nodeLabel.substring(nodeLabel.indexOf("#"), nodeLabel.length() - 1);
+ List<IFileSpec> fileSpecList = FileSpecBuilder
+ .makeFileSpecList(res.getLocation() + revision);
+ GetChangelistsOptions opts = new GetChangelistsOptions();
+ opts.setMaxMostRecent(1);
+ if (connection.getServer() instanceof Server && !((Server) connection.getServer())
+ .getChangelists(fileSpecList, opts).isEmpty()) {
+ IChangelistSummary changeList = ((Server) connection.getServer())
+ .getChangelists(fileSpecList, opts).get(0);
+ return new PerforceStreamURIConverter(res, changeList);
+ } else {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID,
+ "Cannot load changeList for resource: " + res));
+ }
+ } catch (CoreException e) {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR,
+ EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ } catch (P4JavaException e) {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR,
+ EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ }
+ }
+ }
+ }
+ return ExtensibleURIConverterImpl.INSTANCE;
+ }
+
+ @Override
+ protected String getLabelFor(Object entrypoint) {
+ String label = ((P4CompareNode) entrypoint).getLabel();
+ if (label.indexOf("//") != -1) {
+ return ((P4CompareNode) entrypoint).getName() + " ["
+ + label.substring(label.indexOf('#'), label.indexOf("//") - 3) + "]";
+ }
+ return ((P4CompareNode) entrypoint).getName() + " [" + label + "]";
+ }
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceStreamURIConverter.java b/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceStreamURIConverter.java
new file mode 100644
index 00000000..29741c1c
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.perforce/src/org/eclipse/emf/diffmerge/connector/perforce/PerforceStreamURIConverter.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.perforce;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffMergePerforceConnectorPlugin;
+import org.eclipse.emf.ecore.resource.ContentHandler;
+import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+
+import com.perforce.p4java.core.IChangelistSummary;
+import com.perforce.p4java.core.file.FileSpecBuilder;
+import com.perforce.p4java.core.file.IFileSpec;
+import com.perforce.p4java.exception.AccessException;
+import com.perforce.p4java.exception.ConnectionException;
+import com.perforce.p4java.exception.P4JavaException;
+import com.perforce.p4java.exception.RequestException;
+import com.perforce.team.core.ConnectionParameters;
+import com.perforce.team.core.PerforceTeamProvider;
+import com.perforce.team.core.p4java.IP4Connection;
+import com.perforce.team.core.p4java.IP4Resource;
+import com.perforce.team.core.p4java.P4Workspace;
+
+/**
+ * Remote URI Converter for perforce.
+ */
+public final class PerforceStreamURIConverter extends ExtensibleURIConverterImpl {
+
+ public static final String DEPOT_FILE_REVISION_LABEL = "Depot File";
+ private final IResource res;
+ private IChangelistSummary changelist = null;
+ private String revision = null;
+
+ public PerforceStreamURIConverter(IResource res, IChangelistSummary changelist) {
+ super();
+ this.res = res;
+ this.changelist = changelist;
+ }
+
+ public PerforceStreamURIConverter(IResource res, String revision) {
+ super();
+ this.res = res;
+ this.revision = revision;
+ }
+
+ /**
+ * Depot file URIConverter
+ *
+ * @param res
+ */
+ public PerforceStreamURIConverter(IResource res) {
+ super();
+ this.res = res;
+ }
+
+ /**
+ * The related model needs to be on the same changeList. if not, get the
+ * most approaching by date.
+ *
+ * @see org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl#createInputStream(org.eclipse.emf.common.util.URI,
+ * java.util.Map)
+ */
+ @Override
+ public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
+ if (res != null && res.exists()) {
+ try {
+ ConnectionParameters params = PerforceTeamProvider.getPerforceProvider(res).getProjectProperties(false);
+ IP4Connection connection = P4Workspace.getWorkspace().getConnection(params);
+ IP4Resource p4Res = connection.getResource(getModelResource(uri));
+ if (p4Res != null) {
+ List<IFileSpec> fileSpecList = getFileSpecList(p4Res);
+ if (fileSpecList != null) {
+ InputStream content = connection.getServer().getFileContents(fileSpecList, false, true);
+ if (content != null)
+ return content;
+ }
+ String message = "Cannot load IResource (" + uri.path() + ") from ";
+ if (revision != null)
+ message = message + "Revision: " + revision;
+ else
+ message = message + "ChangeList id:" + changelist.getId();
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, message));
+ } else {
+ EMFDiffMergePerforceConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR,
+ EMFDiffMergePerforceConnectorPlugin.PLUGIN_ID, "Cannot find IResource at: " + uri.path()));
+ }
+ } catch (CoreException e) {
+ throw new IOException(e.getMessage(), e);
+ } catch (P4JavaException e) {
+ throw new IOException(e.getMessage(), e);
+ }
+ }
+ return super.createInputStream(uri, options);
+ }
+
+ private List<IFileSpec> getFileSpecList(IP4Resource p4Res) {
+ if (revision == null && changelist == null) {
+ return FileSpecBuilder.makeFileSpecList(p4Res.getRemotePath() + "#" + IFileSpec.HEAD_REVISION_STRING);
+ }
+
+ else if (revision != null) {
+ String revSpec = "#" + IFileSpec.NONE_REVISION_STRING;
+ if (revision.startsWith("Remote File"))
+ revSpec = revision.substring(revision.indexOf('#'), revision.indexOf(')'));
+ else if (revision.startsWith("#"))
+ revSpec = revision;
+ else if (DEPOT_FILE_REVISION_LABEL.equals(revision))
+ revSpec = "#" + IFileSpec.HEAD_REVISION_STRING;
+ return FileSpecBuilder.makeFileSpecList(p4Res.getRemotePath() + revSpec);
+ } else if (changelist != null) {
+ return FileSpecBuilder.makeFileSpecList(p4Res.getRemotePath() + '@' + changelist.getId());
+ }
+ return null;
+ }
+
+ private IResource getModelResource(URI uri) {
+ if (uri.isPlatform()) {
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true)));
+ }
+ IPath fullPath = res.getFullPath().removeLastSegments(1).append(uri.toString());
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(fullPath);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/.classpath b/plugins/org.eclipse.emf.diffmerge.connector.svn/.classpath
new file mode 100644
index 00000000..2d1a4302
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/.project b/plugins/org.eclipse.emf.diffmerge.connector.svn/.project
new file mode 100644
index 00000000..084f3947
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.diffmerge.connector.svn</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.diffmerge.connector.svn/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..ec18d8b1
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.emf.diffmerge.connector.svn;singleton:=true
+Bundle-Version: 0.5.0.qualifier
+Bundle-Localization: plugin
+Bundle-Vendor: %providerName
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.eclipse.emf.diffmerge.connector.EMFDiffmergeSVNConnectorPlugin
+Require-Bundle: org.eclipse.team.ui;bundle-version="3.6.201",
+ org.eclipse.team.core;bundle-version="3.6.100",
+ org.eclipse.core.filesystem;bundle-version="1.3.200",
+ org.eclipse.osgi,
+ org.eclipse.ui;bundle-version="3.8.2",
+ org.eclipse.core.runtime;bundle-version="3.8.0",
+ org.eclipse.core.resources;bundle-version="3.8.1",
+ org.eclipse.emf.diffmerge.ui.gmf,
+ org.eclipse.team.svn;bundle-version="2.0.1",
+ org.eclipse.team.svn.ui;bundle-version="2.0.1",
+ org.eclipse.emf.transaction,
+ org.eclipse.team.svn.core;bundle-version="2.0.1",
+ org.eclipse.emf.diffmerge.connector.core;bundle-version="0.5.0"
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/about.html b/plugins/org.eclipse.emf.diffmerge.connector.svn/about.html
new file mode 100644
index 00000000..7e766fe1
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/about.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body></html> \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/build.properties b/plugins/org.eclipse.emf.diffmerge.connector.svn/build.properties
new file mode 100644
index 00000000..c592f263
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/build.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2015 Intel Corporation.
+# 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
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/plugin.properties b/plugins/org.eclipse.emf.diffmerge.connector.svn/plugin.properties
new file mode 100644
index 00000000..6890d4e8
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/plugin.properties
@@ -0,0 +1,9 @@
+###############################################################################
+# Copyright (c) 2015 Intel Corporation.
+# 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
+###############################################################################
+pluginName = EMF Diff/Merge Subversion Connector Plug-In (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/plugin.xml b/plugins/org.eclipse.emf.diffmerge.connector.svn/plugin.xml
new file mode 100644
index 00000000..0f08371a
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/plugin.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2015 Intel Corporation.
+ 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:
+ Stephane Bouchet (Intel Corporation) - initial API and implementation
+-->
+<plugin>
+ <extension point="org.eclipse.emf.diffmerge.ui.modelComparisonContext">
+ <scopeDefinition
+ factory="org.eclipse.emf.diffmerge.connector.svn.SVNLocalScopeDefinitionFactory">
+ </scopeDefinition>
+ <comparisonMethod
+ factory="org.eclipse.emf.diffmerge.ui.specification.ext.DefaultComparisonMethodFactory">
+ </comparisonMethod>
+ </extension>
+ <extension point="org.eclipse.emf.diffmerge.ui.modelComparisonContext">
+ <scopeDefinition
+ factory="org.eclipse.emf.diffmerge.connector.svn.SVNRemoteScopeDefinitionFactory">
+ </scopeDefinition>
+ <comparisonMethod
+ factory="org.eclipse.emf.diffmerge.ui.specification.ext.DefaultComparisonMethodFactory">
+ </comparisonMethod>
+ </extension>
+ <extension point="org.eclipse.emf.diffmerge.ui.modelComparisonContext">
+ <scopeDefinition
+ factory="org.eclipse.emf.diffmerge.connector.svn.SVNRevisionScopeDefinitionFactory">
+ </scopeDefinition>
+ <comparisonMethod
+ factory="org.eclipse.emf.diffmerge.ui.specification.ext.DefaultComparisonMethodFactory">
+ </comparisonMethod>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/EMFDiffmergeSVNConnectorPlugin.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/EMFDiffmergeSVNConnectorPlugin.java
new file mode 100644
index 00000000..2d087005
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/EMFDiffmergeSVNConnectorPlugin.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class EMFDiffmergeSVNConnectorPlugin extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID="org.eclipse.emf.diffmerge.connector.svn";
+ private static EMFDiffmergeSVNConnectorPlugin instance;
+
+ public EMFDiffmergeSVNConnectorPlugin() {
+ super();
+ }
+
+ public static EMFDiffmergeSVNConnectorPlugin getInstance() {
+ return instance;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ instance=this;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ instance=null;
+ super.stop(context);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNLocalScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNLocalScopeDefinitionFactory.java
new file mode 100644
index 00000000..2747a86b
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNLocalScopeDefinitionFactory.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.svn;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffmergeSVNConnectorPlugin;
+import org.eclipse.emf.diffmerge.connector.core.LocalScopeDefinition;
+import org.eclipse.emf.diffmerge.ui.gmf.GMFScopeDefinitionFactory;
+import org.eclipse.emf.diffmerge.ui.specification.IModelScopeDefinition;
+import org.eclipse.team.svn.ui.compare.ResourceCompareInput.ResourceElement;
+
+public class SVNLocalScopeDefinitionFactory extends GMFScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>> singleton(GMFScopeDefinitionFactory.class);
+ }
+
+ @Override
+ public boolean isApplicableTo(Object entrypoint) {
+ return entrypoint instanceof ResourceElement && ((ResourceElement) entrypoint).isEditable();
+ }
+
+ @Override
+ public IModelScopeDefinition createScopeDefinition(Object entrypoint, String label, boolean editable) {
+ try {
+ final ResourceElement res = (ResourceElement) entrypoint;
+ final URI uri = getUri(res);
+ return new LocalScopeDefinition(uri, label, editable);
+ } catch (SecurityException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ } catch (IllegalArgumentException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return null;
+ }
+
+ private URI getUri(ResourceElement res) {
+ return URI.createPlatformResourceURI(res.getLocalResource().getResource().getFullPath().toOSString(), true);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRemoteScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRemoteScopeDefinitionFactory.java
new file mode 100644
index 00000000..e3796839
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRemoteScopeDefinitionFactory.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.svn;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffmergeSVNConnectorPlugin;
+import org.eclipse.emf.diffmerge.connector.core.StreamScopeDefinition;
+import org.eclipse.emf.diffmerge.ui.gmf.GMFScopeDefinitionFactory;
+import org.eclipse.emf.diffmerge.ui.specification.IModelScopeDefinition;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.team.svn.core.connector.SVNConnectorException;
+import org.eclipse.team.svn.core.connector.SVNRevision;
+import org.eclipse.team.svn.ui.compare.ResourceCompareInput.ResourceElement;
+
+public class SVNRemoteScopeDefinitionFactory extends GMFScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>> singleton(GMFScopeDefinitionFactory.class);
+ }
+
+ @Override
+ public boolean isApplicableTo(Object entrypoint) {
+ return entrypoint instanceof ResourceElement && !((ResourceElement) entrypoint).isEditable();
+ }
+
+ @Override
+ public IModelScopeDefinition createScopeDefinition(Object entrypoint, String label, boolean editable) {
+ try {
+ final ResourceElement res = (ResourceElement) entrypoint;
+ final URI uri = getUri(res);
+ return new StreamScopeDefinition(entrypoint, (label != null) ? label : getLabelFor(entrypoint), uri,
+ res.getContents(), getURIConverter(res));
+ } catch (SecurityException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ } catch (IllegalArgumentException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return null;
+ }
+
+ private URI getUri(ResourceElement res) {
+ return URI.createURI(res.getRepositoryResource().getUrl());
+
+ }
+
+ private URIConverter getURIConverter(ResourceElement res) {
+ return new SVNStreamURIConverter(res.getRepositoryResource().getRepositoryLocation(),
+ res.getRepositoryResource().getSelectedRevision());
+ }
+
+ @Override
+ protected String getLabelFor(Object entrypoint) {
+ final ResourceElement res = (ResourceElement) entrypoint;
+ SVNRevision rev = res.getRepositoryResource().getSelectedRevision();
+ try {
+ if (rev.equals(SVNRevision.BASE))
+ return res.getRepositoryResource().getUrl() + " [BASE]";
+ else if (rev.equals(SVNRevision.HEAD))
+ return res.getRepositoryResource().getUrl() + " [HEAD]";
+ else
+ return res.getRepositoryResource().getUrl() + " [Rev:"
+ + Long.toString(res.getRepositoryResource().getRevision()) + "]";
+ } catch (SVNConnectorException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return res.getName();
+ }
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRevisionScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRevisionScopeDefinitionFactory.java
new file mode 100644
index 00000000..ea320328
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRevisionScopeDefinitionFactory.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.svn;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.core.FileRevisionScopeDefinitionFactory;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.svn.core.connector.SVNRevision;
+import org.eclipse.team.svn.core.resource.ILocalResource;
+import org.eclipse.team.svn.core.resource.IRepositoryLocation;
+import org.eclipse.team.svn.core.svnstorage.SVNRemoteStorage;
+import org.eclipse.team.svn.core.synchronize.variant.BaseFileVariant;
+
+public class SVNRevisionScopeDefinitionFactory extends FileRevisionScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>>singleton(FileRevisionScopeDefinitionFactory.class);
+ }
+
+ @Override
+ protected IFileRevision getFileRevision(ITypedElement entrypoint) {
+ IFileRevision revision=super.getFileRevision(entrypoint);
+ if (getVariant(revision) instanceof BaseFileVariant) {
+ return revision;
+ }
+ return null;
+ }
+
+ @Override
+ protected URI getUri(IFileRevision revision) throws CoreException {
+ IResourceVariant variant=getVariant(revision);
+ if (variant instanceof BaseFileVariant) {
+ ILocalResource res=((BaseFileVariant)variant).getResource();
+ IRepositoryLocation location=SVNRemoteStorage.instance().getRepositoryLocation(res.getResource());
+ return URI.createURI(location.getRepositoryRootUrl() + ((BaseFileVariant)variant).getResource().getResource().getFullPath(), true);
+ }
+ return super.getUri(revision);
+ }
+
+ @Override
+ protected IStorage getStorage(IFileRevision revision) throws CoreException {
+ IResourceVariant variant=getVariant(revision);
+ if (variant != null) {
+ return variant.getStorage(new NullProgressMonitor());
+ }
+ else
+ return super.getStorage(revision);
+ }
+
+ @Override
+ protected URIConverter getURIConverter(IFileRevision revision) throws CoreException {
+ IResourceVariant variant=getVariant(revision);
+ if (variant instanceof BaseFileVariant) {
+ ILocalResource res=((BaseFileVariant)variant).getResource();
+ IRepositoryLocation location=SVNRemoteStorage.instance().getRepositoryLocation(res.getResource());
+ return new SVNStreamURIConverter(location, SVNRevision.fromString(variant.getContentIdentifier()));
+ }
+ return super.getURIConverter(revision);
+ }
+
+ @Override
+ protected String getLabelFor(Object entrypoint) {
+ IFileRevision revision=getFileRevision((ITypedElement)entrypoint);
+ if (revision != null) {
+ IResourceVariant variant=getVariant(revision);
+ if (variant instanceof BaseFileVariant) {
+ return "Remote File [Rev:" + variant.getContentIdentifier() + "]";
+ }
+ }
+ return super.getLabelFor(entrypoint);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNStreamURIConverter.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNStreamURIConverter.java
new file mode 100644
index 00000000..27bf6fe7
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNStreamURIConverter.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * 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:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.svn;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffmergeSVNConnectorPlugin;
+import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+import org.eclipse.team.svn.core.connector.SVNRevision;
+import org.eclipse.team.svn.core.operation.AbstractGetFileContentOperation;
+import org.eclipse.team.svn.core.operation.IActionOperation;
+import org.eclipse.team.svn.core.operation.local.GetLocalFileContentOperation;
+import org.eclipse.team.svn.core.operation.remote.GetFileContentOperation;
+import org.eclipse.team.svn.core.resource.IRepositoryLocation;
+import org.eclipse.team.svn.core.resource.IRepositoryResource;
+import org.eclipse.team.svn.core.svnstorage.SVNRemoteStorage;
+
+public final class SVNStreamURIConverter extends ExtensibleURIConverterImpl {
+
+ private final IRepositoryLocation repoLocation;
+ private final SVNRevision revision;
+
+ public SVNStreamURIConverter(IRepositoryLocation repositoryLocation, SVNRevision revision) {
+ super();
+ this.repoLocation=repositoryLocation;
+ this.revision=revision;
+ }
+
+ @Override
+ public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
+ // strip the uri that contains the repolocation.
+ if ("svn".equals(uri.scheme())) {
+ //try to locate the file locally
+ String basepath=repoLocation.getRepositoryRootUrl();
+ List<String> basePathSegmentsList=URI.createURI(basepath).segmentsList();
+ List<String> newPathList=new ArrayList<String>(uri.segmentsList());
+ newPathList.removeAll(basePathSegmentsList);
+ IPath newPath=new Path(URI.createHierarchicalURI(newPathList.toArray(new String[] {}), uri.query(), uri.fragment()).devicePath());
+ IResource target=ResourcesPlugin.getWorkspace().getRoot().getFile(newPath);
+ if (target.exists()) {
+ AbstractGetFileContentOperation op;
+ if (revision.equals(SVNRevision.BASE)) {
+ op=new GetLocalFileContentOperation(target, SVNRevision.BASE.getKind());
+ }
+ else {
+ IRepositoryResource res=SVNRemoteStorage.instance().asRepositoryResource(target);
+ // gets the remote contents associated with the revision id
+ res.setSelectedRevision(revision);
+ op=new GetFileContentOperation(res);
+ }
+ op.run(new NullProgressMonitor());
+ if (op.getExecutionState() != IActionOperation.OK)
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, "Cannot load resource: " + op.getStatus().getMessage()));
+ return op.getContent();
+ }
+ else {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, "Cannot load resource at: " + uri));
+ }
+ }
+ return super.createInputStream(uri, options);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java
index 2cddbb87..06a41e9f 100644
--- a/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java
+++ b/plugins/org.eclipse.emf.diffmerge.ui/src/org/eclipse/emf/diffmerge/ui/viewers/ComparisonViewer.java
@@ -10,6 +10,7 @@
* Contributors:
* Thales Global Services S.A.S. - initial API and implementation
* Stephane Bouchet (Intel Corporation) - Bug #442492 : hide number of differences in the UI
+ * Stephane Bouchet (Intel Corporation) - Bug #466706 : support local history
*
* </copyright>
*/
@@ -24,7 +25,11 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.Logger;
import org.eclipse.emf.diffmerge.api.IComparison;
import org.eclipse.emf.diffmerge.api.IMatch;
@@ -47,6 +52,11 @@ import org.eclipse.emf.diffmerge.ui.diffuidata.impl.ComparisonSelectionImpl;
import org.eclipse.emf.diffmerge.ui.diffuidata.impl.MatchAndFeatureImpl;
import org.eclipse.emf.diffmerge.ui.log.CompareLogEvent;
import org.eclipse.emf.diffmerge.ui.log.MergeLogEvent;
+import org.eclipse.emf.diffmerge.ui.setup.ComparisonSetup;
+import org.eclipse.emf.diffmerge.ui.setup.ComparisonSetupManager;
+import org.eclipse.emf.diffmerge.ui.setup.ComparisonSetupWizard;
+import org.eclipse.emf.diffmerge.ui.setup.EMFDiffMergeEditorInput;
+import org.eclipse.emf.diffmerge.ui.specification.IComparisonMethod;
import org.eclipse.emf.diffmerge.ui.util.DelegatingLabelProvider;
import org.eclipse.emf.diffmerge.ui.util.DifferenceKind;
import org.eclipse.emf.diffmerge.ui.util.InconsistencyDialog;
@@ -77,6 +87,8 @@ import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.SashForm;
@@ -95,8 +107,10 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
@@ -2346,4 +2360,86 @@ public class ComparisonViewer extends AbstractComparisonViewer {
firePropertyChangeEvent(PROPERTY_DIFFERENCE_NUMBERS, null);
}
+ @Override
+ public void setInput(Object input_p) {
+ // the initial input is a compareInput from platform.
+ // use it to create a diffmerge input and set it back to the viewer.
+ if (input_p instanceof ICompareInput) {
+ Object left = ((ICompareInput) input_p).getLeft();
+ Object right = ((ICompareInput) input_p).getRight();
+ Object ancestor = ((ICompareInput) input_p).getAncestor();
+ CompareEditorInput edmInput = createCompareInput(left, right, ancestor);
+ if (edmInput == null) {
+ super.setInput(input_p);
+ return;
+ }
+ try {
+ // this will trigger the diffmerge compare process
+ edmInput.run(new NullProgressMonitor());
+ } catch (InvocationTargetException e) {
+ EMFDiffMergeUIPlugin
+ .getDefault()
+ .getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergeUIPlugin.getDefault().getBundle().getSymbolicName(), e
+ .getMessage()));
+ } catch (InterruptedException e) {
+ EMFDiffMergeUIPlugin
+ .getDefault()
+ .getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffMergeUIPlugin.getDefault().getBundle().getSymbolicName(), e
+ .getMessage()));
+ }
+ // set the result to the viewer
+ if (edmInput.getCompareResult() != null) {
+ super.setInput(edmInput.getCompareResult());
+ } else {
+ // no diff, close the viewer and open a dialog
+ String message = edmInput.getMessage();
+ handleDispose();
+ IWorkbenchWindow activeWorkbenchWindow = EMFDiffMergeUIPlugin
+ .getDefault().getWorkbench()
+ .getActiveWorkbenchWindow();
+ IEditorPart editor = activeWorkbenchWindow.getActivePage()
+ .getActiveEditor();
+ activeWorkbenchWindow.getActivePage()
+ .closeEditor(editor, false);
+ if (message == null || message.equals("")) {
+ MessageDialog
+ .openInformation(activeWorkbenchWindow.getShell(),
+ "Compare",
+ "There are no differences between the selected inputs.");
+ } else {
+ MessageDialog.openError(activeWorkbenchWindow.getShell(),
+ "Compare", message);
+ }
+ }
+ // break here. this will prevent to fallback to super.setInput in
+ // other cases.
+ return;
+ }
+ super.setInput(input_p);
+ }
+
+ protected CompareEditorInput createCompareInput(Object left, Object right,
+ Object ancestor) {
+ ComparisonSetupManager manager = EMFDiffMergeUIPlugin.getDefault()
+ .getSetupManager();
+ ComparisonSetup setup = manager.createComparisonSetup(left, right,
+ ancestor);
+ if (setup != null) {
+ ComparisonSetupWizard wizard = new ComparisonSetupWizard(setup);
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ dialog.setHelpAvailable(false);
+ if (Window.OK == dialog.open()) {
+ IComparisonMethod method = setup.getComparisonMethod();
+ if (method != null) {
+ return new EMFDiffMergeEditorInput(method);
+ }
+ }
+ } else {
+ MessageDialog.openError(getShell(), EMFDiffMergeUIPlugin.LABEL,
+ Messages.CompareModelsAction_ModelsOnly);
+ }
+ return null;
+ }
}

Back to the top