Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2012-05-21 09:27:19 -0400
committerIgor Fedorenko2012-05-21 09:27:19 -0400
commitaa4ac7a3cc0e93524a0503310de2907cf36a386f (patch)
tree871eb857db3ab4b16e8f60f22e43fc2986975e9b
parenta5975409390b5addfb73f8f73d5f9b78dd072586 (diff)
downloadm2e-core-aa4ac7a3cc0e93524a0503310de2907cf36a386f.tar.gz
m2e-core-aa4ac7a3cc0e93524a0503310de2907cf36a386f.tar.xz
m2e-core-aa4ac7a3cc0e93524a0503310de2907cf36a386f.zip
369932 fixed update project fails to showup in some casesmilestones/1.1/1.1.0.20120523-1730
Due to apparent bug, IWorkspaceRoot.findContainersForLocationURI fails to return expect project in some cases. As a solution, keep path-to-project map in UpdateMavenProjectsDialog and use it to locate projects by paths. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java37
1 files changed, 18 insertions, 19 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java
index 8281e5cd..9a806989 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java
@@ -16,8 +16,9 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,7 +79,7 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
private Button forceUpdateBtn;
- private List<String> projectPaths;
+ private Map<String,IProject> projectPaths;
private final IProject[] initialSelection;
@@ -176,7 +177,7 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
String elePath = getElePath(parentElement);
String prevPath = null;
List<IProject> children = new ArrayList<IProject>();
- for(String path : projectPaths) {
+ for(String path : projectPaths.keySet()) {
if(path.length() != elePath.length() && path.startsWith(elePath)) {
if(prevPath == null || !path.startsWith(prevPath)) {
prevPath = path;
@@ -194,7 +195,7 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
public Object getParent(Object element) {
String elePath = getElePath(element);
String prevPath = null;
- for(String path : projectPaths) {
+ for(String path : projectPaths.keySet()) {
if(elePath.length() != path.length() && elePath.startsWith(path)
&& (prevPath == null || prevPath.length() < path.length())) {
prevPath = path;
@@ -206,7 +207,7 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
public boolean hasChildren(Object element) {
if(element instanceof IProject) {
String elePath = getElePath(element);
- for(String path : projectPaths) {
+ for(String path : projectPaths.keySet()) {
if(elePath.length() != path.length() && path.startsWith(elePath)) {
return true;
}
@@ -369,31 +370,36 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
}
private Collection<IProject> getMavenCodebases() {
- projectPaths = new LinkedList<String>();
+ projectPaths = new TreeMap<String, IProject>();
for(IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
try {
if(project.isAccessible() && project.hasNature(IMavenConstants.NATURE_ID)) {
if(project.getLocationURI() != null) {
- projectPaths.add(getElePath(project));
+ String path = getElePath(project);
+ if(path != null) {
+ projectPaths.put(path, project);
+ }
}
}
} catch(CoreException ex) {
log.error(ex.getMessage(), ex);
}
}
- Collections.sort(projectPaths);
if(projectPaths.isEmpty()) {
return Collections.<IProject> emptyList();
}
projects = new ArrayList<IProject>();
- String previous = projectPaths.get(0);
+ String previous = projectPaths.keySet().iterator().next();
addProject(projects, previous);
- for(String path : projectPaths) {
+ for(String path : projectPaths.keySet()) {
if(!path.startsWith(previous)) {
previous = path;
- projects.add(getProject(path));
+ IProject project = getProject(path);
+ if(project != null) {
+ projects.add(project);
+ }
}
}
return projects;
@@ -430,14 +436,7 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
}
private IProject getProject(String path) {
- IContainer[] containers = ResourcesPlugin.getWorkspace().getRoot()
- .findContainersForLocationURI(new File(path).toURI());
- for(IContainer container : containers) {
- if(container instanceof IProject) {
- return (IProject) container;
- }
- }
- return null;
+ return projectPaths.get(path);
}
private void createMenu() {

Back to the top