Search in sources :

Example 6 with IPortletFramework

use of com.liferay.ide.project.core.IPortletFramework 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)

Example 7 with IPortletFramework

use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.

the class PortletFrameworkValueImageService method provide.

@Override
public ImageData provide(String value) {
    ImageData data = null;
    IPortletFramework framework = ProjectCore.getPortletFramework(value);
    if (framework != null) {
        String name = framework.getShortName();
        Result<ImageData> result = ImageData.readFromClassLoader(framework.getClass(), "images/" + name + ".png");
        data = result.optional();
    }
    return data;
}
Also used : IPortletFramework(com.liferay.ide.project.core.IPortletFramework) ImageData(org.eclipse.sapphire.ImageData)

Example 8 with IPortletFramework

use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.

the class SDKLocationValidationService method compute.

@Override
protected Status compute() {
    NewLiferayPluginProjectOp op = _op();
    NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
    if (!provider.getShortName().equals("ant")) {
        return Status.createOkStatus();
    }
    int countPossibleWorkspaceSDKProjects = SDKUtil.countPossibleWorkspaceSDKProjects();
    if (countPossibleWorkspaceSDKProjects > 1) {
        return StatusBridge.create(ProjectCore.createErrorStatus("This workspace has more than one SDK."));
    }
    Path sdkLocation = op.getSdkLocation().content(true);
    if ((sdkLocation == null) || sdkLocation.isEmpty()) {
        return StatusBridge.create(ProjectCore.createErrorStatus("This sdk location is empty."));
    }
    SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
    if (sdk != null) {
        IStatus status = sdk.validate(true);
        if (!status.isOK()) {
            return StatusBridge.create(status);
        }
    } else {
        return StatusBridge.create(ProjectCore.createErrorStatus("This sdk location is not correct."));
    }
    Path projectLocation = op.getLocation().content();
    String projectName = op.getProjectName().content();
    IPath projectPath = PathBridge.create(projectLocation);
    if (FileUtil.exists(projectPath)) {
        return StatusBridge.create(ProjectCore.createErrorStatus("Project(" + projectName + ") is existed in sdk folder, please set new project name."));
    }
    PluginType pluginType = op.getPluginType().content();
    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.portlet)) {
        IPortletFramework portletFramework = op.getPortletFramework().content();
        Version requiredVersion = new Version(portletFramework.getRequiredSDKVersion());
        Version sdkVersion = new Version(sdk.getVersion());
        if (CoreUtil.compareVersions(requiredVersion, sdkVersion) > 0) {
            StringBuilder sb = new StringBuilder();
            sb.append("Selected portlet framework requires SDK version at least ");
            sb.append("");
            sb.append(requiredVersion);
            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());
    }
    return Status.createOkStatus();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) IPortletFramework(com.liferay.ide.project.core.IPortletFramework) IPath(org.eclipse.core.runtime.IPath) Version(org.osgi.framework.Version) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK) PluginType(com.liferay.ide.project.core.model.PluginType)

Example 9 with IPortletFramework

use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.

the class NewLiferayPluginProjectOpMethods method getFrameworkName.

public static String getFrameworkName(NewLiferayPluginProjectOp op) {
    IPortletFramework portletFramework = op.getPortletFramework().content();
    String frameworkName = portletFramework.getShortName();
    if (portletFramework.isRequiresAdvanced()) {
        IPortletFramework framework = op.getPortletFrameworkAdvanced().content();
        frameworkName = framework.getShortName();
    }
    return frameworkName;
}
Also used : IPortletFramework(com.liferay.ide.project.core.IPortletFramework)

Example 10 with IPortletFramework

use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.

the class ProjectImportUtil method createSDKPluginProject.

/**
 * @param dataModel
 * @param pluginBinaryRecord
 * @param liferaySDK
 * @return
 * @throws IOException
 */
public static ProjectRecord createSDKPluginProject(BridgedRuntime bridgedRuntime, BinaryProjectRecord pluginBinaryRecord, SDK liferaySDK) throws IOException {
    ProjectRecord projectRecord = null;
    if (!pluginBinaryRecord.isConflicts()) {
        String displayName = pluginBinaryRecord.getDisplayName();
        File binaryFile = pluginBinaryRecord.getBinaryFile();
        IPath projectPath = null;
        IPath sdkPluginProjectFolder = liferaySDK.getLocation();
        // IDE-110 IDE-648
        String webappRootFolder = null;
        IProgressMonitor npm = new NullProgressMonitor();
        ArrayList<String> arguments = new ArrayList<>();
        arguments.add(displayName);
        arguments.add(displayName);
        if (pluginBinaryRecord.isHook()) {
            sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.HOOK_PLUGIN_PROJECT_FOLDER);
            try {
                projectPath = liferaySDK.createNewProject(displayName, arguments, "hook", sdkPluginProjectFolder.toOSString(), npm);
            } catch (CoreException ce) {
                ProjectCore.logError(ce);
            }
            webappRootFolder = IPluginFacetConstants.HOOK_PLUGIN_SDK_CONFIG_FOLDER;
        } else if (pluginBinaryRecord.isPortlet()) {
            IPortletFramework[] portletFrameworks = ProjectCore.getPortletFrameworks();
            String portletFrameworkName = null;
            for (int i = 0; i < portletFrameworks.length; i++) {
                IPortletFramework portletFramework = portletFrameworks[i];
                if (portletFramework.isDefault() && !portletFramework.isAdvanced()) {
                    portletFrameworkName = portletFramework.getShortName();
                    break;
                }
            }
            sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.PORTLET_PLUGIN_PROJECT_FOLDER);
            arguments.add(portletFrameworkName);
            try {
                projectPath = liferaySDK.createNewProject(displayName, arguments, "portlet", sdkPluginProjectFolder.toOSString(), npm);
            } catch (CoreException ce) {
                ProjectCore.logError(ce);
            }
            webappRootFolder = IPluginFacetConstants.PORTLET_PLUGIN_SDK_CONFIG_FOLDER;
        } else if (pluginBinaryRecord.isTheme()) {
            sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.THEME_PLUGIN_PROJECT_FOLDER);
            try {
                projectPath = liferaySDK.createNewProject(displayName, arguments, "theme", sdkPluginProjectFolder.toOSString(), npm);
            } catch (CoreException ce) {
                ProjectCore.logError(ce);
            }
            webappRootFolder = IPluginFacetConstants.THEME_PLUGIN_SDK_CONFIG_FOLDER;
        } else if (pluginBinaryRecord.isLayoutTpl()) {
            sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.LAYOUTTPL_PLUGIN_PROJECT_FOLDER);
            try {
                projectPath = liferaySDK.createNewProject(displayName, arguments, "layouttpl", sdkPluginProjectFolder.toOSString(), npm);
            } catch (CoreException ce) {
                ProjectCore.logError(ce);
            }
            webappRootFolder = IPluginFacetConstants.LAYOUTTPL_PLUGIN_SDK_CONFIG_FOLDER;
        } else if (pluginBinaryRecord.isExt()) {
            sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.EXT_PLUGIN_PROJECT_FOLDER);
            try {
                projectPath = liferaySDK.createNewProject(displayName, arguments, "ext", sdkPluginProjectFolder.toOSString(), npm);
            } catch (CoreException ce) {
                ProjectCore.logError(ce);
            }
            webappRootFolder = IPluginFacetConstants.EXT_PLUGIN_SDK_CONFIG_FOLDER;
        } else if (pluginBinaryRecord.isWeb()) {
            sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.WEB_PLUGIN_PROJECT_FOLDER);
            try {
                projectPath = liferaySDK.createNewProject(displayName, arguments, "web", sdkPluginProjectFolder.toOSString(), npm);
            } catch (CoreException ce) {
                ProjectCore.logError(ce);
            }
            webappRootFolder = IPluginFacetConstants.WEB_PLUGIN_SDK_CONFIG_FOLDER;
        }
        // Extract the contents
        File webappRoot = new File(projectPath.toFile(), webappRootFolder);
        ZipUtil.unzip(binaryFile, webappRoot);
        // IDE-569 check to see if the project already has .project
        File projectFile = new File(projectPath.toFile(), ".project");
        if (FileUtil.exists(projectFile)) {
            projectRecord = new ProjectRecord(projectFile);
        } else {
            projectRecord = new ProjectRecord(projectPath.toFile());
        }
    }
    return projectRecord;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IPortletFramework(com.liferay.ide.project.core.IPortletFramework) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ProjectRecord(com.liferay.ide.project.core.ProjectRecord) BinaryProjectRecord(com.liferay.ide.project.core.BinaryProjectRecord) ArrayList(java.util.ArrayList) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

IPortletFramework (com.liferay.ide.project.core.IPortletFramework)15 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)6 PluginType (com.liferay.ide.project.core.model.PluginType)5 CoreException (org.eclipse.core.runtime.CoreException)5 IPath (org.eclipse.core.runtime.IPath)5 SDK (com.liferay.ide.sdk.core.SDK)4 File (java.io.File)3 PluginFacetProjectCreationDataModelProvider (com.liferay.ide.project.core.facet.PluginFacetProjectCreationDataModelProvider)2 ProjectName (com.liferay.ide.project.core.model.ProjectName)2 ArrayList (java.util.ArrayList)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Path (org.eclipse.core.runtime.Path)2 Test (org.junit.Test)2 Version (org.osgi.framework.Version)2 ILiferayProjectProvider (com.liferay.ide.core.ILiferayProjectProvider)1 BinaryProjectRecord (com.liferay.ide.project.core.BinaryProjectRecord)1 ProjectRecord (com.liferay.ide.project.core.ProjectRecord)1