use of org.eclipse.sapphire.java.JavaPackageName in project liferay-ide by liferay.
the class NewLiferayComponentValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
NewLiferayComponentOp op = _op();
String className = op.getComponentClassName().content(true);
if (!CoreUtil.isNullOrEmpty(className)) {
IStatus status = JavaConventions.validateJavaTypeName(className, CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7);
int classNameStatus = status.getSeverity();
if (className.indexOf('.') != -1) {
classNameStatus = IStatus.ERROR;
}
if (classNameStatus == IStatus.ERROR) {
retval = Status.createErrorStatus("Invalid class name");
}
}
String projectName = op.getProjectName().content(true);
if (projectName != null) {
IProject project = CoreUtil.getProject(projectName);
if (project != null) {
try {
JavaPackageName pack = op.getPackageName().content(true);
if (pack != null) {
String packageName = pack.toString();
IJavaProject javaProject = JavaCore.create(project);
IType type = javaProject.findType(packageName + "." + className);
if (type != null) {
retval = Status.createErrorStatus(packageName + "." + className + " already exists.");
}
}
} catch (Exception e) {
ProjectCore.logError("Checking component class name failed.", e);
}
}
}
return retval;
}
use of org.eclipse.sapphire.java.JavaPackageName in project liferay-ide by liferay.
the class JavaPackageNameValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
NewLiferayComponentOp op = _op();
String projectName = op.getProjectName().text(false);
if (projectName != null) {
IJavaProject javaproject = JavaCore.create(CoreUtil.getProject(op.getProjectName().text(false)));
if (CoreUtil.getSourceFolders(javaproject).size() == 0) {
retval = Status.createErrorStatus("Unable to find any source folders.");
return retval;
}
}
JavaPackageName packageName = op.getPackageName().content(true);
if (packageName != null) {
IStatus status = JavaConventions.validatePackageName(packageName.toString(), CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7);
int packageNameStatus = status.getSeverity();
if (packageNameStatus == IStatus.ERROR) {
retval = Status.createErrorStatus("Invalid package name");
}
}
return retval;
}
Aggregations