Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2010-12-28 07:42:26 -0500
committerMilos Kleint2010-12-28 07:42:26 -0500
commit7dec9732b2dfc1a53981322154c77d8650564f69 (patch)
tree40ce1da23613373f7369b3d8c6cc71d360e9e7f3
parentcf565350118fd3f54cfa51151f99cc9a2918ebf0 (diff)
downloadm2e-core-7dec9732b2dfc1a53981322154c77d8650564f69.tar.gz
m2e-core-7dec9732b2dfc1a53981322154c77d8650564f69.tar.xz
m2e-core-7dec9732b2dfc1a53981322154c77d8650564f69.zip
MNGECLIPSE-2547 have the dependency management's Add button reuse the same selection dialog
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java44
1 files changed, 31 insertions, 13 deletions
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 b6f5dbb7..f6f770ba 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
@@ -444,20 +444,38 @@ public class DependenciesComposite extends Composite {
dependencyManagementEditor.setAddButtonListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- // TODO calculate current list of artifacts for the project
- Set<ArtifactKey> artifacts = Collections.emptySet();
- MavenRepositorySearchDialog dialog = new MavenRepositorySearchDialog(getShell(), //
- Messages.DependenciesComposite_searchDialog_title, IIndex.SEARCH_ARTIFACT, artifacts, true);
- if(dialog.open() == Window.OK) {
- IndexedArtifactFile af = (IndexedArtifactFile) dialog.getFirstResult();
- if(af != null) {
- Dependency dependency = createDependency(dependencyManagementProvider,
- POM_PACKAGE.getDependencyManagement_Dependencies(), //
- af.group, af.artifact, af.version, af.classifier, "jar".equals(nvl(af.type)) ? "" : nvl(af.type), //$NON-NLS-1$ //$NON-NLS-2$
- "compile".equals(nvl(dialog.getSelectedScope())) ? "" : nvl(dialog.getSelectedScope()));//$NON-NLS-1$ //$NON-NLS-2$
- dependencyManagementEditor.setInput(dependencyManagementProvider.getValue().getDependencies());
- dependencyManagementEditor.setSelection(Collections.singletonList(dependency));
+ final AddDependencyDialog addDepDialog = new AddDependencyDialog(getShell(), true, editorPage.getProject(), editorPage.getPomEditor().getMavenProject());
+
+ /*
+ * Load the dependency tree for the dialog so it can show already
+ * added transitive dependencies.
+ */
+ Runnable runnable = new Runnable() {
+
+ public void run() {
+ pomEditor.loadDependencies(new Callback() {
+
+ public void onFinish(DependencyNode node) {
+ addDepDialog.setDepdencyNode(node);
+ }
+
+ public void onException(CoreException ex) {
+ MavenLogger.log(ex);
+ }
+ }, Artifact.SCOPE_TEST);
}
+ };
+
+ addDepDialog.onLoad(runnable);
+
+ if(addDepDialog.open() == Window.OK) {
+ List<Dependency> deps = addDepDialog.getDependencies();
+ for(Dependency dep : deps) {
+ setupDependency(dependencyManagementProvider, POM_PACKAGE.getDependencyManagement_Dependencies(), dep);
+ }
+ setDependenciesInput();
+ dependencyManagementEditor.setInput(dependencyManagementProvider.getValue().getDependencies());
+ dependencyManagementEditor.setSelection(Collections.singletonList(deps.get(0)));
}
}
});

Back to the top