Index: plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java
===================================================================
--- plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 0)
+++ plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java	(.../trunk/openshift)	(revision 37062)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.core;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jgit.lib.Constants;
+
+public class GitIgnore {
+
+	private List<String> entries;
+	private File baseDir;
+
+	public GitIgnore(File baseDir) {
+		this.baseDir = baseDir;
+		this.entries = new ArrayList<String>();
+	}
+
+	public GitIgnore add(String entry) {
+		this.entries.add(entry);
+		return this;
+	}
+
+	/**
+	 * Writes the entries in this instance to the .gitignore file. Overwrites
+	 * and existing file if the given overwrite is set to <code>true</code>,
+	 * appends otherwise.
+	 * 
+	 * @param overwrite
+	 *            overwrites an existing file if <code>true</code>, appends
+	 *            otherwise
+	 * @throws IOException
+	 */
+	public void write(boolean overwrite) throws IOException {
+		File file = getFile();
+		BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file, !overwrite));
+		try {
+			for (String entry : entries) {
+				out.write(entry.getBytes());
+				out.write('\n');
+			}
+			out.flush();
+		} finally {
+			out.close();
+		}
+	}
+
+	public boolean exists() {
+		return getFile().exists();
+	}
+	
+	private File getFile() {
+		File file = new File(baseDir, Constants.GITIGNORE_FILENAME);
+		return file;
+	}
+}

Property changes on: plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/GitIgnore.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
===================================================================
--- plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java	(.../trunk/openshift)	(revision 37062)
@@ -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,245 @@
 
 	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));
+	}
+
+	/**
+	 * Returns <code>true</code> if the given project exists and has a .git
+	 * folder in it.
+	 * 
+	 * @param project
+	 * @return
+	 */
+	public static boolean hasDotGitFolder(IProject project) {
+		if (project == null
+				|| !project.exists()) {
+			return false;
+		}
+		return new File(project.getLocation().toOSString(), Constants.DOT_GIT).exists();
+	}
+
+	/**
+	 * 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 void commit(IProject project, String commitMessage, IProgressMonitor monitor) throws CoreException {
-		Assert.isLegal(project != null, "Cannot commit project. No project provided");
+	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 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 +325,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 +681,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: plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java
===================================================================
--- plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/internal/EGitCoreActivator.java	(.../trunk/openshift)	(revision 37062)
@@ -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: plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF
===================================================================
--- plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF	(.../trunk/openshift)	(revision 37062)
@@ -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: plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java
===================================================================
--- plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 0)
+++ plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java	(.../trunk/openshift)	(revision 37062)
@@ -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: plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF	(.../trunk/openshift)	(revision 37062)
@@ -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,19 +25,17 @@
  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,
  org.eclipse.ui.navigator;bundle-version="3.5.100",
  org.eclipse.ui.console;bundle-version="3.5.100",
- org.eclipse.core.expressions;bundle-version="3.4.300"
+ org.eclipse.core.expressions;bundle-version="3.4.300",
+ org.eclipse.wst.common.modulecore;bundle-version="1.2.101"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Import-Package: org.jboss.tools.common.databinding,
Index: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/utils/UrlUtils.java	(.../trunk/openshift)	(revision 37062)
@@ -20,8 +20,19 @@
 
 	private static final int HTTP_SCHEME_MAX_LENGTH = 8;
 	private static final char HTTP_SCHEME_START_CHAR = 'h';
-	private static final Pattern HTTP_SCHEME_REGEX = Pattern.compile("http?://");
-	
+	private static final Pattern HTTP_SCHEME_REGEX = Pattern.compile("http[s]{0,1}://");
+
+	/**
+	 * Returns an url that was found in the given text. It starts looking
+	 * backwards from the given offset within the given string. Returns
+	 * <code>null</code> if none was found.
+	 * 
+	 * @param offset
+	 *            starting point to look back in the given text.
+	 * @param text
+	 *            the text to search for an url
+	 * @return the url that was found in the text
+	 */
 	public static String getUrl(int offset, String text) {
 		int start = getUrlStart(offset, text);
 		if (start == -1) {
@@ -34,11 +45,19 @@
 		return text.substring(start, stop);
 
 	}
-	
+
+	/**
+	 * Steps back in the given text until the beginning of the text or an
+	 * occurrence of http(s):// is found.
+	 * 
+	 * @param offset the offset to start with stepping backwards 
+	 * @param text the text to search
+	 * @return the index at which http(s):// was found
+	 */
 	private static int getUrlStart(int offset, String text) {
 		for (int i = offset; i > 0; --i) {
-			if (text.charAt(i) == HTTP_SCHEME_START_CHAR 
-					&& (i + HTTP_SCHEME_MAX_LENGTH < text.length())) { 
+			if (text.charAt(i) == HTTP_SCHEME_START_CHAR
+					&& (i + HTTP_SCHEME_MAX_LENGTH < text.length())) {
 				Matcher matcher = HTTP_SCHEME_REGEX.matcher(text.substring(i, i + HTTP_SCHEME_MAX_LENGTH));
 				if (matcher.find()) {
 					return i;
Index: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/BranchNameContentProvider.java	(.../trunk/openshift)	(revision 37062)
@@ -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: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 0)
+++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java	(.../trunk/openshift)	(revision 37062)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.ide.IDE.SharedImages;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.jboss.tools.openshift.egit.core.EGitUtils;
+
+/**
+ * @author André Dietisheim
+ */
+public class SelectExistingProjectDialog extends ElementListSelectionDialog {
+
+	public SelectExistingProjectDialog(String openShiftAppName, Shell shell) {
+		super(shell, new ProjectLabelProvider());
+		setTitle("Select Existing Project");
+		setMessage(NLS.bind(
+				"Select an existing project for {0}.\nOnly java projects which are not Team shared can be used.",
+				openShiftAppName));
+		setMultipleSelection(false);
+		setAllowDuplicates(false);
+		setElements(getProjects());
+	}
+
+	private Object[] getProjects() {
+		List<IProject> projects = new ArrayList<IProject>();
+		for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+			if (isValid(project)) {
+				projects.add(project);
+			}
+		}
+		return projects.toArray();
+	}
+
+	private boolean isValid(IProject project) {
+		if (EGitUtils.isShared(project)) {
+			return false;
+		}
+
+		if (EGitUtils.hasDotGitFolder(project)) {
+			return false;
+		}
+
+		if (!hasModuleNature(project)) {
+			return false;
+		}
+
+		return true;
+	}
+
+	private boolean hasModuleNature(IProject project) {
+		try {
+			return project.hasNature(IModuleConstants.MODULE_NATURE_ID);
+		} catch(CoreException e) {
+			return false;
+		}
+	}
+
+	private static class ProjectLabelProvider extends LabelProvider {
+
+		@Override
+		public Image getImage(Object element) {
+			return PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT);
+		}
+
+		@Override
+		public String getText(Object element) {
+			if (!(element instanceof IProject)) {
+				return null;
+			}
+
+			return ((IProject) element).getName();
+		}
+
+	}
+
+}

Property changes on: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizardModel.java	(.../trunk/openshift)	(revision 37062)
@@ -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,7 +23,8 @@
 import java.util.List;
 
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
@@ -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,15 @@
 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.egit.core.GitIgnore;
 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;
 
@@ -63,15 +69,23 @@
 
 	private HashMap<String, Object> dataModel = new HashMap<String, Object>();
 
+	public static final String NEW_PROJECT = "enableProject";
 	public static final String USER = "user";
 	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 ImportProjectWizardModel() {
+		dataModel.put(NEW_PROJECT, false);
+	}
+
+	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 +97,7 @@
 	}
 
 	public IUser getUser() {
-		return (IUser)getProperty(USER);
+		return (IUser) getProperty(USER);
 	}
 
 	public IApplication getApplication() {
@@ -116,7 +130,7 @@
 		}
 		return cartridgeName;
 	}
-	
+
 	public void setApplication(IApplication application) {
 		setProperty(APPLICATION, application);
 	}
@@ -131,76 +145,219 @@
 	}
 
 	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,
-			CoreException,
-			InterruptedException {
-		new WorkspaceJob(NLS.bind("Importing projects from {0}", projectFolder.getAbsolutePath())) {
+	public boolean isNewProject() {
+		return (Boolean) getProperty(NEW_PROJECT);
+	}
 
-			@Override
-			public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
-				try {
-					List<IProject> importedProjects = importMavenProject(projectFolder, monitor);
-					connectToGitRepo(importedProjects, projectFolder, 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);
-					OpenShiftUIActivator.log(status);
-					return status;
-				}
-			}
+	public Boolean setNewProject(boolean newProject) {
+		return (Boolean) setProperty(NEW_PROJECT, newProject);
+	}
 
-		}.schedule();
+	public String setProjectName(String projectName) {
+		return (String) setProperty(PROJECT_NAME, projectName);
 	}
 
-	private List<IProject> importMavenProject(final File projectFolder, IProgressMonitor monitor)
+	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
+	 */
+	private void shareProject(IProgressMonitor monitor) throws CoreException {
+		monitor.subTask(NLS.bind("Sharing project {0}...", getProjectName()));
+		EGitUtils.share(getProject(), monitor);
+	}
+
+	private void copyOpenshiftConfiguration(final File sourceFolder, IProgressMonitor monitor)
+			throws IOException {
+		IProject project = getProject();
+		File projectFolder = project.getLocation().toFile();
+		monitor.subTask(NLS.bind("Copying openshift configuration to project {0}...", getProjectName()));
+		FileUtils.copy(new File(sourceFolder, ".git"), projectFolder, false);
+		FileUtils.copy(new File(sourceFolder, ".openshift"), projectFolder, false);
+		FileUtils.copy(new File(sourceFolder, "deployments"), projectFolder, false);
+		FileUtils.copy(new File(sourceFolder, "pom.xml"), projectFolder, false);
+		createGitIgnore(projectFolder);
+	}
+
+	/**
+	 * Creates the git ignore file with a predefined set of entries. An existing
+	 * .gitignore file is not overwritten, we then just dont do anything.
+	 * 
+	 * @param projectFolder
+	 * @throws IOException
+	 */
+	private void createGitIgnore(File projectFolder) throws IOException {
+		GitIgnore gitIgnore = new GitIgnore(projectFolder);
+		// TODO: merge existing .gitignore
+		// (https://issues.jboss.org/browse/JBIDE-10391)
+		if (gitIgnore.exists()) {
+			return;
+		}
+		gitIgnore.add("target")
+				.add(".settings")
+				.add(".project")
+				.add(".classpath")
+				.add(".factorypath");
+		gitIgnore.write(false);
+	}
+
+	/**
+	 * Returns the user provided project.
+	 * 
+	 * @throws OpenShiftException
+	 * 
+	 * @see #getProjectName
+	 */
+	private IProject getProject() {
+		String projectName = getProjectName();
+		IProject project = getProject(projectName);
+		Assert.isTrue(project != null && project.exists(),
+				NLS.bind("Could not find project {0} in your workspace.", projectName));
+		return project;
+	}
+
+	public void importProject(IProgressMonitor monitor)
+			throws OpenShiftException, CoreException, InterruptedException, URISyntaxException,
+			InvocationTargetException {
+		File repositoryFolder = cloneRepository(monitor);
+		List<IProject> importedProjects = importMavenProject(repositoryFolder, monitor);
+		connectToGitRepo(importedProjects, repositoryFolder, monitor);
+		createServerAdapterIfRequired(importedProjects, monitor);
+	}
+
+	/**
+	 * Enables the user chosen project to be used on the chosen OpenShift
+	 * application. Clones the application git repository, copies the
+	 * configuration files to the user project (in the workspace), shares the
+	 * user project with git and creates the server adapter.
+	 * 
+	 * @param monitor
+	 *            the monitor to report progress to
+	 * @throws URISyntaxException
+	 *             The OpenShift application repository could not be cloned,
+	 *             because the uri it is located at is not a valid git uri
+	 * @throws OpenShiftException
+	 * 
+	 * @throws InvocationTargetException
+	 *             The OpenShift application repository could not be cloned, the
+	 *             clone operation failed.
+	 * @throws InterruptedException
+	 *             The OpenShift application repository could not be cloned, the
+	 *             clone operation was interrupted.
+	 * @throws IOException
+	 *             The configuration files could not be copied from the git
+	 *             clone to the user project
+	 * @throws CoreException
+	 *             The user project could not be shared with the git
+	 * 
+	 * @see #cloneRepository
+	 * @see #copyOpenshiftConfiguration
+	 * @see #shareProject
+	 * @see #createServerAdapterIfRequired
+	 */
+	public void addToExistingProject(IProgressMonitor monitor)
+			throws OpenShiftException, InvocationTargetException, InterruptedException, IOException, CoreException,
+			URISyntaxException {
+		// File repositoryFile =
+		// model.cloneRepository(monitor);
+		// model.importProject(repositoryFile, monitor);
+		// Repository repository =
+		// model.shareProject(monitor);
+		// model.mergeWithApplicationRepository(repository,
+		// monitor);
+		File repositoryFile = cloneRepository(monitor);
+		copyOpenshiftConfiguration(repositoryFile, monitor);
+		shareProject(monitor);
+		createServerAdapterIfRequired(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();
+	}
+
+	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);
-	}
-
-	public File cloneRepository(IProgressMonitor monitor) throws URISyntaxException, OpenShiftException,
-			InvocationTargetException,
-			InterruptedException {
+	/**
+	 * 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()
+	 */
+	private File cloneRepository(IProgressMonitor monitor)
+			throws OpenShiftException, InvocationTargetException, InterruptedException, URISyntaxException {
 		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;
 	}
 
-	private void cloneRepository(String uri, File destination, IProgressMonitor monitor) throws URISyntaxException,
-			OpenShiftException,
-			InvocationTargetException,
-			InterruptedException {
+	private void cloneRepository(String uri, File destination, IProgressMonitor monitor)
+			throws OpenShiftException, URISyntaxException, InvocationTargetException, InterruptedException {
 		if (destination.exists()) {
 			FileUtil.completeDelete(destination);
 		}
@@ -234,17 +391,30 @@
 		Activator.getDefault();
 	}
 
+	/**
+	 * creates an OpenShift server adapter for the user chosen project.
+	 * 
+	 * @param monitor
+	 *            the monitor to report progress to.
+	 * @throws OpenShiftException
+	 */
+	private 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() ) {
+		Boolean b = (Boolean) getProperty(AdapterWizardPageModel.CREATE_SERVER);
+		if (b != null && b.booleanValue()) {
 			try {
 				renameWebContextRoot(importedProjects);
 				IServer server = createServerAdapter();
 				addModules(getModules(importedProjects), server, monitor);
-			} catch(CoreException ce) {
+			} catch (CoreException ce) {
 				OpenShiftUIActivator.getDefault().getLog().log(ce.getStatus());
-			} catch(OpenShiftException ose) {
-				IStatus s = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, "Cannot create openshift server adapter", ose);
+			} catch (OpenShiftException ose) {
+				IStatus s = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
+						"Cannot create openshift server adapter", ose);
 				OpenShiftUIActivator.getDefault().getLog().log(s);
 			}
 		}
@@ -262,16 +432,16 @@
 
 	private IServer createServerAdapter() throws CoreException,
 			OpenShiftException {
-		IServerType type = (IServerType)getProperty(AdapterWizardPageModel.SERVER_TYPE);
-		IRuntime rt = (IRuntime)getProperty(AdapterWizardPageModel.RUNTIME_DELEGATE);
-		String mode = (String)getProperty(AdapterWizardPageModel.MODE);
+		IServerType type = (IServerType) getProperty(AdapterWizardPageModel.SERVER_TYPE);
+		IRuntime rt = (IRuntime) getProperty(AdapterWizardPageModel.RUNTIME_DELEGATE);
+		String mode = (String) getProperty(AdapterWizardPageModel.MODE);
 
 		String serverNameBase = getApplication().getName() + " OpenShift Server";
 		String serverName = org.jboss.ide.eclipse.as.core.util.ServerUtil.getDefaultServerName(serverNameBase);
-		
+
 		IServer server = ExpressServerUtils.createServer(rt, type, serverName);
-		ExpressServerUtils.fillServerWithOpenShiftDetails(server, getApplication().getApplicationUrl(), 
-				getUser().getRhlogin(), getUser().getPassword(), 
+		ExpressServerUtils.fillServerWithOpenShiftDetails(server, getApplication().getApplicationUrl(),
+				getUser().getRhlogin(), getUser().getPassword(),
 				getUser().getDomain().getNamespace(), getApplication().getName(), getApplication().getUUID(), mode);
 		return server;
 	}
@@ -285,16 +455,16 @@
 		IModule[] add = modules.toArray(new IModule[modules.size()]);
 		wc.modifyModules(add, new IModule[0], new NullProgressMonitor());
 		server = wc.save(true, monitor);
-		((Server)server).setModulePublishState(add, IServer.PUBLISH_STATE_NONE);
+		((Server) server).setModulePublishState(add, IServer.PUBLISH_STATE_NONE);
 	}
 
 	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: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPageModel.java	(.../trunk/openshift)	(revision 37062)
@@ -10,10 +10,10 @@
  ******************************************************************************/
 package org.jboss.tools.openshift.express.internal.ui.wizard;
 
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.UIPreferences;
 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;
 
 /**
@@ -24,7 +24,10 @@
 
 	private static final String REMOTE_NAME_DEFAULT = "origin";
 
-	public static final String PROPERTY_GIT_URI = "gitUri";
+	public static final String PROPERTY_NEW_PROJECT = "newProject";
+	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";
@@ -43,20 +46,103 @@
 	public AdapterWizardPageModel(ImportProjectWizardModel wizardModel) {
 		this.wizardModel = wizardModel;
 		setRemoteName(REMOTE_NAME_DEFAULT);
+		setNewProject(true);
 	}
 
+	public void setNewProject(boolean newProject) {
+		firePropertyChange(PROPERTY_NEW_PROJECT, wizardModel.isNewProject(), wizardModel.setNewProject(newProject));
+	}
+
+	public boolean isNewProject() {
+		return wizardModel.isNewProject();
+	}
+	
+	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;
@@ -79,6 +165,22 @@
 		return application.getApplicationUrl();
 	}
 
+	public String getApplicationName() {
+		IApplication application = wizardModel.getApplication();
+		if (application == null) {
+			return null;
+		}
+		return application.getName();
+	}
+
+	public boolean isJBossAS7Application() {
+		IApplication application = wizardModel.getApplication();
+		if (application == null) {
+			return false;
+		}
+		return ICartridge.JBOSSAS_7.equals(application.getCartridge());
+	}
+
 	public void setApplicationUrl(String applicationUrl) {
 		firePropertyChange(PROPERTY_APPLICATION_URL, null, applicationUrl);
 	}
@@ -98,13 +200,9 @@
 	}
 
 	private String getDefaultRepositoryPath() {
-		return getEGitDefaultRepositoryPath();
+		return EGitUIUtils.getEGitDefaultRepositoryPath();
 	}
 
-	private String getEGitDefaultRepositoryPath() {
-		return Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR);
-	}
-
 	public String getRemoteName() {
 		return wizardModel.getRemoteName();
 	}
@@ -120,7 +218,7 @@
 	}
 
 	// TODO should this stay?
-	public ImportProjectWizardModel getParentModel() {
+	public ImportProjectWizardModel getWizardModel() {
 		return wizardModel;
 	}
 
@@ -132,4 +230,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: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportProjectWizard.java	(.../trunk/openshift)	(revision 37062)
@@ -10,21 +10,24 @@
  ******************************************************************************/
 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.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jgit.api.errors.JGitInternalException;
 import org.eclipse.jgit.errors.TransportException;
+import org.eclipse.osgi.util.NLS;
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
 import org.jboss.tools.common.ui.WizardUtils;
@@ -51,41 +54,61 @@
 	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("Importing project to workspace...") {
+
+						@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 {
+								if (model.isNewProject()) {
+									model.importProject(monitor);
+								} else {
+									if (!askForConfirmation(model.getApplicationName(), model.getProjectName())) {
+										return Status.CANCEL_STATUS;
+									}
+									model.addToExistingProject(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();
@@ -97,6 +120,22 @@
 		}
 	}
 
+	private boolean askForConfirmation(final String applicationName, final String projectName) {
+		final boolean[] confirmed = new boolean[1]; 
+		getShell().getDisplay().syncExec(new Runnable() {
+
+			@Override
+			public void run() {
+				confirmed[0] = MessageDialog.openConfirm(getShell(), 
+						NLS.bind("Import OpenShift Application ", applicationName), 
+						NLS.bind(
+								"OpenShift application {0} will be enabled on project {1} by copying OpenShift " +
+								"configuration and enable Git for the project.\n " +
+						"This cannot be undone. Do you wish to continue ?", applicationName, projectName));
+			}});
+		return confirmed[0]; 
+	}
+
 	@Override
 	public void addPages() {
 		this.model = new ImportProjectWizardModel();
Index: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java	(.../trunk/openshift)	(revision 37062)
@@ -20,19 +20,21 @@
 import org.eclipse.core.databinding.validation.IValidator;
 import org.eclipse.core.databinding.validation.MultiValidator;
 import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.resources.IProject;
 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.databinding.swt.WidgetProperties;
+import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;
 import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.osgi.util.NLS;
 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.layout.FillLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.DirectoryDialog;
@@ -55,20 +57,22 @@
  * 
  */
 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;
+	private IObservableValue newProjectCheckboxIsEnabled;
 
 	public AdapterWizardPage(ImportProjectWizard wizard, ImportProjectWizardModel model) {
 		super(
-				"Import Project",
-				"Select the Git clone destination, the branch to clone "
+				"Import OpenShift application",
+				"Choose to create a new/use existing project, " +
+						"the GITbranch and clone destination, "
 						+ "and configure your server adapter ",
 				"Server Adapter",
 				wizard);
@@ -80,15 +84,86 @@
 	protected void doCreateControls(Composite parent, DataBindingContext dbc) {
 		GridLayoutFactory.fillDefaults().applyTo(parent);
 
-		Group projectGroup = createCloneGroup(parent, dbc);
+		Group mergeGroup = createProjectGroup(parent, dbc);
 		GridDataFactory.fillDefaults()
-				.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(projectGroup);
+				.align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(mergeGroup);
 
+		Group cloneGroup = createCloneGroup(parent, dbc);
+		GridDataFactory.fillDefaults()
+				.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);
+				.align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(serverAdapterGroup);
+
+		Label fillerLabel = new Label(parent, SWT.NONE);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(fillerLabel);
+
 	}
 
+	private Group createProjectGroup(Composite parent, DataBindingContext dbc) {
+		Group projectGroup = new Group(parent, SWT.BORDER);
+		projectGroup.setText("Project");
+		GridDataFactory.fillDefaults()
+				.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(projectGroup);
+		GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(3).applyTo(projectGroup);
+
+		Button newProjectCheckbox = new Button(projectGroup, SWT.CHECK);
+		newProjectCheckbox.setText("Create new Project");
+		GridDataFactory.fillDefaults()
+				.span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, true).applyTo(newProjectCheckbox);
+		IObservableValue newProjectObservable =
+				BeanProperties.value(AdapterWizardPageModel.PROPERTY_NEW_PROJECT).observe(model);
+		ValueBindingBuilder
+				.bind(WidgetProperties.selection().observe(newProjectCheckbox))
+				.to(newProjectObservable)
+				.in(dbc);
+
+		this.newProjectCheckboxIsEnabled = WidgetProperties.enabled().observe(newProjectCheckbox);
+
+		Label existingProjectLabel = new Label(projectGroup, SWT.NONE);
+		existingProjectLabel.setText("Existing Project");
+		GridDataFactory
+				.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(existingProjectLabel);
+		ValueBindingBuilder
+				.bind(WidgetProperties.enabled().observe(existingProjectLabel))
+				.notUpdating(newProjectObservable)
+				.converting(new InvertingBooleanConverter())
+				.in(dbc);
+		Text newProjectText = new Text(projectGroup, SWT.BORDER);
+		newProjectText.setEditable(false);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.CENTER).grab(true, true).applyTo(newProjectText);
+
+		IObservableValue newProjectNameObservable =
+				BeanProperties.value(AdapterWizardPageModel.PROPERTY_PROJECT_NAME).observe(model);
+		ValueBindingBuilder
+				.bind(WidgetProperties.text().observe(newProjectText))
+				.to(newProjectNameObservable)
+				.in(dbc);
+		ValueBindingBuilder
+				.bind(WidgetProperties.enabled().observe(newProjectText))
+				.notUpdating(newProjectObservable)
+				.converting(new InvertingBooleanConverter())
+				.in(dbc);
+		dbc.addValidationStatusProvider(
+				new NewProjectValidator(newProjectObservable, newProjectNameObservable));
+
+		Button browseProjectsButton = new Button(projectGroup, SWT.NONE);
+		browseProjectsButton.setText("Browse");
+		GridDataFactory.fillDefaults()
+				.align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseProjectsButton);
+		browseProjectsButton.addSelectionListener(onBrowseProjects());
+		ValueBindingBuilder
+				.bind(WidgetProperties.enabled().observe(browseProjectsButton))
+				.notUpdating(newProjectObservable)
+				.converting(new InvertingBooleanConverter())
+				.in(dbc);
+
+		return projectGroup;
+	}
+
 	private Group createCloneGroup(Composite parent, DataBindingContext dbc) {
 		Group cloneGroup = new Group(parent, SWT.BORDER);
 		cloneGroup.setText("Git clone");
@@ -100,16 +175,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);
@@ -204,6 +279,24 @@
 		return cloneGroup;
 	}
 
+	private SelectionListener onBrowseProjects() {
+		return new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				SelectExistingProjectDialog dialog =
+						new SelectExistingProjectDialog(model.getApplicationName(), getShell());
+				if (dialog.open() == Dialog.OK) {
+					Object selectedProject = dialog.getFirstResult();
+					if (selectedProject instanceof IProject) {
+						model.setProjectName(((IProject) selectedProject).getName());
+					}
+				}
+			}
+
+		};
+	}
+
 	private SelectionListener onDefaultRepoPath() {
 		return new SelectionAdapter() {
 
@@ -251,79 +344,77 @@
 
 	private Group createAdapterGroup(Composite parent, DataBindingContext dbc) {
 		Group serverAdapterGroup = new Group(parent, SWT.BORDER);
-		serverAdapterGroup.setText("JBoss Server adapter");
-		FillLayout fillLayout = new FillLayout();
-		fillLayout.marginHeight = 6;
-		fillLayout.marginWidth = 6;
-		serverAdapterGroup.setLayout(fillLayout);
-		fillServerAdapterGroup(serverAdapterGroup);
+		serverAdapterGroup.setText("Server Adapter");
+		GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(serverAdapterGroup);
 
-		return serverAdapterGroup;
-	}
-
-	protected void enableServerWidgets(boolean enabled) {
-		domainValueLabel.setEnabled(enabled);
-		modeValueLabel.setEnabled(enabled);
-	}
-
-	private void fillServerAdapterGroup(Group serverAdapterGroup) {
 		Composite c = new Composite(serverAdapterGroup, SWT.NONE);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(c);
 		GridLayoutFactory.fillDefaults().numColumns(3).spacing(12, 8).applyTo(c);
 
 		serverAdapterCheckbox = new Button(c, SWT.CHECK);
-		serverAdapterCheckbox.setText("Create a JBoss server adapter");
-		serverAdapterCheckbox.addSelectionListener(new SelectionListener() {
-			public void widgetSelected(SelectionEvent e) {
-				model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
-						serverAdapterCheckbox.getSelection());
-				enableServerWidgets(serverAdapterCheckbox.getSelection());
-			}
+		serverAdapterCheckbox.setText("Create OpenShift Server Adapter");
+		GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER)
+				.grab(true, false).applyTo(serverAdapterCheckbox);
+		serverAdapterCheckbox.addSelectionListener(onCreateAdapter());
 
-			public void widgetDefaultSelected(SelectionEvent e) {
-			}
-		});
-
 		Label domainLabel = new Label(c, SWT.NONE);
+		GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(domainLabel);
 		domainLabel.setText("Host");
 		domainValueLabel = new Label(c, SWT.NONE);
-		DataBindingContext dbc = getDataBindingContext();
+		GridDataFactory.fillDefaults()
+				.span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(domainValueLabel);
 		ValueBindingBuilder
 				.bind(WidgetProperties.text().observe(domainValueLabel))
 				.notUpdating(BeanProperties.value(AdapterWizardPageModel.PROPERTY_APPLICATION_URL).observe(model))
 				.in(dbc);
-		// appLabel = new Label(c, SWT.NONE);
+
 		Label modeLabel = new Label(c, SWT.NONE);
 		modeLabel.setText("Mode");
+		GridDataFactory.fillDefaults()
+				.align(SWT.LEFT, SWT.CENTER).applyTo(modeLabel);
 		modeValueLabel = new Label(c, SWT.NONE);
+		GridDataFactory.fillDefaults()
+				.span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(modeValueLabel);
 
-		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);
-		GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER)
-						.grab(true, false).applyTo(serverAdapterCheckbox);
-		GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER)
-						.grab(true, false).applyTo(modeValueLabel);
-
-		model.getParentModel().setProperty(AdapterWizardPageModel.CREATE_SERVER,
-				serverAdapterCheckbox.getSelection());
+		model.getWizardModel().setProperty(
+				AdapterWizardPageModel.CREATE_SERVER, serverAdapterCheckbox.getSelection());
 		this.serverAdapterCheckboxObservable =
 				WidgetProperties.selection().observe(serverAdapterCheckbox);
 
-		SelectedRuntimeValidator selectedRuntimeValidator = new SelectedRuntimeValidator();
-		dbc.addValidationStatusProvider(selectedRuntimeValidator);
+		return serverAdapterGroup;
 	}
 
+	private SelectionListener onCreateAdapter() {
+		return new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				model.getWizardModel().setProperty(
+						AdapterWizardPageModel.CREATE_SERVER, serverAdapterCheckbox.getSelection());
+				enableServerWidgets(serverAdapterCheckbox.getSelection());
+			}
+		};
+	}
+
+	protected void enableServerWidgets(boolean enabled) {
+		domainValueLabel.setEnabled(enabled);
+		modeValueLabel.setEnabled(enabled);
+	}
+
 	private IServerType getServerTypeToCreate() {
 		return ServerCore.findServerType("org.jboss.tools.openshift.express.openshift.server.type");
 	}
 
 	protected void onPageActivated(DataBindingContext dbc) {
+		// allow to enable a proj only for as7 openshift applications
+		setTitle(NLS.bind("Import OpenShift application {0}", model.getApplicationName()));
+
+		newProjectCheckboxIsEnabled.setValue(model.isJBossAS7Application());
+
 		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);
 	}
 
@@ -334,7 +425,9 @@
 					model.loadGitUri();
 					model.loadApplicationUrl();
 				} catch (OpenShiftException e) {
-					OpenShiftUIActivator.log(OpenShiftUIActivator.createErrorStatus(e.getMessage(), e));
+					IStatus status = OpenShiftUIActivator.createErrorStatus(e.getMessage(), e);
+					OpenShiftUIActivator.log(status);
+					return status;
 				}
 				return Status.OK_STATUS;
 			}
@@ -356,12 +449,25 @@
 		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 {
+	/**
+	 * A multi validator that validates the state of the project that shall be
+	 * (OpenShift) enabled
+	 */
+	private class NewProjectValidator extends MultiValidator {
 
+		private IObservableValue newProjectObservable;
+		private IObservableValue newProjectNameObservable;
+
+		public NewProjectValidator(IObservableValue newProjectObservable,
+				IObservableValue newProjectNameObservable) {
+			this.newProjectObservable = newProjectObservable;
+			this.newProjectNameObservable = newProjectNameObservable;
+		}
+
 		@Override
 		protected IStatus validate() {
 			/**
@@ -370,10 +476,73 @@
 			 * is tracking what observables are read to know when he has to
 			 * recalculate it's state.
 			 */
-			if (Boolean.FALSE.equals(serverAdapterCheckboxObservable.getValue())) {
+			if (Boolean.TRUE.equals(newProjectObservable.getValue())) {
 				return ValidationStatus.ok();
 			}
-			return ValidationStatus.ok();
+
+			if (newProjectNameObservable.getValue() != null
+					&& (!((String) newProjectNameObservable.getValue()).isEmpty())) {
+				return ValidationStatus.ok();
+			} else {
+				return ValidationStatus.error(
+						"Select an existing project to use with OpenShift");
+			}
 		}
 	}
+
+	// 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: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/common/FileUtils.java	(.../trunk/openshift)	(revision 37062)
@@ -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,140 @@
 		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;
+		writeTo(new BufferedInputStream(new FileInputStream(source)), destination);
+	}
+
+	private static final void writeTo(InputStream in, File destination) throws IOException {
+		Assert.isLegal(in != null);
+		Assert.isLegal(destination != null);
+
+		OutputStream out = null;
+		try {
+			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: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java	(.../trunk/openshift)	(revision 37062)
@@ -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: plugins/org.jboss.tools.openshift.express.ui/plugin.properties
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/plugin.properties	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/plugin.properties	(.../trunk/openshift)	(revision 37062)
@@ -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
Index: plugins/org.jboss.tools.openshift.express.ui/build.properties
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/build.properties	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/build.properties	(.../trunk/openshift)	(revision 37062)
@@ -5,4 +5,11 @@
                pom.xml,\
                META-INF/,\
                bin/,\
-               plugin.xml
+               plugin.xml,\
+               plugin.properties
+src.includes = plugin.properties,\
+               META-INF/,\
+               bin/,\
+               icons/,\
+               plugin.xml,\
+               pom.xml
Index: plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- plugins/org.jboss.tools.openshift.express.ui/plugin.xml	(.../branches/jbosstools-3.3.0.M5/openshift)	(revision 37062)
+++ plugins/org.jboss.tools.openshift.express.ui/plugin.xml	(.../trunk/openshift)	(revision 37062)
@@ -212,7 +212,7 @@
           type="org.eclipse.ui.console.MessageConsole">
       </propertyTester>
     </extension>
-    
+  
     <extension  point="org.eclipse.ui.editors.templates">    
         <template id="org.jboss.tools.maven.editor.xml.templates.profiles.openshift"
          contextTypeId="org.eclipse.m2e.editor.xml.templates.contextType.profiles"
@@ -238,8 +238,5 @@
     &lt;/build&gt;
 &lt;/profile&gt;</pattern>
        </template>
-    </extension>
-    
-    
-    
+    </extension>      
 </plugin>

Property changes on: plugins/org.jboss.tools.openshift.express.client
___________________________________________________________________
Modified: svn:ignore
   - target

   + build
bin
target
buildlog.latest.txt



Property changes on: tests/org.jboss.tools.openshift.ui.bot.test
___________________________________________________________________
Added: svn:ignore
   + build
bin
target
buildlog.latest.txt



Property changes on: tests/org.jboss.tools.openshift.egit.test
___________________________________________________________________
Modified: svn:ignore
   - target

   + build
bin
target
buildlog.latest.txt


