Index: trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java	(revision 36970)
@@ -10,10 +10,15 @@
  ******************************************************************************/
 package org.jboss.tools.openshift.egit.core;
 
+import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
+import java.text.MessageFormat;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 import org.eclipse.core.resources.IProject;
@@ -24,24 +29,36 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.egit.core.EclipseGitProgressTransformer;
 import org.eclipse.egit.core.IteratorService;
+import org.eclipse.egit.core.op.AddToIndexOperation;
 import org.eclipse.egit.core.op.CommitOperation;
+import org.eclipse.egit.core.op.ConnectProviderOperation;
+import org.eclipse.egit.core.op.FetchOperation;
+import org.eclipse.egit.core.op.MergeOperation;
 import org.eclipse.egit.core.op.PushOperation;
 import org.eclipse.egit.core.op.PushOperationSpecification;
 import org.eclipse.egit.core.project.RepositoryMapping;
 import org.eclipse.egit.ui.UIText;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.InitCommand;
+import org.eclipse.jgit.api.MergeResult;
+import org.eclipse.jgit.api.errors.JGitInternalException;
 import org.eclipse.jgit.errors.NotSupportedException;
 import org.eclipse.jgit.lib.ConfigConstants;
 import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.IndexDiff;
 import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.lib.StoredConfig;
 import org.eclipse.jgit.lib.UserConfig;
+import org.eclipse.jgit.merge.MergeStrategy;
+import org.eclipse.jgit.transport.FetchResult;
 import org.eclipse.jgit.transport.RefSpec;
 import org.eclipse.jgit.transport.RemoteConfig;
 import org.eclipse.jgit.transport.Transport;
 import org.eclipse.jgit.transport.URIish;
 import org.eclipse.osgi.util.NLS;
+import org.eclipse.team.core.RepositoryProvider;
 import org.jboss.tools.openshift.egit.core.internal.EGitCoreActivator;
 
 /**
@@ -56,26 +73,230 @@
 
 	private static final int PUSH_TIMEOUT = 10 * 1024;
 
+	private static final String EGIT_TEAM_PROVIDER_ID =
+			"org.eclipse.egit.core·GitProvider";
+
+	private EGitUtils() {
+		// inhibit instantiation
+	}
+
 	/**
-	 * Commits the given project to it's configured repository.
+	 * Returns <code>true</code> if the given project is associated to any team
+	 * provider (git, svn, cvs, etc.). Returns <code>false</code> otherwise.
 	 * 
 	 * @param project
-	 *            the project
+	 *            the project to check
+	 * @return <code>true</code> if the project is associated with any team
+	 *         provider.
+	 */
+	public static boolean isShared(IProject project) {
+		return RepositoryProvider.getProvider(project) != null;
+	}
+
+	/**
+	 * Returns <code>true</code> if the given project is associated to the egit
+	 * team provider. Returns <code>false</code> otherwise.
+	 * 
+	 * @param project
+	 *            the project to check
+	 * @return <code>true</code> if the project is associated with the git team
+	 *         provider.
+	 */
+	public static boolean isSharedWithGit(IProject project) {
+		return EGIT_TEAM_PROVIDER_ID.equals(RepositoryProvider.getProvider(project));
+	}
+
+	/**
+	 * Shares the given project. A repository is created within the given
+	 * project and the project is connected to the freshly created repository.
+	 * 
+	 * @param project
 	 * @param monitor
-	 *            the monitor
+	 * @return
 	 * @throws CoreException
-	 *             the core exception
+	 */
+	public static Repository share(IProject project, IProgressMonitor monitor) throws CoreException {
+		Repository repository = createRepository(project, monitor);
+		connect(project, repository, monitor);
+		addToRepository(project, repository, monitor);
+		commit(project, monitor);
+		// checkout("master", repository);
+		return repository;
+	}
+
+	/**
+	 * Creates a repository for the given project. The repository is created in
+	 * the .git directory within the given project. The project is not connected
+	 * with the new repository
+	 * 
+	 * @param project
+	 *            the project to create the repository for.
+	 * @param monitor
+	 *            the monitor to report the progress to
+	 * @return
+	 * @throws CoreException
+	 * 
+	 * @see #connect(IProject, Repository, IProgressMonitor)
+	 */
+	public static Repository createRepository(IProject project, IProgressMonitor monitor) throws CoreException {
+		try {
+			InitCommand init = Git.init();
+			init.setBare(false).setDirectory(project.getLocation().toFile());
+			Git git = init.call();
+			return git.getRepository();
+		} catch (JGitInternalException e) {
+			throw new CoreException(EGitCoreActivator.createErrorStatus(
+					NLS.bind("Could not initialize a git repository at {0}: {1}",
+							getRepositoryPathFor(project),
+							e.getMessage()), e));
+		}
+	}
+
+	public static File getRepositoryPathFor(IProject project) {
+		return new File(project.getLocationURI().getPath(), Constants.DOT_GIT);
+	}
+
+	public static void addToRepository(IProject project, Repository repository, IProgressMonitor monitor)
+			throws CoreException {
+		AddToIndexOperation add = new AddToIndexOperation(Collections.singletonList(project));
+		add.execute(monitor);
+	}
+
+	/**
+	 * Connects the given project to the repository within it.
+	 * 
+	 * @param project
+	 *            the project to connect
+	 * @param monitor
+	 *            the monitor to report progress to
+	 * @throws CoreException
 	 */
-	public static void commit(IProject project, String commitMessage, IProgressMonitor monitor) throws CoreException {
-		Assert.isLegal(project != null, "Cannot commit project. No project provided");
+	public static void connect(IProject project, IProgressMonitor monitor) throws CoreException {
+		connect(project, getRepositoryPathFor(project), monitor);
+	}
+
+	/**
+	 * Connects the given project to the given repository.
+	 * 
+	 * @param project
+	 *            the project to connect
+	 * @param repository
+	 *            the repository to connect the project to
+	 * @param monitor
+	 *            the monitor to report progress to
+	 * @throws CoreException
+	 */
+	private static void connect(IProject project, Repository repository, IProgressMonitor monitor) throws CoreException {
+		connect(project, repository.getDirectory(), monitor);
+	}
+
+	private static void connect(IProject project, File repositoryFolder, IProgressMonitor monitor) throws CoreException {
+		new ConnectProviderOperation(project, repositoryFolder).execute(monitor);
+	}
+
+	/**
+	 * Merges the given uri to HEAD in the given repository. The given branch is
+	 * the branch in the local repo the fetched HEAD is fetched to.
+	 * 
+	 * @param branch
+	 * @param uri
+	 * @param repository
+	 * @param monitor
+	 * @throws CoreException
+	 * @throws InvocationTargetException
+	 */
+	public static void mergeWithRemote(URIish uri, String branch, Repository repository, IProgressMonitor monitor)
+			throws CoreException, InvocationTargetException {
+		RefSpec ref = new RefSpec().setSource(Constants.HEAD).setDestination(branch);
+		fetch(uri, Collections.singletonList(ref), repository, monitor);
+		merge(branch, repository, monitor);
+	}
+
+	/**
+	 * Merges current master with the given branch. The strategy used is Resolve
+	 * since egit does still not support the Recusive stragety.
+	 * 
+	 * @param branch
+	 *            the branch to merge
+	 * @param repository
+	 *            the repository the branch is in
+	 * @param monitor
+	 *            the monitor to report the progress to
+	 * @return the result of the merge
+	 * @throws CoreException
+	 * 
+	 * @see MergeStrategy#RESOLVE
+	 * @link 
+	 *       http://www.eclipse.org/forums/index.php/mv/msg/261278/753913/#msg_753913
+	 * @link https://bugs.eclipse.org/bugs/show_bug.cgi?id=354099
+	 * @link https://bugs.eclipse.org/bugs/show_bug.cgi?id=359951
+	 */
+	private static MergeResult merge(String branch, Repository repository, IProgressMonitor monitor)
+			throws CoreException {
+		MergeOperation merge = new MergeOperation(repository, branch, MergeStrategy.RESOLVE.getName());
+		merge.execute(monitor);
+		return merge.getResult();
+	}
+
+	/**
+	 * Fetches the source ref(s) (from the given ref spec(s)) from the given uri
+	 * to the given destination(s) (in the given ref spec(s)) to the given
+	 * repository.
+	 * 
+	 * @param uri
+	 *            the uri to fetch from
+	 * @param fetchRefsRefSpecs
+	 *            the references with the sources and destinations
+	 * @param repository
+	 *            the repository to fetch to
+	 * @param monitor
+	 *            the monitor to report progress to
+	 * @return
+	 * @throws InvocationTargetException
+	 * @throws CoreException
+	 */
+	private static Collection<Ref> fetch(URIish uri, List<RefSpec> fetchRefsRefSpecs, Repository repository,
+			IProgressMonitor monitor)
+			throws InvocationTargetException, CoreException {
+		FetchOperation fetch = new FetchOperation(repository, uri, fetchRefsRefSpecs, 10 * 1024, false);
+		fetch.run(monitor);
+		FetchResult result = fetch.getOperationResult();
+		return result.getAdvertisedRefs();
+	}
+
+	/**
+	 * Commits the changes within the given project to it's configured
+	 * repository. The project has to be connected to a repository.
+	 * 
+	 * @param project
+	 *            the project whose changes shall be committed
+	 * @param monitor
+	 *            the monitor to report progress to
+	 * @throws CoreException
+	 * 
+	 * @see #connect(IProject, Repository)
+	 */
+	private static void commit(IProject project, String commitMessage, IProgressMonitor monitor) throws CoreException {
+		Repository repository = getRepository(project);
+		Assert.isLegal(repository != null, "Cannot commit project to repository. ");
+		commit(project, commitMessage, repository, monitor);
+	}
+
+	public static void commit(IProject project, IProgressMonitor monitor) throws CoreException {
+		commit(project, "Commit from JBoss Tools", monitor);
+	}
+
+	private static void commit(IProject project, String commitMessage, Repository repository, IProgressMonitor monitor)
+			throws CoreException {
+		Assert.isLegal(project != null, "Could not commit project. No project provided");
+		Assert.isLegal(
+				repository != null,
+				MessageFormat
+						.format("Could not commit. Project \"{0}\" is not connected to a repository (call #connect(project, repository) first)",
+								project.getName()));
 		/**
 		 * TODO: add capability to commit selectively
 		 */
-		Repository repository = getRepository(project);
-		if (repository == null) {
-			throw new CoreException(createStatus(null,
-					"Could not commit. Project \"{0}\" is not attached to a git repo", project.getName()));
-		}
 		UserConfig userConfig = getUserConfig(repository);
 		CommitOperation op = new CommitOperation(
 				null,
@@ -89,10 +310,6 @@
 		op.execute(monitor);
 	}
 
-	public static void commit(IProject project, IProgressMonitor monitor) throws CoreException {
-		commit(project, "Commit from JBoss Tools", monitor);
-	}
-	
 	/**
 	 * Pushes the given repository to the remote repository it's current branch
 	 * originates from.
@@ -449,26 +666,26 @@
 		}
 		return status;
 	}
-	
+
 	public static int countCommitableChanges(IProject project, IProgressMonitor monitor) {
 		try {
 			Repository repo = getRepository(project);
-			
+
 			EclipseGitProgressTransformer jgitMonitor = new EclipseGitProgressTransformer(monitor);
 			IndexDiff indexDiff = new IndexDiff(repo, Constants.HEAD,
 					IteratorService.createInitialIterator(repo));
 			indexDiff.diff(jgitMonitor, 0, 0, NLS.bind(
 					UIText.CommitActionHandler_repository, repo.getDirectory().getPath()));
-//			System.out.println(indexDiff.getAdded().size());
-//			System.out.println(indexDiff.getChanged().size());
-//			System.out.println(indexDiff.getConflicting().size());
-//			System.out.println(indexDiff.getMissing().size());
-//			System.out.println(indexDiff.getModified().size());
-//			System.out.println(indexDiff.getRemoved().size());
-//			System.out.println(indexDiff.getUntracked().size());
-			
+			// System.out.println(indexDiff.getAdded().size());
+			// System.out.println(indexDiff.getChanged().size());
+			// System.out.println(indexDiff.getConflicting().size());
+			// System.out.println(indexDiff.getMissing().size());
+			// System.out.println(indexDiff.getModified().size());
+			// System.out.println(indexDiff.getRemoved().size());
+			// System.out.println(indexDiff.getUntracked().size());
+
 			return indexDiff.getModified().size();
-		} catch( IOException ioe ) {
+		} catch (IOException ioe) {
 		}
 		return -1;
 	}
Index: trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java	(revision 36970)
@@ -10,6 +10,8 @@
  ******************************************************************************/ 
 package org.jboss.tools.openshift.egit.core.internal;
 
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
@@ -34,4 +36,16 @@
 	public void stop(BundleContext bundleContext) throws Exception {
 		EGitCoreActivator.context = null;
 	}
+	
+	public static IStatus createErrorStatus(String message, Throwable throwable) {
+		return createStatus(IStatus.ERROR, message, throwable);
+	}
+	
+	public static IStatus createStatus(int severity, String message, Throwable throwable) {
+		if (throwable == null) {
+			return new Status(severity, PLUGIN_ID, message);
+		} else {
+			return new Status(severity, PLUGIN_ID, message, throwable);
+		}
+	}
 }
Index: trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF	(revision 36970)
@@ -4,9 +4,10 @@
 Bundle-SymbolicName: org.jboss.tools.openshift.egit.ui;singleton:=true
 Bundle-Version: 2.3.0.qualifier
 Bundle-Activator: org.jboss.tools.openshift.egit.ui.EGitUIActivator
-Require-Bundle: org.eclipse.egit.core;bundle-version="1.0.0",
- org.eclipse.jgit;bundle-version="1.0.0",
- org.eclipse.ui,
+Require-Bundle: org.eclipse.egit.core;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.egit.ui;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jgit;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.ui;bundle-version="[3.7.0,4.0.0)",
  org.eclipse.core.runtime,
  org.eclipse.core.expressions;bundle-version="[3.4.300,4.0.0)",
  org.eclipse.core.resources;bundle-version="[3.7.100,4.0.0)",
@@ -15,3 +16,4 @@
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-Vendor: JBoss by Red Hat
+Export-Package: org.jboss.tools.openshift.egit.ui.util
Index: trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java	(revision 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java	(revision 36970)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.egit.ui.util;
+
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
+
+public class EGitUIUtils {
+
+	public static String getEGitDefaultRepositoryPath() {
+		return Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR);
+	}
+
+}

Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF	(revision 36970)
@@ -6,6 +6,9 @@
 Bundle-Localization: plugin
 Bundle-Activator: org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator
 Require-Bundle: org.jboss.tools.openshift.express.client;bundle-version="2.3.0",
+ org.jboss.tools.openshift.egit.core;bundle-version="2.3.0",
+ org.jboss.tools.openshift.egit.ui;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.ui;bundle-version="[2.3.0,3.0.0)",
  org.eclipse.egit.ui;bundle-version="[1.0.0,2.0.0)",
  org.eclipse.egit.core;bundle-version="[1.1.0,2.0.0)",
  org.eclipse.jgit;bundle-version="[1.1.0,2.1.0)",
@@ -22,13 +25,11 @@
  org.eclipse.jface.databinding;bundle-version="[1.5.0,2.0.0)",
  org.eclipse.wst.server.core;bundle-version="[1.1.3,2.0.0)",
  org.eclipse.debug.core;bundle-version="[3.7.0,4.0.0)",
- org.jboss.ide.eclipse.as.ui;bundle-version="[2.3.0,3.0.0)",
  org.eclipse.wst.server.ui;bundle-version="[1.1.3,2.0.0)",
  org.eclipse.ui.ide;bundle-version="3.7.0",
  org.eclipse.m2e.core.ui;bundle-version="1.0.100",
  org.eclipse.wst.common.modulecore;bundle-version="1.2.100",
  org.eclipse.team.ui;bundle-version="3.6.100",
- org.jboss.tools.openshift.egit.core;bundle-version="2.3.0",
  org.eclipse.jdt.launching;bundle-version="3.6.0",
  org.eclipse.debug.ui;bundle-version="3.7.0",
  com.jcraft.jsch.source;bundle-version="0.1.44";resolution:=optional,
Index: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java	(revision 36970)
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- *     Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.openshift.express.internal.ui.wizard;
-
-import java.util.Set;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jgit.lib.Repository;
-
-/**
- * @author André Dietisheim
- */
-public class BranchNameContentProvider implements IStructuredContentProvider {
-
-	@Override
-	public void dispose() {
-
-	}
-
-	@Override
-	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-	}
-
-	@Override
-	public Object[] getElements(Object inputElement) {
-		if (!(inputElement instanceof Repository)) {
-			return new Object[] {};
-		}
-		
-		return getBranches((Repository) inputElement);
-	}
-
-	private Object[] getBranches(Repository repository) {
-
-		Set<String> refNames = repository.getAllRefs().keySet();
-		return refNames.toArray(new String[refNames.size()]);
-	}
-
-}
Index: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java	(revision 36970)
@@ -11,7 +11,9 @@
 package org.jboss.tools.openshift.express.internal.ui.wizard;
 
 import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -21,6 +23,7 @@
 import java.util.List;
 
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.resources.WorkspaceJob;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -29,9 +32,9 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.egit.core.RepositoryUtil;
 import org.eclipse.egit.core.op.CloneOperation;
-import org.eclipse.egit.core.op.ConnectProviderOperation;
 import org.eclipse.egit.ui.Activator;
 import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.transport.JschConfigSessionFactory;
 import org.eclipse.jgit.transport.URIish;
 import org.eclipse.osgi.util.NLS;
@@ -45,12 +48,14 @@
 import org.eclipse.wst.server.core.internal.Server;
 import org.jboss.ide.eclipse.as.core.util.FileUtil;
 import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.egit.core.EGitUtils;
 import org.jboss.tools.openshift.express.client.IApplication;
 import org.jboss.tools.openshift.express.client.ICartridge;
 import org.jboss.tools.openshift.express.client.IUser;
 import org.jboss.tools.openshift.express.client.OpenShiftException;
 import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
 import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.common.FileUtils;
 import org.jboss.tools.openshift.express.internal.ui.wizard.projectimport.GeneralProjectImportOperation;
 import org.jboss.tools.openshift.express.internal.ui.wizard.projectimport.MavenProjectImportOperation;
 
@@ -67,11 +72,14 @@
 	public static final String APPLICATION = "application";
 	public static final String REMOTE_NAME = "remoteName";
 	public static final String REPOSITORY_PATH = "repositoryPath";
+	public static final String PROJECT_NAME = "projectName";
+	public static final String MERGE_URI = "mergeUri";
 
-	public void setProperty(String key, Object value) {
+	public Object setProperty(String key, Object value) {
 		Object oldVal = dataModel.get(key);
 		dataModel.put(key, value);
 		firePropertyChange(key, oldVal, value);
+		return value;
 	}
 
 	public Object getProperty(String key) {
@@ -83,7 +91,7 @@
 	}
 
 	public IUser getUser() {
-		return (IUser)getProperty(USER);
+		return (IUser) getProperty(USER);
 	}
 
 	public IApplication getApplication() {
@@ -116,7 +124,7 @@
 		}
 		return cartridgeName;
 	}
-	
+
 	public void setApplication(IApplication application) {
 		setProperty(APPLICATION, application);
 	}
@@ -131,29 +139,92 @@
 	}
 
 	public String setRepositoryPath(String repositoryPath) {
-		setProperty(REPOSITORY_PATH, repositoryPath);
-		return repositoryPath;
+		return (String) setProperty(REPOSITORY_PATH, repositoryPath);
 	}
 
 	public String getRepositoryPath() {
 		return (String) getProperty(REPOSITORY_PATH);
 	}
 
-	public void importProject(final File projectFolder, IProgressMonitor monitor) throws OpenShiftException,
+	public String setProjectName(String projectName) {
+		return (String) setProperty(PROJECT_NAME, projectName);
+	}
+
+	public String getProjectName() {
+		return (String) getProperty(PROJECT_NAME);
+	}
+
+	public String setMergeUri(String mergeUri) {
+		return (String) setProperty(MERGE_URI, mergeUri);
+	}
+
+	public String getMergeUri() {
+		return (String) getProperty(MERGE_URI);
+	}
+
+	/**
+	 * Shares (git enables) the user provided project.
+	 * 
+	 * @param monitor
+	 *            the monitor to report progress to.
+	 * @return
+	 * @throws CoreException
+	 */
+	public void shareProject(IProgressMonitor monitor) throws CoreException {
+		monitor.subTask(NLS.bind("Sharing project {0}...", getProjectName()));
+		shareProject(getProjectName(), monitor);
+	}
+
+	private Repository shareProject(String projectName, IProgressMonitor monitor) throws CoreException {
+		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+		if (project == null) {
+			throw new CoreException(
+					OpenShiftUIActivator.createErrorStatus("Could not find project {0} in your workspace."));
+		}
+		return EGitUtils.share(project, monitor);
+	}
+
+	public void copyOpenshiftConfiguration(final File sourceFolder, IProgressMonitor monitor)
+			throws OpenShiftException, IOException {
+		IProject project = getProject();
+		monitor.subTask(NLS.bind("Copying openshift configuration to project {0}...", getProjectName()));
+		FileUtils.copy(new File(sourceFolder, ".git"), project.getLocation().toFile(), false);
+		FileUtils.copy(new File(sourceFolder, ".openshift"), project.getLocation().toFile(), false);
+		FileUtils.copy(new File(sourceFolder, "deployments"), project.getLocation().toFile(), false);
+		FileUtils.copy(new File(sourceFolder, "pom.xml"), project.getLocation().toFile(), false);
+	}
+
+	/**
+	 * Returns the user provided project.
+	 * 
+	 * @throws OpenShiftException
+	 * 
+	 * @see #getProjectName
+	 */
+	private IProject getProject() throws OpenShiftException {
+		IProject project = getProject(getProjectName());
+		if (project == null
+				|| !project.exists()) {
+			throw new OpenShiftException("Could not find project {0} in your workspace.", getProjectName());
+		}
+		return project;
+	}
+
+	public void importProject(final File gitProjectFolder, IProgressMonitor monitor) throws OpenShiftException,
 			CoreException,
 			InterruptedException {
-		new WorkspaceJob(NLS.bind("Importing projects from {0}", projectFolder.getAbsolutePath())) {
+		new WorkspaceJob(NLS.bind("Importing projects from {0}", gitProjectFolder.getAbsolutePath())) {
 
 			@Override
 			public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
 				try {
-					List<IProject> importedProjects = importMavenProject(projectFolder, monitor);
-					connectToGitRepo(importedProjects, projectFolder, monitor);
+					List<IProject> importedProjects = importMavenProject(gitProjectFolder, monitor);
+					connectToGitRepo(importedProjects, gitProjectFolder, monitor);
 					createServerAdapterIfRequired(importedProjects, monitor);
 					return Status.OK_STATUS;
 				} catch (Exception e) {
 					IStatus status = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
-							NLS.bind("Could not import projects from {0}", projectFolder.getAbsolutePath()), e);
+							NLS.bind("Could not import projects from {0}", gitProjectFolder.getAbsolutePath()), e);
 					OpenShiftUIActivator.log(status);
 					return status;
 				}
@@ -162,36 +233,69 @@
 		}.schedule();
 	}
 
-	private List<IProject> importMavenProject(final File projectFolder, IProgressMonitor monitor)
+	public void mergeWithApplicationRepository(Repository repository, IProgressMonitor monitor)
+			throws MalformedURLException, URISyntaxException, IOException, OpenShiftException, CoreException,
+			InvocationTargetException {
+		String uri = getApplication().getGitUri();
+		EGitUtils.addRemoteTo("openshift", new URIish(uri), repository);
+		EGitUtils.mergeWithRemote(new URIish(uri), "refs/remotes/openshift/HEAD", repository, monitor);
+	}
+
+	private IProject getProject(String projectName) {
+		return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+	}
+
+	public boolean projectExists(final File gitProjectFolder) {
+		String projectName = gitProjectFolder.getName();
+		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+		return project.exists();
+	}
+
+	public void removeProject(String name) {
+
+	}
+
+	private List<IProject> importMavenProject(final File gitProjectFolder, IProgressMonitor monitor)
 			throws CoreException, InterruptedException {
-		MavenProjectImportOperation mavenImport = new MavenProjectImportOperation(projectFolder);
+		MavenProjectImportOperation mavenImport = new MavenProjectImportOperation(gitProjectFolder);
 		List<IProject> importedProjects = Collections.emptyList();
 		if (mavenImport.isMavenProject()) {
 			importedProjects = mavenImport.importToWorkspace(monitor);
 		} else {
-			importedProjects = new GeneralProjectImportOperation(projectFolder).importToWorkspace(monitor);
+			importedProjects = new GeneralProjectImportOperation(gitProjectFolder).importToWorkspace(monitor);
 		}
 		return importedProjects;
 	}
-	
+
 	private void connectToGitRepo(List<IProject> projects, File projectFolder, IProgressMonitor monitor)
 			throws CoreException {
-		File gitFolder = new File(projectFolder, Constants.DOT_GIT);
 		for (IProject project : projects) {
 			if (project != null) {
-				connectToGitRepo(project, gitFolder, monitor);
+				EGitUtils.connect(project, monitor);
 			}
 		}
 	}
 
-	private void connectToGitRepo(IProject project, File gitFolder, IProgressMonitor monitor) throws CoreException {
-		new ConnectProviderOperation(project, gitFolder).execute(monitor);
-	}
-
+	/**
+	 * Clones the repository of the selected OpenShift application to the user
+	 * provided path
+	 * 
+	 * @param monitor
+	 *            the monitor to report progress to
+	 * @return
+	 * @throws URISyntaxException
+	 * @throws OpenShiftException
+	 * @throws InvocationTargetException
+	 * @throws InterruptedException
+	 * 
+	 * @see ImportProjectWizardModel#getApplication()
+	 * @see #getRepositoryPath()
+	 */
 	public File cloneRepository(IProgressMonitor monitor) throws URISyntaxException, OpenShiftException,
 			InvocationTargetException,
 			InterruptedException {
 		IApplication application = getApplication();
+		monitor.subTask(NLS.bind("Cloning repository for application {0}...", application.getName()));
 		File destination = new File(getRepositoryPath(), application.getName());
 		cloneRepository(application.getGitUri(), destination, monitor);
 		return destination;
@@ -234,6 +338,18 @@
 		Activator.getDefault();
 	}
 
+	/**
+	 * creates an OpenShift server adapter for the user chosen project.
+	 * 
+	 * @param monitor
+	 *            the monitor to report progress to.
+	 * @throws OpenShiftException
+	 */
+	public void createServerAdapterIfRequired(IProgressMonitor monitor) throws OpenShiftException {
+		monitor.subTask(NLS.bind("Creating server adapter for project {0}", getProjectName()));
+		createServerAdapterIfRequired(Collections.singletonList(getProject()), monitor);
+	}
+
 	private void createServerAdapterIfRequired(List<IProject> importedProjects, IProgressMonitor monitor) {
 		Boolean b = (Boolean)getProperty(AdapterWizardPageModel.CREATE_SERVER);
 		if( b != null && b.booleanValue() ) {
@@ -291,10 +407,10 @@
 	private List<IModule> getModules(List<IProject> importedProjects) {
 		Iterator<IProject> i = importedProjects.iterator();
 		ArrayList<IModule> toAdd = new ArrayList<IModule>();
-		while(i.hasNext()) {
+		while (i.hasNext()) {
 			IProject p = i.next();
 			IModule[] m = ServerUtil.getModules(p);
-			if( m != null && m.length > 0 ) {
+			if (m != null && m.length > 0) {
 				toAdd.addAll(Arrays.asList(m));
 			}
 		}
Index: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java	(revision 36970)
@@ -10,11 +10,17 @@
  ******************************************************************************/
 package org.jboss.tools.openshift.express.internal.ui.wizard;
 
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.UIPreferences;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jgit.transport.URIish;
 import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.egit.ui.util.EGitUIUtils;
 import org.jboss.tools.openshift.express.client.IApplication;
+import org.jboss.tools.openshift.express.client.ICartridge;
 import org.jboss.tools.openshift.express.client.OpenShiftException;
+import org.jboss.tools.openshift.express.internal.client.Cartridge;
 
 /**
  * @author André Dietisheim
@@ -24,7 +30,9 @@
 
 	private static final String REMOTE_NAME_DEFAULT = "origin";
 
-	public static final String PROPERTY_GIT_URI = "gitUri";
+	public static final String PROPERTY_CLONE_URI = "cloneUri";
+//	public static final String PROPERTY_MERGE_URI = "mergeUri";
+	public static final String PROPERTY_PROJECT_NAME = "projectName";
 	public static final String PROPERTY_APPLICATION_URL = "applicationUrl";
 	public static final String PROPERTY_REPO_PATH = "repositoryPath";
 	public static final String PROPERTY_REMOTE_NAME = "remoteName";
@@ -45,18 +53,92 @@
 		setRemoteName(REMOTE_NAME_DEFAULT);
 	}
 
+	public void setProjectName(String projectName) {
+		firePropertyChange(PROPERTY_PROJECT_NAME, wizardModel.getProjectName(), wizardModel.setProjectName(projectName));
+	}
+
+	public String getProjectName() {
+		return wizardModel.getProjectName();
+	}
+
+//	public void setMergeUri(String mergeUri) {
+//		firePropertyChange(PROPERTY_MERGE_URI, wizardModel.getMergeUri(), wizardModel.setMergeUri(mergeUri));
+//	}
+//
+//	public String getMergeUri() {
+//		return wizardModel.getMergeUri();
+//	}
+
+	public GitUri getKnownMergeUri(String uriOrLabel) {
+		GitUri gitUri = null;
+		if (isGitUri(uriOrLabel)) {
+			gitUri = getKnownMergeUriByUri(uriOrLabel);
+		} else {
+			gitUri = getKnownMergeUriByLabel(uriOrLabel);
+		}
+		return gitUri;
+	}
+
+	private boolean isGitUri(String gitUriString) {
+		try {
+			URIish uriish = new URIish(gitUriString);
+			return uriish.isRemote();
+		} catch (URISyntaxException e) {
+			return false;
+		}
+	}
+
+	private GitUri getKnownMergeUriByUri(String gitUriString) {
+		GitUri matchingGitUri = null;
+		for (GitUri gitUri : getMergeUris()) {
+			if (gitUri.getGitUri().equals(gitUriString)) {
+				matchingGitUri = gitUri;
+				break;
+			}
+		}
+		return matchingGitUri;
+	}
+
+	private GitUri getKnownMergeUriByLabel(String label) {
+		GitUri matchingGitUri = null;
+		for (GitUri gitUri : getMergeUris()) {
+			if (gitUri.getLabel().equals(label)) {
+				matchingGitUri = gitUri;
+				break;
+			}
+		}
+		return matchingGitUri;
+	}
+
+	public List<GitUri> getMergeUris() {
+		ArrayList<GitUri> mergeUris = new ArrayList<GitUri>();
+		mergeUris.add(new GitUri(
+				"seambooking-example", "git://github.com/openshift/seambooking-example.git",
+				ICartridge.JBOSSAS_7));
+		mergeUris.add(new GitUri(
+				"tweetstream-example", "git://github.com/openshift/tweetstream-example.git",
+				ICartridge.JBOSSAS_7));
+		mergeUris.add(new GitUri(
+				"sinatra-example", "git://github.com/openshift/sinatra-example.git",
+				new Cartridge("rack-1.1")));
+		mergeUris.add(new GitUri(
+				"sugarcrm-example", "git://github.com/openshift/sugarcrm-example.git",
+				new Cartridge("php-5.3")));
+		return mergeUris;
+	}
+
 	public void loadGitUri() throws OpenShiftException {
 		setLoading(true);
-		setGitUri("Loading...");
-		setGitUri(getGitUri());
+		setCloneUri("Loading...");
+		setCloneUri(getCloneUri());
 		setLoading(false);
 	}
 
-	private void setGitUri(String gitUri) {
-		firePropertyChange(PROPERTY_GIT_URI, null, gitUri);
+	private void setCloneUri(String gitUri) {
+		firePropertyChange(PROPERTY_CLONE_URI, null, gitUri);
 	}
 
-	public String getGitUri() throws OpenShiftException {
+	public String getCloneUri() throws OpenShiftException {
 		IApplication application = wizardModel.getApplication();
 		if (application == null) {
 			return null;
@@ -98,11 +180,7 @@
 	}
 
 	private String getDefaultRepositoryPath() {
-		return getEGitDefaultRepositoryPath();
-	}
-
-	private String getEGitDefaultRepositoryPath() {
-		return Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR);
+		return EGitUIUtils.getEGitDefaultRepositoryPath();
 	}
 
 	public String getRemoteName() {
@@ -120,7 +198,7 @@
 	}
 
 	// TODO should this stay?
-	public ImportProjectWizardModel getParentModel() {
+	public ImportProjectWizardModel getWizardModel() {
 		return wizardModel;
 	}
 
@@ -132,4 +210,43 @@
 		firePropertyChange(PROPERTY_LOADING, this.loading, this.loading = loading);
 	}
 
+	public boolean isCompatibleToApplicationCartridge(ICartridge cartridge) {
+		IApplication application = wizardModel.getApplication();
+		return application != null
+				&& application.getCartridge() != null
+				&& application.getCartridge().equals(cartridge);
+	}
+
+	public static class GitUri {
+
+		private String label;
+		private String gitUri;
+		private ICartridge cartridge;
+
+		private GitUri(String label, String gitUri, ICartridge cartridge) {
+			this.label = label;
+			this.gitUri = gitUri;
+			this.cartridge = cartridge;
+		}
+
+		public String getLabel() {
+			return label;
+		}
+
+		public String getGitUri() {
+			return gitUri;
+		}
+
+		public String toString() {
+			return getLabel();
+		}
+
+		public ICartridge getCartridge() {
+			return cartridge;
+		}
+
+		public boolean isCompatible(ICartridge cartridge) {
+			return this.cartridge.equals(cartridge);
+		}
+	}
 }
Index: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java	(revision 36970)
@@ -11,15 +11,17 @@
 package org.jboss.tools.openshift.express.internal.ui.wizard;
 
 import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.net.URISyntaxException;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.dialogs.ErrorDialog;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
@@ -51,41 +53,65 @@
 	public boolean performFinish() {
 		try {
 			final ArrayBlockingQueue<IStatus> queue = new ArrayBlockingQueue<IStatus>(1);
-			WizardUtils.runInWizard(new Job("Cloning local git repo...") {
-				@Override
-				protected IStatus run(IProgressMonitor monitor) {
-					IStatus status = Status.OK_STATUS;
-					try {
-						File repositoryFile = model.cloneRepository(monitor);
-						model.importProject(repositoryFile, monitor);
-					} catch (OpenShiftException e) {
-						status = OpenShiftUIActivator.createErrorStatus(
-								"An exception occurred while creating local git repository.", e);
-					} catch (URISyntaxException e) {
-						status = OpenShiftUIActivator.createErrorStatus(
-								"The url of the remote git repository is not valid", e);
-					} catch (InvocationTargetException e) {
-						if (isTransportException(e)) {
-							TransportException te = getTransportException(e);
-							status = OpenShiftUIActivator.createErrorStatus(
-											"Could not clone the repository. Authentication failed.\n"
-													+ " Please make sure that you added your private key to the ssh preferences.", te);
-						} else {
-							status = OpenShiftUIActivator.createErrorStatus(
-									"An exception occurred while creating local git repository.", e);
+			WizardUtils.runInWizard(
+					new WorkspaceJob("") {
+
+						@Override
+						public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+							IStatus status = Status.OK_STATUS;
+							status = performOperations(monitor, status);
+
+							if (!status.isOK()) {
+								OpenShiftUIActivator.log(status);
+							}
+							queue.offer(status);
+							return status;
 						}
-					} catch (Exception e) {
-						status = OpenShiftUIActivator.createErrorStatus(
-								"An exception occurred while creating local git repository.", e);
-					}
 
-					if (!status.isOK()) {
-						OpenShiftUIActivator.log(status);
-					}
-					queue.offer(status);
-					return status;
-				}
-			}, getContainer());
+						private IStatus performOperations(IProgressMonitor monitor, IStatus status) {
+							try {
+								// File repositoryFile =
+								// model.cloneRepository(monitor);
+								// model.importProject(repositoryFile, monitor);
+								// Repository repository =
+								// model.shareProject(monitor);
+								// model.mergeWithApplicationRepository(repository,
+								// monitor);
+								File repositoryFile = model.cloneRepository(monitor);
+								model.copyOpenshiftConfiguration(repositoryFile, monitor);
+								model.shareProject(monitor);
+								model.createServerAdapterIfRequired(monitor);
+								return Status.OK_STATUS;
+							} catch (IOException e) {
+								status = OpenShiftUIActivator.createErrorStatus(
+										"Could not copy openshift configuration files to project {0}", e,
+										model.getProjectName());
+								return status;
+							} catch (OpenShiftException e) {
+								status = OpenShiftUIActivator.createErrorStatus(
+										"Could not import project to the workspace.", e);
+							} catch (URISyntaxException e) {
+								status = OpenShiftUIActivator.createErrorStatus(
+										"The url of the remote git repository is not valid", e);
+							} catch (InvocationTargetException e) {
+								if (isTransportException(e)) {
+									TransportException te = getTransportException(e);
+									status = OpenShiftUIActivator
+											.createErrorStatus(
+													"Could not clone the repository. Authentication failed.\n"
+															+ " Please make sure that you added your private key to the ssh preferences.",
+													te);
+								} else {
+									status = OpenShiftUIActivator.createErrorStatus(
+											"An exception occurred while creating local git repository.", e);
+								}
+							} catch (Exception e) {
+								status = OpenShiftUIActivator.createErrorStatus(
+										"Could int import project to the workspace.", e);
+							}
+							return status;
+						}
+					}, getContainer());
 			IStatus status = queue.poll(10, TimeUnit.SECONDS);
 			return status != null
 					&& status.isOK();
Index: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java	(revision 36970)
@@ -27,13 +27,19 @@
 import org.eclipse.jface.databinding.swt.WidgetProperties;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
 import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.DirectoryDialog;
 import org.eclipse.swt.widgets.Group;
@@ -48,6 +54,7 @@
 import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
 import org.jboss.tools.openshift.express.client.OpenShiftException;
 import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.wizard.AdapterWizardPageModel.GitUri;
 
 /**
  * @author André Dietisheim
@@ -55,13 +62,13 @@
  * 
  */
 public class AdapterWizardPage extends AbstractOpenShiftWizardPage implements IWizardPage, PropertyChangeListener {
-	private Text gitUriValueText;
 
 	private AdapterWizardPageModel model;
-	private IServerType serverTypeToCreate;
+	private Text cloneUriValueText;
 	private Label domainValueLabel;
 	private Label modeValueLabel;
 	private Button serverAdapterCheckbox;
+	private IServerType serverTypeToCreate;
 
 	private IObservableValue serverAdapterCheckboxObservable;
 
@@ -80,15 +87,57 @@
 	protected void doCreateControls(Composite parent, DataBindingContext dbc) {
 		GridLayoutFactory.fillDefaults().applyTo(parent);
 
-		Group projectGroup = createCloneGroup(parent, dbc);
+		Group mergeGroup = createMergeGroup(parent, dbc);
 		GridDataFactory.fillDefaults()
-				.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(projectGroup);
+				.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(mergeGroup);
+
+		Group cloneGroup = createCloneGroup(parent, dbc);
+		GridDataFactory.fillDefaults()
+				.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(cloneGroup);
 
 		Group serverAdapterGroup = createAdapterGroup(parent, dbc);
 		GridDataFactory.fillDefaults()
 				.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(serverAdapterGroup);
 	}
 
+	private Group createMergeGroup(Composite parent, DataBindingContext dbc) {
+		Group mergeGroup = new Group(parent, SWT.BORDER);
+		mergeGroup.setText("Git Merge");
+		GridDataFactory.fillDefaults()
+				.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(mergeGroup);
+		GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(mergeGroup);
+
+		Button mergeEnabledButton = new Button(mergeGroup, SWT.CHECK);
+		mergeEnabledButton.setText("merge with Git URI");
+		GridDataFactory.fillDefaults()
+				.align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(mergeEnabledButton);
+		IObservableValue mergeEnabledButtonSelection = WidgetProperties.selection().observe(mergeEnabledButton);
+		mergeEnabledButtonSelection.setValue(false);
+
+		Combo mergeUriCombo = new Combo(mergeGroup, SWT.NONE);
+		ComboViewer mergeUriComboViewer = new ComboViewer(mergeUriCombo);
+		GridDataFactory
+				.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(mergeUriCombo);
+		mergeUriComboViewer.setContentProvider(new ArrayContentProvider());
+		mergeUriComboViewer.setLabelProvider(new GitUriLabelProvider());
+		mergeUriComboViewer.setInput(model.getMergeUris());
+//		ValueBindingBuilder
+//				.bind(WidgetProperties.text().observe(mergeUriCombo))
+//				.validatingAfterGet(new MergeUriValidator())
+//				.to(BeanProperties.value(AdapterWizardPageModel.PROPERTY_MERGE_URI).observe(model))
+//				.in(dbc);
+		ValueBindingBuilder
+			.bind(WidgetProperties.text().observe(mergeUriCombo))
+			.to(BeanProperties.value(AdapterWizardPageModel.PROPERTY_PROJECT_NAME).observe(model))
+			.in(dbc);
+		ValueBindingBuilder
+				.bind(mergeEnabledButtonSelection)
+				.to(WidgetProperties.enabled().observe(mergeUriCombo))
+				.in(dbc);
+
+		return mergeGroup;
+	}
+
 	private Group createCloneGroup(Composite parent, DataBindingContext dbc) {
 		Group cloneGroup = new Group(parent, SWT.BORDER);
 		cloneGroup.setText("Git clone");
@@ -100,16 +149,16 @@
 		gitUriLabel.setText("Cloning From");
 		GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(gitUriLabel);
 
-		gitUriValueText = new Text(cloneGroup, SWT.BORDER);
-		gitUriValueText.setEditable(false);
+		cloneUriValueText = new Text(cloneGroup, SWT.BORDER);
+		cloneUriValueText.setEditable(false);
 		GridDataFactory
-				.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(gitUriValueText);
+				.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(cloneUriValueText);
 		ValueBindingBuilder
-				.bind(WidgetProperties.text(SWT.Modify).observe(gitUriValueText))
-				.notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_GIT_URI).observe(model))
+				.bind(WidgetProperties.text(SWT.Modify).observe(cloneUriValueText))
+				.notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_CLONE_URI).observe(model))
 				.in(dbc);
 		ValueBindingBuilder
-				.bind(WidgetProperties.enabled().observe(gitUriValueText))
+				.bind(WidgetProperties.enabled().observe(cloneUriValueText))
 				.notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_LOADING).observe(model))
 				.converting(new InvertingBooleanConverter())
 				.in(dbc);
@@ -274,7 +323,7 @@
 		serverAdapterCheckbox.setText("Create a JBoss server adapter");
 		serverAdapterCheckbox.addSelectionListener(new SelectionListener() {
 			public void widgetSelected(SelectionEvent e) {
-				model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
+				model.getWizardModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
 						serverAdapterCheckbox.getSelection());
 				enableServerWidgets(serverAdapterCheckbox.getSelection());
 			}
@@ -299,13 +348,13 @@
 		GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(domainLabel);
 		GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(modeLabel);
 		GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER)
-						.grab(true, false).applyTo(domainValueLabel);
+				.grab(true, false).applyTo(domainValueLabel);
 		GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER)
-						.grab(true, false).applyTo(serverAdapterCheckbox);
+				.grab(true, false).applyTo(serverAdapterCheckbox);
 		GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER)
-						.grab(true, false).applyTo(modeValueLabel);
+				.grab(true, false).applyTo(modeValueLabel);
 
-		model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
+		model.getWizardModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
 				serverAdapterCheckbox.getSelection());
 		this.serverAdapterCheckboxObservable =
 				WidgetProperties.selection().observe(serverAdapterCheckbox);
@@ -321,9 +370,9 @@
 	protected void onPageActivated(DataBindingContext dbc) {
 		model.resetRepositoryPath();
 		serverTypeToCreate = getServerTypeToCreate();
-		model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
+		model.getWizardModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
 		modeValueLabel.setText("Source");
-		model.getParentModel().setProperty(AdapterWizardPageModel.MODE, AdapterWizardPageModel.MODE_SOURCE);
+		model.getWizardModel().setProperty(AdapterWizardPageModel.MODE, AdapterWizardPageModel.MODE_SOURCE);
 		onPageActivatedBackground(dbc);
 	}
 
@@ -356,8 +405,8 @@
 		serverAdapterCheckbox.setEnabled(canCreateServer);
 		serverAdapterCheckboxObservable.setValue(canCreateServer);
 		enableServerWidgets(canCreateServer);
-		model.getParentModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
-		model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER, canCreateServer);
+		model.getWizardModel().setProperty(AdapterWizardPageModel.SERVER_TYPE, serverTypeToCreate);
+		model.getWizardModel().setProperty(AdapterWizardPageModel.CREATE_SERVER, canCreateServer);
 	}
 
 	private class SelectedRuntimeValidator extends MultiValidator {
@@ -376,4 +425,60 @@
 			return ValidationStatus.ok();
 		}
 	}
+
+	private static class GitUriLabelProvider implements ILabelProvider {
+
+		@Override
+		public void addListener(ILabelProviderListener listener) {
+		}
+
+		@Override
+		public void dispose() {
+		}
+
+		@Override
+		public boolean isLabelProperty(Object element, String property) {
+			return true;
+		}
+
+		@Override
+		public void removeListener(ILabelProviderListener listener) {
+		}
+
+		@Override
+		public Image getImage(Object element) {
+			return null;
+		}
+
+		@Override
+		public String getText(Object element) {
+			if (!(element instanceof GitUri)) {
+				return null;
+			}
+			return ((GitUri) element).getLabel();
+		}
+	}
+
+//	private class MergeUriValidator implements IValidator {
+//
+//		@Override
+//		public IStatus validate(Object value) {
+//			String mergeUri = (String) value;
+//			if (mergeUri == null
+//					|| mergeUri.length() == 0) {
+//				return ValidationStatus
+//						.warning("You have to provide a git uri to merge with");
+//			} 
+//			GitUri gitUri = model.getKnownMergeUri(mergeUri);
+//			if (gitUri == null) {
+//				return ValidationStatus
+//						.warning("You are not merging with an official example. Things may go wrong");
+//			} 
+//			if (!model.isCompatibleToApplicationCartridge(gitUri.getCartridge())) {
+//				return ValidationStatus
+//						.warning("The example you've chosen is not compatible to your application");
+//			}
+//			return ValidationStatus.ok();
+//		}
+//	}
 }
Index: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java	(revision 36970)
@@ -10,13 +10,24 @@
  ******************************************************************************/
 package org.jboss.tools.openshift.express.internal.ui.common;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.Assert;
 
 /**
  * @author André Dietisheim
  */
 public class FileUtils {
 
+	private static final byte[] buffer = new byte[1024];
+
 	public static boolean canRead(String path) {
 		if (path == null) {
 			return false;
@@ -31,5 +42,134 @@
 		return file.canRead();
 	}
 
-	
+	public static boolean exists(File file) {
+		return file != null
+				&& file.exists();
+	}
+
+	public static boolean isDirectory(File file) {
+		return file != null
+				&& file.isDirectory();
+	}
+
+	/**
+	 * Copies the ginve source to the given destination recursively. Overwrites
+	 * existing files/directory on the destination path if told so.
+	 * 
+	 * @param source
+	 *            the source file/directory to copy
+	 * @param destination
+	 *            the destination to copy to
+	 * @param overwrite
+	 *            overwrites existing files/directories if <code>true</code>.
+	 *            Does not overwrite otherwise.
+	 * @throws IOException
+	 */
+	public static void copy(File source, File destination, boolean overwrite) throws IOException {
+		if (!exists(source)
+				|| destination == null) {
+			return;
+		}
+
+		if (source.isDirectory()) {
+			copyDirectory(source, destination, overwrite);
+		} else {
+			copyFile(source, destination, overwrite);
+		}
+	}
+
+	private static void copyDirectory(File source, File destination, boolean overwrite) throws IOException {
+		Assert.isLegal(source != null);
+		Assert.isLegal(source.isDirectory());
+		Assert.isLegal(destination != null);
+
+		destination = getDestinationDirectory(source, destination);
+		
+		if (!destination.exists()) {
+			destination.mkdir();
+		}
+
+		for (File content : source.listFiles()) {
+			if (content.isDirectory()) {
+				copyDirectory(content, new File(destination, content.getName()), overwrite);
+			} else {
+				copyFile(content, new File(destination, content.getName()), overwrite);
+			}
+		}
+	}
+
+	private static File getDestinationDirectory(File source, File destination) {
+		if (!source.getName().equals(destination.getName())) {
+			destination = new File(destination, source.getName());
+		}
+		return destination;
+	}
+
+	private static void copyFile(File source, File destination, boolean overwrite) throws IOException {
+		Assert.isLegal(source != null);
+		Assert.isLegal(source.isFile());
+		Assert.isLegal(destination != null);
+
+		destination = getDestinationFile(source, destination);
+		
+		if (exists(destination)
+				&& !overwrite) {
+			return;
+		}
+
+		if (isDirectory(destination)) {
+			if (!overwrite) {
+				return;
+			}
+			destination.delete();
+		}
+
+		writeTo(source, destination);
+	}
+
+	private static File getDestinationFile(File source, File destination) {
+		if (!source.getName().equals(destination.getName())) {
+			destination = new File(destination, source.getName());
+		}
+		return destination;
+	}
+
+	private static final void writeTo(File source, File destination) throws IOException {
+		Assert.isLegal(source != null);
+		Assert.isLegal(destination != null);
+
+		InputStream in = null;
+		OutputStream out = null;
+		try {
+			in = new BufferedInputStream(new FileInputStream(source));
+			out = new BufferedOutputStream(new FileOutputStream(destination));
+			for (int read = -1; (read = in.read(buffer)) != -1; ) {
+				out.write(buffer, 0, read);
+			}
+			out.flush();
+		} finally {
+			silentlyClose(in);
+			silentlyClose(out);
+		}
+	}
+
+	private static void silentlyClose(InputStream in) {
+		try {
+			if (in != null) {
+				in.close();
+			}
+		} catch (IOException e) {
+			// ignore
+		}
+	}
+
+	private static void silentlyClose(OutputStream out) {
+		try {
+			if (out != null) {
+				out.close();
+			}
+		} catch (IOException e) {
+			// ignore
+		}
+	}
 }
Index: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java	(revision 36970)
@@ -68,6 +68,10 @@
 		log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e));
 	}
 
+	public static IStatus createErrorStatus(String message) {
+		return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, message);
+	}
+
 	public static IStatus createErrorStatus(String message, Throwable throwable) {
 		return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, message, throwable);
 	}
Index: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties	(revision 36969)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties	(revision 36970)
@@ -5,4 +5,4 @@
 # Version Delegates
 openshift.express.name=OpenShift Express Runtime
 openshift.express.description=A server adapter for use interfacing with the OpenShift Express Framework
-openshift.express.runtime.name=OpenShift Express Runtime
+openshift.express.runtime.name = OpenShift Express Runtime

