Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2010-12-28 06:45:27 -0500
committerMilos Kleint2010-12-28 06:45:27 -0500
commit373952ec1885a6621cd6e8a511ff2b1b3f118ecd (patch)
tree54e5f2ea926cf7b6fbf4201debffe8ad82b9bcd9
parente9a25d2d488facc89c289296a2c7f36fd6992f02 (diff)
downloadm2e-core-373952ec1885a6621cd6e8a511ff2b1b3f118ecd.tar.gz
m2e-core-373952ec1885a6621cd6e8a511ff2b1b3f118ecd.tar.xz
m2e-core-373952ec1885a6621cd6e8a511ff2b1b3f118ecd.zip
MNGECLIPSE-2547 have the add dependency dialog show the currently managed entries
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/ui/dialogs/AddDependencyDialog.java19
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java2
2 files changed, 18 insertions, 3 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 3eccb828..a70dce81 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
@@ -8,10 +8,13 @@
package org.eclipse.m2e.core.ui.dialogs;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
+import java.util.Set;
import com.ibm.icu.text.DateFormat;
@@ -49,6 +52,8 @@ import org.eclipse.swt.widgets.Tree;
import org.apache.lucene.search.BooleanQuery;
+import org.apache.maven.project.MavenProject;
+
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.graph.DependencyNode;
import org.sonatype.aether.graph.DependencyVisitor;
@@ -135,6 +140,8 @@ public class AddDependencyDialog extends AbstractMavenDialog {
protected boolean updating;
+ private MavenProject mavenProject;
+
/**
* 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
@@ -144,9 +151,10 @@ public class AddDependencyDialog extends AbstractMavenDialog {
* @param isForDependencyManagement
* @param project the project which contains this POM. Used for looking up indices
*/
- public AddDependencyDialog(Shell parent, boolean isForDependencyManagement, IProject project) {
+ public AddDependencyDialog(Shell parent, boolean isForDependencyManagement, IProject project, MavenProject mavenProject) {
super(parent, DIALOG_SETTINGS);
this.project = project;
+ this.mavenProject = mavenProject;
setShellStyle(getShellStyle() | SWT.RESIZE);
setTitle(Messages.AddDependencyDialog_title);
@@ -346,8 +354,15 @@ 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>();
+ 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());
+ }
+ }
resultsViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(
- new MavenPomSelectionComponent.SearchResultLabelProvider(Collections.EMPTY_SET, Collections.EMPTY_SET,
+ new MavenPomSelectionComponent.SearchResultLabelProvider(Collections.<String>emptySet(), managed,
IIndex.SEARCH_ARTIFACT)));
/*
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
index c4828432..b6f5dbb7 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
@@ -250,7 +250,7 @@ public class DependenciesComposite extends Composite {
dependenciesEditor.setAddButtonListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- final AddDependencyDialog addDepDialog = new AddDependencyDialog(getShell(), false, editorPage.getProject());
+ final AddDependencyDialog addDepDialog = new AddDependencyDialog(getShell(), false, editorPage.getProject(), editorPage.getPomEditor().getMavenProject());
/*
* Load the dependency tree for the dialog so it can show already

Back to the top