Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2011-01-13 15:13:19 +0000
committerMilos Kleint2011-01-13 15:13:19 +0000
commit525f684aa83481e1f9ed7a83dee387eb4adad350 (patch)
tree933c49ef8d24634070d69e0635f5a4d9617a3131 /org.eclipse.m2e.editor
parent84ec24d279a1aa563273ea3136a3282eaffed008 (diff)
downloadm2e-core-525f684aa83481e1f9ed7a83dee387eb4adad350.tar.gz
m2e-core-525f684aa83481e1f9ed7a83dee387eb4adad350.tar.xz
m2e-core-525f684aa83481e1f9ed7a83dee387eb4adad350.zip
MNGECLIPSE-2717 proper updating of values in the dependencies lists based on currently edited DM model
Diffstat (limited to 'org.eclipse.m2e.editor')
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java13
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java34
2 files changed, 42 insertions, 5 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 d4dd3742..9e965b64 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
@@ -393,6 +393,8 @@ public class DependenciesComposite extends Composite {
if(d.open() == Window.OK) {
dependencyManagementEditor.setInput(dependencyManagementProvider.getValue().getDependencies());
dependencyManagementEditor.setSelection(Collections.singletonList(dependency));
+ //refresh this one to update decorations..
+ dependenciesEditor.refresh();
}
}
});
@@ -421,6 +423,8 @@ public class DependenciesComposite extends Composite {
setDependenciesInput();
dependencyManagementEditor.setInput(dependencyManagementProvider.getValue().getDependencies());
dependencyManagementEditor.setSelection(Collections.singletonList(deps.get(0)));
+ //refresh this one to update decorations..
+ dependenciesEditor.refresh();
}
}
});
@@ -502,8 +506,8 @@ public class DependenciesComposite extends Composite {
public void loadData(Model model, ValueProvider<DependencyManagement> dependencyManagementProvider) {
this.model = model;
this.dependencyManagementProvider = dependencyManagementProvider;
- this.dependencyLabelProvider.setPomEditor(editorPage.getPomEditor());
- this.dependencyManagementLabelProvider.setPomEditor(editorPage.getPomEditor());
+ this.dependencyLabelProvider.setPomEditor(editorPage.getPomEditor(), dependencyManagementProvider);
+ this.dependencyManagementLabelProvider.setPomEditor(editorPage.getPomEditor(), dependencyManagementProvider);
setDependenciesInput();
@@ -550,6 +554,8 @@ public class DependenciesComposite extends Composite {
dependencyManagementEditor.setInput(((DependencyManagement) object).getDependencies());
}
dependencyManagementEditor.refresh();
+ //refresh this one to update decorations..
+ dependenciesEditor.refresh();
}
if (object instanceof Dependency) {
dependenciesEditor.refresh();
@@ -883,5 +889,6 @@ public class DependenciesComposite extends Composite {
if (showInheritedDependencies) {
setDependenciesInput();
}
+ dependenciesEditor.refresh();
}
- }
+}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java
index c8064fe4..50742999 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependencyLabelProvider.java
@@ -15,6 +15,7 @@ import java.util.Collection;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.DependencyManagement;
+import org.apache.maven.model.InputLocation;
import org.apache.maven.project.MavenProject;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IDecoration;
@@ -27,6 +28,7 @@ import org.eclipse.m2e.core.project.MavenProjectManager;
import org.eclipse.m2e.editor.MavenEditorImages;
import org.eclipse.m2e.editor.internal.Messages;
import org.eclipse.m2e.editor.pom.MavenPomEditor;
+import org.eclipse.m2e.editor.pom.ValueProvider;
import org.eclipse.m2e.model.edit.pom.Dependency;
import org.eclipse.m2e.model.edit.pom.Exclusion;
import org.eclipse.m2e.model.edit.pom.Extension;
@@ -50,6 +52,8 @@ public class DependencyLabelProvider extends LabelProvider implements IColorProv
private boolean showGroupId = false;
private final boolean showManagedOverlay;
+
+ private ValueProvider<org.eclipse.m2e.model.edit.pom.DependencyManagement> managementProvider;
public DependencyLabelProvider() {
this(false);
@@ -60,8 +64,11 @@ public class DependencyLabelProvider extends LabelProvider implements IColorProv
this.showManagedOverlay = showManagedOverlay;
}
- public void setPomEditor(MavenPomEditor pomEditor) {
+ public void setPomEditor(MavenPomEditor pomEditor, ValueProvider<org.eclipse.m2e.model.edit.pom.DependencyManagement> dependencyManagementProvider) {
+ assert pomEditor != null;
+ assert managementProvider != null;
this.pomEditor = pomEditor;
+ this.managementProvider = dependencyManagementProvider;
}
public void setShowGroupId(boolean showGroupId) {
@@ -85,17 +92,40 @@ public class DependencyLabelProvider extends LabelProvider implements IColorProv
private String findManagedVersion(Dependency dep) {
if (pomEditor != null) {
MavenProject mp = pomEditor.getMavenProject();
+ String version = null;
if(mp != null) {
+ String id = mp.getGroupId() + ":" + mp.getArtifactId() + ":" + mp.getVersion();
DependencyManagement dm = mp.getDependencyManagement();
if(dm != null) {
for(org.apache.maven.model.Dependency d : dm.getDependencies()) {
if(d.getGroupId().equals(dep.getGroupId()) && d.getArtifactId().equals(dep.getArtifactId())) {
- //TODO based on location, try finding a match in the live Model
+ //based on location, try finding a match in the live Model
+ InputLocation location = d.getLocation("artifactId");
+ if (location != null) {
+ if (id.equals(location.getSource().getModelId())) {
+ version = d.getVersion();
+ break;
+ }
+ }
return d.getVersion();
}
}
}
}
+ org.eclipse.m2e.model.edit.pom.DependencyManagement dm = managementProvider.getValue();
+ for (Dependency modelDep : dm.getDependencies()) {
+ String modelGroupId = modelDep.getGroupId();
+ String modelArtifactId = modelDep.getArtifactId();
+ String modelVersion = modelDep.getVersion();
+ if (modelGroupId != null && modelGroupId.equals(dep.getGroupId()) &&
+ modelArtifactId != null && modelArtifactId.equals(dep.getArtifactId())) {
+ if (version != null && (modelVersion == null || modelVersion.contains("${"))) {
+ //prefer the resolved version to the model one if the model version as expressions..
+ return version;
+ }
+ return modelVersion;
+ }
+ }
}
return null;
}

Back to the top