Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Trying to set multiple source folders in Java facet
Trying to set multiple source folders in Java facet [message #637832] Tue, 09 November 2010 05:58 Go to next message
Kent Rancourt is currently offline Kent RancourtFriend
Messages: 6
Registered: November 2010
Junior Member
I hope I'm filing this question under the correct sub-project. If not, I apologize sincerely in advance.

I'm rather new to developing plugins and I'm currently attempting to create a customized new project wizard that is essentially a pretty minimal customization of the WebProjectWizard. The intend is merely to load a different faceted template that includes not only the jst.java facet and jst.web facet, but some facets of my own that will ultimately provide support for my company's proprietary Spring-based framework.

Sounds simple enough, right? I'm actually having a reasonable degree of success thus far, BUT...

The thing I am stuck on is that when the end-user is configuring the Java facet, I'd like for the JavaFacetInstallPage to show multiple source directories by defults, with those multiple directories being those commonly used in a Maven project (although we're not using Maven):

* src/main/java
* src/main/resources
* src/test/java
* src/test/resources

It seems that if I wish to do this sort of customization to the data model when the wizard loads, the createDataModel() method in my wizard would be the ideal place to do that.

Unfortunately, however, I see that to specify source folders, I need to somehow get a handle to a JavaFacetInstallConfig object. I do know that I can dig through the working copy of the faceted project to try to find the install action for the Java facet and I can get a reference to the JavaFacetInstallConfig object thre, but at this point in the lifecycle, no such object exists because the Java facet hasn't really been selected at that point (and thus isn't slated for install).

I think this explains my dilemma pretty clearly. I need to either find another means of specifying the source folders, or I need to find another point in the lifecycle of the wizard where I can intercept and customize the default configuration of the Java facet before the user sees the JavaFacetInstallPage.

Any assistance is tremendously appreciated.
Re: Trying to set multiple source folders in Java facet [message #638347 is a reply to message #637832] Wed, 10 November 2010 22:44 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
> It seems that if I wish to do this sort of customization to the data model
> when the wizard loads, the createDataModel() method in my wizard
> would be the ideal place to do that.

No. The datamodel is a thin legacy veneer that doesn't give you access to all of the available API.

Here is what I would do... Get a handle on the working copy (getFacetedProjectWorkingCopy() from the wizard). The working copy is created in the constructor, so it's safe to call it whenever. Add a listener and watch for java facet being added. When its added, configure it as appropriate using JavaFacetInstallConfig API.

- Konstantin
Re: Trying to set multiple source folders in Java facet [message #640986 is a reply to message #638347] Tue, 23 November 2010 18:44 Go to previous messageGo to next message
Kent Rancourt is currently offline Kent RancourtFriend
Messages: 6
Registered: November 2010
Junior Member
This is pretty close to what I ended up doing. I created and registered a JavaFacetPreInstallDelegate.

This delegate determines whether my own facet is also being installed, and if it is, then it follows the exact steps you described to modify the list of source folders using the JavaFacetInstallConfig API.

Thank you very much for the advice!

I do have one further question, if you don't mind...

Later on down the line- for instance- within the install delegate for my own facet, how can I access the list of source folders? There's no way of doing this that's jumping right out at me. I have a reference to an IProject, but it seems to me that I somehow need to get at the install config for the Java facet and that means I need to first get at a FacetedProjectWorkingCopy (?). Not sure how to get there from where I am.
Re: Trying to set multiple source folders in Java facet [message #640994 is a reply to message #640986] Tue, 23 November 2010 19:19 Go to previous message
Kent Rancourt is currently offline Kent RancourtFriend
Messages: 6
Registered: November 2010
Junior Member
Nevermind. After more trial and error, this did the trick:

IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] classpathEntries = javaProject.getRawClasspath();
for (IClasspathEntry classpathEntry : classpathEntries) {
  if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
    // Code for each source folder goes here
  }	
}
Previous Topic:extending the wtp xml-editor
Next Topic:Somebody Please Come In ASAP And Point Me In The Right Direction
Goto Forum:
  


Current Time: Thu Apr 25 08:57:21 GMT 2024

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

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

Back to the top