Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2010-12-28 08:09:14 -0500
committerMilos Kleint2010-12-28 08:09:14 -0500
commitb3f86f9675addd1ff2f507773626dfc15b35a644 (patch)
tree7c5af2aff45c05ec59bf77fa9b91a32b5927bf3c
parent7dec9732b2dfc1a53981322154c77d8650564f69 (diff)
downloadm2e-core-b3f86f9675addd1ff2f507773626dfc15b35a644.tar.gz
m2e-core-b3f86f9675addd1ff2f507773626dfc15b35a644.tar.xz
m2e-core-b3f86f9675addd1ff2f507773626dfc15b35a644.zip
MNGECLIPSE-2547 the top node shall represent the managed version, not the first version
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/ui/dialogs/AddDependencyDialog.java33
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/wizards/MavenPomSelectionComponent.java4
2 files changed, 27 insertions, 10 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/ui/dialogs/AddDependencyDialog.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/ui/dialogs/AddDependencyDialog.java
index 074b5124..b61dab44 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/ui/dialogs/AddDependencyDialog.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/ui/dialogs/AddDependencyDialog.java
@@ -142,6 +142,10 @@ public class AddDependencyDialog extends AbstractMavenDialog {
private final boolean isForDependencyManagement;
+ private Set<String> managedKeys;
+
+ private Set<String> existingKeys;
+
/**
* The AddDependencyDialog differs slightly in behaviour depending on context. If it is being used to apply a
* dependency under the "dependencyManagement" context, the extra "import" scope is available. Set @param
@@ -356,20 +360,20 @@ public class AddDependencyDialog extends AbstractMavenDialog {
resultsViewer = new TreeViewer(resultsTree);
resultsViewer.setContentProvider(new MavenPomSelectionComponent.SearchResultContentProvider());
//TODO we want to have the artifacts marked for presence and management..
- Set<String> managed = new HashSet<String>();
- Set<String> existing = new HashSet<String>();
+ managedKeys = new HashSet<String>();
+ existingKeys = new HashSet<String>();
if (mavenProject != null && mavenProject.getDependencyManagement() != null) {
for (org.apache.maven.model.Dependency d : mavenProject.getDependencyManagement().getDependencies()) {
- managed.add(d.getGroupId() + ":" + d.getArtifactId());
- managed.add(d.getGroupId() + ":" + d.getArtifactId() + ":" + d.getVersion());
+ managedKeys.add(d.getGroupId() + ":" + d.getArtifactId());
+ managedKeys.add(d.getGroupId() + ":" + d.getArtifactId() + ":" + d.getVersion());
}
}
if (isForDependencyManagement) {
- existing = managed;
- managed = Collections.<String>emptySet();
+ existingKeys = managedKeys;
+ managedKeys = Collections.<String>emptySet();
}
resultsViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(
- new MavenPomSelectionComponent.SearchResultLabelProvider(existing, managed,
+ new MavenPomSelectionComponent.SearchResultLabelProvider(existingKeys, managedKeys,
IIndex.SEARCH_ARTIFACT)));
/*
@@ -558,7 +562,20 @@ public class AddDependencyDialog extends AbstractMavenDialog {
IndexedArtifactFile file = null;
if(obj instanceof IndexedArtifact) {
- file = ((IndexedArtifact) obj).getFiles().iterator().next();
+ //the idea here is that if we have a managed version for something, then the IndexedArtifact shall
+ //represent that value..
+ IndexedArtifact ia = (IndexedArtifact)obj;
+ if (managedKeys.contains(MavenPomSelectionComponent.getKey(ia))) {
+ for (IndexedArtifactFile f : ia.getFiles()) {
+ if (managedKeys.contains(MavenPomSelectionComponent.getKey(f))) {
+ file = f;
+ break;
+ }
+ }
+ }
+ if (file == null) {
+ file = ((IndexedArtifact) obj).getFiles().iterator().next();
+ }
} else {
file = (IndexedArtifactFile) obj;
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/wizards/MavenPomSelectionComponent.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/wizards/MavenPomSelectionComponent.java
index a797aca1..f1df93c6 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/wizards/MavenPomSelectionComponent.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/wizards/MavenPomSelectionComponent.java
@@ -319,10 +319,10 @@ public class MavenPomSelectionComponent extends Composite {
}
}
- static String getKey(IndexedArtifactFile file) {
+ public static String getKey(IndexedArtifactFile file) {
return file.group + ":" + file.artifact + ":" + file.version; //$NON-NLS-1$ //$NON-NLS-2$
}
- static String getKey(IndexedArtifact art) {
+ public static String getKey(IndexedArtifact art) {
return art.getGroupId() + ":" + art.getArtifactId(); //$NON-NLS-1$
}

Back to the top