Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Faceted Project Framework » How to access facets programmaticaly
How to access facets programmaticaly [message #484653] Tue, 08 September 2009 16:01 Go to next message
Gabriel Petrovay is currently offline Gabriel PetrovayFriend
Messages: 42
Registered: July 2009
Member
Hello Konstantin,

I have just implemented facets for my plugins. But now I want to perform
some extra tasks programmaticaly:
1. to change a certain facet on a project based on the user actions. For
example, my projects have an interpreter (DLTK model) and when the user
chooses a particular interpreter type I want to change/set one of the
facets the project has.

2. is there an API to work with project facets and with the
org.eclipse.wst.common.project.facet.core.xml file. Is there a facet
registry?

Thanks!

Regards,
Gabriel
www.xqdt.org
Re: How to access facets programmaticaly [message #484703 is a reply to message #484653] Tue, 08 September 2009 19:49 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 952
Registered: July 2009
Senior Member
Hi Gabriel,

The framework API entry point is ProjectFacetsManager class. You will be able to use this class to browse through available facets and to create IFacetedProject objects which let you manipulate specific projects.

Here is a small snippet that installs a facet on an existing faceted project:

import org.eclipse.wst.common.project.facet.core.*;

IProjectFacet f = ProjectFacetsManager.getProjectFacet( "my.facet" );
IProjectFacetVersion fv = f.getVersion( "1.0" );
IFacetedProject proj = ProjectFacetsManager.create( [IProject] );
proj.installProjectFacet( fv, null, null );

You may also want to take a look at IFacetedProjectWorkingCopy (accessible via IFacetedProject.createWorkingCopy() among other means). That interface gives you more control in manipulating various aspects of project's configuration before applying all of the changes in bulk.

Hope this helps and don't hesitate to ask more questions.

- Konstantin
Re: How to access facets programmaticaly [message #571960 is a reply to message #484653] Tue, 08 September 2009 19:49 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 952
Registered: July 2009
Senior Member
Hi Gabriel,

The framework API entry point is ProjectFacetsManager class. You will be able to use this class to browse through available facets and to create IFacetedProject objects which let you manipulate specific projects.

Here is a small snippet that installs a facet on an existing faceted project:

import org.eclipse.wst.common.project.facet.core.*;

IProjectFacet f = ProjectFacetsManager.getProjectFacet( "my.facet" );
IProjectFacetVersion fv = f.getVersion( "1.0" );
IFacetedProject proj = ProjectFacetsManager.create( [IProject] );
proj.installProjectFacet( fv, null, null );

You may also want to take a look at IFacetedProjectWorkingCopy (accessible via IFacetedProject.createWorkingCopy() among other means). That interface gives you more control in manipulating various aspects of project's configuration before applying all of the changes in bulk.

Hope this helps and don't hesitate to ask more questions.

- Konstantin
Previous Topic:How to access facets programmaticaly
Next Topic:Is Faceted Project Framework supported in Ganymede?
Goto Forum:
  


Current Time: Fri Nov 28 10:02:57 GMT 2014

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

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