Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2014-04-25 10:07:12 -0400
committerFred Bricon2014-04-25 10:07:34 -0400
commitaaa276afcd310b24d97260ba156a3252e017c8d3 (patch)
treece86df0bc9be421baf37af0c39a2f344687c5f8b
parent4f6f5eb95cfaa08f6ab6d3934992927273f47944 (diff)
downloadm2e-core-aaa276afcd310b24d97260ba156a3252e017c8d3.tar.gz
m2e-core-aaa276afcd310b24d97260ba156a3252e017c8d3.tar.xz
m2e-core-aaa276afcd310b24d97260ba156a3252e017c8d3.zip
433520 : improve SCM URL validation in wizard
Change-Id: I517580bdf0e5e8da915c93cfafdf162bed6f29c1 Signed-off-by: Fred Bricon <fbricon@gmail.com>
-rw-r--r--org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java51
1 files changed, 34 insertions, 17 deletions
diff --git a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java
index dd314beb..30af024d 100644
--- a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java
+++ b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenCheckoutLocationPage.java
@@ -113,8 +113,8 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
for(int i = 0; i < types.length; i++ ) {
scmTypeCombo.add(types[i]);
}
- scmTypeCombo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
+ scmTypeCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
String newScmType = scmTypeCombo.getText();
if(!newScmType.equals(scmType)) {
scmType = newScmType;
@@ -303,6 +303,7 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
}
});
}
+
updatePage();
}
@@ -312,6 +313,11 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
public void setVisible(boolean visible) {
super.setVisible(visible);
+ if(scmType == null && scmTypeCombo != null && scmTypeCombo.getItems().length == 1
+ && !scmTypeCombo.getItem(0).isEmpty()) {
+ scmTypeCombo.select(0);
+ }
+
if(dialogSettings != null && scmUrlCombo != null) {
String[] items = dialogSettings.getArray("scmUrl"); //$NON-NLS-1$
if(items != null) {
@@ -378,25 +384,23 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
private boolean isPageValid() {
setErrorMessage(null);
- if(scmUrls != null && scmUrls.length < 2) {
- if(scmType == null) {
- setErrorMessage(Messages.MavenCheckoutLocationPage_error_empty);
- return false;
- }
+ boolean emptyUrl = isEmptyScmUrl(scmUrls);
+
+ if(scmType == null && emptyUrl) {
+ setErrorMessage(Messages.MavenCheckoutLocationPage_error_empty);
+ return false;
}
- ScmHandlerUi handlerUi = ScmHandlerFactory.getHandlerUiByType(scmType);
+ if(emptyUrl) {
+ setErrorMessage(Messages.MavenCheckoutLocationPage_error_empty_url);
+ return false;
+ }
- if(scmUrls == null || scmUrls.length < 2) {
- if(scmUrls == null || scmUrls.length == 0) {
- setErrorMessage(Messages.MavenCheckoutLocationPage_error_empty_url);
- return false;
- }
+ ScmHandlerUi handlerUi = ScmHandlerFactory.getHandlerUiByType(scmType);
- if(handlerUi != null && !handlerUi.isValidUrl(scmUrls[0].getUrl())) {
- setErrorMessage(Messages.MavenCheckoutLocationPage_error_url_empty);
- return false;
- }
+ if(handlerUi != null && !handlerUi.isValidUrl(scmUrls[0].getUrl())) {
+ setErrorMessage(Messages.MavenCheckoutLocationPage_error_url_empty);
+ return false;
}
if(!isHeadRevision()) {
@@ -415,6 +419,19 @@ public class MavenCheckoutLocationPage extends AbstractMavenWizardPage {
return true;
}
+ private boolean isEmptyScmUrl(ScmUrl[] scmUrls) {
+ if(scmUrls == null || scmUrls.length == 0) {
+ return true;
+ }
+ String type = null;
+ String url = scmUrls[0].getUrl();
+ try {
+ type = ScmUrl.getType(url);
+ } catch(CoreException ignore) {
+ }
+ return ("scm:" + type + ":").equals(url);
+ }
+
public void setParent(String parentUrl) {
this.scmParentUrl = parentUrl;
}

Back to the top