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

Bug 258402

Summary: Need better API to check if project is faceted
Product: [WebTools] WTP Common Tools Reporter: kiril mitov <thebravoman>
Component: Faceted Project FrameworkAssignee: Konstantin Komissarchik <konstantin>
Status: RESOLVED FIXED QA Contact: Konstantin Komissarchik <konstantin>
Severity: enhancement    
Priority: P3 CC: Dimo.Stoilov, thatnitind
Version: 3.1Keywords: plan
Target Milestone: 3.1 M5   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
isFaceted method none

Description kiril mitov CLA 2008-12-11 03:23:50 EST
Hi,
The FacetedProjectNature.NATURE_ID is a convenient way to check for a facet nature for a give project.
Could it be exposed as an API (as in JavaCore.NATURE_ID for example)?
Comment 1 Konstantin Komissarchik CLA 2008-12-11 14:07:27 EST
I would prefer to not expose nature id directly like that since the fact that a nature is required for a project to be faceted is an implementation detail that may change in the future.

There is a existing ProjectFacetsManager.create( IProject ) api that can be used as a similar check. This API returns null if the project is not faceted. I suppose I can add isFaceted( IProject ) API to make it more obvious. Would this be sufficient to meet your requirements. If not, please describe in more detail the situation where you need access to the nature id.
Comment 2 kiril mitov CLA 2008-12-12 02:47:15 EST
I have a resource visitor for all the projects in the workspace. This visitor is performing a certain job and needs to work only on faceted projects. 

I would like to visit the projects "lazy" and not load the facet framework if there are no faceted projects. This is way I am checking for a nature.



Comment 3 Konstantin Komissarchik CLA 2008-12-16 14:09:27 EST
Ok. We have some API already with similar requirements (only activate the framework if necessary). These are clustered in FacetedProjectFramework (like hasProjectFacet). I can see adding isFaceted( IProject ) which would allow you to check the project without activating the framework and without hardcodding dependency on the nature.
Comment 4 kiril mitov CLA 2008-12-17 01:50:42 EST
(In reply to comment #3)
> Ok. We have some API already with similar requirements (only activate the
> framework if necessary). These are clustered in FacetedProjectFramework (like
> hasProjectFacet). I can see adding isFaceted( IProject ) which would allow you
> to check the project without activating the framework and without hardcodding
> dependency on the nature.
> 
Great, I have no objections to that.
Comment 5 kiril mitov CLA 2008-12-17 02:01:05 EST
Created attachment 120658 [details]
isFaceted method

I could propose a patch for the isFaceted method. 
(It was hard for me to format the code as the rest of the class :) )

I was also not sure if I should try to create an IFacetedProject with 
final IFacetedProject fproj = ProjectFacetsManager.create(project); to make sure that the project is really faceted. Probably checking for a facet is enough.
Comment 6 Konstantin Komissarchik CLA 2009-01-27 00:29:21 EST
Apologies for the delay. Released a change that adds FacetedProjectFramework.isFacetedProject( IProject ) method. The implementation checks if the project is accessible and has the right nature. No other checks are necessary.