All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] [eclipse-poky][master]Add more comprehensive error message for invalid project name
@ 2013-03-14 11:50 Ioana Grigoropol
  2013-03-15  0:06 ` Zhang, Jessica
  0 siblings, 1 reply; 4+ messages in thread
From: Ioana Grigoropol @ 2013-03-14 11:50 UTC (permalink / raw)
  To: yocto

[Yocto #4008]

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |    1 +
 .../sdk/ide/wizard/NewYoctoCProjectTemplate.java   |   27 ++++++++++++++++----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
index 8596123..fc9813f 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
@@ -10,6 +10,7 @@
  * BMW Car IT - added keys for target profiles
  *******************************************************************************/
 Wizard.SDK.Warning.Title = Invalid Yocto Project ADT Location
+Wizard.SDK.Error.ProjecName = Project name "{0}" is invalid! \nNone of these characters are accepted inside project names: whitespaces, {1}
 
 Poky.SDK.Location.Empty = Specified Toolchain Root Location is empty.
 Poky.SDK.Location.Empty.Advice = You need specify Toolchain Root Location before building any project.
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
index 5ffd6b7..4d1684a 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
@@ -10,8 +10,11 @@
  *******************************************************************************/
 package org.yocto.sdk.ide.wizard;
 
+import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
 import org.eclipse.cdt.core.CCorePlugin;
@@ -46,11 +49,12 @@ import org.yocto.sdk.ide.YoctoProfileElement;
 import org.yocto.sdk.ide.YoctoSDKChecker;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
+import org.yocto.sdk.ide.YoctoSDKMessages;
+import org.yocto.sdk.ide.YoctoSDKPlugin;
+import org.yocto.sdk.ide.YoctoUIElement;
 import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
 import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
-import org.yocto.sdk.ide.YoctoSDKPlugin;
-import org.yocto.sdk.ide.YoctoUIElement;
 
 
 @SuppressWarnings("restriction")
@@ -58,11 +62,19 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
 	protected boolean savedAutoBuildingValue;
 	protected ProjectCreatedActions pca;
 	protected IManagedBuildInfo info;
+	protected List<Character> illegalChars = Arrays.asList('$', '"','#','%','&','\'','(',')','*', '+', ',','.','/',':',';','<','=','>','?','@','[','\\',']','^','`','{','|','}','~');
+	private static final String PROJECT_NAME_ERROR = "Wizard.SDK.Error.ProjecName";
 	
 	public NewYoctoCProjectTemplate() {
 		pca = new ProjectCreatedActions();
 	}
-	
+	private String printIllegalChars(){
+		String print = "";
+		for (Character ch : illegalChars)
+			print += ch + ", ";
+		print = print.substring(0, print.length() - 2);
+		return print;
+	}
 	public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
 
 		String projectName = args[0].getSimpleValue();
@@ -74,9 +86,9 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
 		boolean isEmptryProject = Boolean.valueOf(isEmptyProjetValue).booleanValue();
 		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
 		try {
-			if (projectName.contains(" ")) {
+			if (!isValidProjectName(projectName)) {
 				project.delete(true, null);
-				throw new ProcessFailureException(projectName + " contains space(s).  Project name can't contain space(s)");
+				throw new ProcessFailureException(YoctoSDKMessages.getFormattedString(PROJECT_NAME_ERROR, new Object[]{projectName, printIllegalChars()}));
 			}
 			if (!project.exists()) {
 				IWorkspace workspace = ResourcesPlugin.getWorkspace();
@@ -166,6 +178,11 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
 			throw new OperationCanceledException(Messages.getString("NewManagedProject.3") + e.getMessage());
 		}
 	}
+	private boolean isValidProjectName(String projectName) {
+		Pattern pattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_\\-]*$");
+		Matcher matcher = pattern.matcher(projectName);
+		return matcher.find();
+}
 
 	protected final void turnOffAutoBuild(IWorkspace workspace) throws CoreException {
 		IWorkspaceDescription workspaceDesc = workspace.getDescription();
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] [eclipse-poky][master]Add more comprehensive error message for invalid project name
  2013-03-14 11:50 [PATCH v2] [eclipse-poky][master]Add more comprehensive error message for invalid project name Ioana Grigoropol
@ 2013-03-15  0:06 ` Zhang, Jessica
  2013-03-27 13:55   ` Grigoropol, IoanaX
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang, Jessica @ 2013-03-15  0:06 UTC (permalink / raw)
  To: Grigoropol, IoanaX, yocto

Hi Ioana,

This patch still can't address the situation that found by Timo as following....

Thanks,
Jessica

I forgot to mention. I found a way to create projects with invalid names.

# Create a new Yocto C Project
# Enter a wrong name eg. Test"
# Press next
# Press finish
# --> Error Message is shown, press ok
# Press back
# Change the name to an also invalid name eg. Test$ # Click finish

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Thursday, March 14, 2013 4:50 AM
To: yocto@yoctoproject.org
Subject: [yocto] [PATCH v2] [eclipse-poky][master]Add more comprehensive error message for invalid project name

[Yocto #4008]

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |    1 +
 .../sdk/ide/wizard/NewYoctoCProjectTemplate.java   |   27 ++++++++++++++++----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
index 8596123..fc9813f 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.p
+++ roperties
@@ -10,6 +10,7 @@
  * BMW Car IT - added keys for target profiles
  *******************************************************************************/
 Wizard.SDK.Warning.Title = Invalid Yocto Project ADT Location
+Wizard.SDK.Error.ProjecName = Project name "{0}" is invalid! \nNone of
+these characters are accepted inside project names: whitespaces, {1}

 Poky.SDK.Location.Empty = Specified Toolchain Root Location is empty.
 Poky.SDK.Location.Empty.Advice = You need specify Toolchain Root Location before building any project.
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
index 5ffd6b7..4d1684a 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCPr
+++ ojectTemplate.java
@@ -10,8 +10,11 @@
  *******************************************************************************/
 package org.yocto.sdk.ide.wizard;

+import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;

 import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
 import org.eclipse.cdt.core.CCorePlugin; @@ -46,11 +49,12 @@ import org.yocto.sdk.ide.YoctoProfileElement;
 import org.yocto.sdk.ide.YoctoSDKChecker;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
+import org.yocto.sdk.ide.YoctoSDKMessages;
+import org.yocto.sdk.ide.YoctoSDKPlugin; import
+org.yocto.sdk.ide.YoctoUIElement;
 import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
 import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
-import org.yocto.sdk.ide.YoctoSDKPlugin; -import org.yocto.sdk.ide.YoctoUIElement;


 @SuppressWarnings("restriction")
@@ -58,11 +62,19 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
        protected boolean savedAutoBuildingValue;
        protected ProjectCreatedActions pca;
        protected IManagedBuildInfo info;
+       protected List<Character> illegalChars = Arrays.asList('$', '"','#','%','&','\'','(',')','*', '+', ',','.','/',':',';','<','=','>','?','@','[','\\',']','^','`','{','|','}','~');
+       private static final String PROJECT_NAME_ERROR =
+"Wizard.SDK.Error.ProjecName";

        public NewYoctoCProjectTemplate() {
                pca = new ProjectCreatedActions();
        }
-
+       private String printIllegalChars(){
+               String print = "";
+               for (Character ch : illegalChars)
+                       print += ch + ", ";
+               print = print.substring(0, print.length() - 2);
+               return print;
+       }
        public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {

                String projectName = args[0].getSimpleValue(); @@ -74,9 +86,9 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
                boolean isEmptryProject = Boolean.valueOf(isEmptyProjetValue).booleanValue();
                IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
                try {
-                       if (projectName.contains(" ")) {
+                       if (!isValidProjectName(projectName)) {
                                project.delete(true, null);
-                               throw new ProcessFailureException(projectName + " contains space(s).  Project name can't contain space(s)");
+                               throw new
+ProcessFailureException(YoctoSDKMessages.getFormattedString(PROJECT_NAM
+E_ERROR, new Object[]{projectName, printIllegalChars()}));
                        }
                        if (!project.exists()) {
                                IWorkspace workspace = ResourcesPlugin.getWorkspace(); @@ -166,6 +178,11 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
                        throw new OperationCanceledException(Messages.getString("NewManagedProject.3") + e.getMessage());
                }
        }
+       private boolean isValidProjectName(String projectName) {
+               Pattern pattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_\\-]*$");
+               Matcher matcher = pattern.matcher(projectName);
+               return matcher.find();
+}

        protected final void turnOffAutoBuild(IWorkspace workspace) throws CoreException {
                IWorkspaceDescription workspaceDesc = workspace.getDescription();
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] [eclipse-poky][master]Add more comprehensive error message for invalid project name
  2013-03-15  0:06 ` Zhang, Jessica
@ 2013-03-27 13:55   ` Grigoropol, IoanaX
  2013-04-02 11:14     ` Grigoropol, IoanaX
  0 siblings, 1 reply; 4+ messages in thread
From: Grigoropol, IoanaX @ 2013-03-27 13:55 UTC (permalink / raw)
  To: Zhang, Jessica, yocto

Hi Jessica,

What is the issue that Time found you are referring to ?

Regarding the way you found to allow creating projects with invalid names, this comes from the org.eclipse.cdt.core.templates, and in my opinion is a bug. 
What happens is that the template arguments, in our case the project name, is resolved the first time we press finish, with the invalid name we have set. 
When we receive an error and choose to go back, and change the project name to yet a new invalid project name, the argument of the template(project name), is not updated(for some sort of cache reasons) and thus by using the old project name, it surpasses the exception received in the first case.
I will open a bug for this on the cdt bugzilla.

Thanks,
Ioana

________________________________________
From: Zhang, Jessica
Sent: Friday, March 15, 2013 2:06 AM
To: Grigoropol, IoanaX; yocto@yoctoproject.org
Subject: RE: [yocto] [PATCH v2] [eclipse-poky][master]Add more comprehensive    error message for invalid project name

Hi Ioana,

This patch still can't address the situation that found by Timo as following....

Thanks,
Jessica

I forgot to mention. I found a way to create projects with invalid names.

# Create a new Yocto C Project
# Enter a wrong name eg. Test"
# Press next
# Press finish
# --> Error Message is shown, press ok
# Press back
# Change the name to an also invalid name eg. Test$ # Click finish

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Thursday, March 14, 2013 4:50 AM
To: yocto@yoctoproject.org
Subject: [yocto] [PATCH v2] [eclipse-poky][master]Add more comprehensive error message for invalid project name

[Yocto #4008]

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |    1 +
 .../sdk/ide/wizard/NewYoctoCProjectTemplate.java   |   27 ++++++++++++++++----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
index 8596123..fc9813f 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.p
+++ roperties
@@ -10,6 +10,7 @@
  * BMW Car IT - added keys for target profiles
  *******************************************************************************/
 Wizard.SDK.Warning.Title = Invalid Yocto Project ADT Location
+Wizard.SDK.Error.ProjecName = Project name "{0}" is invalid! \nNone of
+these characters are accepted inside project names: whitespaces, {1}

 Poky.SDK.Location.Empty = Specified Toolchain Root Location is empty.
 Poky.SDK.Location.Empty.Advice = You need specify Toolchain Root Location before building any project.
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
index 5ffd6b7..4d1684a 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCPr
+++ ojectTemplate.java
@@ -10,8 +10,11 @@
  *******************************************************************************/
 package org.yocto.sdk.ide.wizard;

+import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;

 import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
 import org.eclipse.cdt.core.CCorePlugin; @@ -46,11 +49,12 @@ import org.yocto.sdk.ide.YoctoProfileElement;
 import org.yocto.sdk.ide.YoctoSDKChecker;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
+import org.yocto.sdk.ide.YoctoSDKMessages;
+import org.yocto.sdk.ide.YoctoSDKPlugin; import
+org.yocto.sdk.ide.YoctoUIElement;
 import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
 import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
-import org.yocto.sdk.ide.YoctoSDKPlugin; -import org.yocto.sdk.ide.YoctoUIElement;


 @SuppressWarnings("restriction")
@@ -58,11 +62,19 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
        protected boolean savedAutoBuildingValue;
        protected ProjectCreatedActions pca;
        protected IManagedBuildInfo info;
+       protected List<Character> illegalChars = Arrays.asList('$', '"','#','%','&','\'','(',')','*', '+', ',','.','/',':',';','<','=','>','?','@','[','\\',']','^','`','{','|','}','~');
+       private static final String PROJECT_NAME_ERROR =
+"Wizard.SDK.Error.ProjecName";

        public NewYoctoCProjectTemplate() {
                pca = new ProjectCreatedActions();
        }
-
+       private String printIllegalChars(){
+               String print = "";
+               for (Character ch : illegalChars)
+                       print += ch + ", ";
+               print = print.substring(0, print.length() - 2);
+               return print;
+       }
        public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {

                String projectName = args[0].getSimpleValue(); @@ -74,9 +86,9 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
                boolean isEmptryProject = Boolean.valueOf(isEmptyProjetValue).booleanValue();
                IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
                try {
-                       if (projectName.contains(" ")) {
+                       if (!isValidProjectName(projectName)) {
                                project.delete(true, null);
-                               throw new ProcessFailureException(projectName + " contains space(s).  Project name can't contain space(s)");
+                               throw new
+ProcessFailureException(YoctoSDKMessages.getFormattedString(PROJECT_NAM
+E_ERROR, new Object[]{projectName, printIllegalChars()}));
                        }
                        if (!project.exists()) {
                                IWorkspace workspace = ResourcesPlugin.getWorkspace(); @@ -166,6 +178,11 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
                        throw new OperationCanceledException(Messages.getString("NewManagedProject.3") + e.getMessage());
                }
        }
+       private boolean isValidProjectName(String projectName) {
+               Pattern pattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_\\-]*$");
+               Matcher matcher = pattern.matcher(projectName);
+               return matcher.find();
+}

        protected final void turnOffAutoBuild(IWorkspace workspace) throws CoreException {
                IWorkspaceDescription workspaceDesc = workspace.getDescription();
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] [eclipse-poky][master]Add more comprehensive error message for invalid project name
  2013-03-27 13:55   ` Grigoropol, IoanaX
@ 2013-04-02 11:14     ` Grigoropol, IoanaX
  0 siblings, 0 replies; 4+ messages in thread
From: Grigoropol, IoanaX @ 2013-04-02 11:14 UTC (permalink / raw)
  To: Zhang, Jessica, yocto

Opened upstream bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404710

________________________________________
From: yocto-bounces@yoctoproject.org [yocto-bounces@yoctoproject.org] on behalf of Grigoropol, IoanaX [ioanax.grigoropol@intel.com]
Sent: Wednesday, March 27, 2013 3:55 PM
To: Zhang, Jessica; yocto@yoctoproject.org
Subject: Re: [yocto] [PATCH v2] [eclipse-poky][master]Add more  comprehensive   error message for invalid project name

Hi Jessica,

What is the issue that Time found you are referring to ?

Regarding the way you found to allow creating projects with invalid names, this comes from the org.eclipse.cdt.core.templates, and in my opinion is a bug.
What happens is that the template arguments, in our case the project name, is resolved the first time we press finish, with the invalid name we have set.
When we receive an error and choose to go back, and change the project name to yet a new invalid project name, the argument of the template(project name), is not updated(for some sort of cache reasons) and thus by using the old project name, it surpasses the exception received in the first case.
I will open a bug for this on the cdt bugzilla.


Thanks,
Ioana

________________________________________
From: Zhang, Jessica
Sent: Friday, March 15, 2013 2:06 AM
To: Grigoropol, IoanaX; yocto@yoctoproject.org
Subject: RE: [yocto] [PATCH v2] [eclipse-poky][master]Add more comprehensive    error message for invalid project name

Hi Ioana,

This patch still can't address the situation that found by Timo as following....

Thanks,
Jessica

I forgot to mention. I found a way to create projects with invalid names.

# Create a new Yocto C Project
# Enter a wrong name eg. Test"
# Press next
# Press finish
# --> Error Message is shown, press ok
# Press back
# Change the name to an also invalid name eg. Test$ # Click finish

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Ioana Grigoropol
Sent: Thursday, March 14, 2013 4:50 AM
To: yocto@yoctoproject.org
Subject: [yocto] [PATCH v2] [eclipse-poky][master]Add more comprehensive error message for invalid project name

[Yocto #4008]

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |    1 +
 .../sdk/ide/wizard/NewYoctoCProjectTemplate.java   |   27 ++++++++++++++++----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
index 8596123..fc9813f 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.p
+++ roperties
@@ -10,6 +10,7 @@
  * BMW Car IT - added keys for target profiles
  *******************************************************************************/
 Wizard.SDK.Warning.Title = Invalid Yocto Project ADT Location
+Wizard.SDK.Error.ProjecName = Project name "{0}" is invalid! \nNone of
+these characters are accepted inside project names: whitespaces, {1}

 Poky.SDK.Location.Empty = Specified Toolchain Root Location is empty.
 Poky.SDK.Location.Empty.Advice = You need specify Toolchain Root Location before building any project.
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
index 5ffd6b7..4d1684a 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCPr
+++ ojectTemplate.java
@@ -10,8 +10,11 @@
  *******************************************************************************/
 package org.yocto.sdk.ide.wizard;

+import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;

 import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
 import org.eclipse.cdt.core.CCorePlugin; @@ -46,11 +49,12 @@ import org.yocto.sdk.ide.YoctoProfileElement;
 import org.yocto.sdk.ide.YoctoSDKChecker;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
+import org.yocto.sdk.ide.YoctoSDKMessages;
+import org.yocto.sdk.ide.YoctoSDKPlugin; import
+org.yocto.sdk.ide.YoctoUIElement;
 import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
 import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
-import org.yocto.sdk.ide.YoctoSDKPlugin; -import org.yocto.sdk.ide.YoctoUIElement;


 @SuppressWarnings("restriction")
@@ -58,11 +62,19 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
        protected boolean savedAutoBuildingValue;
        protected ProjectCreatedActions pca;
        protected IManagedBuildInfo info;
+       protected List<Character> illegalChars = Arrays.asList('$', '"','#','%','&','\'','(',')','*', '+', ',','.','/',':',';','<','=','>','?','@','[','\\',']','^','`','{','|','}','~');
+       private static final String PROJECT_NAME_ERROR =
+"Wizard.SDK.Error.ProjecName";

        public NewYoctoCProjectTemplate() {
                pca = new ProjectCreatedActions();
        }
-
+       private String printIllegalChars(){
+               String print = "";
+               for (Character ch : illegalChars)
+                       print += ch + ", ";
+               print = print.substring(0, print.length() - 2);
+               return print;
+       }
        public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {

                String projectName = args[0].getSimpleValue(); @@ -74,9 +86,9 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
                boolean isEmptryProject = Boolean.valueOf(isEmptyProjetValue).booleanValue();
                IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
                try {
-                       if (projectName.contains(" ")) {
+                       if (!isValidProjectName(projectName)) {
                                project.delete(true, null);
-                               throw new ProcessFailureException(projectName + " contains space(s).  Project name can't contain space(s)");
+                               throw new
+ProcessFailureException(YoctoSDKMessages.getFormattedString(PROJECT_NAM
+E_ERROR, new Object[]{projectName, printIllegalChars()}));
                        }
                        if (!project.exists()) {
                                IWorkspace workspace = ResourcesPlugin.getWorkspace(); @@ -166,6 +178,11 @@ public class NewYoctoCProjectTemplate extends ProcessRunner {
                        throw new OperationCanceledException(Messages.getString("NewManagedProject.3") + e.getMessage());
                }
        }
+       private boolean isValidProjectName(String projectName) {
+               Pattern pattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_\\-]*$");
+               Matcher matcher = pattern.matcher(projectName);
+               return matcher.find();
+}

        protected final void turnOffAutoBuild(IWorkspace workspace) throws CoreException {
                IWorkspaceDescription workspaceDesc = workspace.getDescription();
--
1.7.9.5

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-04-02 11:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-14 11:50 [PATCH v2] [eclipse-poky][master]Add more comprehensive error message for invalid project name Ioana Grigoropol
2013-03-15  0:06 ` Zhang, Jessica
2013-03-27 13:55   ` Grigoropol, IoanaX
2013-04-02 11:14     ` Grigoropol, IoanaX

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.