Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2013-06-14 04:01:17 -0400
committerIgor Fedorenko2013-06-14 04:01:17 -0400
commit073ee9daf7613bd0ec83b00f5f0bfa615f796e0d (patch)
tree291be50381fbfb79ce824a3bb812a60fc6e082e8 /org.eclipse.m2e.editor.xml
parenta04f6f45fd741929effaebc0a207ef467c3b45d9 (diff)
downloadm2e-core-073ee9daf7613bd0ec83b00f5f0bfa615f796e0d.tar.gz
m2e-core-073ee9daf7613bd0ec83b00f5f0bfa615f796e0d.tar.xz
m2e-core-073ee9daf7613bd0ec83b00f5f0bfa615f796e0d.zip
Reworked ParentGatherer and related pom.xml manipulations
Introduced ParentHierarchyEntry that encapsulates MavenProject and corresponding IMavenProjectFacade and reworked all clients of ParentGatherer to use ParentHierarchyEntry instead of brittle mapping between MavenProject and IMavenProjectFacade instances. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.editor.xml')
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java12
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingDialog.java31
2 files changed, 16 insertions, 27 deletions
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java
index 13e10cc8..861c2439 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/dialogs/SelectSPDXLicenseDialog.java
@@ -42,12 +42,10 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
-import org.apache.maven.project.MavenProject;
-
-import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.ui.internal.components.PomHierarchyComposite;
import org.eclipse.m2e.core.ui.internal.dialogs.AbstractMavenDialog;
+import org.eclipse.m2e.core.ui.internal.util.ParentHierarchyEntry;
import org.eclipse.m2e.editor.xml.MvnIndexPlugin;
import org.eclipse.m2e.editor.xml.internal.Messages;
@@ -180,15 +178,15 @@ public class SelectSPDXLicenseDialog extends AbstractMavenDialog {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = parentComposite.getSelection();
if(selection instanceof IStructuredSelection && !selection.isEmpty()) {
- MavenProject mavenProject = (MavenProject) ((IStructuredSelection) selection).getFirstElement();
- targetProject = MavenPlugin.getMavenProjectRegistry().getMavenProject(mavenProject.getGroupId(),
- mavenProject.getArtifactId(), mavenProject.getVersion());
+ ParentHierarchyEntry mavenProject = (ParentHierarchyEntry) ((IStructuredSelection) selection)
+ .getFirstElement();
+ targetProject = mavenProject.getFacade();
updateStatus();
}
}
});
parentComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- parentComposite.computeHeirarchy(project, null); // FIXME proper progress monitor
+ parentComposite.computeHeirarchy(project, null);
parentComposite.setSelection(new StructuredSelection(parentComposite.getHierarchy().get(0)));
return container;
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingDialog.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingDialog.java
index af53849b..1f1b041b 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingDialog.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/lifecycle/LifecycleMappingDialog.java
@@ -12,13 +12,10 @@
package org.eclipse.m2e.editor.xml.internal.lifecycle;
import java.io.File;
-import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -38,9 +35,9 @@ import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.internal.M2EUtils;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.ui.internal.components.PomHierarchyComposite;
+import org.eclipse.m2e.core.ui.internal.util.ParentHierarchyEntry;
@SuppressWarnings("restriction")
@@ -62,7 +59,7 @@ public class LifecycleMappingDialog extends Dialog implements ISelectionChangedL
private String goal;
- private MavenProject pluginProject;
+ private ParentHierarchyEntry pluginProject;
public LifecycleMappingDialog(Shell parentShell, IFile pom, String pluginGroupId, String pluginArtifactId,
String pluginVersion, String goal) {
@@ -88,13 +85,7 @@ public class LifecycleMappingDialog extends Dialog implements ISelectionChangedL
pomComposite = new PomHierarchyComposite(container, SWT.BORDER);
pomComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
pomComposite.addSelectionChangedListener(this);
- pomComposite.computeHeirarchy(facade, new IRunnableContext() {
-
- public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
- throws InvocationTargetException, InterruptedException {
- runnable.run(new NullProgressMonitor());
- }
- });
+ pomComposite.computeHeirarchy(facade, null);
status = new CLabel(container, SWT.WRAP);
status.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
@@ -115,15 +106,15 @@ public class LifecycleMappingDialog extends Dialog implements ISelectionChangedL
}
public void selectionChanged(SelectionChangedEvent event) {
- MavenProject project = pomComposite.fromSelection();
+ ParentHierarchyEntry project = pomComposite.fromSelection();
if(getButton(OK) != null) {
- getButton(OK).setEnabled(project != null && project.getFile() != null);
+ getButton(OK).setEnabled(project != null && project.getResource() != null);
}
updateStatus(project);
}
- private void updateStatus(MavenProject project) {
- if(project.getFile() == null) {
+ private void updateStatus(ParentHierarchyEntry project) {
+ if(project.getResource() == null) {
status.setText("Non-workspace pom");
status.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
} else if(project.equals(pluginProject)) {
@@ -137,7 +128,7 @@ public class LifecycleMappingDialog extends Dialog implements ISelectionChangedL
@Override
protected void okPressed() {
- pomFile = M2EUtils.getPomFile(pomComposite.fromSelection());
+ pomFile = pomComposite.fromSelection().getResource();
super.okPressed();
}
@@ -148,7 +139,7 @@ public class LifecycleMappingDialog extends Dialog implements ISelectionChangedL
return pomFile;
}
- private MavenProject locatePlugin() {
+ private ParentHierarchyEntry locatePlugin() {
MavenProject project = facade.getMavenProject(); // if we got here, facade.getMavenProject cannot be null
Plugin plugin = project.getPlugin(pluginGroupId + ":" + pluginArtifactId);
@@ -165,8 +156,8 @@ public class LifecycleMappingDialog extends Dialog implements ISelectionChangedL
}
File basedir = new File(location.getSource().getLocation()).getParentFile(); // should be canonical file already
- for(MavenProject other : pomComposite.getHierarchy()) {
- if(basedir.equals(other.getBasedir())) {
+ for(ParentHierarchyEntry other : pomComposite.getHierarchy()) {
+ if(basedir.equals(other.getFile().getParentFile())) {
return other;
}
}

Back to the top