Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2010-12-28 08:45:47 -0500
committerMilos Kleint2010-12-28 08:45:47 -0500
commitde368af70aa11b14620da6704e6054c501d6b6aa (patch)
tree49bec6a42a9e0b1ec524cdc8f00a05a016a89b54
parentb3f86f9675addd1ff2f507773626dfc15b35a644 (diff)
downloadm2e-core-de368af70aa11b14620da6704e6054c501d6b6aa.tar.gz
m2e-core-de368af70aa11b14620da6704e6054c501d6b6aa.tar.xz
m2e-core-de368af70aa11b14620da6704e6054c501d6b6aa.zip
MNGECLIPSE-2547, MNGECLIPSE-2687 remove unused code, no longer load the DependencyNodes and use them to add information about transitiveness
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/ui/dialogs/AddDependencyDialog.java129
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java59
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java82
3 files changed, 56 insertions, 214 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 b61dab44..3f8334bf 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
@@ -124,14 +124,6 @@ public class AddDependencyDialog extends AbstractMavenDialog {
protected IProject project;
- protected DependencyNode dependencyNode;
-
- /*
- * This is to be run when the dialog is done creating its controls, but
- * before open() is called
- */
- protected Runnable onLoad;
-
protected IStatus lastStatus;
protected SelectionListener resultsListener;
@@ -192,8 +184,6 @@ public class AddDependencyDialog extends AbstractMavenDialog {
Composite searchControls = createSearchControls(composite);
searchControls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Display.getDefault().asyncExec(this.onLoad);
-
updateStatus();
return composite;
}
@@ -280,28 +270,32 @@ public class AddDependencyDialog extends AbstractMavenDialog {
resultsViewer.setSelection(StructuredSelection.EMPTY);
updateStatus();
}
- if(dependencyNode == null) {
- return;
- }
- dependencyNode.accept(new DependencyVisitor() {
-
- public boolean visitLeave(DependencyNode node) {
- if(node.getDependency() != null && node.getDependency().getArtifact() != null) {
- Artifact artifact = node.getDependency().getArtifact();
- if(artifact.getGroupId().equalsIgnoreCase(groupIDtext.getText().trim())
- && artifact.getArtifactId().equalsIgnoreCase(artifactIDtext.getText().trim())) {
- infoTextarea.setText(NLS.bind(Messages.AddDependencyDialog_info_transitive,
- new String[] {artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()}));
- }
- return false;
- }
- return true;
- }
-
- public boolean visitEnter(DependencyNode node) {
- return true;
- }
- });
+ // TODO mkleint: for now just ignore..
+// this snippet is supposed to tell people that they selected dependency already in the
+// project
+
+// if(dependencyNode == null) {
+// return;
+// }
+// dependencyNode.accept(new DependencyVisitor() {
+//
+// public boolean visitLeave(DependencyNode node) {
+// if(node.getDependency() != null && node.getDependency().getArtifact() != null) {
+// Artifact artifact = node.getDependency().getArtifact();
+// if(artifact.getGroupId().equalsIgnoreCase(groupIDtext.getText().trim())
+// && artifact.getArtifactId().equalsIgnoreCase(artifactIDtext.getText().trim())) {
+// infoTextarea.setText(NLS.bind(Messages.AddDependencyDialog_info_transitive,
+// new String[] {artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()}));
+// }
+// return false;
+// }
+// return true;
+// }
+//
+// public boolean visitEnter(DependencyNode node) {
+// return true;
+// }
+// });
}
@@ -432,32 +426,36 @@ public class AddDependencyDialog extends AbstractMavenDialog {
buffer.append(", date: " + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(file.date));
buffer.append("\n");
- if(dependencyNode != null) {
- dependencyNode.accept(new DependencyVisitor() {
-
- public boolean visitEnter(DependencyNode node) {
- return true;
- }
-
- public boolean visitLeave(DependencyNode node) {
- if(node.getDependency() == null || node.getDependency().getArtifact() == null) {
- return true;
- }
- Artifact artifact = node.getDependency().getArtifact();
- if(artifact.getGroupId().equalsIgnoreCase(file.group)
- && artifact.getArtifactId().equalsIgnoreCase(file.artifact)) {
- buffer.append(NLS.bind(Messages.AddDependencyDialog_transitive_dependency,
- new String[] {artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()}));
- /*
- * DependencyNodes don't know their parents. Determining which transitive dependency
- * is using the selected dependency is non trivial :(
- */
- return false;
- }
- return true;
- }
- });
- }
+// TODO mkleint: for now just ignore..
+// this snippet is supposed to tell people that they selected dependency already in the
+// project
+
+// if(dependencyNode != null) {
+// dependencyNode.accept(new DependencyVisitor() {
+//
+// public boolean visitEnter(DependencyNode node) {
+// return true;
+// }
+//
+// public boolean visitLeave(DependencyNode node) {
+// if(node.getDependency() == null || node.getDependency().getArtifact() == null) {
+// return true;
+// }
+// Artifact artifact = node.getDependency().getArtifact();
+// if(artifact.getGroupId().equalsIgnoreCase(file.group)
+// && artifact.getArtifactId().equalsIgnoreCase(file.artifact)) {
+// buffer.append(NLS.bind(Messages.AddDependencyDialog_transitive_dependency,
+// new String[] {artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()}));
+// /*
+// * DependencyNodes don't know their parents. Determining which transitive dependency
+// * is using the selected dependency is non trivial :(
+// */
+// return false;
+// }
+// return true;
+// }
+// });
+// }
}
protected void search(String query) {
@@ -681,19 +679,4 @@ public class AddDependencyDialog extends AbstractMavenDialog {
}
}
-
- public void setDepdencyNode(DependencyNode node) {
- this.dependencyNode = node;
- }
-
- /**
- * The provided runnable will be called after createDialogArea is done, but before it returns. This provides a way for
- * long running operations to be executed in such a way as to not block the UI. This is primarily intended to allow
- * the loading of the dependencyTree. The runnable should load the tree and then call setDependencyNode()
- *
- * @param runnable
- */
- public void onLoad(Runnable runnable) {
- this.onLoad = runnable;
- }
}
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 f6f770ba..fd280be8 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
@@ -11,20 +11,15 @@
package org.eclipse.m2e.editor.composites;
-import static org.eclipse.m2e.editor.pom.FormUtils.nvl;
-
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -40,7 +35,6 @@ import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -51,22 +45,16 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.core.MavenLogger;
-import org.eclipse.m2e.core.embedder.ArtifactKey;
-import org.eclipse.m2e.core.index.IIndex;
-import org.eclipse.m2e.core.index.IndexedArtifactFile;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenProjectManager;
import org.eclipse.m2e.core.ui.dialogs.AddDependencyDialog;
import org.eclipse.m2e.core.ui.dialogs.EditDependencyDialog;
-import org.eclipse.m2e.core.ui.dialogs.MavenRepositorySearchDialog;
import org.eclipse.m2e.editor.MavenEditorImages;
import org.eclipse.m2e.editor.MavenEditorPlugin;
import org.eclipse.m2e.editor.dialogs.ManageDependenciesDialog;
import org.eclipse.m2e.editor.internal.Messages;
import org.eclipse.m2e.editor.pom.MavenPomEditor;
-import org.eclipse.m2e.editor.pom.MavenPomEditor.Callback;
import org.eclipse.m2e.editor.pom.MavenPomEditorPage;
import org.eclipse.m2e.editor.pom.SearchControl;
import org.eclipse.m2e.editor.pom.SearchMatcher;
@@ -92,7 +80,6 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
-import org.sonatype.aether.graph.DependencyNode;
/**
@@ -251,29 +238,6 @@ public class DependenciesComposite extends Composite {
dependenciesEditor.setAddButtonListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
final AddDependencyDialog addDepDialog = new AddDependencyDialog(getShell(), false, 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) {
@@ -445,29 +409,6 @@ public class DependenciesComposite extends Composite {
dependencyManagementEditor.setAddButtonListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
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) {
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
index 8cd206e4..1015d3e4 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
@@ -210,8 +210,6 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
List<IPomFileChangedListener> fileChangeListeners = new ArrayList<IPomFileChangedListener>();
- private LoadDependenciesJob loadDependenciesJob;
-
protected boolean resourceChangeEventSkip = false;
public MavenPomEditor() {
@@ -508,86 +506,6 @@ public class MavenPomEditor extends FormEditor implements IResourceChangeListene
}
}
- public void loadDependencies(Callback callback, String classpath) {
- if (this.loadDependenciesJob != null && this.loadDependenciesJob.dependencyNode != null) {
- //Already loaded, we're done!
- callback.onFinish(loadDependenciesJob.dependencyNode);
- return;
- } else if (this.loadDependenciesJob != null && this.loadDependenciesJob.getState() != Job.NONE) {
- //Currently running
- loadDependenciesJob.addCallback(callback);
- return;
- }
-
- this.loadDependenciesJob = new LoadDependenciesJob(this, classpath, callback);
- loadDependenciesJob.schedule();
- }
-
- public static interface Callback {
- /**
- * Called when the dependency tree is done loading. The node parameter
- * points to the root of the tree.
- * @param node
- */
- public void onFinish(DependencyNode node);
-
- /**
- * Called if an exception occurs while loading the dependency tree.
- * @param ex
- */
- public void onException(CoreException ex);
- }
-
- /**
- * Loads the dependency tree in a Job so as to not block the UI.
- * Once the loading is done, it calls the provided callback with the root
- * node of the dependency tree. If there is an error, it notifies the
- * callback's onException method.
- */
- class LoadDependenciesJob extends Job {
-
- private MavenPomEditor pomEditor;
- private String classpath;
- private List<Callback> callbacks = new LinkedList<MavenPomEditor.Callback>();
- DependencyNode dependencyNode;
-
- public LoadDependenciesJob(MavenPomEditor editor, String classpath, Callback callback) {
- super("Resolving dependencies");
- this.pomEditor = editor;
- this.classpath = classpath;
- this.callbacks.add( callback );
- }
-
- void addCallback(Callback callback) {
- if (!this.callbacks.contains(callback)) {
- this.callbacks.add( callback );
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus run(IProgressMonitor monitor) {
- boolean force = false;
- try {
- final DependencyNode dependencyNode = pomEditor.readDependencyTree(force, classpath, monitor);
-
- if(dependencyNode == null) {
- return Status.CANCEL_STATUS;
- }
- this.dependencyNode = dependencyNode;
- for (Callback callback : callbacks) {
- callback.onFinish(dependencyNode);
- }
- } catch(final CoreException ex) {
- for (Callback callback : callbacks) {
- callback.onException(ex);
- }
- }
-
- return Status.OK_STATUS;
- }
- }
/**
* Load the effective POM in a job and then update the effective pom page when its done

Back to the top