diff options
author | Sopot Cela | 2012-04-15 14:52:56 +0000 |
---|---|---|
committer | Tom Schindl | 2012-04-15 14:52:56 +0000 |
commit | ebd452dcf1726eb62c82cb4333353a8cf6379ecb (patch) | |
tree | bcbf272dbf26be724f76560cd9c1c4e8ffafabe7 | |
parent | aa3ff97360b4e928761ea8137498a96f4d84199b (diff) | |
download | org.eclipse.e4.tools-I20120420-0100.tar.gz org.eclipse.e4.tools-I20120420-0100.tar.xz org.eclipse.e4.tools-I20120420-0100.zip |
Bug 375261 - [Tools] No check on Java type names when creating classesv20120415-1452I20120425-0950I20120424-1736I20120423-1745I20120423-1300I20120422-1305I20120420-0130I20120420-0100I20120417-1720I20120416-1710
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); } } |