Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2011-01-03 13:51:52 +0000
committerMilos Kleint2011-01-03 13:51:52 +0000
commitedb01caa14fe4685d992de8131817ee3846a7fa7 (patch)
tree925596199c5750e69168386e3e61876539ffe8b7 /org.eclipse.m2e.editor
parent0022fb6be37883070b2fb9a24a1155258241ccad (diff)
downloadm2e-core-edb01caa14fe4685d992de8131817ee3846a7fa7.tar.gz
m2e-core-edb01caa14fe4685d992de8131817ee3846a7fa7.tar.xz
m2e-core-edb01caa14fe4685d992de8131817ee3846a7fa7.zip
improve undo-ability of the changes
Diffstat (limited to 'org.eclipse.m2e.editor')
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java
index 4781492f..8e626e2c 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java
@@ -296,18 +296,22 @@ public class ManageDependenciesDialog extends AbstractMavenDialog {
//Add new entry in dependency mgt section
for(Dependency dep : dependencies) {
Dependency clone = PomFactory.eINSTANCE.createDependency();
- clone.setGroupId(dep.getGroupId());
- clone.setArtifactId(dep.getArtifactId());
- clone.setVersion(dep.getVersion());
-
Command addDepCommand = AddCommand.create(editingDomain, management,
PomPackage.eINSTANCE.getDependencyManagement_Dependencies(), clone);
-
command.append(addDepCommand);
+ command.append(createCommand(clone, dep.getGroupId(), PomPackage.eINSTANCE.getDependency_GroupId(), ""));
+ command.append(createCommand(clone, dep.getArtifactId(), PomPackage.eINSTANCE.getDependency_ArtifactId(), ""));
+ command.append(createCommand(clone, dep.getVersion(), PomPackage.eINSTANCE.getDependency_Version(), ""));
+
}
editingDomain.getCommandStack().execute(command);
-
}
+
+ private Command createCommand(Dependency dependency, String value, Object feature, String defaultValue) {
+ return SetCommand.create(editingDomain, dependency, feature,
+ value.length() == 0 || value.equals(defaultValue) ? SetCommand.UNSET_VALUE : value);
+ }
+
protected Model loadTargetModel(IMavenProjectFacade facade) {
try {

Back to the top