Search in sources :

Example 1 with LibraryInstallDelegate

use of org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate in project liferay-ide by liferay.

the class JSFPortletFramework method configureNewProject.

@Override
public IStatus configureNewProject(IDataModel dataModel, IFacetedProjectWorkingCopy facetedProject) {
    IProjectFacetVersion jsfFacetVersion = getJSFProjectFacet(facetedProject);
    IProjectFacet jsfFacet = PortletCore.JSF_FACET;
    if (jsfFacetVersion == null) {
        jsfFacetVersion = jsfFacet.getVersion(JSF_FACET_SUPPORTED_VERSION);
        facetedProject.addProjectFacet(jsfFacetVersion);
    }
    Action action = facetedProject.getProjectFacetAction(jsfFacet);
    IDataModel jsfFacetDataModel = (IDataModel) action.getConfig();
    // TODO IDE-648 IDE-110
    jsfFacetDataModel.setProperty(SERVLET_URL_PATTERNS, null);
    jsfFacetDataModel.setProperty(WEBCONTENT_DIR, ISDKConstants.DEFAULT_DOCROOT_FOLDER);
    LibraryInstallDelegate libraryInstallDelegate = (LibraryInstallDelegate) jsfFacetDataModel.getProperty(LIBRARY_PROVIDER_DELEGATE);
    List<ILibraryProvider> providers = libraryInstallDelegate.getLibraryProviders();
    ILibraryProvider noOpProvider = null;
    for (ILibraryProvider provider : providers) {
        if (provider.getId().equals("jsf-no-op-library-provider")) {
            noOpProvider = provider;
            break;
        }
    }
    if (noOpProvider != null) {
        libraryInstallDelegate.setLibraryProvider(noOpProvider);
    }
    return Status.OK_STATUS;
}
Also used : Action(org.eclipse.wst.common.project.facet.core.IFacetedProject.Action) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) 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)

Example 2 with LibraryInstallDelegate

use of org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate in project liferay-ide by liferay.

the class PluginFacetInstall method installPluginLibraryDelegate.

protected void installPluginLibraryDelegate() throws CoreException {
    LibraryInstallDelegate libraryDelegate = (LibraryInstallDelegate) model.getProperty(IPluginProjectDataModelProperties.LIFERAY_PLUGIN_LIBRARY_DELEGATE);
    libraryDelegate.execute(monitor);
}
Also used : LibraryInstallDelegate(org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate)

Example 3 with LibraryInstallDelegate

use of org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate 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)

Aggregations

LibraryInstallDelegate (org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate)3 ILibraryProvider (org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider)2 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)2 Action (org.eclipse.wst.common.project.facet.core.IFacetedProject.Action)2 IProjectFacet (org.eclipse.wst.common.project.facet.core.IProjectFacet)2 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)2 LinkedHashSet (java.util.LinkedHashSet)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 JptXmlResource (org.eclipse.jpt.common.core.resource.xml.JptXmlResource)1 JpaPlatform (org.eclipse.jpt.jpa.core.JpaPlatform)1 JpaFacetInstallDataModelProvider (org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProvider)1 PersistenceXmlResourceProvider (org.eclipse.jpt.jpa.core.internal.resource.persistence.PersistenceXmlResourceProvider)1 RecursiveFileFinder (org.eclipse.ui.wizards.datatransfer.RecursiveFileFinder)1 IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)1