Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Munoz2013-03-21 16:47:36 -0400
committerIgor Fedorenko2013-05-04 13:05:22 -0400
commit99de7feb2f2dcfa3a5328b532f3f2804ae4d825a (patch)
tree43bc244bf750e4800315ca5b489953b986155eea
parent21c23445bd0d5f8a966ea118a92ae218afd2e02e (diff)
downloadm2e-core-99de7feb2f2dcfa3a5328b532f3f2804ae4d825a.tar.gz
m2e-core-99de7feb2f2dcfa3a5328b532f3f2804ae4d825a.tar.xz
m2e-core-99de7feb2f2dcfa3a5328b532f3f2804ae4d825a.zip
Adding a managed dependency adds a blank dependency instead
- I wrote 100% of the code; - I have the right to contribute the code to Eclipse - I have updated the header Changes to be committed: modified: src/org/eclipse/m2e/core/ui/internal/Messages.java modified: src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java modified: src/org/eclipse/m2e/core/ui/internal/messages.properties
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java4
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java21
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties2
3 files changed, 26 insertions, 1 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
index 48824ed9..339c4796 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
@@ -31,8 +31,12 @@ public class Messages extends NLS {
public static String AddDependencyDialog_artifactId_label;
+ public static String AddDependencyDialog_artifactId_error;
+
public static String AddDependencyDialog_groupId_label;
+ public static String AddDependencyDialog_groupId_error;
+
public static String AddDependencyDialog_scope_label;
public static String AddDependencyDialog_version_label;
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java
index 82c1a450..ae1c6cda 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java
@@ -17,6 +17,7 @@ import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -44,6 +45,7 @@ import org.eclipse.m2e.core.embedder.ArtifactKey;
import org.eclipse.m2e.core.internal.index.IIndex;
import org.eclipse.m2e.core.internal.index.IndexedArtifact;
import org.eclipse.m2e.core.internal.index.IndexedArtifactFile;
+import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator;
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.m2e.core.ui.internal.search.util.Packaging;
import org.eclipse.m2e.core.ui.internal.util.M2EUIUtils;
@@ -321,6 +323,7 @@ public class MavenRepositorySearchDialog extends AbstractMavenDialog {
txtArtifactId.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
+ updateStatus(validateArtifactEntries());
if(!ignoreTextChange) {
computeResultFromField(valueOrNull(txtGroupId.getText()), valueOrNull(txtArtifactId.getText()),
valueOrNull(txtVersion.getText()));
@@ -331,6 +334,7 @@ public class MavenRepositorySearchDialog extends AbstractMavenDialog {
txtGroupId.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
+ updateStatus(validateArtifactEntries());
if(!ignoreTextChange) {
computeResultFromField(valueOrNull(txtGroupId.getText()), valueOrNull(txtArtifactId.getText()),
valueOrNull(txtVersion.getText()));
@@ -347,15 +351,30 @@ public class MavenRepositorySearchDialog extends AbstractMavenDialog {
}
});
+ updateStatus(validateArtifactEntries());
return composite;
}
+ IStatus validateArtifactEntries() {
+ if(txtArtifactId.getText().isEmpty())
+ return new Status(IStatus.ERROR, M2EUIPluginActivator.PLUGIN_ID, Messages.AddDependencyDialog_artifactId_error);
+
+ if(txtGroupId.getText().isEmpty())
+ return new Status(IStatus.ERROR, M2EUIPluginActivator.PLUGIN_ID, Messages.AddDependencyDialog_groupId_error);
+
+ return new Status(IStatus.OK, M2EUIPluginActivator.PLUGIN_ID, "");//$NON-NLS-1$;
+ }
+
void okPressedDelegate() {
okPressed();
}
void updateStatusDelegate(IStatus status) {
- updateStatus(status);
+ IStatus validationStatus = validateArtifactEntries();
+ if(validationStatus.isOK())
+ updateStatus(status);
+ else
+ updateStatus(validationStatus);
}
private String valueOrNull(String text) {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
index 9b64ff40..cc7917f3 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
@@ -4,7 +4,9 @@ AddDependencyAction_error_msg=Can't add dependency to {0}
AddDependencyAction_error_title=Add Dependency
AddDependencyAction_searchDialog_title=Add Dependency
AddDependencyDialog_artifactId_label=Artifact Id\:
+AddDependencyDialog_artifactId_error=Artifact Id cannot be empty
AddDependencyDialog_groupId_label=Group Id\:
+AddDependencyDialog_groupId_error=Group Id cannot be empty
AddDependencyDialog_scope_label=Scope\:
AddDependencyDialog_version_label=Version\:
AddPluginAction_searchDialog_title=Add Plugin

Back to the top