Search in sources :

Example 41 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class BackupLocationValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    Value<Path> backupLocation = _op().getBackupLocation();
    Path location = backupLocation.content();
    if (location != null) {
        if (!location.isAbsolute()) {
            return Status.createErrorStatus("\"" + location.toPortableString() + "\" is not an absolute path.");
        }
        if (location.toFile().isFile()) {
            return Status.createErrorStatus("\"" + location.toPortableString() + "\" is not a folder.");
        }
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path)

Example 42 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class PortletColumnWeightValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    PortletColumnElement portletColumn = context(PortletColumnElement.class);
    int weight = portletColumn.getWeight().content();
    LayoutTplElement layoutTpl = portletColumn.nearest(LayoutTplElement.class);
    if (layoutTpl != null) {
        if (layoutTpl.getBootstrapStyle().content()) {
            if ((weight <= 0) || (weight > 12)) {
                retval = Status.createErrorStatus("The weight value is invalid, should be in (0, 12]");
            }
        } else {
            if ((weight <= 0) || (weight > 100)) {
                retval = Status.createErrorStatus("The weight value is invalid, should be in (0, 100]");
            }
        }
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement)

Example 43 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class PortletColumnsValidtionSerivce method compute.

// store PortletColumns who have attached the listener
@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    PortletLayoutElement portletLayout = context(PortletLayoutElement.class);
    LayoutTplElement layoutTpl = portletLayout.nearest(LayoutTplElement.class);
    int actualWeightSum = 0;
    int exceptedweightSum = layoutTpl.getBootstrapStyle().content() ? 12 : 100;
    for (PortletColumnElement col : portletLayout.getPortletColumns()) {
        /*
			 * attach listener for the newly added PortletColumn there should be a better
			 * way to do this which makes more sense
			 */
        if (!_columnsAttachedListener.contains(col)) {
            col.getWeight().attach(_listener);
            _columnsAttachedListener.add(col);
        }
        Value<Integer> weight = col.getWeight();
        Integer content = weight.content();
        actualWeightSum += content.intValue();
    }
    if (!((actualWeightSum == exceptedweightSum) || ((exceptedweightSum == 100) && (actualWeightSum == 99)))) {
        retval = Status.createErrorStatus("The sum of weight of columns should be: " + exceptedweightSum);
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement)

Example 44 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class PluginTypeValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    NewLiferayPluginProjectOp op = _op();
    try {
        SDK sdk = SDKUtil.getWorkspaceSDK();
        if (sdk == null) {
            Path sdkLocation = op.getSdkLocation().content();
            if (sdkLocation != null) {
                sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
            }
        }
        PluginType pluginType = op.getPluginType().content();
        if (sdk != null) {
            if (pluginType.equals(PluginType.web) && !supportsTypePlugin(op, "web")) {
                StringBuilder sb = new StringBuilder();
                sb.append("The selected Plugins SDK does not support creating new web type plugins. ");
                sb.append("");
                sb.append("Please configure version 7.0 or greater.");
                return Status.createErrorStatus(sb.toString());
            } else if (pluginType.equals(PluginType.theme) && !supportsTypePlugin(op, "theme")) {
                StringBuilder sb = new StringBuilder();
                sb.append("The selected Plugins SDK does not support creating theme type plugins. ");
                sb.append("");
                sb.append("Please configure version 6.2 or less or using gulp way.");
                return Status.createErrorStatus(sb.toString());
            } else if (pluginType.equals(PluginType.ext) && !supportsTypePlugin(op, "ext")) {
                StringBuilder sb = new StringBuilder();
                sb.append("The selected Plugins SDK does not support creating ext type plugins. ");
                sb.append("");
                sb.append("Please try to confirm whether sdk has ext folder.");
                return Status.createErrorStatus(sb.toString());
            }
        } else if (pluginType.equals(PluginType.ext) && !supportsTypePlugin(op, "ext")) {
            retval = Status.createErrorStatus("New ext plugins with maven build type are no longer supported.");
        }
    } catch (CoreException ce) {
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) CoreException(org.eclipse.core.runtime.CoreException) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK) PluginType(com.liferay.ide.project.core.model.PluginType)

Example 45 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class PortletFrameworkValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    NewLiferayPluginProjectOp op = _op();
    ILiferayProjectProvider projectProvider = op.getProjectProvider().content();
    IPortletFramework portletFramework = op.getPortletFramework().content();
    if (!portletFramework.supports(projectProvider)) {
        return Status.createErrorStatus("Selected portlet framework is not supported with " + projectProvider.getDisplayName());
    }
    try {
        if ("ant".equals(projectProvider.getShortName())) {
            SDK sdk = SDKUtil.getWorkspaceSDK();
            if (sdk != null) {
                Version requiredVersion = new Version(portletFramework.getRequiredSDKVersion());
                Version sdkVersion = new Version(sdk.getVersion());
                if (CoreUtil.compareVersions(requiredVersion, sdkVersion) > 0) {
                    retval = Status.createErrorStatus("Selected portlet framework requires SDK version at least " + requiredVersion);
                }
            }
        }
    } catch (CoreException ce) {
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) IPortletFramework(com.liferay.ide.project.core.IPortletFramework) CoreException(org.eclipse.core.runtime.CoreException) Version(org.osgi.framework.Version) ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) 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