Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Validate a project facet
Validate a project facet [message #232478] Mon, 15 June 2009 09:26 Go to next message
Steve is currently offline Steve
Messages: 16
Registered: July 2009
Junior Member
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 #232512 is a reply to message #232478] Mon, 15 June 2009 12:36 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
> 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
Re: Validate a project facet [message #232528 is a reply to message #232512] Mon, 15 June 2009 13:14 Go to previous message
Steve is currently offline Steve
Messages: 16
Registered: July 2009
Junior Member
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
Previous Topic:Custom Facet Installation fails when no InstallDelegate class is created
Next Topic:Tomcat server timeout
Goto Forum:
  


Current Time: Sat Aug 30 20:23:21 EDT 2014

Powered by FUDForum. Page generated in 0.01748 seconds