Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 207526

Summary: Facets should provide a preference scope for storing related information
Product: [WebTools] WTP Common Tools Reporter: Cameron Bateman <cameron.bateman>
Component: Faceted Project FrameworkAssignee: Konstantin Komissarchik <konstantin>
Status: RESOLVED FIXED QA Contact: Konstantin Komissarchik <konstantin>
Severity: enhancement    
Priority: P3 CC: konstantin, thatnitind
Version: 3.0Keywords: plan
Target Milestone: 3.1 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Cameron Bateman CLA 2007-10-25 20:44:49 EDT
A key aspect of project facets is the ability to collect data from the user on installation that gets used to do configuration.  However, this configuration information often needs to be modified after installation.  It would very useful for a facet to provide a scope context (or manage some data under the ProjectScope) in which to store and retrieve this information.

Example Use Case:

When the JSF facet is installed, the user may specify the name of their FacesServlet name.  This is used to initialize the web.xml with the servlet information.  However, the web.xml can be modified independent of the facet installer.  The user may choose a different faces servlet class after the fact.  However, we have no way of knowing that this new servlet class is a Faces Servlet.  We wish to collect this information from the user as an option preference.  We can store it as our own project scope data, but since it is tied to the facet lifecycle it would be nice if the facet would manage the data for us and provide at least rudimentary UI support for allowing the user to edit it (i.e. at least a button on the Project Facets properties page that launch a delegate method.

A follow on to this might also be the ability to validate the current facet configuration data against the actual state of the project.  i.e. if the user specifies a Facelet Servlet class name and later deletes the class name we could warn that it is no longer likely to be valid.
Comment 1 Konstantin Komissarchik CLA 2007-10-26 17:08:54 EDT
1. Providing a facet-level preference scope to make it easier for facets to store project-level configuration information idea definitely has merit. 

2. I am very reluctant to go down the UI path, because I don't want to be creating a new framework that would compete with the existing project properties facility. We already have a property tester facility that let's you check for facets. This property tester can be used when registering a project properties page in order to show the page only if the facet is installed.

3. To validate your facet's state after creation, you can either implement a validator using WTP's validation framework or you can use the mini validation framework that's part of the faceted project framework (take a look at org.eclipse.wst.common.project.facet.core.validators extension point).
Comment 2 Konstantin Komissarchik CLA 2008-10-07 12:20:36 EDT
Added two new API methods to support storing facet-related preferences:

project-scoped: IFacetedProject.getPreferences( IProjectFacet facet )
workspace-scoped: FacetedProjectFramework.getPreferences( IProjectFacet facet )

The methods are javadoced and there is even some new content regarding this feature in the framework docs.