use of org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate 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.IFacetedProjectTemplate in project liferay-ide by liferay.
the class SDKPluginFacetUtil method configureProjectAsSDKProject.
public static void configureProjectAsSDKProject(IFacetedProjectWorkingCopy fpjwc, String pluginType, String sdkLocation, ProjectRecord projectRecord) throws CoreException {
IFacetedProjectTemplate template = getLiferayTemplateForProject(pluginType);
IPreset preset = getLiferayPresetForProject(pluginType);
if (preset == null) {
throw new CoreException(ProjectCore.createErrorStatus(NLS.bind(Msgs.noFacetPreset, fpjwc.getProjectName())));
}
IRuntime primaryRuntime = fpjwc.getPrimaryRuntime();
if (primaryRuntime != null) {
fpjwc.removeTargetedRuntime(primaryRuntime);
}
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)) {
// TODO how to check the bundle support status?
boolean requiredVersion = _isRequiredVersion(currentFacetVersion);
if (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);
}
}
}
}
Aggregations