use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class ProjectNameValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
NewLiferayPluginProjectOp op = _op();
NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
if (provider.getShortName().equals("ant")) {
SDK sdk = null;
try {
sdk = SDKUtil.getWorkspaceSDK();
if (sdk != null) {
IStatus sdkStatus = sdk.validate();
if (!sdkStatus.isOK()) {
retval = Status.createErrorStatus(sdkStatus.getChildren()[0].getMessage());
}
}
} catch (CoreException ce) {
retval = Status.createErrorStatus(ce);
}
}
String currentProjectName = op.getProjectName().content();
if (currentProjectName != null) {
IStatus nameStatus = CoreUtil.getWorkspace().validateName(currentProjectName, IResource.PROJECT);
if (!nameStatus.isOK()) {
retval = StatusBridge.create(nameStatus);
} else if (_isInvalidProjectName(op)) {
Boolean projectImported = op.getImportProjectStatus().content();
if (projectImported == false) {
retval = Status.createErrorStatus("A project with that name already exists.");
}
} else if (_isAntProject(op) && _isSuffixOnly(currentProjectName)) {
retval = Status.createErrorStatus("A project name cannot only be a type suffix.");
} else if (!_hasValidDisplayName(currentProjectName)) {
retval = Status.createErrorStatus("The project name is invalid.");
} else if (_isMavenProject(op) && !_isValidMavenProjectName(currentProjectName)) {
retval = Status.createErrorStatus("The project name is invalid for a maven project");
} else {
Path currentProjectLocation = op.getLocation().content(true);
if ((currentProjectName != null) && (currentProjectLocation != null)) {
String currentPath = currentProjectLocation.toOSString();
IPath osPath = org.eclipse.core.runtime.Path.fromOSString(currentPath);
IStatus projectStatus = provider.validateProjectLocation(currentProjectName, osPath);
if (!projectStatus.isOK()) {
retval = StatusBridge.create(projectStatus);
}
}
}
}
op.getSdkLocation().refresh();
return retval;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class ModuleFragmentProjectArtifactVersionDefaultValueService method compute.
@Override
protected String compute() {
String data = null;
NewModuleFragmentOp op = _op();
Path location = op.getLocation().content();
if (location != null) {
String parentProjectLocation = location.toOSString();
IPath parentProjectOsPath = org.eclipse.core.runtime.Path.fromOSString(parentProjectLocation);
String projectName = op.getProjectName().content();
data = NewModuleFragmentOpMethods.getMavenParentPomVersion(op, projectName, parentProjectOsPath);
}
if (data == null) {
data = "1.0.0-SNAPSHOT";
}
return data;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class WorkspaceLocationValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
/*
* 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.
*
* 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.
*/
Path currentProjectLocation = _op().getLocation().content(true);
boolean useDefaultLocation = _op().getUseDefaultLocation().content(true);
if (!useDefaultLocation) {
if (currentProjectLocation != null) {
String currentPath = currentProjectLocation.toOSString();
File osPathFile = Path.fromOSString(currentPath).toFile();
if (!osPathFile.isAbsolute()) {
return Status.createErrorStatus("\"" + currentPath + "\" is not an absolute path.");
}
if (!_canCreate(osPathFile)) {
return Status.createErrorStatus("Cannot create project content at \"" + currentPath + "\".");
}
} else {
return Status.createErrorStatus("Location must be specified.");
}
}
return retval;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class LocationListener method handleTypedEvent.
@Override
protected void handleTypedEvent(ValuePropertyContentEvent event) {
NewLiferayPluginProjectOp op = op(event);
boolean useDefaultLocation = op.getUseDefaultLocation().content(true);
if (useDefaultLocation) {
return;
}
String afterValue = event.after();
String beforeValue = event.before();
if ((beforeValue == null) && (afterValue != null)) {
NewLiferayPluginProjectOpMethods.updateLocation(op, new Path(afterValue));
}
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class LocationValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
NewLiferayPluginProjectOp op = _op();
NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
if (provider.getShortName().equals("ant")) {
SDK sdk = null;
try {
sdk = SDKUtil.getWorkspaceSDK();
if (sdk != null) {
IStatus sdkStatus = sdk.validate();
if (!sdkStatus.isOK()) {
retval = Status.createErrorStatus(sdkStatus.getChildren()[0].getMessage());
}
}
} catch (CoreException ce) {
retval = Status.createErrorStatus(ce);
}
}
Path currentProjectLocation = op.getLocation().content(true);
String currentProjectName = op.getProjectName().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.
*/
Value<Boolean> useDefalutLocationValue = op.getUseDefaultLocation();
Status status = useDefalutLocationValue.service(UseDefaultLocationValidationService.class).validation();
if (!useDefalutLocationValue.content(true) && status.ok() && (currentProjectName != null)) {
/*
* 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 (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.");
}
IPath osPath = org.eclipse.core.runtime.Path.fromOSString(currentPath);
if (!osPath.toFile().isAbsolute()) {
return Status.createErrorStatus("\"" + currentPath + "\" is not an absolute path.");
}
if (FileUtil.notExists(osPath) && !_canCreate(osPath.toFile())) {
retval = Status.createErrorStatus("Cannot create project content at \"" + currentPath + "\"");
}
IStatus locationStatus = provider.validateProjectLocation(currentProjectName, osPath);
if (!locationStatus.isOK()) {
retval = Status.createErrorStatus(locationStatus.getMessage());
}
}
return retval;
}
Aggregations