Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Validate a project facet
Validate a project facet [message #232478] Mon, 15 June 2009 13:26 Go to next message
Steve is currently offline SteveFriend
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 16:36 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
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 17:14 Go to previous message
Steve is currently offline SteveFriend
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: Tue Apr 23 11:31:20 GMT 2024

Powered by FUDForum. Page generated in 0.03154 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top