Author: fbricon
Date: 2011-11-09 10:00:39 -0500 (Wed, 09 Nov 2011)
New Revision: 36250
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectUtil.java
trunk/maven/plugins/org.jboss.tools.maven.jaxrs/src/org/jboss/tools/maven/jaxrs/configurators/JaxrsProjectConfigurator.java
trunk/maven/plugins/org.jboss.tools.maven.jaxrs/src/org/jboss/tools/maven/jaxrs/messages.properties
Log:
JBIDE-10037 : tweaked refresh hierarchy logic.
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectUtil.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectUtil.java 2011-11-09
14:04:24 UTC (rev 36249)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectUtil.java 2011-11-09
15:00:39 UTC (rev 36250)
@@ -1,11 +1,11 @@
package org.jboss.tools.maven.core;
import java.io.File;
-import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
-import org.apache.maven.project.MavenProject;
-import org.eclipse.core.internal.resources.Project;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -14,7 +14,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.JavaCore;
/**
* A utility class for Eclipse Projects.
@@ -40,20 +39,29 @@
try {
int count = 0;
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- final IProject[] projects = root.getProjects();
+ final List<IProject> projects = new
ArrayList<IProject>(Arrays.asList(root.getProjects()));
+
final IPath rootLocation = root.getLocation();
IPath basedirPath = new Path(basedir.getAbsolutePath());
- while(basedirPath.matchingFirstSegments(rootLocation) > 0) {
- for(IProject project : projects) {
+ while(!rootLocation.equals(basedirPath) &&
rootLocation.isPrefixOf(basedirPath)) {
+ Iterator<IProject> ite = projects.iterator();
+
+ // In case of maven module projects, root.findContainersForLocationURI(...) would
return an IFolder
+ // instead of an IProject. So we manually loop through all projects and test their
path against the
+ // current basedirPath. Refreshed projects will be removed from the list for
subsequent checks
+ while(ite.hasNext()) {
+ IProject project = ite.next();
final IPath projectLocation = project.getLocation();
- if(projectLocation.equals(basedirPath) && project.isOpen()) {
+ if(projectLocation.equals(basedirPath) && project.isAccessible()) {
project.refreshLocal(refreshDepth, monitor);
count++;
+ ite.remove();
break;
}
}
basedirPath = basedirPath.removeLastSegments(1);
}
+
return count;
} finally {
monitor.done();
Modified:
trunk/maven/plugins/org.jboss.tools.maven.jaxrs/src/org/jboss/tools/maven/jaxrs/configurators/JaxrsProjectConfigurator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jaxrs/src/org/jboss/tools/maven/jaxrs/configurators/JaxrsProjectConfigurator.java 2011-11-09
14:04:24 UTC (rev 36249)
+++
trunk/maven/plugins/org.jboss.tools.maven.jaxrs/src/org/jboss/tools/maven/jaxrs/configurators/JaxrsProjectConfigurator.java 2011-11-09
15:00:39 UTC (rev 36250)
@@ -10,18 +10,13 @@
************************************************************************************/
package org.jboss.tools.maven.jaxrs.configurators;
-import java.io.File;
-
import org.apache.maven.project.MavenProject;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
@@ -134,7 +129,8 @@
if (facetVersion != null) {
IStatus status = facetVersion.getConstraint().check(fproj.getProjectFacets());
if (status.isOK()) {
- // refreshing the project hierarchy to make sure that Eclipse "sees" the
.settings folder and file, to be able to add the JAX-RS Facet
+ // refreshing the project hierarchy to make sure that Eclipse "sees" the
.settings folder and file,
+ // to be able to add the JAX-RS Facet. This only occurs if the projects are created
via the project example UI.
// see
https://issues.jboss.org/browse/JBIDE-10037
ProjectUtil.refreshHierarchy(mavenProject.getBasedir(), IResource.DEPTH_INFINITE, new
SubProgressMonitor(monitor, 1));
IDataModel model = createJaxRsDataModel(fproj,facetVersion);
Modified:
trunk/maven/plugins/org.jboss.tools.maven.jaxrs/src/org/jboss/tools/maven/jaxrs/messages.properties
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.jaxrs/src/org/jboss/tools/maven/jaxrs/messages.properties 2011-11-09
14:04:24 UTC (rev 36249)
+++
trunk/maven/plugins/org.jboss.tools.maven.jaxrs/src/org/jboss/tools/maven/jaxrs/messages.properties 2011-11-09
15:00:39 UTC (rev 36250)
@@ -1 +1 @@
-JaxrsProjectConfigurator_The_project_does_not_contain_required_facets=The {0} project
does not contain the Dynamic Web Module facet or the EJB Module facet.
+JaxrsProjectConfigurator_The_project_does_not_contain_required_facets=The {0} project
does not contain the Dynamic Web Module facet or the EJB Module facet required to enable
JAX-RS support.