Search in sources :

Example 6 with IProjectFacet

use of org.eclipse.wst.common.project.facet.core.IProjectFacet in project liferay-ide by liferay.

the class SDKProjectsImportDataModelProvider method init.

@Override
public void init() {
    super.init();
    // set the project facets to get the runtime target dropdown to only show liferay runtimes
    IFacetedProjectWorkingCopy facetedProject = getFacetedProjectWorkingCopy();
    facetedProject.setSelectedPreset(IPluginFacetConstants.LIFERAY_PORTLET_PRESET);
    Set<IProjectFacet> fixedFacets = new HashSet<>();
    fixedFacets.add(ProjectFacetsManager.getProjectFacet(IPluginFacetConstants.LIFERAY_EXT_FACET_ID));
    facetedProject.setFixedProjectFacets(Collections.unmodifiableSet(fixedFacets));
    ProjectUtil.setDefaultRuntime(getDataModel());
}
Also used : IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy) HashSet(java.util.HashSet)

Example 7 with IProjectFacet

use of org.eclipse.wst.common.project.facet.core.IProjectFacet 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 8 with IProjectFacet

use of org.eclipse.wst.common.project.facet.core.IProjectFacet in project liferay-ide by liferay.

the class SDKPluginFacetUtil method configureProjectAsRuntimeProject.

public static void configureProjectAsRuntimeProject(IFacetedProjectWorkingCopy fpjwc, IRuntime runtime, String pluginType, String sdkLocation, ProjectRecord projectRecord) throws CoreException {
    fpjwc.setTargetedRuntimes(Collections.<IRuntime>emptySet());
    if (runtime != null) {
        fpjwc.setTargetedRuntimes(Collections.singleton(runtime));
    }
    fpjwc.setPrimaryRuntime(runtime);
    // fpjwc.setSelectedPreset(
    // FacetedProjectFramework.DEFAULT_CONFIGURATION_PRESET_ID );
    IFacetedProjectTemplate template = getLiferayTemplateForProject(pluginType);
    IPreset preset = getLiferayPresetForProject(pluginType);
    if (preset == null) {
        throw new CoreException(ProjectCore.createErrorStatus(NLS.bind(Msgs.noFacetPreset, fpjwc.getProjectName())));
    }
    Set<IProjectFacetVersion> currentProjectFacetVersions = fpjwc.getProjectFacets();
    Set<IProjectFacet> requiredFacets = template.getFixedProjectFacets();
    for (IProjectFacet requiredFacet : requiredFacets) {
        boolean hasRequiredFacet = false;
        for (IProjectFacetVersion currentFacetVersion : currentProjectFacetVersions) {
            if (currentFacetVersion.getProjectFacet().equals(requiredFacet)) {
                boolean supports = runtime.supports(currentFacetVersion);
                boolean requiredVersion = _isRequiredVersion(currentFacetVersion);
                if (supports && requiredVersion) {
                    hasRequiredFacet = true;
                } else {
                    fpjwc.removeProjectFacet(currentFacetVersion);
                }
                break;
            }
        }
        if (!hasRequiredFacet) {
            IProjectFacetVersion requiredFacetVersion = _getRequiredFacetVersionFromPreset(requiredFacet, preset);
            if (requiredFacetVersion != null) {
                fpjwc.addProjectFacet(requiredFacetVersion);
                if (ProjectUtil.isJavaFacet(requiredFacetVersion)) {
                    configureJavaFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset, projectRecord);
                } else if (ProjectUtil.isDynamicWebFacet(requiredFacetVersion)) {
                    configureWebFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset);
                }
            }
        } else {
            if (ProjectUtil.isJavaFacet(requiredFacet)) {
                configureJavaFacet(fpjwc, requiredFacet, preset, projectRecord);
            } else if (ProjectUtil.isDynamicWebFacet(requiredFacet)) {
                configureWebFacet(fpjwc, requiredFacet, preset);
            }
        }
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IFacetedProjectTemplate(org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate) IPreset(org.eclipse.wst.common.project.facet.core.IPreset) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Example 9 with IProjectFacet

use of org.eclipse.wst.common.project.facet.core.IProjectFacet in project jbosstools-hibernate by jbosstools.

the class JPAProjectConfigurator method configure.

@Override
public void configure(IProject project, Set<IPath> ignoredDirectories, IProgressMonitor monitor) {
    try {
        IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, monitor);
        // $NON-NLS-1$
        IProjectFacet JPA_FACET = ProjectFacetsManager.getProjectFacet("jpt.jpa");
        if (!facetedProject.hasProjectFacet(JPA_FACET)) {
            Set<Action> actions = new LinkedHashSet<>(2, 1);
            IProjectFacetVersion javaFv = JavaFacet.FACET.getVersion(JavaFacetUtil.getCompilerLevel(project));
            if (!facetedProject.hasProjectFacet(JavaFacet.FACET)) {
                actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL, javaFv, null));
            } else if (!facetedProject.hasProjectFacet(javaFv)) {
                actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.VERSION_CHANGE, javaFv, null));
            }
            // $NON-NLS-1$
            RecursiveFileFinder finder = new RecursiveFileFinder("persistence.xml", ignoredDirectories);
            project.accept(finder);
            PersistenceXmlResourceProvider provider = PersistenceXmlResourceProvider.getXmlResourceProvider(finder.getFile());
            JptXmlResource jpaXmlResource = provider.getXmlResource();
            IProjectFacetVersion version = null;
            if (jpaXmlResource.getVersion() != null) {
                version = JpaProject.FACET.getVersion(jpaXmlResource.getVersion());
            }
            if (version == null) {
                version = JpaProject.FACET.getLatestVersion();
            }
            // use default
            JpaPlatform platform = null;
            // TODO improve platform detection
            LibraryInstallDelegate libraryDelegate = new LibraryInstallDelegate(facetedProject, version);
            // $NON-NLS-1$
            ILibraryProvider libraryProvider = LibraryProviderFramework.getProvider("jpa-no-op-library-provider");
            libraryDelegate.setLibraryProvider(libraryProvider);
            IDataModel dm = DataModelFactory.createDataModel(new JpaFacetInstallDataModelProvider());
            dm.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, version.getVersionString());
            dm.setProperty(JpaFacetDataModelProperties.PLATFORM, platform);
            dm.setProperty(JpaFacetInstallDataModelProperties.DISCOVER_ANNOTATED_CLASSES, true);
            dm.setProperty(JpaFacetInstallDataModelProperties.LIBRARY_PROVIDER_DELEGATE, libraryDelegate);
            actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL, version, dm));
            facetedProject.modify(actions, monitor);
        }
    } catch (Exception ex) {
        HibernateJptUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, HibernateJptUIPlugin.PLUGIN_ID, ex.getMessage(), ex));
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) Action(org.eclipse.wst.common.project.facet.core.IFacetedProject.Action) JptXmlResource(org.eclipse.jpt.common.core.resource.xml.JptXmlResource) RecursiveFileFinder(org.eclipse.ui.wizards.datatransfer.RecursiveFileFinder) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) JpaFacetInstallDataModelProvider(org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProvider) LibraryInstallDelegate(org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate) ILibraryProvider(org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) JpaPlatform(org.eclipse.jpt.jpa.core.JpaPlatform) CoreException(org.eclipse.core.runtime.CoreException) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) Action(org.eclipse.wst.common.project.facet.core.IFacetedProject.Action) PersistenceXmlResourceProvider(org.eclipse.jpt.jpa.core.internal.resource.persistence.PersistenceXmlResourceProvider)

Example 10 with IProjectFacet

use of org.eclipse.wst.common.project.facet.core.IProjectFacet in project webtools.servertools by eclipse.

the class RuntimeClasspathProvider method getClasspathEntries.

public List getClasspathEntries(IProjectFacetVersion fv) {
    IProjectFacet pf = fv.getProjectFacet();
    if (pf == null)
        return null;
    if (pf.equals(WEB_FACET) || pf.equals(EJB_FACET) || pf.equals(EAR_FACET) || pf.equals(UTILITY_FACET) || pf.equals(CONNECTOR_FACET) || pf.equals(APP_CLIENT_FACET) || pf.equals(WEBFRAGMENT_FACET)) {
        String runtimeTypeId = rc.getProperty("type-id");
        String runtimeId = rc.getProperty("id");
        if (runtimeTypeId == null || runtimeId == null)
            return null;
        RuntimeClasspathProviderWrapper rcpw = JavaServerPlugin.findRuntimeClasspathProviderBySupport(runtimeTypeId);
        if (rcpw != null) {
            IPath path = new Path(RuntimeClasspathContainer.SERVER_CONTAINER);
            path = path.append(rcpw.getId()).append(runtimeId);
            IClasspathEntry cpentry = JavaCore.newContainerEntry(path);
            return Collections.singletonList(cpentry);
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Aggregations

IProjectFacet (org.eclipse.wst.common.project.facet.core.IProjectFacet)28 IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)17 CoreException (org.eclipse.core.runtime.CoreException)14 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 HashSet (java.util.HashSet)6 IProject (org.eclipse.core.resources.IProject)6 IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)5 IStatus (org.eclipse.core.runtime.IStatus)3 Action (org.eclipse.wst.common.project.facet.core.IFacetedProject.Action)3 IPluginPublisher (com.liferay.ide.server.core.IPluginPublisher)2 ArrayList (java.util.ArrayList)2 IFile (org.eclipse.core.resources.IFile)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ILibraryProvider (org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider)2 LibraryInstallDelegate (org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate)2 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)2 IRuntime (org.eclipse.wst.server.core.IRuntime)2 MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)1 VcsRepository (com.centurylink.mdw.plugin.project.model.VcsRepository)1