Author: adietish
Date: 2012-01-17 13:25:01 -0500 (Tue, 17 Jan 2012)
New Revision: 37906
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/META-INF/MANIFEST.MF
trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF
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.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AbstractImportApplicationOperation.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureUnsharedProject.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportNewProject.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java
Log:
[JBIDE-10479] implemented basic import strategy to enable OpenShift on git shared projects
in your workspace
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/META-INF/MANIFEST.MF
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/META-INF/MANIFEST.MF 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/META-INF/MANIFEST.MF 2012-01-17
18:25:01 UTC (rev 37906)
@@ -7,8 +7,8 @@
Require-Bundle: org.jboss.ide.eclipse.as.core;bundle-version="2.3.0",
org.eclipse.jgit;bundle-version="[1.0.0,2.1.0)",
org.eclipse.egit;bundle-version="[1.0.0,2.0.0)",
+ com.jcraft.jsch;bundle-version="0.1.44",
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.team.core;bundle-version="[3.6.0,4.0.0)",
org.eclipse.wst.server.core;bundle-version="[1.1.302,2.0.0)",
org.eclipse.core.resources;bundle-version="[3.7.100,4.0.0)",
Modified: 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 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/META-INF/MANIFEST.MF 2012-01-17
18:25:01 UTC (rev 37906)
@@ -4,15 +4,16 @@
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,2.0.0)",
+Require-Bundle:
org.jboss.tools.openshift.egit.core;bundle-version="[2.3.0,3.0.0)",
+ 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)",
+ com.jcraft.jsch;bundle-version="[0.1.44,1.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)",
- org.eclipse.ui.ide;bundle-version="[3.7.0,4.0.0)",
- org.jboss.tools.openshift.egit.core;bundle-version="0.0.1"
+ org.eclipse.ui.ide;bundle-version="[3.7.0,4.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: JBoss by Red Hat
Modified:
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 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.ui/src/org/jboss/tools/openshift/egit/ui/util/EGitUIUtils.java 2012-01-17
18:25:01 UTC (rev 37906)
@@ -10,13 +10,56 @@
******************************************************************************/
package org.jboss.tools.openshift.egit.ui.util;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.egit.core.RepositoryUtil;
+import org.eclipse.egit.core.op.CloneOperation.PostCloneTask;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.transport.JschConfigSessionFactory;
+/**
+ * @author Andre Dietisheim
+ */
public class EGitUIUtils {
+ /**
+ * A post clone task that will add the new repo (that was created when
+ * cloning) to the EGit repositories view.
+ */
+ public static final PostCloneTask ADD_TO_REPOVIEW_TASK = new PostCloneTask() {
+
+ @Override
+ public void execute(Repository repository, IProgressMonitor monitor) throws
CoreException {
+ RepositoryUtil repositoryUtil = Activator.getDefault().getRepositoryUtil();
+ repositoryUtil.addConfiguredRepository(repository.getDirectory());
+ }
+ };
+
public static String getEGitDefaultRepositoryPath() {
return
Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR);
}
+ /**
+ * The EGit UI plugin initializes the ssh factory to present the user a
+ * passphrase prompt if the ssh key was not read yet. If this initialization
+ * is not executed, the ssh connection to the git repo would just fail with
+ * an authentication error. We therefore have to make sure that the EGit UI
+ * plugin is started and initializes the JSchConfigSessionFactory.
+ * <p>
+ * EGit initializes the SshSessionFactory with the EclipseSshSessionFactory.
+ * The EclipseSshSessionFactory overrides JschConfigSessionFactory#configure
+ * to present a UserInfoPrompter if the key passphrase was not entered
+ * before.
+ *
+ * @see Activator#start(org.osgi.framework.BundleContext)
+ * @see Activator#setupSSH
+ * @see JschConfigSessionFactory#configure
+ * @see EclipseSshSessionFactory#configure
+ */
+ public static void ensureEgitUIIsStarted() {
+ Activator.getDefault();
+ }
+
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/SelectExistingProjectDialog.java 2012-01-17
18:25:01 UTC (rev 37906)
@@ -54,13 +54,11 @@
private boolean isValid(IProject project) {
if (EGitUtils.isShared(project)) {
- return false;
+ if (!EGitUtils.isSharedWithGit(project)) {
+ return false;
+ }
}
- if (EGitUtils.hasDotGitFolder(project)) {
- return false;
- }
-
if (!hasModuleNature(project)) {
return false;
}
@@ -71,7 +69,7 @@
private boolean hasModuleNature(IProject project) {
try {
return project.hasNature(IModuleConstants.MODULE_NATURE_ID);
- } catch(CoreException e) {
+ } catch (CoreException e) {
return false;
}
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AbstractImportApplicationOperation.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AbstractImportApplicationOperation.java 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AbstractImportApplicationOperation.java 2012-01-17
18:25:01 UTC (rev 37906)
@@ -18,13 +18,9 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.egit.core.RepositoryUtil;
-import org.eclipse.egit.core.op.CloneOperation;
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.transport.JschConfigSessionFactory;
-import org.eclipse.jgit.transport.URIish;
import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.openshift.egit.core.EGitUtils;
+import org.jboss.tools.openshift.egit.ui.util.EGitUIUtils;
import com.openshift.express.client.IApplication;
import com.openshift.express.client.OpenShiftException;
@@ -34,8 +30,6 @@
*/
abstract class AbstractImportApplicationOperation implements IImportApplicationStrategy
{
- private static final int CLONE_TIMEOUT = 10 * 1024;
-
private String projectName;
private IApplication application;
private String remoteName;
@@ -48,58 +42,44 @@
/**
* Clones the repository of the selected OpenShift application to the user
- * provided path
+ * provided path.
*
+ * @param application
+ * the application to clone
+ * @param remoteName
+ * the name of the remote repo to clone
+ * @param destination
+ * the destination to clone to
+ * @param addToRepoView
+ * if true, the clone repo will get added to the (egit)
+ * repositories view
* @param monitor
* the monitor to report progress to
- * @return
- * @throws URISyntaxException
+ *
+ * @return the location of the cloned repository
* @throws OpenShiftException
* @throws InvocationTargetException
* @throws InterruptedException
+ * @throws URISyntaxException
*
* @see AbstractImportApplicationOperation#getApplication()
* @see #getRepositoryPath()
*/
- protected File cloneRepository(IApplication application, String remoteName, File
destination, IProgressMonitor monitor)
+ protected File cloneRepository(IApplication application, String remoteName, File
destination,
+ boolean addToRepoView, IProgressMonitor monitor)
throws OpenShiftException, InvocationTargetException, InterruptedException,
URISyntaxException {
monitor.subTask(NLS.bind("Cloning repository for application {0}...",
application.getName()));
- cloneRepository(application.getGitUri(), remoteName, destination, monitor);
+ EGitUIUtils.ensureEgitUIIsStarted();
+ if (addToRepoView) {
+ EGitUtils.cloneRepository(
+ application.getGitUri(), remoteName, destination, EGitUIUtils.ADD_TO_REPOVIEW_TASK,
monitor);
+ } else {
+ EGitUtils.cloneRepository(
+ application.getGitUri(), remoteName, destination, monitor);
+ }
return destination;
}
- private void cloneRepository(String uri, String remoteName, File destination,
IProgressMonitor monitor)
- throws OpenShiftException, URISyntaxException, InvocationTargetException,
InterruptedException {
- ensureEgitUIIsStarted();
- URIish gitUri = new URIish(uri);
- CloneOperation cloneOperation =
- new CloneOperation(gitUri, true, null, destination, Constants.HEAD, remoteName,
CLONE_TIMEOUT);
- cloneOperation.run(monitor);
- RepositoryUtil repositoryUtil = Activator.getDefault().getRepositoryUtil();
- repositoryUtil.addConfiguredRepository(new File(destination, Constants.DOT_GIT));
- }
-
- /**
- * The EGit UI plugin initializes the ssh factory to present the user a
- * passphrase prompt if the ssh key was not read yet. If this initialization
- * is not executed, the ssh connection to the git repo would just fail with
- * an authentication error. We therefore have to make sure that the EGit UI
- * plugin is started and initializes the JSchConfigSessionFactory.
- * <p>
- * EGit initializes the SshSessionFactory with the EclipseSshSessionFactory.
- * The EclipseSshSessionFactory overrides JschConfigSessionFactory#configure
- * to present a UserInfoPrompter if the key passphrase was not entered
- * before.
- *
- * @see Activator#start(org.osgi.framework.BundleContext)
- * @see Activator#setupSSH
- * @see JschConfigSessionFactory#configure
- * @see EclipseSshSessionFactory#configure
- */
- private void ensureEgitUIIsStarted() {
- Activator.getDefault();
- }
-
protected String getProjectName() {
return projectName;
}
@@ -112,13 +92,17 @@
* the project name
* @return the project with the given name
*/
- protected IProject getProject(String name) {
+ private IProject getProject(String name) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
Assert.isTrue(project != null && project.exists(),
NLS.bind("Could not find project {0} in your workspace.", name));
return project;
}
+ protected IProject getProject() {
+ return getProject(getProjectName());
+ }
+
protected IApplication getApplication() {
return application;
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java 2012-01-17
18:25:01 UTC (rev 37906)
@@ -25,6 +25,7 @@
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.egit.core.GitIgnore;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.FileUtils;
import com.openshift.express.client.IApplication;
@@ -32,6 +33,9 @@
import com.openshift.express.client.OpenShiftException;
/**
+ * Strategy that enables the given git shared project to be used on the chosen
+ * OpenShift application.
+ *
* @author André Dietisheim <adietish(a)redhat.com>
*/
public class ConfigureGitSharedProject extends AbstractImportApplicationOperation {
@@ -43,9 +47,12 @@
/**
* 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.
+ * application.
+ * <ul>
+ * <li>clones the application git repository</li>
+ * <li>copies the configuration files to the user project (in the
workspace)</li>
+ * <li>adds the appication git repo as remote</li>
+ * </ul>
*
* @param monitor
* the monitor to report progress to
@@ -76,17 +83,38 @@
public List<IProject> execute(IProgressMonitor monitor)
throws OpenShiftException, InvocationTargetException, InterruptedException,
IOException, CoreException,
URISyntaxException {
- IProject project = getProject(getProjectName());
+ IProject project = getProject();
Assert.isTrue(EGitUtils.isSharedWithGit(project));
File tmpFolder = FileUtils.getRandomTmpFolder();
- File repositoryFile = cloneRepository(getApplication(), getRemoteName(), tmpFolder,
monitor);
+ File repositoryFile = cloneRepository(getApplication(), getRemoteName(), tmpFolder,
false, monitor);
+
copyOpenshiftConfigurations(repositoryFile, project, monitor);
FileUtil.safeDelete(tmpFolder);
+ setupGitIgnore(project);
+
+ EGitUtils.addRemoteTo(
+ getRemoteName(),
+ getApplication().getGitUri(),
+ EGitUtils.getRepository(project));
+
+ setupOpenShiftMavenProfile(project);
+
return Collections.singletonList(project);
}
+ private void setupOpenShiftMavenProfile(IProject project) throws CoreException {
+ Assert.isLegal(OpenShiftMavenProfile.isMavenProject(project));
+
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(project,
OpenShiftUIActivator.PLUGIN_ID);
+ if (profile.existsInPom()) {
+ return;
+ }
+ profile.addToPom(project.getName());
+ profile.savePom();
+ }
+
/**
* Copies the openshift configuration from the given source folder to the
* given project. Copies
@@ -110,27 +138,21 @@
Assert.isLegal(project != null);
File projectFolder = project.getLocation().toFile();
monitor.subTask(NLS.bind("Copying openshift configuration to project {0}...",
project.getName()));
-
+
FileUtils.copy(new File(sourceFolder, ".openshift"), projectFolder, false);
FileUtils.copy(new File(sourceFolder, "deployments"), projectFolder, false);
-
- createGitIgnore(project);
}
/**
- * Creates the git ignore file with a predefined set of entries. An existing
- * .gitignore file is not overwritten, we then just dont do anything.
+ * Adds a predefined set of entries to the gitignore file in (root of) the
+ * given project. If no .gitignore exists yet, a fresh one is created.
*
- * @param projectFolder
+ * @param project
+ * the project to which the .gitignore shall be configured
* @throws IOException
*/
- private void createGitIgnore(IProject project) throws IOException {
+ private void setupGitIgnore(IProject project) throws IOException {
GitIgnore gitIgnore = new GitIgnore(project);
- // TODO: merge existing .gitignore
- // (
https://issues.jboss.org/browse/JBIDE-10391)
- if (gitIgnore.exists()) {
- return;
- }
gitIgnore.add("target")
.add(".settings")
.add(".project")
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureUnsharedProject.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureUnsharedProject.java 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureUnsharedProject.java 2012-01-17
18:25:01 UTC (rev 37906)
@@ -32,6 +32,9 @@
import com.openshift.express.client.OpenShiftException;
/**
+ * Strategy that enables the given git shared project to be used on the chosen
+ * OpenShift application.
+ *
* @author André Dietisheim <adietish(a)redhat.com>
*/
public class ConfigureUnsharedProject extends AbstractImportApplicationOperation {
@@ -43,9 +46,12 @@
/**
* 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.
+ * application. *
+ * <ul>
+ * <li>clones the application git repository</li>
+ * <li>copies the configuration files to the user project (in the
workspace)</li>
+ * <li>shares the given project with git</li>
+ * </ul>
*
* @param monitor
* the monitor to report progress to
@@ -84,11 +90,15 @@
// model.mergeWithApplicationRepository(repository,
// monitor);
File tmpFolder = FileUtils.getRandomTmpFolder();
- File repositoryFile = cloneRepository(getApplication(), getRemoteName(), tmpFolder,
monitor);
- IProject project = getProject(getProjectName());
+ IProject project = getProject();
+
+ File repositoryFile = cloneRepository(getApplication(), getRemoteName(), tmpFolder,
false, monitor);
+
copyOpenshiftConfigurations(repositoryFile, project, monitor);
FileUtil.safeDelete(tmpFolder);
+ createGitIgnore(project);
+
shareProject(project, monitor);
return Collections.singletonList(project);
}
@@ -126,23 +136,18 @@
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.
+ * Adds a predefined set of entries to the gitignore file in (root of) the
+ * given project. If no .gitignore exists yet, a fresh one is created.
*
- * @param projectFolder
+ * @param project
+ * the project to which the .gitignore shall be configured
* @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;
- }
+ private void createGitIgnore(IProject project) throws IOException {
+ GitIgnore gitIgnore = new GitIgnore(project);
gitIgnore.add("target")
.add(".settings")
.add(".project")
@@ -151,12 +156,15 @@
gitIgnore.write(false);
}
-// private void mergeWithApplicationRepository(Repository repository, IApplication
application,
-// IProgressMonitor monitor)
-// throws MalformedURLException, URISyntaxException, IOException, OpenShiftException,
CoreException,
-// InvocationTargetException {
-// URIish uri = new URIish(application.getGitUri());
-// EGitUtils.addRemoteTo("openshift", uri, repository);
-// EGitUtils.mergeWithRemote(uri, "refs/remotes/openshift/HEAD", repository,
monitor);
-// }
+ // private void mergeWithApplicationRepository(Repository repository,
+ // IApplication application,
+ // IProgressMonitor monitor)
+ // throws MalformedURLException, URISyntaxException, IOException,
+ // OpenShiftException, CoreException,
+ // InvocationTargetException {
+ // URIish uri = new URIish(application.getGitUri());
+ // EGitUtils.addRemoteTo("openshift", uri, repository);
+ // EGitUtils.mergeWithRemote(uri, "refs/remotes/openshift/HEAD", repository,
+ // monitor);
+ // }
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportNewProject.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportNewProject.java 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportNewProject.java 2012-01-17
18:25:01 UTC (rev 37906)
@@ -68,7 +68,7 @@
}
File repositoryFolder =
- cloneRepository(getApplication(), getRemoteName(), cloneDestination, monitor);
+ cloneRepository(getApplication(), getRemoteName(), cloneDestination, true, monitor);
List<IProject> importedProjects = importProjectsFrom(repositoryFolder, monitor);
if (importedProjects.size() == 0) {
throw new ImportFailedException(
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java 2012-01-17
18:25:01 UTC (rev 37906)
@@ -75,19 +75,16 @@
}
}
- private boolean askForConfirmation(final String applicationName, final String
projectName) {
+ private boolean askForConfirmation(final String message, final String applicationName)
{
final boolean[] confirmed = new boolean[1];
getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
- confirmed[0] = MessageDialog.openConfirm(getShell(),
+ 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));
+ message);
}
});
return confirmed[0];
@@ -133,11 +130,26 @@
if (model.isNewProject()) {
model.importProject(delegatingMonitor);
+ } else if (!model.isGitSharedProject()) {
+ if (!askForConfirmation(
+ NLS.bind("OpenShift application {0} will be enabled on project {1} by "
+
+ "copying OpenShift configuration and enabling Git for the project.\n "
+
+ "This cannot be undone. Do you wish to continue ?",
+ model.getApplicationName(), model.getProjectName()),
+ model.getApplicationName())) {
+ return Status.CANCEL_STATUS;
+ }
+ model.configureUnsharedProject(delegatingMonitor);
} else {
- if (!askForConfirmation(model.getApplicationName(), model.getProjectName())) {
+ if (!askForConfirmation(
+ NLS.bind("OpenShift application {0} will be enabled on project {1} by copying
OpenShift " +
+ "configuration and adding the OpenShift git repo as remote.\n " +
+ "This cannot be undone. Do you wish to continue ?",
+ model.getApplicationName(), model.getProjectName()),
+ model.getApplicationName())) {
return Status.CANCEL_STATUS;
}
- model.addToExistingProject(delegatingMonitor);
+ model.configureGitSharedProject(delegatingMonitor);
}
return Status.OK_STATUS;
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java 2012-01-17
18:19:23 UTC (rev 37905)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java 2012-01-17
18:25:01 UTC (rev 37906)
@@ -18,12 +18,14 @@
import java.util.List;
import org.eclipse.core.resources.IProject;
+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.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServerType;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.ui.wizard.AdapterWizardPageModel;
import com.openshift.express.client.IApplication;
@@ -74,8 +76,8 @@
}
/**
- * Enables the user chosen project to be used on the chosen OpenShift
- * application. Clones the application git repository, copies the
+ * Enables the user chosen, unshared 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.
*
@@ -98,7 +100,7 @@
* @throws CoreException
* The user project could not be shared with the git
*/
- public void addToExistingProject(IProgressMonitor monitor)
+ public void configureUnsharedProject(IProgressMonitor monitor)
throws OpenShiftException, InvocationTargetException, InterruptedException,
IOException, CoreException,
URISyntaxException {
List<IProject> importedProjects = new ConfigureUnsharedProject(
@@ -110,6 +112,43 @@
createServerAdapter(monitor, importedProjects);
}
+ /**
+ * Enables the user chosen, unshared 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), adds the
+ * appication git repo as remote 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
+ */
+ public void configureGitSharedProject(IProgressMonitor monitor)
+ throws OpenShiftException, InvocationTargetException, InterruptedException,
IOException, CoreException,
+ URISyntaxException {
+ List<IProject> importedProjects = new ConfigureGitSharedProject(
+ getProjectName()
+ , getApplication()
+ , getRemoteName()
+ , getUser())
+ .execute(monitor);
+ createServerAdapter(monitor, importedProjects);
+ }
+
private void createServerAdapter(IProgressMonitor monitor, List<IProject>
importedProjects)
throws OpenShiftException {
Assert.isTrue(importedProjects.size() > 0);
@@ -201,6 +240,14 @@
return (Boolean) getProperty(NEW_PROJECT);
}
+ public boolean isGitSharedProject() {
+ return EGitUtils.isSharedWithGit(getProject());
+ }
+
+ private IProject getProject() {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
+ }
+
public Boolean setNewProject(boolean newProject) {
return (Boolean) setProperty(NEW_PROJECT, newProject);
}