use of org.eclipse.sapphire.modeling.Status 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.modeling.Status in project liferay-ide by liferay.
the class SDKImportLocationValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
SDKProjectsImportOp op = _op();
Path currentProjectLocation = op.getSdkLocation().content(true);
if ((currentProjectLocation != null) && !currentProjectLocation.isEmpty()) {
String currentPath = currentProjectLocation.toOSString();
retval = StatusBridge.create(ProjectImportUtil.validateSDKPath(currentPath));
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class SDKImportValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
ParentSDKProjectImportOp op = _op();
try {
SDK sdk = SDKUtil.getWorkspaceSDK();
if (sdk != null) {
return StatusBridge.create(ProjectCore.createErrorStatus(" This workspace already has another sdk."));
}
Path currentProjectLocation = op.getSdkLocation().content(true);
if ((currentProjectLocation != null) && !currentProjectLocation.isEmpty()) {
sdk = SDKUtil.createSDKFromLocation(PathBridge.create(currentProjectLocation));
if (sdk != null) {
IStatus sdkStatus = sdk.validate(true);
if (!sdkStatus.isOK()) {
retval = StatusBridge.create(ProjectCore.createWarningStatus(sdkStatus.getChildren()[0].getMessage()));
}
} else {
retval = StatusBridge.create(ProjectCore.createErrorStatus("This parent sdk project path is invalid."));
}
}
} catch (CoreException ce) {
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class UseDefaultLocationValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
NewLiferayPluginProjectOp op = _op();
NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
if ((op.getProjectName().content() != null) && "ant".equals(provider.getShortName()) && !op.getUseDefaultLocation().content() && !NewLiferayPluginProjectOpMethods.canUseCustomLocation(op)) {
retval = Status.createErrorStatus("The specified SDK version is not allowed to use custom location.");
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class AbstractProjectLocationValidationService method compute.
@Override
protected Status compute() {
BaseModuleOp op = op();
Status retval = Status.createOkStatus();
String currentProjectName = op.getProjectName().content();
Path currentProjectLocation = op.getLocation().content();
Boolean userDefaultLocation = op.getUseDefaultLocation().content();
/*
* Location won't be validated if the UseDefaultLocation has an error.
* Get the validation of the property might not work as excepted,
* let's use call the validation service manually.
*/
if (userDefaultLocation) {
return retval;
}
/*
* IDE-1150, instead of using annotation "@Required",use this service to
* validate the custom project location must be specified, let the wizard
* display the error of project name when project name and location are both
* null.
*/
if (currentProjectName == null) {
return retval;
}
if (currentProjectLocation == null) {
return Status.createErrorStatus("Location must be specified.");
}
String currentPath = currentProjectLocation.toOSString();
if (!org.eclipse.core.runtime.Path.EMPTY.isValidPath(currentPath)) {
return Status.createErrorStatus("\"" + currentPath + "\" is not a valid path.");
} else {
IPath osPath = org.eclipse.core.runtime.Path.fromOSString(currentPath);
if (!osPath.toFile().isAbsolute()) {
retval = Status.createErrorStatus("\"" + currentPath + "\" is not an absolute path.");
} else {
if (FileUtil.notExists(osPath)) {
if (!_canCreate(osPath.toFile())) {
retval = Status.createErrorStatus("Cannot create project content at \"" + currentPath + "\"");
}
}
NewLiferayProjectProvider<BaseModuleOp> provider = op.getProjectProvider().content();
IStatus locationStatus = provider.validateProjectLocation(currentProjectName, osPath);
if (!locationStatus.isOK()) {
retval = Status.createErrorStatus(locationStatus.getMessage());
}
}
}
return retval;
}
Aggregations