From 4cad7f9690d828d42f54114d2a61103076a9a1b1 Mon Sep 17 00:00:00 2001 From: aedelmann Date: Sun, 20 May 2018 21:30:30 +0800 Subject: [PATCH] Fixes #913 --- .../vorto/wizard/AbstractProjectWizardPage.java | 14 ++++++++------ .../eclipse/vorto/wizard/AbstractWizardPage.java | 7 +++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/framework/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractProjectWizardPage.java b/framework/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractProjectWizardPage.java index 55b1e10eac..d0f7897709 100644 --- a/framework/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractProjectWizardPage.java +++ b/framework/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractProjectWizardPage.java @@ -145,13 +145,15 @@ protected void handleBrowse(SelectionEvent e) { } protected boolean validateProject() { - boolean result = true; String projectName = getProjectName(); - result &= validateStrExist(projectName, - "Project name must be specified"); - result &= validateExistingSameProjectName(projectName); - result &= checkProjectName(projectName); - return result; + if (!validateStrExist(projectName, + "Project name must be specified") + || !validateExistingSameProjectName(projectName) + || !checkProjectName(projectName)) { + return false; + } else { + return true; + } } public void updateWorkspaceLocationField(String directory) { diff --git a/framework/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractWizardPage.java b/framework/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractWizardPage.java index f6bca29085..7ad1f0ac8d 100644 --- a/framework/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractWizardPage.java +++ b/framework/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractWizardPage.java @@ -28,7 +28,7 @@ public abstract class AbstractWizardPage extends WizardPage { - public static final String PROJECTNAME_REGEX = "[^a-zA-Z0-9 \\._]"; + public static final String PROJECTNAME_REGEX = "[A-Z][a-zA-Z0-9_]*$"; public static final String MODEL_NAME_REGEX = "[A-Z][a-zA-Z0-9_]*$"; public static final String VERSION_REGEX = "^\\d+\\.\\d+\\.\\d+(-\\w+)*$"; @@ -45,7 +45,7 @@ protected String getWindowTitle() { } protected boolean checkProjectName(String projectName) { - if (checkForRegexPattern(projectName, true, PROJECTNAME_REGEX)) { + if (checkForRegexPattern(projectName, false, PROJECTNAME_REGEX)) { setErrorMessage("Project name should not contain special characters."); return false; } @@ -66,6 +66,9 @@ protected boolean validateStrExist(String string, String errorMsgToBeShown) { } protected boolean validateExistingSameProjectName(String projectName) { + if (projectName.length() == 0 ) { + return false; + } IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace.getRoot().getProject(getProjectName()).exists()) {