Search in sources :

Example 11 with Status

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;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) File(java.io.File)

Example 12 with Status

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK)

Example 13 with Status

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;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NewLiferayProfile(com.liferay.ide.project.core.model.NewLiferayProfile)

Example 14 with Status

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;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NewLiferayProfile(com.liferay.ide.project.core.model.NewLiferayProfile) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 15 with Status

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;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) SDK(com.liferay.ide.sdk.core.SDK)

Aggregations

Status (org.eclipse.sapphire.modeling.Status)83 IProject (org.eclipse.core.resources.IProject)33 Test (org.junit.Test)31 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)29 IStatus (org.eclipse.core.runtime.IStatus)25 Path (org.eclipse.sapphire.modeling.Path)18 CoreException (org.eclipse.core.runtime.CoreException)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 NewLiferayJSFModuleProjectOp (com.liferay.ide.project.core.jsf.NewLiferayJSFModuleProjectOp)14 IFile (org.eclipse.core.resources.IFile)12 IPath (org.eclipse.core.runtime.IPath)11 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)10 NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)9 SDK (com.liferay.ide.sdk.core.SDK)9 File (java.io.File)6 NewLiferayComponentOp (com.liferay.ide.project.core.modules.NewLiferayComponentOp)5 IRuntime (org.eclipse.wst.server.core.IRuntime)5 PropertyKey (com.liferay.ide.project.core.modules.PropertyKey)3 NewModuleFragmentOp (com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)3 ArrayList (java.util.ArrayList)3