diff options
author | Sopot Cela | 2012-04-15 14:52:56 +0000 |
---|---|---|
committer | Tom Schindl | 2012-04-15 14:52:56 +0000 |
commit | 4f0ec28cc618215e74bf875a2970cb7f57b7857c (patch) | |
tree | f25f05b767146c93d0f5dc0b1dfb0c5791eb67d7 | |
parent | 7291fed1ab58bb99eea813f2fd9931e47495d851 (diff) | |
download | eclipse.platform.ui.tools-4f0ec28cc618215e74bf875a2970cb7f57b7857c.tar.gz eclipse.platform.ui.tools-4f0ec28cc618215e74bf875a2970cb7f57b7857c.tar.xz eclipse.platform.ui.tools-4f0ec28cc618215e74bf875a2970cb7f57b7857c.zip |
Bug 375261 - [Tools] No check on Java type names when creating classes
for handlers, parts and addons from Application.e4xmi editor.
-rw-r--r-- | bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java index a304714f..c137f6c6 100644 --- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java +++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java @@ -23,11 +23,13 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.e4.internal.tools.ToolsPlugin; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaModel; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.JavaConventions; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; @@ -205,7 +207,8 @@ public abstract class AbstractNewClassPage extends WizardPage { Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dbc.bindValue(textProp.observe(t), BeanProperties.value("name", String.class).observe(clazz)); + dbc.bindValue(textProp.observe(t), BeanProperties.value("name", String.class).observe(clazz), + new UpdateValueStrategy().setBeforeSetValidator(new ClassnameValidator()),null); new Label(parent, SWT.NONE); } @@ -324,18 +327,12 @@ public abstract class AbstractNewClassPage extends WizardPage { public IStatus validate(Object value) { String name = value.toString(); - char[] ar = name.toCharArray(); - for (char c : ar) { - if (!Character.isJavaIdentifierPart(c)) { - return new Status(IStatus.ERROR, "", "'" + c + "' is not allowed in a Class-Name"); - } - } - - if (!Character.isJavaIdentifierStart(ar[0])) { - return new Status(IStatus.ERROR, "", "'" + ar[0] + "' is not allowed as the first character of a Class-Name"); - } + if (name.length()==0) + return new Status(IStatus.ERROR,ToolsPlugin.PLUGIN_ID,"Name must not be empty"); + if ((name.indexOf('.')!=-1)||(name.trim().indexOf(' ')!=-1)) + return new Status(IStatus.ERROR,ToolsPlugin.PLUGIN_ID,"Name must not be qualified or contain spaces"); - return Status.OK_STATUS; + return JavaConventions.validateJavaTypeName(name,JavaCore.VERSION_1_3,JavaCore.VERSION_1_3); } } |