use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion 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;
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion in project liferay-ide by liferay.
the class SDKProjectConvertDataModelProvider 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();
Set<IProjectFacetVersion> facets = ProjectUtil.getFacetsForPreset(IPluginFacetConstants.LIFERAY_PORTLET_PRESET);
Set<IProjectFacet> fixedFacets = new HashSet<>();
for (IProjectFacetVersion pfv : facets) {
fixedFacets.add(pfv.getProjectFacet());
}
facetedProject.setFixedProjectFacets(Collections.unmodifiableSet(fixedFacets));
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion in project liferay-ide by liferay.
the class PluginFacetProjectCreationDataModelProvider method removeFacet.
protected void removeFacet(IFacetedProjectWorkingCopy facetedProject, IProjectFacet facet) {
if ((facetedProject == null) || (facet == null)) {
return;
}
Set<IProjectFacetVersion> newFacetSet = new HashSet<>();
Set<IProjectFacetVersion> facets = facetedProject.getProjectFacets();
for (IProjectFacetVersion fv : facets) {
if (!(fv.getProjectFacet().equals(facet))) {
newFacetSet.add(fv);
}
}
facetedProject.setProjectFacets(newFacetSet);
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion 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);
}
}
}
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion 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));
}
}
Aggregations