summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2012-04-15 10:52:56 (EDT)
committer Tom Schindl2012-04-15 10:52:56 (EDT)
commitebd452dcf1726eb62c82cb4333353a8cf6379ecb (patch)
treebcbf272dbf26be724f76560cd9c1c4e8ffafabe7
parentaa3ff97360b4e928761ea8137498a96f4d84199b (diff)
downloadorg.eclipse.e4.tools-ebd452dcf1726eb62c82cb4333353a8cf6379ecb.zip
org.eclipse.e4.tools-ebd452dcf1726eb62c82cb4333353a8cf6379ecb.tar.gz
org.eclipse.e4.tools-ebd452dcf1726eb62c82cb4333353a8cf6379ecb.tar.bz2
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.java21
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 a304714..c137f6c 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);
}
}