use of org.eclipse.wst.common.project.facet.core.IPreset 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.IPreset in project webtools.sourceediting by eclipse.
the class NewProjectDataModelFacetWizard method createPageControls.
@Override
public void createPageControls(Composite container) {
super.createPageControls(container);
final IPreset preset = this.template.getInitialPreset();
final IRuntime runtime = (IRuntime) model.getProperty(FACET_RUNTIME);
if (preset == null) {
// If no preset is specified, select the runtime and it's default
// facets.
setRuntimeAndDefaultFacets(runtime);
} else {
// If preset is specified, select the runtime only if supports all
// of the facets included in the preset.
getFacetedProjectWorkingCopy().setSelectedPreset(preset.getId());
boolean supports = false;
if (runtime != null) {
supports = true;
for (Iterator itr = preset.getProjectFacets().iterator(); itr.hasNext(); ) {
final IProjectFacetVersion fv = (IProjectFacetVersion) itr.next();
if (!runtime.supports(fv)) {
supports = false;
break;
}
}
}
if (supports) {
getFacetedProjectWorkingCopy().setTargetedRuntimes(Collections.singleton(runtime));
} else {
model.setProperty(FACET_RUNTIME, null);
}
}
synchRuntimes();
}
use of org.eclipse.wst.common.project.facet.core.IPreset in project webtools.sourceediting by eclipse.
the class DataModelFacetCreationWizardPage method createPresetPanel.
protected void createPresetPanel(Composite top) {
final IFacetedProjectWorkingCopy workingCopy = ((ModifyFacetedProjectWizard) getWizard()).getFacetedProjectWorkingCopy();
final IFilter<IPreset> filter = new AbstractFilter<IPreset>() {
{
IFacetedProjectListener fpjwcListenerForPreset = new IFacetedProjectListener() {
@Override
public void handleEvent(final IFacetedProjectEvent event) {
handleProjectFacetsChangedEvent((IProjectFacetsChangedEvent) event);
}
};
facetedProjectListeners.add(fpjwcListenerForPreset);
workingCopy.addListener(fpjwcListenerForPreset, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED);
}
@Override
public boolean check(final IPreset preset) {
final IProjectFacetVersion primaryFacetVersion = getPrimaryFacetVersion();
return preset.getProjectFacets().contains(primaryFacetVersion);
}
private void handleProjectFacetsChangedEvent(final IProjectFacetsChangedEvent event) {
for (IProjectFacetVersion fv : event.getFacetsWithChangedVersions()) {
if (fv.getProjectFacet() == getPrimaryFacet()) {
final IFilterEvent<IPreset> filterEvent = new FilterEvent<IPreset>(this, IFilterEvent.Type.FILTER_CHANGED);
notifyListeners(filterEvent);
}
}
}
};
final PresetSelectionPanel ppanel = new PresetSelectionPanel(top, workingCopy, filter);
ppanel.setLayoutData(gdhfill());
}
use of org.eclipse.wst.common.project.facet.core.IPreset 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