Search in sources :

Example 1 with IPortletFramework

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

the class PluginFacetProjectCreationDataModelProvider method setupPortletFramework.

protected void setupPortletFramework(IPortletFramework portletFramework) {
    IPortletFramework[] portletFrameworks = ProjectCore.getPortletFrameworks();
    for (IPortletFramework framework : portletFrameworks) {
        if (!framework.equals(portletFramework)) {
            IProjectFacet[] facets = framework.getFacets();
            for (IProjectFacet facet : facets) {
                removeFacet(getFacetedProjectWorkingCopy(), facet);
            }
        }
    }
    portletFramework.configureNewProject(getDataModel(), getFacetedProjectWorkingCopy());
}
Also used : IPortletFramework(com.liferay.ide.project.core.IPortletFramework) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Example 2 with IPortletFramework

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

the class ArchetypeDefaultValueService method compute.

@Override
protected String compute() {
    NewLiferayPluginProjectOp op = _op();
    PluginType pluginType = op.getPluginType().content();
    String frameworkType = null;
    if (pluginType.equals(PluginType.portlet)) {
        IPortletFramework portletFramework = op.getPortletFramework().content();
        if (portletFramework.isRequiresAdvanced()) {
            IPortletFramework framework = op.getPortletFrameworkAdvanced().content();
            frameworkType = framework.getShortName();
        } else {
            frameworkType = portletFramework.getShortName();
        }
    } else {
        frameworkType = pluginType.name();
    }
    frameworkType = frameworkType.replaceAll("_", "-");
    NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
    return provider.getData("archetypeGAV", String.class, frameworkType).get(0);
}
Also used : IPortletFramework(com.liferay.ide.project.core.IPortletFramework) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) PluginType(com.liferay.ide.project.core.model.PluginType)

Example 3 with IPortletFramework

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

the class ProjectUtil method createNewSDKProject.

public static IProject createNewSDKProject(ProjectRecord projectRecord, IPath sdkLocation, IProgressMonitor monitor, NewLiferayPluginProjectOp op) throws CoreException {
    IDataModel newProjectDataModel = DataModelFactory.createDataModel(new PluginFacetProjectCreationDataModelProvider());
    // we are importing so set flag to not create anything
    newProjectDataModel.setBooleanProperty(IPluginProjectDataModelProperties.CREATE_PROJECT_OPERATION, false);
    IDataModel nestedModel = newProjectDataModel.getNestedModel(IPluginProjectDataModelProperties.NESTED_PROJECT_DM);
    // using sdk location
    nestedModel.setBooleanProperty(IPluginProjectDataModelProperties.USE_DEFAULT_LOCATION, true);
    newProjectDataModel.setBooleanProperty(IPluginProjectDataModelProperties.LIFERAY_USE_SDK_LOCATION, false);
    newProjectDataModel.setBooleanProperty(IPluginProjectDataModelProperties.LIFERAY_USE_WORKSPACE_LOCATION, true);
    setGenerateDD(newProjectDataModel, false);
    IPath webXmlPath = projectRecord.getProjectLocation().append(ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/web.xml");
    File webXmlFile = webXmlPath.toFile();
    if (projectRecord.getProjectName().endsWith(ISDKConstants.PORTLET_PLUGIN_PROJECT_SUFFIX)) {
        newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_PORTLET, true);
        if (FileUtil.notExists(webXmlFile)) {
            createDefaultWebXml(webXmlFile, projectRecord.getProjectName());
        }
    } else if (projectRecord.getProjectName().endsWith(ISDKConstants.HOOK_PLUGIN_PROJECT_SUFFIX)) {
        newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_HOOK, true);
        if (FileUtil.notExists(webXmlFile)) {
            createDefaultWebXml(webXmlFile, projectRecord.getProjectName());
        }
    } else if (projectRecord.getProjectName().endsWith(ISDKConstants.EXT_PLUGIN_PROJECT_SUFFIX)) {
        Path path = new Path(ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/ext-web/docroot/WEB-INF/web.xml");
        webXmlPath = webXmlPath.removeLastSegments(3).append(path);
        webXmlFile = webXmlPath.toFile();
        newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_EXT, true);
        if (FileUtil.notExists(webXmlFile)) {
            createDefaultWebXml(webXmlPath.toFile(), projectRecord.getProjectName());
        }
    } else if (projectRecord.getProjectName().endsWith(ISDKConstants.LAYOUTTPL_PLUGIN_PROJECT_SUFFIX)) {
        newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_LAYOUTTPL, true);
    } else if (projectRecord.getProjectName().endsWith(ISDKConstants.THEME_PLUGIN_PROJECT_SUFFIX)) {
        newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_THEME, true);
    } else if (projectRecord.getProjectName().endsWith(ISDKConstants.WEB_PLUGIN_PROJECT_SUFFIX)) {
        newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_WEB, true);
    }
    IFacetedProjectWorkingCopy fpwc = (IFacetedProjectWorkingCopy) newProjectDataModel.getProperty(IFacetProjectCreationDataModelProperties.FACETED_PROJECT_WORKING_COPY);
    fpwc.setProjectName(projectRecord.getProjectName());
    IPath projectLocation = projectRecord.getProjectLocation();
    String projectDirName = projectLocation.lastSegment();
    // for now always set a project location (so it can be used by facet install methods) may be unset later
    fpwc.setProjectLocation(projectRecord.getProjectLocation());
    String pluginType = null;
    if (op != null) {
        PluginType type = op.getPluginType().content();
        pluginType = type.name();
        if (PluginType.theme.name().equals(pluginType)) {
            newProjectDataModel.setProperty(IPluginProjectDataModelProperties.THEME_PARENT, op.getThemeParent().content(true));
            newProjectDataModel.setProperty(IPluginProjectDataModelProperties.THEME_TEMPLATE_FRAMEWORK, op.getThemeFramework().content(true));
        }
    } else {
        pluginType = guessPluginType(fpwc);
    }
    SDKPluginFacetUtil.configureProjectAsSDKProject(fpwc, pluginType, sdkLocation.toPortableString(), projectRecord);
    if ((op != null) && PluginType.portlet.name().equals(pluginType)) {
        IPortletFramework portletFramework = op.getPortletFramework().content(true);
        portletFramework.configureNewProject(newProjectDataModel, fpwc);
    }
    // if project is located in natural workspace location then don't need to set a project location
    IPath rootLocation = CoreUtil.getWorkspaceRoot().getLocation();
    if (rootLocation.append(projectDirName).equals(projectLocation)) {
        fpwc.setProjectLocation(null);
    }
    fpwc.commitChanges(monitor);
    CoreUtil.getWorkspace().run(new IWorkspaceRunnable() {

        @Override
        public void run(IProgressMonitor monitor) throws CoreException {
            SDK sdk = SDKUtil.createSDKFromLocation(sdkLocation);
            SDKUtil.openAsProject(sdk);
        }
    }, monitor);
    return fpwc.getProject();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IPath(org.eclipse.core.runtime.IPath) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) PluginType(com.liferay.ide.project.core.model.PluginType) IPortletFramework(com.liferay.ide.project.core.IPortletFramework) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy) SDK(com.liferay.ide.sdk.core.SDK) PluginFacetProjectCreationDataModelProvider(com.liferay.ide.project.core.facet.PluginFacetProjectCreationDataModelProvider) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 4 with IPortletFramework

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

the class PluginFacetProjectCreationDataModelProvider method propertySet.

@Override
public boolean propertySet(final String propertyName, final Object propertyValue) {
    String portletFrameworkId = getStringProperty(PORTLET_FRAMEWORK_ID);
    IPortletFramework portletFramework = ProjectCore.getPortletFramework(portletFrameworkId);
    if (FACET_PROJECT_NAME.equals(propertyName) || LIFERAY_SDK_NAME.equals(propertyName) || LIFERAY_USE_WORKSPACE_LOCATION.equals(propertyName) || LIFERAY_USE_CUSTOM_LOCATION.equals(propertyName)) {
        updateProjectLocation();
    } else if (DISPLAY_NAME.equals(propertyName)) {
        String displayName = ProjectUtil.removePluginSuffix(propertyValue.toString());
        return super.propertySet(DISPLAY_NAME, displayName);
    } else if (PORTLET_FRAMEWORK_ID.equals(propertyName) && (portletFramework != null)) {
        setupPortletFramework(portletFramework);
    }
    return super.propertySet(propertyName, propertyValue);
}
Also used : IPortletFramework(com.liferay.ide.project.core.IPortletFramework)

Example 5 with IPortletFramework

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

the class PortletFrameworkPossibleValuesService method initPossibleValuesService.

@Override
protected void initPossibleValuesService() {
    super.initPossibleValuesService();
    _possibleValues = new ArrayList<>();
    for (IPortletFramework portletFramework : ProjectCore.getPortletFrameworks()) {
        if (shouldAdd(portletFramework)) {
            _possibleValues.add(portletFramework.getShortName());
        }
    }
}
Also used : IPortletFramework(com.liferay.ide.project.core.IPortletFramework)

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