Validate a project facet [message #232478] |
Mon, 15 June 2009 09:26  |
Eclipse User |
|
|
|
Hi,
I have a FacetedProject. Is there an API to determine if another facet
can be installed into this FacetedProject? I've looked through the
methods in ProjectFacetsManager and IProjectFacetVersion (isValidFor and
conflictsWith), but they don't appear to be what I am looking for. I
thought it might be a method in FacetedProject, but I couldn't find it
there either. For example, let's say I have an EJB project. I want to
know if I can install the Web facet into this project. I don't want to
install it at this time, I just want to know if this new facet is valid
for an existing faceted project.
Thanks,
Steve
|
|
|
|
Re: Validate a project facet [message #232528 is a reply to message #232512] |
Mon, 15 June 2009 13:14  |
Eclipse User |
|
|
|
Konstantin Komissarchik wrote:
>> I have a FacetedProject. Is there an API to determine if another facet
>> can be installed into this FacetedProject? I've looked through the
>> methods in ProjectFacetsManager and IProjectFacetVersion (isValidFor and
>> conflictsWith), but they don't appear to be what I am looking for. I
>> thought it might be a method in FacetedProject, but I couldn't find it
>> there either. For example, let's say I have an EJB project. I want to
>> know if I can install the Web facet into this project. I don't want to
>> install it at this time, I just want to know if this new facet is valid
>> for an existing faceted project.
> Yes, there is definitely a way to do this. The best approach is to get a
> working copy from your IFacetedProject, add the facet in question to it
> and then validate the working copy. Like this:
> IFacetedProject fpj = ...
> IFacetedProjectWorkingCopy fpjwc = fpj.createWorkingCopy();
> try
> {
> fpjwc.addProjectFacet( ... );
> IStatus result = fpjwc.validate();
> }
> finally
> {
> fpjwc.dispose();
> }
> You can use this technique to try out any type of change to the project.
> Operations you perform on the working copy are not persisted unless you
> call fpjwc.commitChanges().
> - Konstantin
Konstantin,
Thank you very much. This is exactly what I was looking for.
Steve
|
|
|
Powered by
FUDForum. Page generated in 0.07473 seconds