Wrapper Project for NetBeans Projects

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. 

Comments:

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.

Posted by Tomas Zezula on July 22, 2012 at 12:07 AM PDT #

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...

Posted by Lisdey on November 05, 2013 at 07:32 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today