moved standalone plugins to archive
diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.checkstyle b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.checkstyle
new file mode 100644
index 0000000..2f2667a
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.checkstyle
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+  <fileset name="all" enabled="true" check-config-name="emfstoreStyle" local="false">
+    <file-match-pattern match-pattern="." include-pattern="true"/>
+  </fileset>
+</fileset-config>
diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.classpath b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.classpath
new file mode 100644
index 0000000..2d1a430
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.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/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.project b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.project
new file mode 100644
index 0000000..38446ab
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<projectDescription>

+	<name>org.eclipse.emf.emfstore.standalone.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>

+		<buildCommand>

+			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+	</buildSpec>

+	<natures>

+		<nature>org.eclipse.pde.PluginNature</nature>

+		<nature>org.eclipse.jdt.core.javanature</nature>

+		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>

+	</natures>

+</projectDescription>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.settings/org.eclipse.jdt.core.prefs b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..98f7d89
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Jun 29 17:41:52 CEST 2011

+eclipse.preferences.version=1

+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled

+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5

+org.eclipse.jdt.core.compiler.compliance=1.5

+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error

+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error

+org.eclipse.jdt.core.compiler.source=1.5

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/META-INF/MANIFEST.MF b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..f173ab0
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: EMFStore Standalone
+Bundle-SymbolicName: org.eclipse.emf.emfstore.standalone.core;singleton:=true
+Bundle-Version: 0.9.3.M930
+Bundle-Activator: org.eclipse.emf.emfstore.standalone.core.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.edit;bundle-version="2.6.0",
+ org.eclipse.egit.core;bundle-version="1.0.0",
+ org.eclipse.compare;bundle-version="3.5.101",
+ org.eclipse.team.core;bundle-version="3.5.101";visibility:=reexport,
+ org.eclipse.emf.emfstore.client;bundle-version="0.9.3";visibility:=reexport
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.emf.emfstore.standalone.core;uses:="org.eclipse.ui,org.eclipse.ui.plugin,org.osgi.framework",
+ org.eclipse.emf.emfstore.standalone.core.artifacts;
+  uses:="org.eclipse.emf.emfstore.client.model.impl,
+   org.eclipse.emf.ecore.resource,
+   org.eclipse.emf.ecore.xmi,
+   org.eclipse.emf.common.notify.impl,
+   org.eclipse.emf.common.util,
+   org.eclipse.core.resources,
+   org.eclipse.emf.emfstore.common.model,
+   org.eclipse.emf.emfstore.server.model.versioning.operations,
+   org.eclipse.emf.common.notify",
+ org.eclipse.emf.emfstore.standalone.core.exceptions,
+ org.eclipse.emf.emfstore.standalone.core.util,
+ org.eclipse.emf.emfstore.standalone.core.vcs,
+ org.eclipse.emf.emfstore.standalone.core.workspace
diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/build.properties b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/build.properties
new file mode 100644
index 0000000..6f20375
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/build.properties
@@ -0,0 +1,5 @@
+source.. = src/

+output.. = bin/

+bin.includes = META-INF/,\

+               .,\

+               plugin.xml

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/plugin.xml b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/plugin.xml
new file mode 100644
index 0000000..5d08786
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/plugin.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<?eclipse version="3.4"?>

+<plugin>

+   <extension-point id="org.eclipse.emf.emfstore.standalone.core.vcs.provider" name="Model Merge VCS Provider" schema="schema/org.eclipse.emf.emfstore.standalone.core.vcs.provider.exsd"/>

+   <extension-point id="org.eclipse.emf.emfstore.standalone.core.workspace.resourceOpened" name="Resource Opened Observer" schema="schema/org.eclipse.emf.emfstore.standalone.core.workspace.resourceOpened.exsd"/>

+

+   

+</plugin>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/schema/org.eclipse.emf.emfstore.standalone.core.vcs.provider.exsd b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/schema/org.eclipse.emf.emfstore.standalone.core.vcs.provider.exsd
new file mode 100644
index 0000000..14b1f57
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/schema/org.eclipse.emf.emfstore.standalone.core.vcs.provider.exsd
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>

+<!-- Schema file written by PDE -->

+<schema targetNamespace="org.eclipse.emf.emfstore.standalone.core" xmlns="http://www.w3.org/2001/XMLSchema">

+<annotation>

+      <appinfo>

+         <meta.schema plugin="org.eclipse.emf.emfstore.standalone.core" id="org.eclipse.emf.emfstore.standalone.core.vcs.provider" name="Model Merge VCS Provider"/>

+      </appinfo>

+      <documentation>

+         [Enter description of this extension point.]

+      </documentation>

+   </annotation>

+

+   <element name="extension">

+      <annotation>

+         <appinfo>

+            <meta.element />

+         </appinfo>

+      </annotation>

+      <complexType>

+         <sequence>

+            <element ref="provider"/>

+         </sequence>

+         <attribute name="point" type="string" use="required">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="id" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="name" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute translatable="true"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <element name="provider">

+      <complexType>

+         <attribute name="class" type="string" use="required">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute kind="java" basedOn=":org.eclipse.emf.emfstore.teamprovider.recording.IVCSProvider"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="id" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="since"/>

+      </appinfo>

+      <documentation>

+         [Enter the first release in which this extension point appears.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="examples"/>

+      </appinfo>

+      <documentation>

+         [Enter extension point usage example here.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="apiinfo"/>

+      </appinfo>

+      <documentation>

+         [Enter API information here.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="implementation"/>

+      </appinfo>

+      <documentation>

+         [Enter information about supplied implementation of this extension point.]

+      </documentation>

+   </annotation>

+

+

+</schema>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/schema/org.eclipse.emf.emfstore.standalone.core.workspace.resourceOpened.exsd b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/schema/org.eclipse.emf.emfstore.standalone.core.workspace.resourceOpened.exsd
new file mode 100644
index 0000000..55884a1
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/schema/org.eclipse.emf.emfstore.standalone.core.workspace.resourceOpened.exsd
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>

+<!-- Schema file written by PDE -->

+<schema targetNamespace="org.eclipse.emf.emfstore.standalone.core" xmlns="http://www.w3.org/2001/XMLSchema">

+<annotation>

+      <appinfo>

+         <meta.schema plugin="org.eclipse.emf.emfstore.standalone.core" id="org.eclipse.emf.emfstore.standalone.core.workspace.resourceOpened" name="Resource Opened Observer"/>

+      </appinfo>

+      <documentation>

+         [Enter description of this extension point.]

+      </documentation>

+   </annotation>

+

+   <element name="extension">

+      <annotation>

+         <appinfo>

+            <meta.element />

+         </appinfo>

+      </annotation>

+      <complexType>

+         <sequence>

+            <element ref="observer"/>

+         </sequence>

+         <attribute name="point" type="string" use="required">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="id" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="name" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute translatable="true"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <element name="observer">

+      <complexType>

+         <attribute name="class" type="string" use="required">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute kind="java" basedOn=":org.eclipse.emf.emfstore.standalone.core.workspace.IResourceOpenedObserver"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="id" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="since"/>

+      </appinfo>

+      <documentation>

+         [Enter the first release in which this extension point appears.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="examples"/>

+      </appinfo>

+      <documentation>

+         [Enter extension point usage example here.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="apiinfo"/>

+      </appinfo>

+      <documentation>

+         [Enter API information here.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="implementation"/>

+      </appinfo>

+      <documentation>

+         [Enter information about supplied implementation of this extension point.]

+      </documentation>

+   </annotation>

+

+

+</schema>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/Activator.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/Activator.java
new file mode 100644
index 0000000..9460eac
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/Activator.java
@@ -0,0 +1,72 @@
+/*******************************************************************************

+ * Copyright (c) 2008-2011 Chair for Applied Software Engineering, Technische Universitaet Muenchen. 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:

+ ******************************************************************************/

+package org.eclipse.emf.emfstore.standalone.core;

+

+import org.eclipse.core.runtime.Plugin;

+import org.osgi.framework.BundleContext;

+

+/**

+ * The activator class controls the plug-in life cycle.

+ * 

+ * @author emueller

+ */

+public class Activator extends Plugin {

+

+	/**

+	 * The plug-in ID.

+	 */

+	public static final String PLUGIN_ID = "org.eclipse.emf.emfstore.teamprovider.recording";

+

+	/**

+	 * The shared instance.

+	 */

+	private static Activator plugin;

+

+	// TODO: enable multiple providesr

+//	public static Map<String ,IVCSProvider> vcsProviders;

+

+	/**

+	 * The constructor.

+	 */

+	public Activator() {

+		

+	}

+

+	/*

+	 * (non-Javadoc)

+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)

+	 */

+	// BEGIN SUPRESS CATCH EXCEPTION

+	@Override

+	public void start(BundleContext context) throws Exception {

+		// END SUPRESS CATCH EXCEPTION

+		super.start(context);

+		plugin = this;

+

+	}

+

+	/*

+	 * (non-Javadoc)

+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)

+	 */

+	// BEGIN SUPRESS CATCH EXCEPTION

+	@Override

+	public void stop(BundleContext context) throws Exception {

+		// END SUPRESS CATCH EXCEPTION

+		plugin = null;

+		super.stop(context);

+	}

+

+	/**

+	 * Returns the shared instance.

+	 * 

+	 * @return the shared instance

+	 */

+	public static Activator getDefault() {

+		return plugin;

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/artifacts/Artifact.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/artifacts/Artifact.java
new file mode 100644
index 0000000..70f4e61
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/artifacts/Artifact.java
@@ -0,0 +1,128 @@
+package org.eclipse.emf.emfstore.standalone.core.artifacts;

+

+import java.io.IOException;

+

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.ecore.resource.ResourceSet;

+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

+import org.eclipse.emf.ecore.xmi.XMIResource;

+import org.eclipse.emf.emfstore.client.model.impl.OperationRecorder;

+import org.eclipse.emf.emfstore.common.model.Project;

+import org.eclipse.emf.emfstore.common.model.impl.ProjectImpl;

+import org.eclipse.emf.emfstore.standalone.core.exceptions.NoActiveVCSProviderException;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+import org.eclipse.emf.emfstore.standalone.core.vcs.IVCSProvider;

+import org.eclipse.emf.emfstore.standalone.core.vcs.VCSProviderRegistry;

+

+public class Artifact {

+

+	private XMIResource xmiResource;

+	private XMIResource historyResource;

+	private OperationRecorder operationRecorder;

+	private OperationPersister operationPersister;

+	private boolean isInitialized;

+	private Project project;

+	private URI historyURI;

+

+	/**

+	 * Constructor.

+	 * @param modelResource the model resource

+	 */

+	public Artifact(XMIResource modelResource, URI historyURI) {

+		this.xmiResource = modelResource;

+		this.historyURI = historyURI;

+	}

+	

+	public void initialize() throws NoActiveVCSProviderException {

+		if (getModelResource() != null) {

+			initialize(getModelResource());

+		}

+	}

+	

+	public void initialize(XMIResource xmiResource) throws NoActiveVCSProviderException {

+		this.xmiResource = xmiResource;

+		boolean shouldClearHistoryResource = false;

+		

+		IVCSProvider activeProvider = VCSProviderRegistry.getInstance().getActiveProvider();

+		if (activeProvider == IVCSProvider.NONE) {

+			throw new NoActiveVCSProviderException();

+		}

+		

+		try {

+			project = new ProjectImpl(getModelResource());

+			operationRecorder = new OperationRecorder(getProject(), getProject().getChangeNotifier());

+			

+			if (activeProvider.isModified(FileUtil.getFile(historyURI))) {

+				shouldClearHistoryResource   = true;

+			}

+			

+			ResourceSet resourceSet = getModelResource().getResourceSet() == null ? new ResourceSetImpl() : getModelResource().getResourceSet();

+			this.historyResource = ((XMIResource) resourceSet.createResource(historyURI));

+			

+			if (shouldClearHistoryResource) {

+				historyResource.getContents().clear();

+			}

+			

+			historyResource.save(null);

+		} catch (IOException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+			return;

+		}

+		

+		operationPersister = new OperationPersister(getModelResource(), getHistoryResource());

+		operationRecorder.addOperationRecorderListener(operationPersister);		

+		operationRecorder.startChangeRecording();

+		isInitialized = true;

+	}

+	

+	public void dispose() {

+		// TODO: in which cases are the recorder and the persister null?

+		if (operationRecorder != null){

+			operationRecorder.stopChangeRecording();

+			operationRecorder.removeOperationRecorderListener(operationPersister);

+		}

+

+		if (operationPersister != null){

+			operationPersister.dispose();

+		}

+		

+		this.project = null;

+		operationRecorder = null;

+		operationPersister = null;		

+		isInitialized = false;

+	}

+

+	public boolean isInitialized() {

+		return isInitialized;

+	}

+	

+	public URI getURI() {

+		return getModelResource().getURI();

+	}

+

+	// TODO: hide

+	public Project getProject() {

+		return project;

+	}

+

+	/**

+	 * Returns the history resource of this artifact.

+	 * @return the history resource

+	 */

+	public XMIResource getHistoryResource() {

+		return historyResource;

+	}

+	

+	/**

+	 * Returns the model resource of this artifact.

+	 * @return the model resource

+	 */

+	public XMIResource getModelResource() {

+		return xmiResource;

+	}

+

+	public void setProject(Project project) {

+		this.project = project;

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/artifacts/ArtifactRegistry.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/artifacts/ArtifactRegistry.java
new file mode 100644
index 0000000..ce78a90
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/artifacts/ArtifactRegistry.java
@@ -0,0 +1,109 @@
+package org.eclipse.emf.emfstore.standalone.core.artifacts;

+

+import java.util.HashMap;

+import java.util.HashSet;

+import java.util.Map;

+import java.util.Set;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.NullProgressMonitor;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+

+/**

+ * Keeps track of which artifacts are considered to be under recorder control.

+ * @author emueller

+ *

+ */

+public class ArtifactRegistry {

+	

+	private Map<URI, Artifact> recordedArtifacts;

+	private Set<URI> flags;

+	

+	private static ArtifactRegistry registry;

+	

+	public static ArtifactRegistry getInstance() {

+		if (registry == null) {

+			registry = new ArtifactRegistry();

+		}

+		return registry;

+	}

+

+	private ArtifactRegistry() {

+		recordedArtifacts = new HashMap<URI, Artifact>();

+		flags = new HashSet<URI>();

+	}

+

+	/**

+	 * Adds a {@link Artifact} to the registry.

+	 * @param artifact the artifact to be added 

+	 * @param isLoading whether the artifact is loading or whether it is 

+	 * 		considered to be a new one not yet put under recorder control

+	 */

+	public void register(Artifact artifact) {

+		recordedArtifacts.put(artifact.getURI(), artifact);

+//		artifact.initialize();

+		// TODO: write versioned artifact to preference store

+		//		 e.g. by means of using the filename/URI

+	}

+	

+	public Artifact getArtifact(URI uri) {

+		return recordedArtifacts.get(uri);

+	}

+	

+	

+	/**

+	 * Removes the artifact 

+	 * @param uri 

+	 * @throws CoreException if the history file can not be deleted

+	 */

+	public void unregister(URI uri) throws CoreException {

+		Artifact versionedArtifact = recordedArtifacts.get(uri);

+		versionedArtifact.dispose();

+		recordedArtifacts.remove(uri);

+		IFile historyFile = FileUtil.getHistoryFile(FileUtil.getFile(uri));

+		historyFile.delete(true, new NullProgressMonitor());

+	}

+	

+	// TODO: remove?

+	public boolean isRegistered(URI uri) {

+		return recordedArtifacts.containsKey(uri);

+	}

+	

+	public boolean isRegistered(IFile artifactFile) {

+		return recordedArtifacts.containsKey(FileUtil.getUri(artifactFile));

+	}

+	

+	public void flag(URI uri) {

+		flags.add(uri);

+	}

+	

+	public void flag(IFile artifactFile) {

+		flags.add(FileUtil.getUri(artifactFile));

+	}

+	

+//	public void markClearHistory(URI uri) {

+//		clearHistoryFiles.put(uri, true);

+//	}

+//	

+//	public void removeClearHistory(URI uri) {

+//		clearHistoryFiles.remove(uri);

+//	}

+//	

+//	public boolean isMarkedForClearHistory(URI uri) {

+//		return clearHistoryFiles.containsKey(uri);

+//	}

+	

+	public boolean isFlagged(URI uri) {

+		return flags.contains(uri);

+	}

+	

+	public boolean isFlagged(IFile artifactFile) {

+		return flags.contains(FileUtil.getUri(artifactFile));

+	}

+	

+	public void unflag(URI uri) {

+		flags.remove(uri);

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/artifacts/OperationPersister.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/artifacts/OperationPersister.java
new file mode 100644
index 0000000..4c61889
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/artifacts/OperationPersister.java
@@ -0,0 +1,86 @@
+package org.eclipse.emf.emfstore.standalone.core.artifacts;

+

+import java.io.IOException;

+import java.util.List;

+

+import org.eclipse.emf.common.notify.Notification;

+import org.eclipse.emf.common.notify.impl.AdapterImpl;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.ecore.resource.Resource;

+import org.eclipse.emf.ecore.xmi.XMIResource;

+import org.eclipse.emf.emfstore.client.model.impl.OperationRecorderListener;

+import org.eclipse.emf.emfstore.common.model.util.ModelUtil;

+import org.eclipse.emf.emfstore.server.model.versioning.operations.AbstractOperation;

+

+/**

+ * Persists operations into a history file.

+ * 

+ * @author emueller

+ *

+ */

+public class OperationPersister extends AdapterImpl implements OperationRecorderListener {

+

+	private Resource historyResource;

+	private boolean isResourceModified;

+	private URI historyUri;

+	private Resource resource;

+

+	/**

+	 * Constructor.

+	 * 

+	 * @param resource the resource, whose location will be used to create the history file.

+	 * @param historyFilePath the path at which the history file will be written

+	 */

+	public OperationPersister(Resource resource, XMIResource historyResource) {

+		init(resource, historyResource);

+	}

+	

+	private void init(Resource resource, XMIResource historyResource) {

+		this.resource = resource;

+		this.historyResource = historyResource;

+//		ResourceSet resourceSet = resource.getResourceSet() == null ? new ResourceSetImpl() : resource.getResourceSet();

+//		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot

+		resource.setTrackingModification(true);

+		resource.eAdapters().add(this);

+	}

+	

+	public void dispose() {

+		resource.setTrackingModification(false);

+		resource.eAdapters().remove(this);

+	}

+

+	/**

+	 * {@inheritDoc}

+	 */

+	public void operationsRecorded(List<? extends AbstractOperation> operations) {

+		for (AbstractOperation op : operations) {

+			historyResource.getContents().add(op);

+		}

+	}

+

+	/**

+	 * {@inheritDoc}

+	 */

+	@Override

+	public void notifyChanged(Notification msg) {

+		if (msg.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED) {

+			isResourceModified = !isResourceModified;

+		}

+		

+		if (!isResourceModified) {

+			saveResource();

+		}

+	}

+	

+	/**

+	 * Saves the history file.

+	 */

+	private void saveResource() {

+		try {

+			historyResource.save(null);

+		} catch (IOException e) {

+			 ModelUtil.logException(String.format("Could not write operations file %s.",

+					 historyUri), e);

+		}

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/exceptions/NoActiveVCSProviderException.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/exceptions/NoActiveVCSProviderException.java
new file mode 100644
index 0000000..3eae8e1
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/exceptions/NoActiveVCSProviderException.java
@@ -0,0 +1,7 @@
+package org.eclipse.emf.emfstore.standalone.core.exceptions;

+

+public class NoActiveVCSProviderException extends Exception {

+

+	private static final long serialVersionUID = 6551086981520016383L;

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/exceptions/RepositoryNotFoundException.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/exceptions/RepositoryNotFoundException.java
new file mode 100644
index 0000000..ae2dfbd
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/exceptions/RepositoryNotFoundException.java
@@ -0,0 +1,10 @@
+package org.eclipse.emf.emfstore.standalone.core.exceptions;

+

+public class RepositoryNotFoundException extends Exception {

+

+	private static final long serialVersionUID = 1485604779291238587L;

+

+	public RepositoryNotFoundException(Throwable cause) {

+		super(cause);

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/exceptions/VCSProviderNotFoundException.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/exceptions/VCSProviderNotFoundException.java
new file mode 100644
index 0000000..237f1ef
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/exceptions/VCSProviderNotFoundException.java
@@ -0,0 +1,7 @@
+package org.eclipse.emf.emfstore.standalone.core.exceptions;

+

+public class VCSProviderNotFoundException extends Exception {

+

+	private static final long serialVersionUID = 4259651016043456563L;

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/util/FileUtil.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/util/FileUtil.java
new file mode 100644
index 0000000..4c24030
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/util/FileUtil.java
@@ -0,0 +1,149 @@
+package org.eclipse.emf.emfstore.standalone.core.util;

+

+import java.io.IOException;

+import java.io.InputStream;

+import java.util.ArrayList;

+import java.util.HashSet;

+import java.util.List;

+import java.util.Set;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IResource;

+import org.eclipse.core.resources.IWorkspaceRoot;

+import org.eclipse.core.resources.ResourcesPlugin;

+import org.eclipse.core.runtime.Path;

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.emf.ecore.xmi.XMIResource;

+import org.eclipse.emf.emfstore.server.model.versioning.operations.AbstractOperation;

+

+public class FileUtil {

+	

+	private static final String HISTORY_EXTENSION = "hist";

+	private static Set<String> managedFileExtensions;

+

+	private static void addFileExtensions() {

+		managedFileExtensions.add("ecore");

+		managedFileExtensions.add("umldi-history");

+		managedFileExtensions.add("umldi");

+		managedFileExtensions.add("uml");

+		// TODO: provide extensions points to read them here

+	}

+

+	/**

+	 * Determines whether a {@link IFile} has an extension that may be versioned.

+	 * @param file a {@link IFile}

+	 * @return true, if the file may by the {@link RecorderHeap}, false otherwise

+	 */

+	public static boolean hasManagedFileExtension(IFile file) {

+		initFileExtensionsStore();

+		String fileExtension = file.getFileExtension();

+		return managedFileExtensions.contains(fileExtension);

+	}

+

+	private static void initFileExtensionsStore() {

+		if (managedFileExtensions == null) {

+			managedFileExtensions = new HashSet<String>();

+			addFileExtensions();

+		}

+	}

+	

+	/**

+	 * Returns a set of extensions that are currently managed.

+	 * @return a list containing all file extensions that may be versioned

+	 */

+	public static Set<String> getManagedFileExtensions() {

+		initFileExtensionsStore();

+		return managedFileExtensions;

+	}

+

+	/**

+	 * Convert a given {@link IFile} to its {@link URI} representation

+	 * @param file a file

+	 * @return the {@link URI} representation of the file

+	 */

+	public static URI getUri(IFile file) {

+		return URI.createPlatformResourceURI(file.getFullPath().toString(), true);

+	}

+	

+	/**

+	 * Convert a {@link URI} to its {@link IFile} representation

+	 * @param uri a {@link URI}

+	 * @return the {@link URI} representation of the file

+	 */

+	public static IFile getFile(URI uri) {

+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

+		return root.getFile(new Path(uri.toPlatformString(true)));

+	}

+	

+	public static URI getHistoryURI(URI artifactURI) {

+		return artifactURI.appendFileExtension(HISTORY_EXTENSION);

+	}

+		

+	public static IFile getHistoryFile(IFile artifactFile) {

+		String artifactFileName = artifactFile.getName() + "." +  HISTORY_EXTENSION;

+		IResource resource = artifactFile.getProject().findMember(artifactFileName);

+		

+		if (!(resource instanceof IFile) || !resource.exists()) {

+			throw new IllegalStateException("Artifact file either does not exist or is not a file");

+		}

+		

+		return (IFile) resource;

+	}

+	

+	/**

+	 * Returns the artifact based on the history file. 

+	 * 

+	 * @param file the history file

+	 * @return the artifact file

+	 * @throws IllegalStateException if the given history file exists, but the artifact file does not

+	 * 		or if the artifact file is not an instance of {@link IFile}

+	 */

+	public static IFile getArtifactFile(IFile historyFile) {

+		String artifactFileName = historyFile.getName().replace("." + HISTORY_EXTENSION, "");

+		IResource resource = historyFile.getProject().findMember(artifactFileName);

+		return (IFile) resource;

+	}

+	

+	// TODO: copied method

+	public static String slurpAndClose(InputStream inputStream) throws IOException {

+		StringBuilder stringBuilder = new StringBuilder();

+		try {

+			int ch;

+			while ((ch = inputStream.read()) != -1) {

+				stringBuilder.append((char) ch);

+			}

+		} finally {

+			inputStream.close();

+		}

+		return stringBuilder.toString();

+	}

+	

+	// TODO: copied method

+	public static List<AbstractOperation> slurpAndCloseHistoryResource(XMIResource xmiResource) throws IOException {

+		xmiResource.load(null);

+		List<AbstractOperation> result = new ArrayList<AbstractOperation>();

+		EList<EObject> contents = xmiResource.getContents();

+		for (EObject obj : contents) {

+			result.add((AbstractOperation) obj);

+		}

+		

+		return result;

+	}

+	

+	/**

+	 * Checks whether a given file is a history file.

+	 * 

+	 * @param file

+	 * @throws IllegalArgumentException if the given file is null

+	 */

+	public static boolean isHistoryFile(IFile file) {

+		

+		if (file == null) {

+			throw new IllegalArgumentException("file must not be null.");

+		}

+		

+		return file.getFileExtension().equals(HISTORY_EXTENSION);

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/vcs/AbstractVCSProvider.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/vcs/AbstractVCSProvider.java
new file mode 100644
index 0000000..a579430
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/vcs/AbstractVCSProvider.java
@@ -0,0 +1,124 @@
+package org.eclipse.emf.emfstore.standalone.core.vcs;

+

+import java.io.IOException;

+import java.io.StringReader;

+import java.io.UnsupportedEncodingException;

+import java.util.ArrayList;

+import java.util.List;

+

+import org.eclipse.core.resources.IResource;

+import org.eclipse.core.runtime.IProgressMonitor;

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

+import org.eclipse.emf.ecore.util.EcoreUtil;

+import org.eclipse.emf.ecore.xmi.XMIResource;

+import org.eclipse.emf.emfstore.common.model.util.ModelUtil;

+import org.eclipse.emf.emfstore.common.model.util.SerializationException;

+import org.eclipse.emf.emfstore.server.model.versioning.operations.AbstractOperation;

+import org.xml.sax.InputSource;

+

+public abstract class AbstractVCSProvider implements IVCSProvider {

+

+	/**

+	 * URI used to serialize EObject with the model util.

+	 */

+	public static final URI VIRTUAL_URI = URI.createURI("virtualUri");

+	

+	public List<AbstractOperation> getTheirOperations(IResource resource, IProgressMonitor monitor) {

+		try {

+			String theirRevision = getTheirRevision(resource, monitor);

+			List<AbstractOperation> theirOperations = getOperations(theirRevision);

+			return theirOperations;

+		} catch (IOException moe) {

+			// TODO Auto-generated moe catch block

+			moe.printStackTrace();

+		} catch (InterruptedException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+		

+		return null;

+	}

+	

+	public List<AbstractOperation> getMyOperations(IResource resource, IProgressMonitor monitor) {

+		try {

+			String myRevision = getMyRevision(resource, monitor);

+			List<AbstractOperation> myOperations = getOperations(myRevision);

+			return myOperations;

+		} catch (IOException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (InterruptedException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+	

+		return null;

+	}

+	

+	private List<AbstractOperation> getOperations(String s) {

+		// TODO Auto-generated method stub

+		EList<EObject> ops1 = null;

+		try {

+			ops1 = stringToEObject(s);

+		} catch (SerializationException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+		List<AbstractOperation> result = new ArrayList<AbstractOperation>();

+		for (EObject obj : ops1) {

+			if (obj instanceof AbstractOperation) {

+				AbstractOperation op = (AbstractOperation) obj;

+				result.add(op);

+			}

+		}

+		

+		return result;

+	}

+	

+	/**

+	 * Converts a {@link String} to an {@link EObject}. <b>Note</b>:

+	 * {@link String} must be the result of

+	 * {@link ModelUtil#eObjectToString(EObject)}

+	 * 

+	 * @param object

+	 *            the {@link String} representation of the {@link EObject}

+	 * @return the deserialized {@link EObject}

+	 * @throws SerializationException

+	 *             if deserialization fails

+	 */

+	private EList<EObject> stringToEObject(String object)

+			throws SerializationException {

+		if (object == null) {

+			return null;

+		}

+

+		XMIResource res = (XMIResource) (new ResourceSetImpl())

+				.createResource(VIRTUAL_URI);

+

+		try {

+			res.load(new InputSource(new StringReader(object)),

+					null);

+		} catch (UnsupportedEncodingException e) {

+			// TODO;

+			e.printStackTrace();

+		} catch (IOException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} 

+

+		EList<EObject> result = res.getContents();

+		

+

+		// TODO: added to resolve model element map in a CreateDeleteOp

+		// check whether we can generalize this

+		for (EObject o : result) {

+			EcoreUtil.resolveAll(o);

+		}

+

+		res.getContents().remove(result);

+		return result;

+	}

+}
\ No newline at end of file
diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/vcs/IVCSProvider.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/vcs/IVCSProvider.java
new file mode 100644
index 0000000..57a0d0c
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/vcs/IVCSProvider.java
@@ -0,0 +1,137 @@
+package org.eclipse.emf.emfstore.standalone.core.vcs;

+

+import java.io.IOException;

+import java.util.List;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IResource;

+import org.eclipse.core.runtime.IProgressMonitor;

+import org.eclipse.emf.emfstore.server.model.versioning.operations.AbstractOperation;

+

+/**

+ * Common interface for VCS connector implementations.

+ * @author emueller 

+ *

+ */

+public interface IVCSProvider {

+

+	IVCSProvider NONE = null;

+

+	/**

+	 * Adds an {@link IFile} to be versioned by the VCS.

+	 * @param file the file to be added to the VCS

+	 */

+	void addToVCS(IFile file);

+	

+	/**

+	 * Determines whether a file has been modified since the last base revision

+	 * @param file the file that needs to be checked

+	 * @return true, if the history file has been modified, false otherwise

+	 * @throws IOException if it could not be determined whether the history file 

+	 * 		has been modified

+	 */

+	boolean isModified(IFile file) throws IOException;

+	

+	/**

+	 * Returns the local version of the model resource file.

+	 * @param resource the model resource

+	 * @param monitor a {@link IProgressMonitor} instance

+	 * @return the content of the model resource file

+	 * @throws IOException in case the model resource file can not be read

+	 * @throws InterruptedException if the {@link IProgressMonitor} has been canceled

+	 * @throws RepositoryNotFoundException if the repository the given resource is 

+	 * 		considered to be in, can not be found

+	 */

+//	String getMyModelResourceFile(IResource resource, IProgressMonitor monitor) 

+//	throws IOException, InterruptedException, RepositoryNotFoundException;

+	

+	/**

+	 * Resolves a conflict state on the given file.

+	 * @param file the file being in a conflict state

+	 */

+	void resolveConflict(IFile file);

+	

+	/**

+	 * Returns the {@link IRepository} the given resource is managed with.

+	 * @param resource the resource, whose repository should be determined

+	 * @return the repository the given resource is in

+	 * @throws RepositoryNotFoundException if the repository can not be 

+	 * 	determined

+	 */

+//	IRepository<R> getRepository(IResource resource)

+//	throws RepositoryNotFoundException;

+

+	/**

+	 * Returns the local {@link IRevision} of the given resource.

+	 * @param resource the resource 

+	 * @param monitor a {@link IProgressMonitor} instance

+	 * @return the content of the given resource as it is locally available  

+	 * @throws IOException if the revision can not be determined

+	 * @throws InterruptedException if the {@link IProgressMonitor} has been canceled

+	 */

+	String getMyRevision(IResource resource, IProgressMonitor monitor)

+	throws IOException, InterruptedException;

+	

+	/**

+	 * Returns the head {@link IRevision} of the given resource.

+	 * @param resource the resource 

+	 * @param monitor a {@link IProgressMonitor} instance

+	 * @return the content of the given resource as it is locally available  

+	 * @throws IOException if the revision can not be determined

+	 * @throws InterruptedException if the {@link IProgressMonitor} has been canceled

+	 */

+	String getTheirRevision(IResource resource, IProgressMonitor monitor)

+	throws IOException, InterruptedException;

+	

+	/**

+	 * Returns the ancestor {@link IRevision} of the given resource.

+	 * @param myRevision the local revision

+	 * @param theirRevision the incoming revision

+	 * @param the local repository 

+	 * @param monitor a {@link IProgressMonitor} instance

+	 * @return the ancestor revision of <code>myRevision</code> and <code>theirRevision</code> 

+	 * @throws IOException if the revision can not be determined

+	 * @throws InterruptedException if the {@link IProgressMonitor} has been canceled

+	 */

+//	IRevision<T> getAncestorRevision(IRevision<T> myRevision, IRevision<T> theirRevision,

+//			IRepository<R> repository, IProgressMonitor monitor) 

+//	throws IOException, InterruptedException;

+

+	/**

+	 * Returns the ancestor {@link IRevision} of the given resource.

+	 * @param myRevision the local revision

+	 * @param theirRevision the incoming revision

+	 * @param the local repository 

+	 * @param monitor a {@link IProgressMonitor} instance

+	 * @return the ancestor revision of <code>myRevision</code> and <code>theirRevision</code> 

+	 * @throws IOException if the revision can not be determined

+	 * @throws InterruptedException if the {@link IProgressMonitor} has been canceled

+	 */

+//	IFileRevision getFileRevision(IRepository<R> repository,

+//			IRevision<T> revision, String objectId);

+	

+	/**

+	 * Returns the incoming operations.

+	 * @param resource the resource, which contains the operations

+	 * @param monitor a {@link IProgressMonitor} instance

+	 * @return the incoming operations

+	 */

+	List<AbstractOperation> getTheirOperations(IResource resource, IProgressMonitor monitor);

+	

+	/**

+	 * Returns the local operations.

+	 * @param resource the resource, which contains the operations

+	 * @param monitor a {@link IProgressMonitor} instance

+	 * @return the local operations

+	 */

+	List<AbstractOperation> getMyOperations(IResource resource, IProgressMonitor monitor);

+	

+	/**

+	 * Returns the content of given {@link IResource} as it has been in the given {@link IRevision}.

+	 * @param resource a resource

+	 * @param revision a revision

+	 * @param monitor an {@link IProgressMonitor} instance

+	 * @return the content of the given resource

+	 */

+//	String getFileContent(IResource resource, IRevision<T> revision, IProgressMonitor monitor);

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/vcs/VCSProviderRegistry.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/vcs/VCSProviderRegistry.java
new file mode 100644
index 0000000..86ed694
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/vcs/VCSProviderRegistry.java
@@ -0,0 +1,138 @@
+package org.eclipse.emf.emfstore.standalone.core.vcs;

+

+import java.io.IOException;

+import java.lang.reflect.InvocationTargetException;

+import java.util.Collection;

+import java.util.HashMap;

+import java.util.HashSet;

+import java.util.Map;

+

+import org.eclipse.core.resources.IContainer;

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IProject;

+import org.eclipse.core.resources.IResource;

+import org.eclipse.core.resources.IWorkspaceRoot;

+import org.eclipse.core.resources.ResourcesPlugin;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.emf.emfstore.common.model.util.ModelUtil;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.ArtifactRegistry;

+import org.eclipse.emf.emfstore.standalone.core.exceptions.VCSProviderNotFoundException;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+

+

+public class VCSProviderRegistry {

+	

+	private static VCSProviderRegistry instance;

+	private static Map<String, IVCSProvider> providers;

+	// TODO: currentProvider nach ArtifactMerger umziehen oder entsprechendes Attribute anlegen

+	private IVCSProvider currentProvider;

+	

+	private VCSProviderRegistry() {

+		providers = new HashMap<String, IVCSProvider>();

+	}

+	

+	public static VCSProviderRegistry getInstance() {

+		if (instance == null) {

+			instance = new VCSProviderRegistry();

+		}

+		

+		return instance;

+	}

+	

+	public IVCSProvider getActiveProvider() {

+		return currentProvider;

+	}

+	

+	public void setActiveProvider(IVCSProvider provider) {

+		currentProvider = provider;

+	}

+

+	public void initArtifacts() throws CoreException, InvocationTargetException, IOException {

+		

+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

+		

+		for (IProject project : root.getProjects()) {

+			for (IFile file: fetchAllFiles(project, new HashSet<IFile>())) {

+				

+				if (!FileUtil.isHistoryFile(file)) {

+					continue;

+				}

+

+				// we know that file now needs to be the history file 

+				IFile artifactFile = FileUtil.getArtifactFile(file);

+				

+				if (!ArtifactRegistry.getInstance().isRegistered(artifactFile) 

+						|| !ArtifactRegistry.getInstance().isFlagged(artifactFile)) {

+					ArtifactRegistry.getInstance().flag(artifactFile);

+//					VCS_PROVIDER.clearHistoryFile(FileUtil.getHistoryFile(artifactFile));

+				}

+			}

+		}

+	}

+	

+	/**

+	 * Fetches all instances of {@link IFile} contained in a {@link IContainer}.

+	 * 

+	 * @param container the container to fetch the files from

+	 * @param files a collection that will hold all instances of files, may be empty, but not null

+	 * @return the given <code>files</code> collection with all files contained within the given container

+	 * @throws CoreException if the given container either does not exist or is not accessible

+	 * @throws IllegalArgumentException if <code>files</code> is null

+	 */

+	private Collection<IFile> fetchAllFiles(IContainer container, Collection<IFile> files) 

+		throws CoreException, IllegalArgumentException {

+		

+		if (files == null) {

+			throw new IllegalArgumentException("files must not be null");

+		}

+		

+		for (IResource resource : container.members()) {

+			if (resource instanceof IContainer) {

+				IContainer c = (IContainer) resource;

+				files.addAll(fetchAllFiles(c, files));

+			} else if (resource instanceof IFile){

+				files.add((IFile) resource);

+			}

+		}

+		return files; 

+	}

+	

+	public void initVCSProviders() {

+//		if (vcsProviders == null) {

+			// collect singleton ID resolvers

+//			vcsProviders = new HashMap<String, IVCSProvider>();

+			IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(

+					"org.eclipse.emf.emfstore.standalone.core.vcs.provider");

+

+			for (IConfigurationElement extension : config) {

+				try {

+					IVCSProvider provider = (IVCSProvider) extension.createExecutableExtension("class");

+					String providerId =  extension.getAttribute("id");

+					providers.put(providerId, provider);					

+				} catch (CoreException e) {

+					ModelUtil.logWarning("Could not instantiate EMFStore Standalone VCS connector:"

+							+ e.getMessage());

+				}

+			}

+//		}

+	}

+

+	/**

+	 * Returns the team provider with the given ID.

+	 * @param teamProviderID the ID of a team provider, e.g. <code></code>

+	 * @return the team provider

+	 * @throws VCSProviderNotFoundException if the desired team provider is not registered

+	 */

+	public IVCSProvider getVCSProvider(String teamProviderID) throws VCSProviderNotFoundException {

+		IVCSProvider provider = providers.get(teamProviderID);

+		

+		if (provider == null) {

+			throw new VCSProviderNotFoundException();

+		}

+		

+		return provider;

+	}

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/IResourceOpenedObserver.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/IResourceOpenedObserver.java
new file mode 100644
index 0000000..153e957
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/IResourceOpenedObserver.java
@@ -0,0 +1,8 @@
+package org.eclipse.emf.emfstore.standalone.core.workspace;

+

+import org.eclipse.core.resources.IResource;

+

+public interface IResourceOpenedObserver {

+

+	void resourceOpened(IResource resource);

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/ResourceDeltaVisitor.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/ResourceDeltaVisitor.java
new file mode 100644
index 0000000..ac8c6fc
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/ResourceDeltaVisitor.java
@@ -0,0 +1,39 @@
+package org.eclipse.emf.emfstore.standalone.core.workspace;

+

+import java.util.HashSet;

+import java.util.Set;

+

+import org.eclipse.core.resources.IResource;

+import org.eclipse.core.resources.IResourceDelta;

+import org.eclipse.core.resources.IResourceDeltaVisitor;

+

+public class ResourceDeltaVisitor implements IResourceDeltaVisitor {

+	

+    private Set<IResource> addedResources;

+    

+    public ResourceDeltaVisitor() {

+    	addedResources = new HashSet<IResource>();

+    }

+

+	public boolean visit(IResourceDelta delta) {

+    	

+        switch (delta.getKind()) {

+        case IResourceDelta.ADDED :

+        	getAddedResources().add(delta.getResource());

+        	break;

+        case IResourceDelta.REMOVED :

+            // handle removed resource

+            break;

+        case IResourceDelta.CHANGED :

+            // handle changed resource

+            break;

+        }

+        

+        return true;

+    }

+

+	public Set<IResource> getAddedResources() {

+		return addedResources;

+	}

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/ResourceFactoryRegistry.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/ResourceFactoryRegistry.java
new file mode 100644
index 0000000..dfba3f6
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/ResourceFactoryRegistry.java
@@ -0,0 +1,207 @@
+/*******************************************************************************

+ * Copyright (c) 2008-2011 Chair for Applied Software Engineering, Technische Universitaet Muenchen. 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:

+ ******************************************************************************/

+package org.eclipse.emf.emfstore.standalone.core.workspace;

+

+import java.util.HashMap;

+import java.util.HashSet;

+import java.util.Map;

+import java.util.Set;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IResource;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IConfigurationElement;

+import org.eclipse.core.runtime.Platform;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.ecore.resource.Resource;

+import org.eclipse.emf.ecore.resource.Resource.Factory;

+import org.eclipse.emf.ecore.xmi.XMIResource;

+import org.eclipse.emf.emfstore.common.model.util.ModelUtil;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.Artifact;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.ArtifactRegistry;

+import org.eclipse.emf.emfstore.standalone.core.exceptions.NoActiveVCSProviderException;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+import org.eclipse.emf.emfstore.standalone.core.vcs.IVCSProvider;

+import org.eclipse.emf.emfstore.standalone.core.vcs.VCSProviderRegistry;

+

+/**

+ *

+ * @author emueller

+ */

+public class ResourceFactoryRegistry implements Resource.Factory, Resource.Factory.Registry {

+

+	/**

+	 * The initial resource factory is kept if a file is not EMF Store managed, so the initial resource factory has to

+	 * handle the file.

+	 */

+	private static Map<String, Object> initialResourceFactory = new HashMap<String, Object>();

+	public static URI CURRENT_URI;

+	

+	/**

+	 * The Resource.Factory.Registry will be manipulated, so that the EMFStoreResourceFactoryWrapper will be responsible

+	 * for Ecore files.

+	 */

+	public static void replaceSupportedFactories() {

+		Map<String, Object> extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();

+		

+		// replace factories for all managed file extensions

+		for (String fileExtension : FileUtil.getManagedFileExtensions()) {

+			Object factory = extensionToFactoryMap.get(fileExtension);

+			for (String key : extensionToFactoryMap.keySet()) {

+				Object currentFactory = extensionToFactoryMap.get(key);

+				if (factory == currentFactory) {

+					// remember initial ResourceFactory

+					initialResourceFactory.put(key, currentFactory);

+					// replace factory in registry with an EMF Store adapted one.

+					extensionToFactoryMap.put(key, new ResourceFactoryRegistry());

+				}

+			}

+		}

+	}

+	

+	private Set<IResourceOpenedObserver> resourceOpenedObservers;

+

+	/**

+	 * {@inheritDoc}

+	 * 

+	 * @see org.eclipse.emf.ecore.resource.Resource.Factory#createResource(org.eclipse.emf.common.util.URI)

+	 */

+	public Resource createResource(final URI uri) {

+	

+		// use initial resource factory

+		Object object = initialResourceFactory.get(uri.fileExtension());

+		Factory factory = null;

+		if (object instanceof Resource.Factory.Registry) {

+			Resource.Factory.Registry registry = (Resource.Factory.Registry) object;

+			factory = registry.getFactory(uri);

+

+		} else if (object instanceof Resource.Factory.Descriptor) {

+			Resource.Factory.Descriptor descriptor = (Resource.Factory.Descriptor) object;

+			factory = descriptor.createFactory();

+		}

+

+		XMIResource xmiResource = (XMIResource) factory.createResource(uri);

+		IFile artifactFile = FileUtil.getFile(xmiResource.getURI());

+		

+		IVCSProvider activeProvider = VCSProviderRegistry.getInstance().getActiveProvider();

+		

+		if (activeProvider == IVCSProvider.NONE) {

+			return xmiResource;

+		}

+		

+		try {

+			// file has been marked to be put under recorder control

+			if (ArtifactRegistry.getInstance().isFlagged(uri)) {

+				//			IFile historyFile = FileUtil.getHistoryFile(artifactFile);

+				Artifact artifact = new Artifact(xmiResource, FileUtil.getHistoryURI(xmiResource.getURI()));

+				ArtifactRegistry.getInstance().register(artifact);

+				artifact.initialize();

+				VCSProviderRegistry.getInstance().getActiveProvider().addToVCS(FileUtil.getHistoryFile(artifactFile));						

+				ArtifactRegistry.getInstance().unflag(uri);

+

+			} else if (ArtifactRegistry.getInstance().isRegistered(uri)) {

+				Artifact versionedArtifact = ArtifactRegistry.getInstance().getArtifact(uri);

+				if (!versionedArtifact.isInitialized()) {

+					versionedArtifact.initialize(xmiResource);

+				}			

+			}

+		} catch (NoActiveVCSProviderException e) {

+			// should not happen because of guard above

+		}

+		

+		CURRENT_URI = uri;

+		

+		if (resourceOpenedObservers == null) {

+			initResourceOpenedObservers();

+		}

+		

+		notifyResourceOpenedObservers(artifactFile);

+		

+		

+

+		return xmiResource;

+	}

+	

+	private void notifyResourceOpenedObservers(IResource resource) {

+		for (IResourceOpenedObserver observer : resourceOpenedObservers) {

+			observer.resourceOpened(resource);

+		}

+	}

+

+	private void initResourceOpenedObservers() {

+		resourceOpenedObservers = new HashSet<IResourceOpenedObserver>();

+		IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(

+				"org.eclipse.emf.emfstore.standalone.core.workspace.resourceOpened");

+

+		for (IConfigurationElement extension : config) {

+			try {

+				IResourceOpenedObserver observer = (IResourceOpenedObserver) extension.createExecutableExtension("class");

+				resourceOpenedObservers.add(observer);

+			} catch (CoreException e) {

+				ModelUtil.logWarning("Could not instantiate EMFStore Standalone ResourceOpenedObserver:"

+						+ e.getMessage());

+			}

+		}

+		

+		if (resourceOpenedObservers.size() == 0) {

+			throw new IllegalStateException("No ResourceOpenedObserver registered.  Artifacts will cause memory leaks. Quitting.");

+		}

+	}

+

+	/**

+	 * {@inheritDoc}

+	 * 

+	 * @see org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getFactory(org.eclipse.emf.common.util.URI)

+	 */

+	public Factory getFactory(URI uri) {

+		return this;

+	}

+

+	/**

+	 * {@inheritDoc}

+	 * 

+	 * @see org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getFactory(org.eclipse.emf.common.util.URI,

+	 *      java.lang.String)

+	 */

+	public Factory getFactory(URI uri, String contentType) {

+		return this;

+	}

+

+	/**

+	 * {@inheritDoc}

+	 * 

+	 * @see org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getProtocolToFactoryMap()

+	 */

+	public Map<String, Object> getProtocolToFactoryMap() {

+		// TODO Auto-generated method stub

+		return null;

+	}

+

+	/**

+	 * {@inheritDoc}

+	 * 

+	 * @see org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getExtensionToFactoryMap()

+	 */

+	public Map<String, Object> getExtensionToFactoryMap() {

+		// TODO Auto-generated method stub

+		return null;

+	}

+

+	/**

+	 * {@inheritDoc}

+	 * 

+	 * @see org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getContentTypeToFactoryMap()

+	 */

+	public Map<String, Object> getContentTypeToFactoryMap() {

+		// TODO Auto-generated method stub

+		return null;

+	}

+	

+	public static Object getDefaultFactory(String extension) {

+		return initialResourceFactory.get(extension);

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/WorkspaceObserver.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/WorkspaceObserver.java
new file mode 100644
index 0000000..a340025
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.core/src/org/eclipse/emf/emfstore/standalone/core/workspace/WorkspaceObserver.java
@@ -0,0 +1,46 @@
+package org.eclipse.emf.emfstore.standalone.core.workspace;

+

+import java.util.Set;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IResource;

+import org.eclipse.core.resources.IResourceChangeEvent;

+import org.eclipse.core.resources.IResourceChangeListener;

+import org.eclipse.core.resources.IResourceDelta;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.emf.emfstore.common.model.util.ModelUtil;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.ArtifactRegistry;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+

+public class WorkspaceObserver implements IResourceChangeListener {

+

+	public void resourceChanged(IResourceChangeEvent event) {

+		

+		IResourceDelta delta = event.getDelta();

+		ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();

+		

+		try {

+			delta.accept(visitor);

+		} catch (CoreException e) {

+			ModelUtil.logException(e);

+

+		}

+		

+		Set<IResource> addedResources = visitor.getAddedResources();

+		

+		for (IResource resource : addedResources) {

+			if (!(resource instanceof IFile) || !FileUtil.isHistoryFile((IFile) resource)) {

+				continue;

+			}

+

+			IFile historyFile = (IFile) resource;

+			IFile artifactFile = FileUtil.getArtifactFile(historyFile);

+			

+			// new model resource together with its history resource must

+			// have been added

+			if (!ArtifactRegistry.getInstance().isRegistered(artifactFile)) {

+				ArtifactRegistry.getInstance().flag(artifactFile);

+			}

+		}

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.checkstyle b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.checkstyle
new file mode 100644
index 0000000..2f2667a
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.checkstyle
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+  <fileset name="all" enabled="true" check-config-name="emfstoreStyle" local="false">
+    <file-match-pattern match-pattern="." include-pattern="true"/>
+  </fileset>
+</fileset-config>
diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.classpath b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.classpath
new file mode 100644
index 0000000..8a8f166
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.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/JavaSE-1.6"/>

+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>

+	<classpathentry kind="src" path="src"/>

+	<classpathentry kind="output" path="bin"/>

+</classpath>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.project b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.project
new file mode 100644
index 0000000..1bea40d
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<projectDescription>

+	<name>org.eclipse.emf.emfstore.standalone.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>

+		<buildCommand>

+			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+	</buildSpec>

+	<natures>

+		<nature>org.eclipse.pde.PluginNature</nature>

+		<nature>org.eclipse.jdt.core.javanature</nature>

+		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>

+	</natures>

+</projectDescription>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.settings/org.eclipse.jdt.core.prefs b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..73f18ff
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue Aug 16 17:12:30 CEST 2011

+eclipse.preferences.version=1

+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled

+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6

+org.eclipse.jdt.core.compiler.compliance=1.6

+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error

+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error

+org.eclipse.jdt.core.compiler.source=1.6

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/META-INF/MANIFEST.MF b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..36548ff
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Git
+Bundle-SymbolicName: org.eclipse.emf.emfstore.standalone.git;singleton:=true
+Bundle-Version: 0.9.3.M930
+Bundle-Activator: org.eclipse.emf.emfstore.standalone.git.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.egit;bundle-version="1.0.0",
+ org.eclipse.egit.core;bundle-version="1.0.0",
+ org.junit4;bundle-version="4.8.1",
+ org.eclipse.jgit;bundle-version="1.0.0",
+ org.eclipse.core.resources;bundle-version="3.6.1",
+ org.eclipse.emf.emfstore.standalone.core,
+ org.eclipse.core.filesystem;bundle-version="1.3.1",
+ org.eclipse.compare;bundle-version="3.5.101",
+ org.eclipse.emf.ecore;bundle-version="2.6.1",
+ org.eclipse.emf.ecore.xmi;bundle-version="2.5.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/build.properties b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/build.properties
new file mode 100644
index 0000000..6f20375
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/build.properties
@@ -0,0 +1,5 @@
+source.. = src/

+output.. = bin/

+bin.includes = META-INF/,\

+               .,\

+               plugin.xml

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/plugin.xml b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/plugin.xml
new file mode 100644
index 0000000..7002744
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<?eclipse version="3.4"?>

+<plugin>

+   <extension

+         name="gitProvider"

+         point="org.eclipse.emf.emfstore.standalone.core.vcs.provider">

+      <provider

+            class="org.eclipse.emf.emfstore.standalone.git.GitVCSProvider"

+            id="org.eclipse.egit.core.GitProvider">

+      </provider>

+   </extension>

+

+</plugin>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/src/org/eclipse/emf/emfstore/standalone/git/Activator.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/src/org/eclipse/emf/emfstore/standalone/git/Activator.java
new file mode 100644
index 0000000..0ac3ee2
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/src/org/eclipse/emf/emfstore/standalone/git/Activator.java
@@ -0,0 +1,50 @@
+package org.eclipse.emf.emfstore.standalone.git;

+

+import org.eclipse.ui.plugin.AbstractUIPlugin;

+import org.osgi.framework.BundleContext;

+

+/**

+ * The activator class controls the plug-in life cycle

+ */

+public class Activator extends AbstractUIPlugin {

+

+	// The plug-in ID

+	public static final String PLUGIN_ID = "org.eclipse.emf.emfstore.standalone.git"; //$NON-NLS-1$

+

+	// The shared instance

+	private static Activator plugin;

+	

+	/**

+	 * The constructor

+	 */

+	public Activator() {

+	}

+

+	/*

+	 * (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 Activator getDefault() {

+		return plugin;

+	}

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/src/org/eclipse/emf/emfstore/standalone/git/GitVCSProvider.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/src/org/eclipse/emf/emfstore/standalone/git/GitVCSProvider.java
new file mode 100644
index 0000000..2a77be8
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.git/src/org/eclipse/emf/emfstore/standalone/git/GitVCSProvider.java
@@ -0,0 +1,447 @@
+package org.eclipse.emf.emfstore.standalone.git;

+

+import java.io.File;

+import java.io.IOException;

+import java.util.ArrayList;

+import java.util.Collections;

+import java.util.List;

+

+import org.eclipse.core.resources.IFile;

+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.IPath;

+import org.eclipse.core.runtime.IProgressMonitor;

+import org.eclipse.core.runtime.NullProgressMonitor;

+import org.eclipse.core.runtime.Path;

+import org.eclipse.egit.core.internal.storage.GitFileRevision;

+import org.eclipse.egit.core.op.AddToIndexOperation;

+import org.eclipse.egit.core.project.RepositoryMapping;

+import org.eclipse.emf.emfstore.standalone.core.exceptions.RepositoryNotFoundException;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+import org.eclipse.emf.emfstore.standalone.core.vcs.AbstractVCSProvider;

+import org.eclipse.jgit.api.AddCommand;

+import org.eclipse.jgit.api.RebaseCommand;

+import org.eclipse.jgit.api.errors.NoFilepatternException;

+import org.eclipse.jgit.dircache.DirCache;

+import org.eclipse.jgit.dircache.DirCacheEntry;

+import org.eclipse.jgit.errors.CorruptObjectException;

+import org.eclipse.jgit.errors.IncorrectObjectTypeException;

+import org.eclipse.jgit.errors.MissingObjectException;

+import org.eclipse.jgit.errors.NoWorkTreeException;

+import org.eclipse.jgit.lib.Constants;

+import org.eclipse.jgit.lib.IndexDiff;

+import org.eclipse.jgit.lib.ObjectId;

+import org.eclipse.jgit.lib.Repository;

+import org.eclipse.jgit.lib.RepositoryState;

+import org.eclipse.jgit.revwalk.RevCommit;

+import org.eclipse.jgit.revwalk.RevWalk;

+import org.eclipse.jgit.treewalk.FileTreeIterator;

+import org.eclipse.jgit.treewalk.TreeWalk;

+import org.eclipse.jgit.treewalk.WorkingTreeIterator;

+import org.eclipse.jgit.treewalk.filter.AndTreeFilter;

+import org.eclipse.jgit.treewalk.filter.NotIgnoredFilter;

+import org.eclipse.jgit.treewalk.filter.OrTreeFilter;

+import org.eclipse.jgit.treewalk.filter.PathFilter;

+import org.eclipse.jgit.treewalk.filter.TreeFilter;

+import org.eclipse.jgit.util.FS;

+import org.eclipse.jgit.util.IO;

+import org.eclipse.jgit.util.RawParseUtils;

+import org.eclipse.osgi.util.NLS;

+import org.eclipse.team.core.history.IFileRevision;

+

+public class GitVCSProvider extends AbstractVCSProvider {

+

+	/**

+	 * {@inheritDoc}

+	 */

+	@Override

+	public boolean isModified(IFile historyFile) throws IOException {

+	

+		RepositoryMapping mapping = RepositoryMapping.getMapping(historyFile.getProject());

+		Repository repo = mapping.getRepository();

+

+		if (repo != null && repo != mapping.getRepository()) {

+					new IllegalStateException("No unique repository");

+		}

+

+		TreeWalk walk = new TreeWalk(repo);

+		walk.addTree(new FileTreeIterator(repo));

+		WorkingTreeIterator workingTreeIterator = walk.getTree(0,

+				WorkingTreeIterator.class);

+

+		IndexDiff diff = new IndexDiff(repo, "HEAD", workingTreeIterator);

+		diff.diff();

+

+		boolean wasCleared = false;

+		if (historyFile.exists()) {

+			// TODO: is there a better way for the containment check?

+			if (diff.getModified().contains(historyFile.getFullPath().toString().substring(1))) {

+				wasCleared = true;

+				// if history file has not been modified, its content may get cleared

+				// in any other cases, operations have been added to the history file

+				// and the modify check will evaluate to true

+//				URI historyUri = FileUtil.getUri(historyFile);

+//				Object defaultFactory = ResourceFactoryRegistry.getDefaultFactory("ecore");

+//				XMIResource historyResource = (XMIResource) ((Resource.Factory.Descriptor) defaultFactory).createFactory().createResource(historyUri); 

+//				historyResource.getContents().clear();

+//				historyResource.save(null);

+//				wasCleared  = true;

+			}

+		}

+

+		return wasCleared;

+	}

+ 

+	/**

+	 * {@inheritDoc}

+	 */

+	@Override

+	public void resolveConflict(IFile file) {

+		AddCommand addCmd;

+		try {

+			addCmd = new AddCommand(getRepository(file.getProject()));

+			addCmd.addFilepattern(file.getFullPath().toString().substring(1));

+			addCmd.addFilepattern(FileUtil.getFile(FileUtil.getUri(file)).getFullPath().toString().substring(1));

+			addCmd.call();

+		} catch (RepositoryNotFoundException e1) {

+			// TODO Auto-generated catch block

+			e1.printStackTrace();

+		} catch (NoFilepatternException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+	}

+	

+	/**

+	 * {@inheritDoc}

+	 */

+	public String getMyRevision(IResource resource, IProgressMonitor monitor) 

+	throws IOException, InterruptedException {

+		String target;

+		Repository repository = null;

+		try {

+			repository = getRepository(resource.getProject());

+		} catch (RepositoryNotFoundException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+ 

+		if (repository.getRepositoryState().equals(RepositoryState.MERGING)) {

+			target = Constants.MERGE_HEAD;

+		} else if (repository.getRepositoryState().equals(RepositoryState.CHERRY_PICKING)) {

+			target = Constants.CHERRY_PICK_HEAD;

+		} else if (repository.getRepositoryState().equals(

+				RepositoryState.REBASING_INTERACTIVE)) {

+			target = readFile(repository.getDirectory(),

+					RebaseCommand.REBASE_MERGE + File.separatorChar

+							+ RebaseCommand.STOPPED_SHA);

+		} else {

+			target = Constants.ORIG_HEAD;

+		}

+		

+		RevCommit commit = getCommit(resource, target, monitor);

+		return getFileContent(resource, commit, monitor);

+	}

+	

+	/**

+	 * {@inheritDoc}

+	 */

+	public String getTheirRevision(IResource resource, IProgressMonitor monitor) 

+	throws IOException, InterruptedException {

+		Repository repository = null;

+		try {

+			repository = getRepository(resource.getProject());

+		} catch (RepositoryNotFoundException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+		ObjectId head = repository.resolve(Constants.HEAD);

+		if (head == null) {

+			throw new IOException("UIText.ValidationUtils_CanNotResolveRefMessage, Constants.HEAD");

+		}

+

+		RevCommit commit = getCommit(resource, Constants.HEAD, monitor);

+		return getFileContent(resource, commit, monitor);

+	}

+	

+	private RevCommit getCommit(IResource resource, String target, IProgressMonitor monitor) 

+	throws InterruptedException, IOException {

+		// make sure all resources belong to the same repository

+		RevWalk revWalk = null;

+

+		monitor.beginTask("Checking resources", IProgressMonitor.UNKNOWN); 

+		List<String> filterPaths = new ArrayList<String>();

+		// TODO: duplicate code -> activator.java

+		Repository repository = null;

+		RepositoryMapping map = RepositoryMapping.getMapping(resource.getProject());

+

+		if (repository != null && repository != map.getRepository()) {

+			throw new IllegalStateException("No unique repository");

+		}

+

+		filterPaths.add(map.getRepoRelativePath(resource));

+		repository = map.getRepository();

+

+		if (repository == null) {

+			throw new IllegalStateException("No unique repository");

+		}

+

+		if (monitor.isCanceled()) {

+			throw new InterruptedException();

+		}

+

+		revWalk = new RevWalk(repository);

+		ObjectId objectId = repository.resolve(target);

+		

+		if (objectId == null) {

+			throw new IOException(NLS.bind(

+					String.format("Can not resolve given target {0}", target),

+					target));

+		}

+		

+		RevCommit commit = revWalk.parseCommit(objectId);

+		return commit; 

+	}

+		

+	public String getFileContent(IResource resource,

+			RevCommit commit, 

+			IProgressMonitor monitor) {

+		

+		monitor.setTaskName("TODO");//UIText.GitMergeEditorInput_CalculatingDiffTaskName);

+		RepositoryMapping map = RepositoryMapping.getMapping(resource.getProject());

+		

+		List<String> filterPaths = new ArrayList<String>();

+		filterPaths.add(map.getRepoRelativePath(resource));

+		Repository repository = map.getRepository();

+		TreeWalk tw = new TreeWalk(repository);

+	

+		String s = null;

+		try {

+			int fileTreeIndex = tw.addTree(new FileTreeIterator(repository));

+			// skip ignored resources

+			NotIgnoredFilter notIgnoredFilter = new NotIgnoredFilter(

+					fileTreeIndex);

+

+			// filter by selected resources

+			if (filterPaths.size() > 1) {

+				List<TreeFilter> suffixFilters = new ArrayList<TreeFilter>();

+				for (String filterPath : filterPaths)

+					suffixFilters.add(PathFilter.create(filterPath));

+				TreeFilter otf = OrTreeFilter.create(suffixFilters);

+				tw.setFilter(AndTreeFilter.create(otf, notIgnoredFilter));

+			} else if (filterPaths.size() > 0)

+				tw.setFilter(AndTreeFilter.create(PathFilter.create(filterPaths

+						.get(0)), notIgnoredFilter));

+			else

+				tw.setFilter(notIgnoredFilter);

+

+			tw.setRecursive(true);

+		

+			while (tw.next()) {

+				if (monitor.isCanceled())

+					throw new InterruptedException();

+				String gitPath = tw.getPathString();

+				monitor.setTaskName(gitPath);

+

+				FileTreeIterator fit = tw.getTree(fileTreeIndex,

+						FileTreeIterator.class);

+				if (fit == null)

+					continue;

+

+				// if this is neither conflicting nor changed, we skip it

+				//				if (!conflicting && !modified)

+				//					continue;

+

+				IFileRevision fileRevision;

+				// TODO: conflicting muss sich auf ecore beziehne

+				// TODO: parameter checken

+				fileRevision = getFileRevision(repository, commit, gitPath);

+

+				try {

+					if (fileRevision != null) {

+						IStorage storage = fileRevision.getStorage(null);

+						s = FileUtil.slurpAndClose(storage.getContents());

+					} else {

+						IPath locationPath = new Path(fit.getEntryFile().getPath());

+						final IFile file = ResourcesPlugin.getWorkspace().getRoot()

+						.getFileForLocation(locationPath);

+						if (file == null) {

+							// TODO in the future, we should be able to show a version

+							// for a non-workspace file as well

+							continue;

+						}

+						fileRevision = GitFileRevision.inCommit(repository, commit,

+								gitPath, null);

+						IStorage storage;

+

+						storage = fileRevision.getStorage(null);

+						s = FileUtil.slurpAndClose(storage.getContents());

+					}

+				} catch (CoreException e) {

+					// TODO Auto-generated catch block

+					e.printStackTrace();

+				}

+

+				tw.release();

+			}

+		} catch (MissingObjectException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (IncorrectObjectTypeException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (CorruptObjectException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (IOException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (InterruptedException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (NoWorkTreeException e1) {

+			// TODO Auto-generated catch block

+			e1.printStackTrace();

+		}

+

+		return s;

+	}

+

+	private String readFile(File directory, String fileName) throws IOException {

+		byte[] content = IO.readFully(new File(directory, fileName));

+		// strip off the last LF

+		int end = content.length;

+		while (0 < end && content[end - 1] == '\n')

+			end--;

+		return RawParseUtils.decode(content, 0, end);

+	}

+

+	public Repository getRepository(IResource resource) throws RepositoryNotFoundException {

+		Repository repository = null;

+		List<String> filterPaths = new ArrayList<String>();

+		RepositoryMapping map = RepositoryMapping.getMapping(resource.getProject());

+		repository = map.getRepository();

+

+		if (repository != null && repository != map.getRepository()) {

+			throw new RepositoryNotFoundException(

+					new IllegalStateException("No unique repository"));

+		}

+

+		filterPaths.add(map.getRepoRelativePath(resource));

+		repository = map.getRepository();

+

+		if (repository == null) {

+			throw new RepositoryNotFoundException(

+					new IllegalStateException("No unique repository"));

+		}

+

+		return repository;

+	}

+

+//	public IRevision<RevCommit> getAncestorRevision(

+//			IRevision<RevCommit> rightRevision,

+//			IRevision<RevCommit> headRevision, IRepository<Repository> repository,

+//			IProgressMonitor monitor)

+//			throws IOException, InterruptedException {

+//		

+//		final String fullBranch;

+//		

+//		RevWalk revWalk = new RevWalk(repository.getRepository());

+//		fullBranch = repository.getRepository().getFullBranch();

+//

+//		// try to obtain the common ancestor

+//		List<RevCommit> startPoints = new ArrayList<RevCommit>();

+//		revWalk.setRevFilter(RevFilter.MERGE_BASE);

+//		startPoints.add(rightRevision.getRevision());

+//		startPoints.add(headRevision.getRevision());

+//		RevCommit ancestorCommit;

+//		

+//		try {

+//			revWalk.markStart(startPoints);

+//			ancestorCommit = revWalk.next();

+//		} catch (Exception e) {

+//			ancestorCommit = null;

+//		}

+//

+//		if (monitor.isCanceled()) {

+//			throw new InterruptedException();

+//		}

+//		

+//		return new GitRevision(ancestorCommit);

+//	}

+

+	public IFileRevision getFileRevision(Repository repository,

+			RevCommit revision, String objectId) {

+//		RevCommit rev = revision.getRevision();

+//		IRepository<Repository> repo = repository.getRepository();

+		TreeWalk w;

+		try {

+			w = TreeWalk.forPath(repository, objectId, revision.getTree());

+			if (w != null) {

+				final IFileRevision fileRevision = GitFileRevision.inCommit(repository,

+						revision, objectId, null);

+				return fileRevision;

+			}

+		} catch (MissingObjectException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (IncorrectObjectTypeException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (CorruptObjectException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (IOException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+		// check if file is contained in commit

+		

+		return null;

+	}

+	

+	/**

+	 * {@inheritDoc}

+	 */

+	public void addToVCS(IFile file) {

+		RepositoryMapping mapping = RepositoryMapping.getMapping(file);

+

+		if (mapping != null) {

+			Repository repository = mapping.getRepository();

+			try {

+				DirCache cache = new DirCache(repository.getIndexFile(), FS.DETECTED);

+				cache.read();

+				for (int i = 0; i < cache.getEntryCount(); i++) {

+					DirCacheEntry entry = cache.getEntry(i);

+					if (entry.getPathString().equals(file.getFullPath().makeRelative().toString())) {

+						// selected file is either added or staged 

+						// thus we may add the version file to the staging area

+//						String historyFileName = FileUtil.getHistoryFilename(file); 

+						

+//						IResource historyFile = file.getProject().findMember(historyFileName);

+						

+						if (file != null) {

+							// add to index -> extract

+							AddToIndexOperation addToIndexOp = new AddToIndexOperation(Collections.singleton(file));

+							addToIndexOp.execute(new NullProgressMonitor());

+						}

+					}

+				}

+			} catch (NoWorkTreeException e) {

+				// TODO Auto-generated catch block

+				e.printStackTrace();

+			} catch (CorruptObjectException e) {

+				// TODO Auto-generated catch block

+				e.printStackTrace();

+			} catch (IOException e) {

+				// TODO Auto-generated catch block

+				e.printStackTrace();

+			} catch (CoreException e) {

+				// TODO Auto-generated catch block

+				e.printStackTrace();

+			}

+		}

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.checkstyle b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.checkstyle
new file mode 100644
index 0000000..2f2667a
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.checkstyle
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+  <fileset name="all" enabled="true" check-config-name="emfstoreStyle" local="false">
+    <file-match-pattern match-pattern="." include-pattern="true"/>
+  </fileset>
+</fileset-config>
diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.classpath b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.classpath
new file mode 100644
index 0000000..8a8f166
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.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/JavaSE-1.6"/>

+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>

+	<classpathentry kind="src" path="src"/>

+	<classpathentry kind="output" path="bin"/>

+</classpath>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.project b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.project
new file mode 100644
index 0000000..74c1938
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<projectDescription>

+	<name>org.eclipse.emf.emfstore.standalone.ui</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>

+		<buildCommand>

+			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+	</buildSpec>

+	<natures>

+		<nature>org.eclipse.pde.PluginNature</nature>

+		<nature>org.eclipse.jdt.core.javanature</nature>

+		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>

+	</natures>

+</projectDescription>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.settings/org.eclipse.jdt.core.prefs b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..2a5026b
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Aug 17 17:11:16 CEST 2011

+eclipse.preferences.version=1

+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled

+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6

+org.eclipse.jdt.core.compiler.compliance=1.6

+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error

+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error

+org.eclipse.jdt.core.compiler.source=1.6

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/META-INF/MANIFEST.MF b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..8c08879
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ui
+Bundle-SymbolicName: org.eclipse.emf.emfstore.standalone.ui;singleton:=true
+Bundle-Version: 0.9.3.M930
+Bundle-Activator: org.eclipse.emf.emfstore.standalone.ui.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources;bundle-version="3.6.1",
+ org.eclipse.emf.ecore.xmi;bundle-version="2.5.0",
+ org.eclipse.emf.emfstore.standalone.core,
+ org.eclipse.emf.emfstore.client.ui;bundle-version="0.9.3"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/build.properties b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/build.properties
new file mode 100644
index 0000000..6f20375
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/build.properties
@@ -0,0 +1,5 @@
+source.. = src/

+output.. = bin/

+bin.includes = META-INF/,\

+               .,\

+               plugin.xml

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/plugin.xml b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/plugin.xml
new file mode 100644
index 0000000..4842136
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/plugin.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<?eclipse version="3.4"?>

+<plugin>

+   <extension

+         point="org.eclipse.ui.popupMenus">

+      <viewerContribution

+            id="org.eclipse.emf.emfstore.teamprovider.recording.ui.navigator"

+            targetID="org.eclipse.ui.views.ResourceNavigator">

+         <action

+               class="org.eclipse.emf.emfstore.standalone.ui.handlers.EnableMergingHandler"

+               enablesFor="1"

+               id="org.eclipse.emf.emfstore.teamprovider.recording.ui.enable"

+               label="Enable EMFStore Merging"

+               menubarPath="org.eclipse.emf.emfstore.teamprovider.recording.ui.menu/group"

+               tooltip="Enables EMFStore merging facility for model files">

+         </action>

+         <action

+               class="org.eclipse.emf.emfstore.standalone.ui.handlers.DisableMergingHandler"

+               enablesFor="1"

+               id="org.eclipse.emf.emfstore.teamprovider.recording.ui.disable"

+               label="Disable EMFStore Merging"

+               menubarPath="org.eclipse.emf.emfstore.teamprovider.recording.ui.menu/group"

+               tooltip="Disables EMFStore merging facility for model files">

+         </action>

+         <action

+               class="org.eclipse.emf.emfstore.standalone.ui.handlers.ExecuteMergerHandler"

+               id="org.eclipse.emf.emfstore.teamprovider.recording.ui.merge"

+               label="Merge"

+               menubarPath="org.eclipse.emf.emfstore.teamprovider.recording.ui.menu/group"

+               tooltip="Executes merging">

+         </action>

+         <menu

+               id="org.eclipse.emf.emfstore.teamprovider.recording.ui.menu"

+               label="emfstore merging">

+            <groupMarker

+                  name="org.eclipse.emf.emfstore.teamprovider.recording.ui.menu/group">

+            </groupMarker>

+         </menu>

+      </viewerContribution>

+   </extension>

+	<extension

+         point="org.eclipse.ui.decorators">

+      <decorator

+            adaptable="false"

+            class="org.eclipse.emf.emfstore.standalone.ui.MergeDecorator"

+            id="org.eclipse.emf.emfstore.teamprovider.recording.decorator"

+            label="Recorder Label"

+            lightweight="true"

+            location="UNDERLAY"

+            state="true">

+      </decorator>

+   </extension>

+   <extension

+         point="org.eclipse.ui.startup">

+      <startup

+            class="org.eclipse.emf.emfstore.standalone.ui.SynchronizeControl"></startup>

+   </extension>

+   <extension

+         point="org.eclipse.emf.emfstore.standalone.core.workspace.resourceOpened">

+      <observer

+            class="org.eclipse.emf.emfstore.standalone.ui.ResourceOpenedObserver">

+      </observer>

+   </extension>

+</plugin>

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/Activator.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/Activator.java
new file mode 100644
index 0000000..fae5ac4
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/Activator.java
@@ -0,0 +1,50 @@
+package org.eclipse.emf.emfstore.standalone.ui;

+

+import org.eclipse.ui.plugin.AbstractUIPlugin;

+import org.osgi.framework.BundleContext;

+

+/**

+ * The activator class controls the plug-in life cycle

+ */

+public class Activator extends AbstractUIPlugin {

+

+	// The plug-in ID

+	public static final String PLUGIN_ID = "org.eclipse.emf.emfstore.teamprovider.recording.ui"; //$NON-NLS-1$

+

+	// The shared instance

+	private static Activator plugin;

+	

+	/**

+	 * The constructor

+	 */

+	public Activator() {

+	}

+

+	/*

+	 * (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 Activator getDefault() {

+		return plugin;

+	}

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/ArtifactDisposeListener.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/ArtifactDisposeListener.java
new file mode 100644
index 0000000..5b0049f
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/ArtifactDisposeListener.java
@@ -0,0 +1,73 @@
+package org.eclipse.emf.emfstore.standalone.ui;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.Artifact;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.ArtifactRegistry;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+import org.eclipse.ui.IPartListener2;

+import org.eclipse.ui.IWorkbenchPartReference;

+

+public class ArtifactDisposeListener implements IPartListener2 {

+	

+	// TODO: read ID from ecore editor plugin

+	public static final String ECORE_EDITOR_ID = "org.eclipse.emf.ecore.presentation.EcoreEditorID";

+	private String fileName;

+	private final IFile file;

+

+	public ArtifactDisposeListener(IFile file) {

+		this.file = file;

+		fileName = file.getName();

+	}

+

+	public void partActivated(IWorkbenchPartReference partRef) {

+		// TODO Auto-generated method stub

+		

+	}

+

+	public void partBroughtToTop(IWorkbenchPartReference partRef) {

+		// TODO Auto-generated method stub

+		

+	}

+

+	public void partClosed(IWorkbenchPartReference partRef) {

+		if (partRef.getId().equals(ECORE_EDITOR_ID)) {

+			String partName = partRef.getPartName();

+			if (partName.equals(fileName)) {

+				URI uri = FileUtil.getUri(file);

+				Artifact mergerArtifact = ArtifactRegistry.getInstance().getArtifact(uri);

+				// may be null in case file is not under merger control

+				if (mergerArtifact != null) {

+					mergerArtifact.dispose();

+				}

+			}

+		}

+		partRef.getPage().removePartListener(this);

+	}

+

+	public void partDeactivated(IWorkbenchPartReference partRef) {

+		// TODO Auto-generated method stub

+		

+	}

+

+	public void partOpened(IWorkbenchPartReference partRef) {

+		// TODO Auto-generated method stub

+		

+	}

+

+	public void partHidden(IWorkbenchPartReference partRef) {

+		// TODO Auto-generated method stub

+		

+	}

+

+	public void partVisible(IWorkbenchPartReference partRef) {

+		// TODO Auto-generated method stub

+		

+	}

+

+	public void partInputChanged(IWorkbenchPartReference partRef) {

+		// TODO Auto-generated method stub

+		

+	}

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/ArtifactMerger.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/ArtifactMerger.java
new file mode 100644
index 0000000..139f7b6
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/ArtifactMerger.java
@@ -0,0 +1,325 @@
+package org.eclipse.emf.emfstore.standalone.ui;

+

+import java.io.IOException;

+import java.io.StringReader;

+import java.io.UnsupportedEncodingException;

+import java.util.ArrayList;

+import java.util.Collections;

+import java.util.List;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IResource;

+import org.eclipse.core.runtime.NullProgressMonitor;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

+import org.eclipse.emf.ecore.util.EcoreUtil;

+import org.eclipse.emf.ecore.xmi.XMIResource;

+import org.eclipse.emf.emfstore.client.ui.dialogs.merge.DecisionManager;

+import org.eclipse.emf.emfstore.client.ui.dialogs.merge.MergeWizard;

+import org.eclipse.emf.emfstore.common.model.ModelElementId;

+import org.eclipse.emf.emfstore.common.model.Project;

+import org.eclipse.emf.emfstore.common.model.impl.ProjectImpl;

+import org.eclipse.emf.emfstore.common.model.util.ModelUtil;

+import org.eclipse.emf.emfstore.common.model.util.SerializationException;

+import org.eclipse.emf.emfstore.server.model.versioning.ChangePackage;

+import org.eclipse.emf.emfstore.server.model.versioning.PrimaryVersionSpec;

+import org.eclipse.emf.emfstore.server.model.versioning.VersioningFactory;

+import org.eclipse.emf.emfstore.server.model.versioning.operations.AbstractOperation;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.Artifact;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.ArtifactRegistry;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+import org.eclipse.emf.emfstore.standalone.core.vcs.IVCSProvider;

+import org.eclipse.emf.emfstore.standalone.core.workspace.ResourceFactoryRegistry;

+import org.eclipse.jface.wizard.WizardDialog;

+import org.eclipse.swt.widgets.Display;

+import org.xml.sax.InputSource;

+

+public class ArtifactMerger {

+

+	private IResource resource;

+//	private Project project;

+//	private XMIResource historyResource;

+//	private final XMIResource xmiResource;

+	private IVCSProvider provider;

+	private Artifact artifact;

+	

+	public ArtifactMerger(IVCSProvider provider, IResource resource,

+			Artifact artifact) {

+		this.resource = resource;

+		this.artifact = artifact;

+//		this.xmiResource = artifact.getModelResource();

+//		this.historyResource = artifact.getHistoryResource();

+//		this.project = artifact.getCollection();

+		this.provider = provider;

+	}

+	

+	public void merge() {

+		artifact.getProject().getChangeNotifier().disableNotifications(true);

+				

+		try {

+			// restore project state 

+			String artifactFileContent = provider.getMyRevision(

+					FileUtil.getFile(artifact.getModelResource().getURI()),	new NullProgressMonitor());

+			artifact.setProject(stringToEObjectIntoProject(artifactFileContent));

+			writeToXMIResource(artifact.getProject().getModelElements(), artifact.getModelResource());

+			

+		} catch (IOException e1) {

+			// TODO Auto-generated catch block

+			e1.printStackTrace();

+		} catch (InterruptedException e1) {

+			// TODO Auto-generated catch block

+			e1.printStackTrace();

+		} catch (SerializationException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+		

+		List theirOperations = provider.getTheirOperations(resource, new NullProgressMonitor());

+		List myOperations = provider.getMyOperations(resource, new NullProgressMonitor());

+		List<AbstractOperation> mergeResult = callMergeDialog(myOperations, theirOperations);

+		// if mergeResult is empty, file have been auto-merged

+		try {

+			Artifact artifact = ArtifactRegistry.getInstance().getArtifact(ResourceFactoryRegistry.CURRENT_URI);

+			applyMergeResult(myOperations, theirOperations, mergeResult);

+			// resolve conflict on ecore

+			IFile artifactFile = FileUtil.getFile(artifact.getModelResource().getURI());

+			provider.resolveConflict(artifactFile);

+			artifact.getHistoryResource().getContents().clear();

+			artifact.getHistoryResource().getContents().addAll(mergeResult);

+			artifact.getHistoryResource().save(null);

+			provider.resolveConflict(FileUtil.getHistoryFile(artifactFile));

+		} catch (IOException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+		

+		artifact.getProject().getChangeNotifier().disableNotifications(false);

+	}

+

+	/**

+	 * Applies a list of operations to the project. The change tracking is

+	 * stopped and the operations are added to the projectspace.

+	 * 

+	 * @see #applyOperationsWithRecording(List, boolean)

+	 * @param operations

+	 *            list of operations

+	 * @param addOperation

+	 *            true if operation should be saved in project space.

+	 */

+	public void applyOperations(List<AbstractOperation> operations) {

+		// TODO: API

+//		((ProjectImpl) artifact.getProject()).getChangeNotifier().disableNotifications(true);

+//		try {

+			for (AbstractOperation operation : operations) {

+				operation.apply(artifact.getProject());

+			}

+//		} finally {

+//			((ProjectImpl) project).getChangeNotifier().disableNotifications(false);

+//		}

+	}

+	

+	private ChangePackage createChangePackage(List<AbstractOperation> operations) {

+		ChangePackage changePackage = VersioningFactory.eINSTANCE.createChangePackage();

+

+		for (EObject o : operations) {

+			AbstractOperation copy = (AbstractOperation) EcoreUtil.copy(o);

+			changePackage.getOperations().add(copy);

+		}

+		

+		return changePackage;

+	}

+

+	private List<AbstractOperation> callMergeDialog(List<AbstractOperation> myOperations, 

+			List<AbstractOperation> theirOperations) {

+		

+		ChangePackage myChangePackage = createChangePackage(myOperations);

+		ChangePackage theirChangePackage = createChangePackage(theirOperations);

+		

+		PrimaryVersionSpec dummy = VersioningFactory.eINSTANCE.createPrimaryVersionSpec();

+		

+		DecisionManager mgr = new DecisionManager(artifact.getProject(), 

+				myChangePackage, Collections.singletonList(theirChangePackage), 

+				dummy, dummy);

+		mgr.calcResult();

+		List<AbstractOperation> mergeResult = new ArrayList<AbstractOperation>();

+	

+		if (mgr.getConflicts().size() > 0 ) {

+			MergeWizard mergeWizard = new MergeWizard(mgr);

+			WizardDialog mergeDialog = new WizardDialog(Display.getCurrent().getActiveShell(), mergeWizard);

+			mergeDialog.create();

+			// TODO: handle cancel case

+			mergeDialog.open();

+

+			// generate merge result and apply to local workspace

+			List<AbstractOperation> acceptedMine = mgr.getAcceptedMine();

+			List<AbstractOperation> rejectedTheirs = mgr.getRejectedTheirs();

+		

+			for (AbstractOperation operationToReverse : rejectedTheirs) {

+				mergeResult.add(0, operationToReverse.reverse());

+			}

+			

+			mergeResult.addAll(acceptedMine);

+		} 

+		

+		return mergeResult;

+	}

+	

+	/**

+	 * Applies the given merge result upon the given {@link Artifact}. 

+	 * @param artifact the {@link Artifact} upon which to apply the merge result

+	 * @param myOperations the local operations

+	 * @param theirOperations the incoming operations

+	 * @param mergeResult the merge result as determined by the user

+	 * @throws IOException

+	 */

+	private void applyMergeResult(List<AbstractOperation> myOperations, 

+			List<AbstractOperation> theirOperations, List<AbstractOperation> mergeResult) 

+		throws IOException {

+		

+		ChangePackage myChangePackage = createChangePackage(myOperations);

+		ChangePackage theirChangePackage = createChangePackage(theirOperations);

+		

+		// revert our changes

+		revert(myChangePackage.getOperations());

+

+		applyOperations(theirChangePackage.getOperations());

+		applyOperations(mergeResult);

+

+		// write merge result back to model resource

+//		List<EObject> modelElements = ModelUtil.clone(project.getModelElements());

+

+		try {

+			writeToXMIResource(mergeResult, artifact.getHistoryResource());

+		} catch (IOException e) {

+			throw new IOException(String.format("Can not write merge result {0} to history resource {1}. Reason: {2}", 

+					mergeResult, artifact.getHistoryResource(), e.getMessage())); 

+		}

+		

+		try {

+			writeToXMIResource(artifact.getProject().getModelElements(), artifact.getModelResource());

+		} catch (IOException e) {

+			throw new IOException(String.format("Can not write model elements {0} to resource {1}. Reason: {2}", 

+					artifact.getProject().getModelElements(), artifact.getModelResource(), e.getMessage())); 

+		}

+	}

+	

+	/**

+	 * Reverts the 

+	 * @param operations

+	 */

+	public void revert(List<AbstractOperation> operations) {

+		while (!operations.isEmpty()) {

+			AbstractOperation lastOperation = operations

+					.get(operations.size() - 1);

+			((ProjectImpl) artifact.getProject()).getChangeNotifier().disableNotifications(true);

+			try {

+				lastOperation.reverse().apply(artifact.getProject());

+			} finally {

+				((ProjectImpl) artifact.getProject()).getChangeNotifier().disableNotifications(false);

+			}

+			operations.remove(lastOperation);

+		}

+	}

+		

+	/**

+	 * Write 

+	 * @param modelElements

+	 * @param resource

+	 * @throws IOException

+	 */

+	private void writeToXMIResource(List<? extends EObject> modelElements, XMIResource resource) throws IOException {

+//		resource.getContents().s

+

+		// TODO: will be slow

+//		int index = 0;

+		for (EObject me : modelElements) {

+

+			List<EObject> allContainedModelElements = ModelUtil.getAllContainedModelElementsAsList(me, false);

+			allContainedModelElements.add(me);

+

+			EObject copiedElement = EcoreUtil.copy(me);

+			List<EObject> copiedAllContainedModelElements = ModelUtil.getAllContainedModelElementsAsList(copiedElement, false);

+			copiedAllContainedModelElements.add(copiedElement);

+			

+			resource.getContents().add(copiedElement);

+

+			for (int i = 0; i < allContainedModelElements.size(); i++) {

+				EObject child = allContainedModelElements.get(i);

+				EObject copiedChild = copiedAllContainedModelElements.get(i);

+				ModelElementId modelElementId = artifact.getProject().getModelElementId(child);

+				if (modelElementId == null) {

+					modelElementId = artifact.getProject().getDeletedModelElementId(child);

+				}				

+				if (modelElementId != null) {

+					resource.setID(copiedChild, modelElementId.getId());

+				}

+			}

+		}

+		

+		for (int i = 0; i < modelElements.size(); i++) {

+			resource.getContents().remove(0);

+		}

+

+		resource.save(null);

+	}

+	

+	/**

+	 * Converts a {@link String} to an {@link EObject}. <b>Note</b>:

+	 * {@link String} must be the result of

+	 * {@link ModelUtil#eObjectToString(EObject)}

+	 * 

+	 * @param object

+	 *            the {@link String} representation of the {@link EObject}

+	 * @return the deserialized {@link EObject}

+	 * @throws SerializationException

+	 *             if deserialization fails

+	 */

+	public static Project stringToEObjectIntoProject(String object)

+			throws SerializationException {

+		if (object == null) {

+			return null;

+		}

+

+		XMIResource res = (XMIResource) (new ResourceSetImpl())

+				.createResource(ModelUtil.VIRTUAL_URI);

+

+		try {

+			res.load(new InputSource(new StringReader(object)),

+					null);

+		} catch (UnsupportedEncodingException e) {

+			throw new SerializationException(e);

+		} catch (IOException e) {

+			throw new SerializationException(e);

+		}

+

+		EObject result = res.getContents().get(0);

+

+		if (result instanceof Project) {

+			return (Project) result;

+		}

+

+		// TODO: init

+		Project project = null;

+		try {

+			project = new ProjectImpl(res);

+		} catch (IOException e) {

+			// TODO Auto-generated catch block

+			// Do NOT catch all Exceptions ("catch (Exception e)")

+			// Log AND handle Exceptions if possible

+			//

+			// You can just uncomment one of the lines below to log an

+			// exception:

+			// logException will show the logged excpetion to the user

+			// ModelUtil.logException(e);

+			// ModelUtil.logException("YOUR MESSAGE HERE", e);

+			// logWarning will only add the message to the error log

+			// ModelUtil.logWarning("YOUR MESSAGE HERE", e);

+			// ModelUtil.logWarning("YOUR MESSAGE HERE");

+			//

+			// If handling is not possible declare and rethrow Exception

+			e.printStackTrace();

+		}

+

+		return project;

+	}

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/MergeDecorator.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/MergeDecorator.java
new file mode 100644
index 0000000..9d2615b
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/MergeDecorator.java
@@ -0,0 +1,50 @@
+package org.eclipse.emf.emfstore.standalone.ui;

+import org.eclipse.core.resources.IFile;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.ArtifactRegistry;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+import org.eclipse.jface.viewers.IDecoration;

+import org.eclipse.jface.viewers.ILabelProviderListener;

+import org.eclipse.jface.viewers.ILightweightLabelDecorator;

+

+

+public class MergeDecorator implements ILightweightLabelDecorator {

+

+	@Override

+	public void decorate(Object element, IDecoration decoration) {

+		if (element instanceof IFile) {

+			IFile file = (IFile) element;

+			URI uri = FileUtil.getUri(file);

+			if (ArtifactRegistry.getInstance().isFlagged(uri)) {

+				decoration.addPrefix("[F]");

+			} else if (ArtifactRegistry.getInstance().isRegistered(uri)) {

+				decoration.addPrefix("[R]");

+			} 

+		}

+	}

+

+	@Override

+	public void addListener(ILabelProviderListener listener) {

+		// TODO Auto-generated method stub

+		

+	}

+

+	@Override

+	public void dispose() {

+		// TODO Auto-generated method stub

+		

+	}

+

+	@Override

+	public boolean isLabelProperty(Object element, String property) {

+		// TODO Auto-generated method stub

+		return false;

+	}

+

+	@Override

+	public void removeListener(ILabelProviderListener listener) {

+		// TODO Auto-generated method stub

+		

+	}

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/ResourceOpenedObserver.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/ResourceOpenedObserver.java
new file mode 100644
index 0000000..503eefb
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/ResourceOpenedObserver.java
@@ -0,0 +1,34 @@
+package org.eclipse.emf.emfstore.standalone.ui;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IResource;

+import org.eclipse.emf.emfstore.standalone.core.workspace.IResourceOpenedObserver;

+import org.eclipse.ui.IWorkbench;

+import org.eclipse.ui.IWorkbenchPage;

+import org.eclipse.ui.IWorkbenchWindow;

+import org.eclipse.ui.PlatformUI;

+

+public class ResourceOpenedObserver implements IResourceOpenedObserver {

+

+	public ResourceOpenedObserver() {

+

+	}

+

+	@Override

+	public void resourceOpened(IResource resource) {

+		

+		if (!(resource instanceof IFile)) {

+			return;

+		}

+		

+		IFile artifactFile = (IFile) resource;

+		IWorkbench wb = PlatformUI.getWorkbench();

+		IWorkbenchWindow win = wb.getActiveWorkbenchWindow();

+		

+		if (win != null) {

+			IWorkbenchPage page = win.getActivePage();

+			page.addPartListener(new ArtifactDisposeListener(artifactFile));

+		}

+	}

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/SynchronizeControl.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/SynchronizeControl.java
new file mode 100644
index 0000000..fe83a75
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/SynchronizeControl.java
@@ -0,0 +1,41 @@
+package org.eclipse.emf.emfstore.standalone.ui;

+

+import java.io.IOException;

+import java.lang.reflect.InvocationTargetException;

+

+import org.eclipse.core.resources.ResourcesPlugin;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.emf.emfstore.standalone.core.vcs.VCSProviderRegistry;

+import org.eclipse.emf.emfstore.standalone.core.workspace.ResourceFactoryRegistry;

+import org.eclipse.emf.emfstore.standalone.core.workspace.WorkspaceObserver;

+import org.eclipse.ui.IStartup;

+

+public class SynchronizeControl extends WorkspaceObserver implements IStartup {

+

+	

+	/**

+	 * {@inheritDoc}

+	 */

+	public void earlyStartup() {

+		ResourceFactoryRegistry.replaceSupportedFactories();

+		

+		try {

+			VCSProviderRegistry.getInstance().initVCSProviders();

+			VCSProviderRegistry.getInstance().initArtifacts();

+		} catch (CoreException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (InvocationTargetException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		} catch (IOException e) {

+			// TODO Auto-generated catch block

+			e.printStackTrace();

+		}

+		

+		// TODO: do we need to dispose this? I guess not?

+		ResourcesPlugin.getWorkspace().addResourceChangeListener(this);	

+	}

+

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/AbstractTeamProviderHandler.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/AbstractTeamProviderHandler.java
new file mode 100644
index 0000000..cab60e0
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/AbstractTeamProviderHandler.java
@@ -0,0 +1,58 @@
+package org.eclipse.emf.emfstore.standalone.ui.handlers;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.resources.IProject;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.QualifiedName;

+import org.eclipse.emf.emfstore.common.model.util.ModelUtil;

+import org.eclipse.emf.emfstore.standalone.core.exceptions.VCSProviderNotFoundException;

+import org.eclipse.emf.emfstore.standalone.core.vcs.IVCSProvider;

+import org.eclipse.emf.emfstore.standalone.core.vcs.VCSProviderRegistry;

+import org.eclipse.jface.action.IAction;

+import org.eclipse.jface.viewers.ISelection;

+import org.eclipse.jface.viewers.StructuredSelection;

+import org.eclipse.ui.IViewActionDelegate;

+

+public abstract class AbstractTeamProviderHandler implements IViewActionDelegate {

+	

+	private static final String TEAM_PROVIDER_KEY = "org.eclipse.team.core.repository";

+	protected IFile selectedFile;

+	

+	protected String getTeamProviderID(IFile file) {

+		IProject project = file.getProject();

+		String key = TEAM_PROVIDER_KEY;

+		int dot = key.lastIndexOf('.');

+		QualifiedName qualifiedName = new QualifiedName(key.substring(0, dot), key.substring(dot + 1));

+		try {

+			Object object = project.getPersistentProperties().get(qualifiedName);

+			return (String) object;

+		} catch (CoreException e) {

+			ModelUtil.logException("Can not determine team provider.", e);

+		}

+		

+		return null;

+	}

+

+	@Override

+	public void selectionChanged(IAction action, ISelection selection) {

+		if (!(selection instanceof StructuredSelection)) {

+			return;

+		}

+		

+		StructuredSelection ss = (StructuredSelection)selection;

+		

+		if (!(ss.getFirstElement() instanceof IFile)) {

+			return;				

+		}

+		

+		selectedFile = (IFile) ss.getFirstElement();

+		String teamProviderID = getTeamProviderID(selectedFile);

+		try {

+			IVCSProvider vcsProvider = VCSProviderRegistry.getInstance().getVCSProvider(teamProviderID);

+			VCSProviderRegistry.getInstance().setActiveProvider(vcsProvider);

+		} catch (VCSProviderNotFoundException e) {

+			// do nothing

+		}

+	}

+	

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/DisableMergingHandler.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/DisableMergingHandler.java
new file mode 100644
index 0000000..1852a39
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/DisableMergingHandler.java
@@ -0,0 +1,54 @@
+package org.eclipse.emf.emfstore.standalone.ui.handlers;

+

+import org.eclipse.core.commands.ExecutionEvent;

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.ArtifactRegistry;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+import org.eclipse.jface.action.IAction;

+import org.eclipse.jface.dialogs.MessageDialog;

+import org.eclipse.swt.widgets.Display;

+import org.eclipse.ui.IViewActionDelegate;

+import org.eclipse.ui.IViewPart;

+

+public class DisableMergingHandler extends AbstractTeamProviderHandler implements IViewActionDelegate {

+

+	public DisableMergingHandler() {

+		// TODO Auto-generated constructor stub

+	}

+

+	@Override

+	public void run(IAction action) {

+		if (selectedFile != null) {

+			URI platformURI = URI.createPlatformResourceURI(selectedFile.getFullPath().toString(), true);

+			if (ArtifactRegistry.getInstance().isRegistered(platformURI)) {

+				try {

+					ArtifactRegistry.getInstance().unregister(platformURI);

+				} catch (CoreException e) {

+					MessageDialog.openError(Display.getCurrent().getActiveShell(), 

+							"Disable merging",

+							"The history file can not be deleted.");

+				}

+			} else if (!ArtifactRegistry.getInstance().isRegistered(platformURI) || !FileUtil.hasManagedFileExtension(selectedFile)) {

+				MessageDialog.openInformation(Display.getCurrent().getActiveShell(), 

+						"File is not under versioned control",

+						"The selected file is not put under versioned control. TODO");

+			} 

+		} else {

+			// TODO: actually this should not get executed ever

+			MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Disable merging", 

+					"Please first select a file");

+		}

+	}

+

+	public Object execute(ExecutionEvent event) throws ExecutionException {

+		return null;

+	}

+

+	@Override

+	public void init(IViewPart view) {

+		// TODO Auto-generated method stub	

+	}

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/EnableMergingHandler.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/EnableMergingHandler.java
new file mode 100644
index 0000000..334ff14
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/EnableMergingHandler.java
@@ -0,0 +1,54 @@
+package org.eclipse.emf.emfstore.standalone.ui.handlers;

+

+import org.eclipse.core.commands.ExecutionEvent;

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.ArtifactRegistry;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+import org.eclipse.emf.emfstore.standalone.core.vcs.IVCSProvider;

+import org.eclipse.emf.emfstore.standalone.core.vcs.VCSProviderRegistry;

+import org.eclipse.jface.action.IAction;

+import org.eclipse.jface.dialogs.MessageDialog;

+import org.eclipse.swt.widgets.Display;

+import org.eclipse.ui.IViewActionDelegate;

+import org.eclipse.ui.IViewPart;

+

+public class EnableMergingHandler extends AbstractTeamProviderHandler implements IViewActionDelegate {

+

+	@Override

+	public void run(IAction action) {

+		

+		if (selectedFile != null) {

+			if (VCSProviderRegistry.getInstance().getActiveProvider() == IVCSProvider.NONE) {

+				MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Enable merging", 

+						"The VCS provider could not be determined.");

+			}

+			

+			if (ArtifactRegistry.getInstance().isRegistered(FileUtil.getUri(selectedFile))) {

+				MessageDialog.openInformation(Display.getCurrent().getActiveShell(), 

+						"File already under EMFStore merger control",

+						"The selected file already is under control of EMFStore merger.");

+			} else if (FileUtil.hasManagedFileExtension(selectedFile)) {

+				ArtifactRegistry.getInstance().flag(FileUtil.getUri(selectedFile));

+			} else {

+				MessageDialog.openInformation(Display.getCurrent().getActiveShell(), 

+						"File can not be put under control of EMFStore merger",

+						"The selected file can not be put under control of EMFStore merger. TODO"); 

+			}

+		} else {

+			// TODO: actually this should not get executed ever

+			MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Enable merging", 

+					"Please first select a file");

+		}

+	}

+

+	public Object execute(ExecutionEvent event) throws ExecutionException {

+		return null;

+	}

+

+	@Override

+	public void init(IViewPart view) {

+		// TODO Auto-generated method stub

+		

+	}

+

+}

diff --git a/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/ExecuteMergerHandler.java b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/ExecuteMergerHandler.java
new file mode 100644
index 0000000..4521c00
--- /dev/null
+++ b/Archive/EMFStoreStandalone/org.eclipse.emf.emfstore.standalone.ui/src/org/eclipse/emf/emfstore/standalone/ui/handlers/ExecuteMergerHandler.java
@@ -0,0 +1,86 @@
+package org.eclipse.emf.emfstore.standalone.ui.handlers;

+

+import org.eclipse.core.commands.ExecutionEvent;

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.resources.IFile;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.Artifact;

+import org.eclipse.emf.emfstore.standalone.core.artifacts.ArtifactRegistry;

+import org.eclipse.emf.emfstore.standalone.core.exceptions.NoActiveVCSProviderException;

+import org.eclipse.emf.emfstore.standalone.core.util.FileUtil;

+import org.eclipse.emf.emfstore.standalone.core.vcs.IVCSProvider;

+import org.eclipse.emf.emfstore.standalone.core.vcs.VCSProviderRegistry;

+import org.eclipse.emf.emfstore.standalone.core.workspace.ResourceFactoryRegistry;

+import org.eclipse.emf.emfstore.standalone.ui.ArtifactMerger;

+import org.eclipse.jface.action.IAction;

+import org.eclipse.jface.dialogs.MessageDialog;

+import org.eclipse.jface.viewers.ISelection;

+import org.eclipse.jface.viewers.StructuredSelection;

+import org.eclipse.swt.widgets.Display;

+import org.eclipse.ui.IViewActionDelegate;

+import org.eclipse.ui.IViewPart;

+

+public class ExecuteMergerHandler extends AbstractTeamProviderHandler implements IViewActionDelegate {

+

+	public Object execute(ExecutionEvent event) throws ExecutionException {

+		return null;

+	}

+

+	@Override

+	public void run(IAction action) {

+		if (selectedFile != null) {

+			

+			IVCSProvider activeProvider = VCSProviderRegistry.getInstance().getActiveProvider();

+			

+			if (activeProvider == IVCSProvider.NONE) {

+				MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Warning", 

+						"The VCS provider could not be determined.");

+				return;

+			}

+			

+			Artifact versionedArtifact = ArtifactRegistry.getInstance().getArtifact(

+					ResourceFactoryRegistry.CURRENT_URI);

+			// TODO: how can this be not initalized?

+			if (!versionedArtifact.isInitialized()) {

+				try {

+					versionedArtifact.initialize();

+				} catch (NoActiveVCSProviderException e) {

+					// should not happen because of guard above

+				}

+			}

+			

+			ArtifactMerger merger = new ArtifactMerger(activeProvider,

+					selectedFile, versionedArtifact);

+			merger.merge(); 

+			

+		} else {

+			MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Execute merging", 

+					"Please first select a conflicting history file.");

+		}

+	}

+

+	@Override

+	public void selectionChanged(IAction action, ISelection selection) {

+		if (!(selection instanceof StructuredSelection)) {

+			return;

+		}

+

+		StructuredSelection ss = (StructuredSelection) selection;

+		Object firstElement = ss.getFirstElement();

+		

+		if (!(firstElement instanceof IFile)) {

+			return;

+		}

+		

+		IFile file = (IFile) firstElement;

+		

+		if (FileUtil.isHistoryFile(file)) {

+			selectedFile = file;

+		}		

+	}

+

+	@Override

+	public void init(IViewPart view) {

+		// TODO Auto-generated method stub

+		

+	}

+}