X

Geertjan's Blog

  • July 21, 2012

Wrapper Project for NetBeans Projects

Geertjan Wielenga
Product Manager

A great question in this blog by swpalmer recently:

I have a need for a custom project type that is mostly just a parent for existing NB project types for Java(Ant or Maven, soon Gradle) and C++. Think of it like a one project for a Java library that uses JNI and the project for the native library that implements the native methods that go with it. Add a little bit of metadata and some custom packaging steps (currently written with Gradle) and that would be my new project type.

Would making a new parent project type that has subprojects of existing NB project types be an easy thing to implement?

Well, here's a simple example. Imagine you have folders for your customers, each containing multiple NetBeans projects. Would be cool to be able to open all those projects together, as part of a new project defined by some recognized structure in the customer folder:

Then, once open, you can do typical things you'd like to be able to do to multiple projects belonging to a shared container of some kind, such as open the individual projects for separate editing:

Notice that, though the icon is retained from the original NetBeans project, the logical view isn't. I don't think there's a way around that.

The way this works is that the "createLogicalView" override of the Project implementation returns a Node that defines its children as FilterNode.Children, with the icons overridden. That defines the logical view. The ability to open the NetBeans project together with the main project is done via a SubprojectProvider in the Lookup of the main project, which recognizes subfolders containing an "nbproject" folder as a subproject of the main project.

Best of all, I can now create Actions which lookup all the subprojects and then do something with the group of subprojects. Maybe, for example, all the subprojects can be built together or run together or something like that. A higher level container like this can open up a lot of possibilities and isn't hard to create, if you combine the instructions in the above paragraph with the instructions in this tutorial:

http://platform.netbeans.org/tutorials/nbm-projecttype.html

Finally, if the customer project in the screenshots above were to be a Gradle project, then I think the question with which this blog entry started would be resolved. 

Join the discussion

Comments ( 2 )
  • Tomas Zezula Sunday, July 22, 2012

    You can retain the subproject children by delegating to subproject LogicalViewProvider, but it's questionable if it's desired. The similar NB Module Suite project shows only the subprojects with a possibility to open them.


  • Lisdey Tuesday, November 5, 2013

    Hello, I saw a lot of your post and it are very helpful. But I have a problem and I would like to know if you can help me. I need to create a custom project type that also implements the j2seproject type. I already see the NetBeans Project Type Extension Module Tutorial tutorial and isn't useful for me. For example in Eclipse one project can have more than one nature, I mean more that one type. My goal here is that I have a j2seproject already created in my computer and this project has an specific .xml file that I create, so I want that NetBeans will be able of recognize that project and set a custom icon but at the same time this project should have all the options of an j2seproject.

    Do you understand me? I really appreciate all the help that you can give me...


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services