So, I am back again…
Last time around, I didn’t go much in finer details of Project Creation, instead gave you an overview of how easy it can be sometimes So, without much delay, lets move ahead.
Talking about templates, have a look at the following (commonly seen) images;
Fig 1. So, when you right-click on Project Node, Source and Test Packages Nodes you get the above Context Menu…Click (or MouseOver) on New to see a submenu..
Fig 2. Click on New > Other… “New File Type Wizard” opens up and you see some “Categories” and corresponding “Templates”.
By the way, have you ever noticed they are actually “Project Context Sensitive”. Not clear? See some of the following images;
Fig. 3. File Templates shown above are collectively known as Privileged Templates (J2SE Project Type)
Fig. 4. Categories and Templates shown above are collectively known as Recommended Templates (J2SE Project Type)
Fig. 5. File Templates shown above are collectively known as Privileged Templates (C/C++ Project Type)
Lets get into more details about the above and what exactly do we mean by Privileged/Recommended
You have LinkedIn account? Do you Recommend anyone? Are you Privileged enough to get special NetBeans inside access?
Thinking of this and creating an analogy, I will let my Project Type to Recommend some File Templates for itself, and out of those templates, some would be Privileged enough for quick view
Don’t know, what am I talking about?
Well, see the Fig. 1, the “File Templates” you look at are collectively known as Privileged Templates.
Now, looking at Fig. 2, the “Categories” and “Templates” – they are actually Project Context Sensitive ( or Type Specific) and thus, they are collectively known as Recommended Templates.
For instance, if you have some categories in Java Project Types, you might not find the same in JavaFX/PHP Project Types and so on. Similarly, every such Project Type would have different set of Privileged Templates.
What to do?
So, how do the developers deal with these issues? What they do, basically is that they just implement either/both of the following interface(s);
This results in providing implementation of one method provided by them and finally, you would see the effect when you run your module.
In NetBeans Sources, I found that these capabilities (as explained earlier in the series) are actually written as nested classes of the class that implements Project Interface, which are then added to the Lookup.
I will soon post more detailed information (also, refer Online Resources) on above by practically applying it, hope you are liking this series. If you’re willing to add/remove some points in this post, comment below.
- Support for providing own templates visible in New File… action
- Community Docs- Matrix of Tips and Tricks, Tutorials
- NetBeans Developers Mailing Lists
Next; I will dig deep into the Platform again, its been a month since I have surfed the sources… By the way, many community members are showing interest in creating a project type, hope to see them documenting their experience soon… See ya, until next time.