Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Piggott2011-04-12 21:10:21 +0000
committerMatthew Piggott2011-04-12 21:10:47 +0000
commit416af3a5f8c49e6e8f89a62bd094eb9a29563927 (patch)
tree11367686d3d96dd2be5fcfd6495f0d3fbe35c47b /org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude
parent82f98e04fecbff44ddda2d95c76a8cb14569a254 (diff)
downloadm2e-core-416af3a5f8c49e6e8f89a62bd094eb9a29563927.tar.gz
m2e-core-416af3a5f8c49e6e8f89a62bd094eb9a29563927.tar.xz
m2e-core-416af3a5f8c49e6e8f89a62bd094eb9a29563927.zip
Added support for choosing pom in hierarchy to ignore goal
Diffstat (limited to 'org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude')
-rw-r--r--org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java29
-rw-r--r--org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeWizardPage.java18
2 files changed, 6 insertions, 41 deletions
diff --git a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java
index b451345e..5597843d 100644
--- a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java
+++ b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.m2e.refactoring.exclude;
-import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -19,22 +18,17 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.Stack;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion;
import org.apache.maven.project.MavenProject;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.ltk.core.refactoring.Change;
@@ -43,6 +37,7 @@ import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.ArtifactKey;
+import org.eclipse.m2e.core.internal.M2EUtils;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.ui.internal.editing.AddDependencyOperation;
import org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation;
@@ -264,26 +259,8 @@ public class ExcludeArtifactRefactoring extends Refactoring {
}
private IFile getFile(MavenProject project) throws CoreException {
- //XXX copied from XmlUtils.extractProject()
- File file = new File(project.getFile().toURI());
- IPath path = Path.fromOSString(file.getAbsolutePath());
- Stack<IFile> stack = new Stack<IFile>();
- //here we need to find the most inner project to the path.
- //we do so by shortening the path and remembering all the resources identified.
- // at the end we pick the last one from the stack. is there a catch to it?
- IFile ifile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
- if (ifile != null) {
- stack.push(ifile);
- }
- while(path.segmentCount() > 1) {
- IResource ires = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
- if(ires != null && ires instanceof IFile) {
- stack.push((IFile)ires);
- }
- path = path.removeFirstSegments(1);
- }
- IFile res = stack.empty() ? null : stack.pop();
-
+ IFile res = M2EUtils.getPomFile(project);
+
if(res == null) {
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(
Messages.ExcludeArtifactRefactoring_failedToLocatePom, project.toString())));
diff --git a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeWizardPage.java b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeWizardPage.java
index ab022947..bd2029b9 100644
--- a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeWizardPage.java
+++ b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeWizardPage.java
@@ -11,13 +11,11 @@
package org.eclipse.m2e.refactoring.exclude;
import org.apache.maven.project.MavenProject;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
-import org.eclipse.m2e.editor.composites.PomHierarchyComposite;
+import org.eclipse.m2e.core.ui.internal.components.PomHierarchyComposite;
import org.eclipse.m2e.refactoring.Messages;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -128,7 +126,7 @@ public class ExcludeWizardPage extends UserInputWizardPage implements SelectionL
private void updateState() {
ExcludeArtifactRefactoring refactoring = (ExcludeArtifactRefactoring) getRefactoring();
if (hierarchy.getSelection()) {
- MavenProject project = fromSelection(pomHierarchy.getSelection());
+ MavenProject project = pomHierarchy.fromSelection();
updateStatusBar(project);
refactoring.setExclusionPoint(project);
} else {
@@ -145,7 +143,7 @@ public class ExcludeWizardPage extends UserInputWizardPage implements SelectionL
setStatus(Messages.ExcludeWizardPage_errorNonWorkspacePom);
setPageComplete(false);
} else if((project = isAboveDependencyManagement(project)) != null) {
- setStatus(NLS.bind("Dependencies managed in {0}.",
+ setStatus(NLS.bind(Messages.ExcludeWizardPage_dependenciesManagedIn,
toString(project)));
setPageComplete(false);
} else {
@@ -161,16 +159,6 @@ public class ExcludeWizardPage extends UserInputWizardPage implements SelectionL
updateState();
}
- private MavenProject fromSelection(ISelection selection) {
- if(selection instanceof IStructuredSelection) {
- Object obj = ((IStructuredSelection) selection).getFirstElement();
- if(obj instanceof MavenProject) {
- return (MavenProject) obj;
- }
- }
- return null;
- }
-
private MavenProject isAboveDependencyManagement(MavenProject project) {
for(MavenProject cProject : pomHierarchy.getHierarchy()) {
if(project == cProject) {

Back to the top