Author: adietish
Date: 2012-02-13 08:04:51 -0500 (Mon, 13 Feb 2012)
New Revision: 38653
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.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/ImportNewProject.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java
Log:
[JBIDE-10887] creating .gitignore with appropriate settings (.project, .classpath,
.settings, etc.)
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftWizardModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftWizardModel.java 2012-02-13
12:05:30 UTC (rev 38652)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftWizardModel.java 2012-02-13
13:04:51 UTC (rev 38653)
@@ -61,9 +61,10 @@
* @throws InterruptedException
* @throws URISyntaxException
* @throws InvocationTargetException
+ * @throws IOException
*/
public void importProject(IProgressMonitor monitor) throws OpenShiftException,
CoreException, InterruptedException,
- URISyntaxException, InvocationTargetException;
+ URISyntaxException, InvocationTargetException, IOException;
/**
* Enables the user chosen, unshared project to be used on the chosen
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-02-13
12:05:30 UTC (rev 38652)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-02-13
13:04:51 UTC (rev 38653)
@@ -64,12 +64,17 @@
* @throws InterruptedException
* @throws URISyntaxException
* @throws InvocationTargetException
+ * @throws IOException
*/
@Override
public void importProject(IProgressMonitor monitor) throws OpenShiftException,
CoreException, InterruptedException,
- URISyntaxException, InvocationTargetException {
+ URISyntaxException, InvocationTargetException, IOException {
List<IProject> importedProjects =
- new ImportNewProject(getProjectName(), getApplication(), getRemoteName(),
getRepositoryFile())
+ new ImportNewProject(
+ getProjectName()
+ , getApplication()
+ , getRemoteName()
+ , getRepositoryFile())
.execute(monitor);
createServerAdapter(monitor, importedProjects);
}
@@ -358,7 +363,8 @@
return selectedEmbeddableCartridges;
}
- public Set<IEmbeddableCartridge>
setSelectedEmbeddableCartridges(Set<IEmbeddableCartridge>
selectedEmbeddableCartridges) {
+ public Set<IEmbeddableCartridge> setSelectedEmbeddableCartridges(
+ Set<IEmbeddableCartridge> selectedEmbeddableCartridges) {
dataModel.put(KEY_SELECTED_EMBEDDABLE_CARTRIDGES, selectedEmbeddableCartridges);
return selectedEmbeddableCartridges;
}
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-02-13
12:05:30 UTC (rev 38652)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AbstractImportApplicationOperation.java 2012-02-13
13:04:51 UTC (rev 38653)
@@ -15,15 +15,23 @@
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
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.egit.core.op.AddToIndexOperation;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.openshift.egit.core.EGitUtils;
+import org.jboss.tools.openshift.egit.core.GitIgnore;
import org.jboss.tools.openshift.egit.ui.util.EGitUIUtils;
import com.openshift.express.client.IApplication;
@@ -37,11 +45,13 @@
private String projectName;
private IApplication application;
private String remoteName;
+ protected List<IResource> modifiedResources;
public AbstractImportApplicationOperation(String projectName, IApplication application,
String remoteName) {
this.projectName = projectName;
this.application = application;
this.remoteName = remoteName;
+ this.modifiedResources = new ArrayList<IResource>();
}
/**
@@ -136,4 +146,81 @@
protected String getRemoteName() {
return remoteName;
}
+
+ /**
+ * Marks the given resources as modified.
+ *
+ * @param resources
+ * the resources that shall be marked as modified
+ *
+ * @see #addAndCommitModifiedResource(IProject, IProgressMonitor)
+ */
+ protected void addToModified(Collection<IResource> resources) {
+ if (resources == null) {
+ return;
+ }
+ modifiedResources.addAll(resources);
+ }
+
+ /**
+ *
+ * Marks the given resource as modified.
+ *
+ * @param resource
+ * the resource that shall be marked as modified
+ *
+ * @see #addAndCommitModifiedResource(IProject, IProgressMonitor)
+ */
+ protected void addToModified(IResource resource) {
+ if (resource == null) {
+ return;
+ }
+ modifiedResources.add(resource);
+ }
+
+ /**
+ * Adds and commits all (modified) resources in the given project to the git
+ * repository that it is attached to.
+ *
+ * @param project
+ * the project to commit
+ * @param monitor
+ * the monitor to report progress to
+ * @throws CoreException
+ * @throws OpenShiftException
+ *
+ * @see #addToModified(Collection<IResource>)
+ * @see #addToModified(IResource)
+ *
+ */
+ protected void addAndCommitModifiedResource(IProject project, IProgressMonitor monitor)
throws CoreException,
+ OpenShiftException {
+ Repository repository = EGitUtils.getRepository(project);
+ if (repository == null) {
+ throw new OpenShiftException("project {0} is not connected to a git
repository.", project.getName());
+ }
+ new AddToIndexOperation(modifiedResources).execute(monitor);
+ EGitUtils.commit(project, monitor);
+ }
+
+ /**
+ * 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 project
+ * the project to which the .gitignore shall be configured
+ * @return
+ * @throws IOException
+ * @throws CoreException
+ */
+ protected IFile setupGitIgnore(IProject project, IProgressMonitor monitor) throws
IOException, CoreException {
+ GitIgnore gitIgnore = new GitIgnore(project);
+ gitIgnore.add("target")
+ .add(".settings")
+ .add(".project")
+ .add(".classpath")
+ .add(".factorypath");
+ return gitIgnore.write(monitor);
+ }
+
}
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-02-13
12:05:30 UTC (rev 38652)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java 2012-02-13
13:04:51 UTC (rev 38653)
@@ -15,26 +15,22 @@
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.egit.core.op.AddToIndexOperation;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.osgi.util.NLS;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.RegExUtils;
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.OpenShiftUIException;
import org.jboss.tools.openshift.express.internal.ui.UnCommittedChangesException;
@@ -53,12 +49,9 @@
*/
public class ConfigureGitSharedProject extends AbstractImportApplicationOperation {
- private List<IResource> modifiedResources;
-
public ConfigureGitSharedProject(String projectName, IApplication application, String
remoteName,
IUser user) {
super(projectName, application, remoteName);
- this.modifiedResources = new ArrayList<IResource>();
}
/**
@@ -139,11 +132,6 @@
EGitUtils.addRemoteTo(getRemoteName(), getApplication().getGitUri(), repository);
}
- private void addAndCommitModifiedResource(IProject project, IProgressMonitor monitor)
throws CoreException {
- new AddToIndexOperation(modifiedResources).execute(monitor);
- EGitUtils.commit(project, monitor);
- }
-
private IResource setupOpenShiftMavenProfile(IProject project, IProgressMonitor monitor)
throws CoreException {
Assert.isLegal(OpenShiftMavenProfile.isMavenProject(project));
@@ -198,39 +186,4 @@
FileUtil.safeDelete(tmpFolder);
return copiedResources;
}
-
- /**
- * 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 project
- * the project to which the .gitignore shall be configured
- * @return
- * @throws IOException
- * @throws CoreException
- */
- private IFile setupGitIgnore(IProject project, IProgressMonitor monitor) throws
IOException, CoreException {
- GitIgnore gitIgnore = new GitIgnore(project);
- gitIgnore.add("target")
- .add(".settings")
- .add(".project")
- .add(".classpath")
- .add(".factorypath");
- return gitIgnore.write(monitor);
- }
-
- private void addToModified(Collection<IResource> resources) {
- if (resources == null) {
- return;
- }
- modifiedResources.addAll(resources);
- }
-
- private void addToModified(IResource resource) {
- if (resource == null) {
- return;
- }
- modifiedResources.add(resource);
- }
-
}
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-02-13
12:05:30 UTC (rev 38652)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportNewProject.java 2012-02-13
13:04:51 UTC (rev 38653)
@@ -56,10 +56,11 @@
* @throws InterruptedException
* @throws URISyntaxException
* @throws InvocationTargetException
+ * @throws IOException
*/
public List<IProject> execute(IProgressMonitor monitor)
throws OpenShiftException, CoreException, InterruptedException, URISyntaxException,
- InvocationTargetException {
+ InvocationTargetException, IOException {
if (cloneDestinationExists()) {
throw new WontOverwriteException(
NLS.bind("There's already a folder at {0}. The new OpenShift project would
overwrite it. " +
@@ -80,8 +81,11 @@
}
connectToGitRepo(importedProjects, repositoryFolder, monitor);
+ // TODO: handle multiple projects (is this really possible?)
+ IProject project = importedProjects.get(0);
+ addToModified(setupGitIgnore(project, monitor));
+ addAndCommitModifiedResource(project, monitor);
-
return importedProjects;
}
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-02-13
12:05:30 UTC (rev 38652)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java 2012-02-13
13:04:51 UTC (rev 38653)
@@ -68,9 +68,10 @@
* @throws InterruptedException
* @throws URISyntaxException
* @throws InvocationTargetException
+ * @throws IOException
*/
public void importProject(IProgressMonitor monitor) throws OpenShiftException,
CoreException, InterruptedException,
- URISyntaxException, InvocationTargetException {
+ URISyntaxException, InvocationTargetException, IOException {
List<IProject> importedProjects = new ImportNewProject(getProjectName()
, getApplication()
, getRemoteName()