#2 | File Templates

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.

Moving Ahead

Talking about templates, have a look at the following (commonly seen) images;

Click to Enlarge!

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

Click to Enlarge!

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;

Click to Enlarge!

Fig. 3. File Templates shown above are collectively known as Privileged Templates (J2SE Project Type)

Click to Enlarge!

Fig. 4. Categories and Templates shown above are collectively known as Recommended Templates (J2SE Project Type)

Click to Enlarge!

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 ๐Ÿ™‚

Privileged/Recommended Templates

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);

  1. PrivilegedTemplates
  2. RecommendedTemplates

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.

Online Resources

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.


One thought on “#2 | File Templates

  1. Pingback: #3 | Geertjan Blogs and Kenai « N, Varun

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s