Search in sources :

Example 16 with IFacetedProject

use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project sling by apache.

the class ProjectAdapter method installFacet.

public void installFacet(String facetId, String facetVersion) throws CoreException {
    IFacetedProject facetedProject = ProjectFacetsManager.create(project);
    IProjectFacet slingBundleFacet = ProjectFacetsManager.getProjectFacet(facetId);
    IProjectFacetVersion projectFacetVersion = slingBundleFacet.getVersion(facetVersion);
    facetedProject.installProjectFacet(projectFacetVersion, null, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Example 17 with IFacetedProject

use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project sling by apache.

the class FacetHelper method containsFacet.

/**
     * Checks if the specified project has the specified facet
     * 
     * @param project the project, may be <code>null</code>
     * @param facetId the facet to check for
     * @return true if the specified <tt>project</tt> has the specified <tt>facetId</tt>
     */
public static boolean containsFacet(IProject project, String facetId) {
    if (project == null) {
        return false;
    }
    IFacetedProject facetedProject = (IFacetedProject) project.getAdapter(IFacetedProject.class);
    if (facetedProject == null) {
        return false;
    }
    IProjectFacet facet = ProjectFacetsManager.getProjectFacet(facetId);
    return facetedProject.hasProjectFacet(facet);
}
Also used : IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Example 18 with IFacetedProject

use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project sling by apache.

the class ConfigurationHelper method convertToContentPackageProject.

public static void convertToContentPackageProject(IProject project, IProgressMonitor monitor, IPath contentSyncRoot) throws CoreException {
    IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, null);
    // install content facet
    IProjectFacet slingContentFacet = ProjectFacetsManager.getProjectFacet("sling.content");
    facetedProject.installProjectFacet(slingContentFacet.getLatestVersion(), null, null);
    ProjectUtil.setSyncDirectoryPath(project, contentSyncRoot);
    // also install sightly facet 1.1 by default
    IProjectFacet sightlyFacet = ProjectFacetsManager.getProjectFacet("sightly");
    if (sightlyFacet != null) {
        facetedProject.installProjectFacet(sightlyFacet.getLatestVersion(), null, null);
    }
    project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Example 19 with IFacetedProject

use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project webtools.sourceediting by eclipse.

the class ConvertJob method runInWorkspace.

public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
    try {
        IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(JSDT_FACET);
        IFacetedProject facetedProject = ProjectFacetsManager.create(fProject);
        if (facetedProject != null && fProject.isAccessible()) {
            if (fInstall) {
                IProjectFacetVersion latestVersion = projectFacet.getLatestVersion();
                facetedProject.installProjectFacet(latestVersion, null, monitor);
            }
            if (fUseExplicitWorkingCopy) {
                IFacetedProjectWorkingCopy copy = facetedProject.createWorkingCopy();
                Set fixed = new HashSet(facetedProject.getFixedProjectFacets());
                fixed.add(projectFacet);
                copy.setFixedProjectFacets(fixed);
                copy.commitChanges(new NullProgressMonitor());
                copy.dispose();
            } else {
                Set fixed = new HashSet(facetedProject.getFixedProjectFacets());
                if (!fixed.contains(projectFacet)) {
                    fixed.add(projectFacet);
                    facetedProject.setFixedProjectFacets(fixed);
                }
            }
        }
    } catch (IllegalArgumentException e) {
    // unknown facet ID, bad installation configuration?
    } catch (Exception e) {
        Logger.logException(e);
    }
    return Status.OK_STATUS;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) Set(java.util.Set) HashSet(java.util.HashSet) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy) CoreException(org.eclipse.core.runtime.CoreException) HashSet(java.util.HashSet)

Example 20 with IFacetedProject

use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project webtools.sourceediting by eclipse.

the class FacetModuleCoreSupportDelegate method isWebFragmentProject.

/**
 * @param project
 * @return
 * @throws CoreException
 */
static boolean isWebFragmentProject(IProject project) {
    if (project == null)
        return false;
    try {
        if (ProjectFacetsManager.isProjectFacetDefined(JST_WEBFRAGMENT_MODULE)) {
            IFacetedProject faceted = ProjectFacetsManager.create(project);
            IProjectFacet webModuleFacet = ProjectFacetsManager.getProjectFacet(JST_WEBFRAGMENT_MODULE);
            if (faceted != null && faceted.hasProjectFacet(webModuleFacet)) {
                return true;
            }
        }
    } catch (CoreException e) {
        Logger.logException(e);
    }
    return false;
}
Also used : IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) CoreException(org.eclipse.core.runtime.CoreException) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Aggregations

IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)32 CoreException (org.eclipse.core.runtime.CoreException)20 IProjectFacet (org.eclipse.wst.common.project.facet.core.IProjectFacet)17 IProject (org.eclipse.core.resources.IProject)16 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IStatus (org.eclipse.core.runtime.IStatus)6 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)5 IRuntime (org.eclipse.wst.server.core.IRuntime)5 IWorkspace (org.eclipse.core.resources.IWorkspace)4 IPath (org.eclipse.core.runtime.IPath)4 IFile (org.eclipse.core.resources.IFile)3 Path (org.eclipse.core.runtime.Path)3 IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)3 FacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy)3 PluginClasspathContainerInitializer (com.liferay.ide.project.core.PluginClasspathContainerInitializer)2 IPluginPublisher (com.liferay.ide.server.core.IPluginPublisher)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Status (org.eclipse.core.runtime.Status)2