2. Improvements to Presets

Significant improvements have been made to the presets facility for the 2.0 release. A new type of preset, referred to as a dynamic preset, is now available. A dynamic preset uses an extender-supplied factory to synthesize the preset definition on the fly based on the context in which it will be used. The "old-style" declarative presets are still available and are now referred to as static presets. Static presets have also been improved to allow them to extend other presets. A static preset can even extend a dynamic preset.

There is also a new preset that's part of the framework. It's a dynamic preset with id of "default.configuration" and whose contents are synthesized as follows:

  1. If a runtime is selected, this preset will contain default facets as specified by IRuntime.getDefaultFacets(Set).
  2. If no runtime is selected, this preset will contain default versions for all of the fixed facets as specified by IProjectFacet.getDefaultVersion().

New Extension Point

 
<extension point="org.eclipse.wst.common.project.facet.core.presets">
  <static-preset id="{string}" extends="{string}">
    <label>{string}</label> (optional)
    <description>{string}</description> (optional)
    <facet id="{string}" version="{string}"/> (1 or more)
  </static-preset> (0 or more)
  <dynamic-preset id="{string}">
    <factory class="{class:org.eclipse.wst.common.project.facet.core.IPresetFactory}"/>
  </dynamic-preset> (0 or more)
<extension>

Deprecated Extension Point

 
<extension point="org.eclipse.wst.common.project.facet.core.facets">
  <preset id="{string}">
    <label>{string}</label> (optional)
    <description>{string}</description> (optional)
    <facet id="{string}" version="{string}"/> (1 or more)
  </preset> (0 or more)
<extension>

Java API Additions

 
interface org.eclipse.wst.common.project.facet.core.IPreset
{
    enum Type { STATIC, DYNAMIC, USER_DEFINED }
    Type getType();
}

interface org.eclipse.wst.common.project.facet.core.IDynamicPreset extends IPreset
{
    static final String CONTEXT_KEY_FIXED_FACETS;
    static final String CONTEXT_KEY_PRIMARY_RUNTIME;
    IPreset resolve( Map context );
}

interface org.eclipse.wst.common.project.facet.core.IPresetFactory
{
    PresetDefinition createPreset( String presetId, Map context );
}

class org.eclipse.wst.common.project.facet.core.PresetDefinition
{
    PresetDefinition( String label, String description, Set facets );
    String getLabel();
    String getDescription();
    Set getProjectFacets();
}

org.eclipse.wst.common.project.facet.core.FacetedProjectFramework
{
    static final String DEFAULT_CONFIGURATION_PRESET_ID;
}

Deprecated Java API

 
interface org.eclipse.wst.common.project.facet.core.IPreset
{
    boolean isUserDefined()
}