Blog Series | New Project Type
Today, I begin a blog series on my learnings of NetBeans API’s, interacting with experienced folks on the mailing lists and browsing through NetBeans sources, that might help me (possibly others as well) “Create a New Project Type” in NetBeans IDE.
Abstract
I will be creating a project type that I could use in my final year project based on NetBeans Platform (updated Jun 10 ’09). Right now, I don’t know how long this series would last, but I would try to cover as much as I learn. Feel free to present your views (negative/positive), suggestions or enhancements to the approaches I will follow.
Introduction
The NetBeans IDE (starting with version 4.0) organizes user work into projects. Each project corresponds to exactly one project folder on disk. A given disk folder may be a project folder or not; you cannot have two projects in one folder.
What do I think?
I think they are talking about a disk folder having a single /nbproject sub-folder, would be considered as a project by NetBeans. That means, we need to create an implementation of an interface, Project.
Project (Project API)
This (public) interface (which extends another interface Lookup.Provider) resides in Project API (Its primarily of interest to the project type provider modules, infrastructure & generic GUI).
public interface Project extends Lookup.Provider
Now, there are two methods to be implemented, one of them specified by Lookup.Provider[1], present in Project (due to inheritance) and the other by Project[2] itself.
Refer Javadocs…
Objects implementing interface Lookup.Provider are capable of and willing to provide a lookup (usually bound to the object).
Lookup getLookup()
Get any optional abilities of this project.
As we are providing a project, so there are a number of interfaces which one should consider implementing and including in lookup, some of which are described in the related Javadocs. I will discuss only those which I have implemented.
private Lookup lookup =
Lookups.fixed(new Object[]{
this,
new MarkupInfo(),
new MarkupLogicalView(this),
new MarkupProjectOpenedHook(),
new MarkupProjectXmlSavedHook()
});
Twist in the Tale..
Hey, I had just mentioned and as per the Javadocs, we are required to add implementation of some of the recommended abilities, which I would refer to MarkupInfo (implementation of ProjectInformation) and MarkupLogicalView (implementation of LogicalViewProvider).
However, one can also add some instances of classes extending certain abstract classes. In the above case, I would refer to MarkupProjectOpenedHook (subclass of ProjectOpenedHook) and MarkupProjectXmlSavedHook (subclass of ProjectXmlSavedHook) as the abstract classes.
Status: In Progress, Not Yet Usable
Online Resources
There’s a guide which should give developers of NetBeans modules (extensions), a basic idea of how to write new project types for NetBeans 4.x, as well as use certain important parts of the project and build system functionality from other kinds of modules.
NOTE
The reader is assumed to be familiar with the basics of developing NetBeans modules: how to compile Java sources against API-providing modules, make the JAR, write the manifest and XML layer, register services in global lookup, etc.
For background, the reader is encouraged to first look at the general design document which explains how the different pieces of the architecture work together to provide the user functionality.

[...] in NetBeans at 12:10 am by Varun If you remember, I had announced a blog series few weeks ago. Today, I would continue that with lot more to learn. By the way, during this [...]
Adding Category and Projects « N, Varun
December 16, 2008 at 12:11 am
[...] NetBeans Sources, I found that these capabilities (as explained in Part #1) are actually written as nested classes of the class that implements Project Interface, which are [...]
File Templates « N, Varun
December 19, 2008 at 12:26 am