Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Piggott2011-03-10 19:38:51 +0000
committerMatthew Piggott2011-03-10 19:38:51 +0000
commitf1da3ffa7a163b33b9a27bf1c06b7a334758da11 (patch)
treefc18067a00e80868910c8399411e7623297b680f /org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude
parentb37f2a1a8337a0ce0cfe094acd397bdffe87a070 (diff)
downloadm2e-core-f1da3ffa7a163b33b9a27bf1c06b7a334758da11.tar.gz
m2e-core-f1da3ffa7a163b33b9a27bf1c06b7a334758da11.tar.xz
m2e-core-f1da3ffa7a163b33b9a27bf1c06b7a334758da11.zip
Bug 337565 - Message cleanup, copy exclusions from parent
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.java30
-rw-r--r--org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeWizardPage.java23
2 files changed, 41 insertions, 12 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 d12c0dc0..4cd1dc6f 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
@@ -17,9 +17,9 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Stack;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.Stack;
import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
@@ -103,7 +103,7 @@ public class ExcludeArtifactRefactoring extends Refactoring {
sb.append(key.toString()).append(',');
}
sb.deleteCharAt(sb.length() - 1);
- return NLS.bind(Messages.ExcludeArtifactRefactoring_name, sb.toString());
+ return NLS.bind(Messages.MavenExcludeWizard_title, sb.toString());
}
/* (non-Javadoc)
@@ -152,9 +152,6 @@ public class ExcludeArtifactRefactoring extends Refactoring {
Dependency dependency = entry.getKey();
operations.add(new RemoveDependencyOperation(dependency));
if(!contains(entry.getValue(), dependency)) {
- CompositeChange change = new CompositeChange(Messages.ExcludeArtifactRefactoring_moveDependency);
- change.add(PomHelper.createChange(getFile(project), new RemoveDependencyOperation(dependency),
- NLS.bind(Messages.ExcludeArtifactRefactoring_removeDependency, toString(dependency))));
exclusionOp.add(new AddDependencyOperation(dependency));
for(ArtifactKey key : entry.getValue()) {
exclusionOp.add(new AddExclusionOperation(dependency, key));
@@ -162,8 +159,9 @@ public class ExcludeArtifactRefactoring extends Refactoring {
}
}
if(operations.size() > 0) {
- changes.add(PomHelper.createChange(getFile(project),
- new CompoundOperation(operations.toArray(new Operation[operations.size()])), "Exclude Artifact"));
+ IFile pom = getFile(project);
+ changes.add(PomHelper.createChange(pom,
+ new CompoundOperation(operations.toArray(new Operation[operations.size()])), getName(pom)));
}
}
@@ -177,8 +175,9 @@ public class ExcludeArtifactRefactoring extends Refactoring {
if(project.getFile() != null) {
statuses.add(new Status(IStatus.INFO, PLUGIN_ID, NLS.bind(Messages.ExcludeArtifactRefactoring_removeDependencyFrom,
toString(dependency), getMavenProjectFacade(project).getPom().getFullPath())));
+ IFile pom = getFile(project);
changes.add(PomHelper.createChange(getFile(project), new RemoveDependencyOperation(dependency),
- NLS.bind(Messages.ExcludeArtifactRefactoring_removeDependency, toString(dependency))));
+ getName(pom)));
}
} else {
exclusionOp.add(new AddDependencyOperation(dependency));
@@ -190,7 +189,7 @@ public class ExcludeArtifactRefactoring extends Refactoring {
}
if(!exclusionOp.isEmpty()) {
changes.add(PomHelper.createChange(getFile(exclusionPoint),
- new CompoundOperation(exclusionOp.toArray(new Operation[exclusionOp.size()])), getName()));
+ new CompoundOperation(exclusionOp.toArray(new Operation[exclusionOp.size()])), getName(pomFile)));
}
if(statuses.size() == 1) {
@@ -214,6 +213,11 @@ public class ExcludeArtifactRefactoring extends Refactoring {
return new RefactoringStatus();
}
+ private String getName(IFile file) {
+ return new StringBuilder().append(file.getName())
+ .append(" - ").append(file.getProject().getName()).toString(); //$NON-NLS-1$
+ }
+
private Visitor locate(MavenProject project, IProgressMonitor monitor) throws CoreException {
DependencyNode root = MavenPlugin.getDefault().getMavenModelManager()
.readDependencyTree(project, JavaScopes.TEST, monitor);
@@ -226,7 +230,7 @@ public class ExcludeArtifactRefactoring extends Refactoring {
* @see org.eclipse.ltk.core.refactoring.Refactoring#createChange(org.eclipse.core.runtime.IProgressMonitor)
*/
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
- CompositeChange change = new CompositeChange(getName());
+ CompositeChange change = new CompositeChange(Messages.ExcludeArtifactRefactoring_changeTitle);
change.addAll(changes.toArray(new Change[changes.size()]));
return change;
}
@@ -314,7 +318,11 @@ public class ExcludeArtifactRefactoring extends Refactoring {
private Map<Dependency, Set<ArtifactKey>> sourceMap = new HashMap<Dependency, Set<ArtifactKey>>();
Visitor(MavenProject project) {
- dependencies = project.getOriginalModel().getDependencies();
+ dependencies = new ArrayList<Dependency>();
+ dependencies.addAll(project.getOriginalModel().getDependencies());
+// for(Profile profile : project.getActiveProfiles()) {
+// dependencies.addAll(profile.getDependencies());
+// }
}
Map<Dependency, Set<ArtifactKey>> getSourceMap() {
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 8c805349..ab022947 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
@@ -19,6 +19,7 @@ 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.refactoring.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.SelectionEvent;
@@ -84,7 +85,7 @@ public class ExcludeWizardPage extends UserInputWizardPage implements SelectionL
pomHierarchy.setEnabled(false);
pomHierarchy.addSelectionChangedListener(this);
- status = new CLabel(composite, SWT.NONE);
+ status = new CLabel(composite, SWT.WRAP);
status.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
Display.getCurrent().asyncExec(new Runnable() {
@@ -143,6 +144,10 @@ public class ExcludeWizardPage extends UserInputWizardPage implements SelectionL
} else if(project.getFile() == null) {
setStatus(Messages.ExcludeWizardPage_errorNonWorkspacePom);
setPageComplete(false);
+ } else if((project = isAboveDependencyManagement(project)) != null) {
+ setStatus(NLS.bind("Dependencies managed in {0}.",
+ toString(project)));
+ setPageComplete(false);
} else {
setStatus(null);
setPageComplete(true);
@@ -165,4 +170,20 @@ public class ExcludeWizardPage extends UserInputWizardPage implements SelectionL
}
return null;
}
+
+ private MavenProject isAboveDependencyManagement(MavenProject project) {
+ for(MavenProject cProject : pomHierarchy.getHierarchy()) {
+ if(project == cProject) {
+ return null;
+ } else if(cProject.getOriginalModel().getDependencyManagement() != null
+ && !cProject.getOriginalModel().getDependencyManagement().getDependencies().isEmpty()) {
+ return cProject;
+ }
+ }
+ return null;
+ }
+
+ private static String toString(MavenProject project) {
+ return NLS.bind("{0}:{1}:{2}", new String[] {project.getGroupId(), project.getArtifactId(), project.getVersion()}); //$NON-NLS-1$
+ }
}

Back to the top