use of org.eclipse.sapphire.modeling.Status 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.Status 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;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class NewLiferayProfileIdValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
NewLiferayProfile newLiferayProfile = _profile();
String profileId = newLiferayProfile.getId().content(true);
if ((profileId == null) || profileId.isEmpty()) {
retval = Status.createErrorStatus("Profile id can not be empty.");
} else if (profileId.contains(StringPool.SPACE)) {
retval = Status.createErrorStatus("No spaces are allowed in profile id.");
}
if (ListUtil.isEmpty(_existingValues)) {
return retval;
}
for (String val : _existingValues) {
if ((val != null) && val.equals(profileId)) {
return Status.createErrorStatus("Profile already exists.");
}
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class NewLiferayProfileRuntimeValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
NewLiferayPluginProjectOp op = context(NewLiferayPluginProjectOp.class);
NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content(true);
if ("maven".equals(provider.getShortName())) {
NewLiferayProfile newLiferayProfile = context(NewLiferayProfile.class);
String runtimeName = newLiferayProfile.getRuntimeName().content(true);
IRuntime runtime = ServerUtil.getRuntime(runtimeName);
if (runtime == null) {
retval = Status.createErrorStatus("Liferay runtime must be configured.");
}
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class ParentSDKProjectImportOpMethods method execute.
public static final Status execute(ParentSDKProjectImportOp op, ProgressMonitor pm) {
IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
monitor.beginTask("Importing Liferay parent sdk project...", 100);
Status retval = Status.createOkStatus();
Path sdkLocation = op.getSdkLocation().content();
if ((sdkLocation == null) || sdkLocation.isEmpty()) {
return Status.createErrorStatus("SDK folder cannot be empty");
}
SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
try {
SDKUtil.openAsProject(sdk, monitor);
} catch (CoreException ce) {
retval = StatusBridge.create(ProjectCore.createErrorStatus(ce));
}
return retval;
}
Aggregations