Author: adietish
Date: 2012-01-19 08:52:26 -0500 (Thu, 19 Jan 2012)
New Revision: 37967
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/ConfigureUnsharedProject.java
Log:
[JBIDE-10479] switched GitIgnore to acces .gitignore-file by the resource API (was:
java.io.File)
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-19
13:51:31 UTC (rev 37966)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureGitSharedProject.java 2012-01-19
13:52:26 UTC (rev 37967)
@@ -95,16 +95,15 @@
IProject project = getProject();
Assert.isTrue(EGitUtils.isSharedWithGit(project));
- copyOpenshiftConfigurations(getApplication(), getRemoteName(), project, monitor);
-
- setupGitIgnore(project);
+ addToModified(copyOpenshiftConfigurations(getApplication(), getRemoteName(), project,
monitor));
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ addToModified(setupGitIgnore(project, monitor));
+ addToModified(setupOpenShiftMavenProfile(project));
EGitUtils.addRemoteTo(
getRemoteName(),
getApplication().getGitUri(),
EGitUtils.getRepository(project));
- setupOpenShiftMavenProfile(project);
addAndCommitModifiedResource(project, monitor);
return Collections.singletonList(project);
@@ -115,16 +114,15 @@
EGitUtils.commit(project, monitor);
}
- private void setupOpenShiftMavenProfile(IProject project) throws CoreException {
+ private IResource setupOpenShiftMavenProfile(IProject project) throws CoreException {
Assert.isLegal(OpenShiftMavenProfile.isMavenProject(project));
OpenShiftMavenProfile profile = new OpenShiftMavenProfile(project,
OpenShiftUIActivator.PLUGIN_ID);
if (profile.existsInPom()) {
- return;
+ return null;
}
profile.addToPom(project.getName());
- IFile pomFile = profile.savePom();
- modifiedResources.add(pomFile);
+ return profile.savePom();
}
/**
@@ -143,6 +141,7 @@
* the project to copy the configuration to.
* @param monitor
* the monitor to report progress to
+ * @return
* @return
* @throws IOException
* @throws CoreException
@@ -151,7 +150,7 @@
* @throws InvocationTargetException
* @throws OpenShiftException
*/
- private void copyOpenshiftConfigurations(IApplication application, String remoteName,
IProject project, IProgressMonitor monitor)
+ private Collection<IResource> copyOpenshiftConfigurations(IApplication
application, String remoteName, IProject project, IProgressMonitor monitor)
throws IOException, CoreException, OpenShiftException, InvocationTargetException,
InterruptedException, URISyntaxException {
Assert.isLegal(project != null);
monitor.subTask(NLS.bind("Copying openshift configuration to project {0}...",
project.getName()));
@@ -161,8 +160,8 @@
Collection<IResource> copiedResources =
copyResources(tmpFolder, new String[] { ".openshift",
"deployments" }, project);
- modifiedResources.addAll(copiedResources);
FileUtil.safeDelete(tmpFolder);
+ return copiedResources;
}
private Collection<IResource> copyResources(File sourceFolder, String[]
sourcePaths, IProject project)
@@ -194,17 +193,32 @@
*
* @param project
* the project to which the .gitignore shall be configured
+ * @return
* @throws IOException
+ * @throws CoreException
*/
- private void setupGitIgnore(IProject project) throws IOException {
+ 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");
- File file = gitIgnore.write(false);
- IFile gitIgnoreFile = project.getFile(file.getName());
- modifiedResources.add(gitIgnoreFile);
+ 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/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-19
13:51:31 UTC (rev 37966)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ConfigureUnsharedProject.java 2012-01-19
13:52:26 UTC (rev 37967)
@@ -92,7 +92,7 @@
IProject project = getProject();
copyOpenshiftConfigurations(getApplication(), getRemoteName(), project, monitor);
- createGitIgnore(project);
+ createGitIgnore(project, monitor);
shareProject(project, monitor);
return Collections.singletonList(project);
@@ -151,15 +151,16 @@
* @param project
* the project to which the .gitignore shall be configured
* @throws IOException
+ * @throws CoreException
*/
- private void createGitIgnore(IProject project) throws IOException {
+ private void createGitIgnore(IProject project, IProgressMonitor monitor) throws
IOException, CoreException {
GitIgnore gitIgnore = new GitIgnore(project);
gitIgnore.add("target")
.add(".settings")
.add(".project")
.add(".classpath")
.add(".factorypath");
- gitIgnore.write(false);
+ gitIgnore.write(monitor);
}
// private void mergeWithApplicationRepository(Repository repository,