taT | Hacking Modules..

10 07 2009

Ever wondered, apart from extending the NetBeans IDE, or some application based on NetBeans Platform. What else can be done with the module?

Brief Overview

Well, NetBeans IDE provides Module Development Support by providing 4 kinds of Project Templates;

  1. Module
  2. Module Suite
  3. Library Wrapper Module
  4. NetBeans Platform Application

I have some knowledge of the first two, so we will stick to them for the rest of this post. So, lets have a look at the simplistic module structure;

Module Structure

This is what you see when you expand the Project node in Files View. We will focus on platform.properties, project.xml. If you switch to the Project View, you would see the files with following names, visible under Important Files node.

NetBeans Platform Config

So, that’s basically the logical view of the file platform.properties. In the past, I have written some pretty useful tips and Tricks (contributed to NetBeans Community Docs) based on this file;

  1. Configure Clusters and Modules
  2. Managing NetBeans Platforms

Project Metadata

This is the logical view of the file project.xml. There’s one more useful tips and Tricks (contributed), that’s based on this file, which lets you add your module as friends to those modules, if you want your module to depend on the specification version of the same.

NetBeans IDE 6.7 (Click to enlarge)

Playing Tricks..

I will be making use of NetBeans 6.7 IDE. Although, these tricks should work well with NetBeans 6.x IDE. So, lets answer the question I asked in the beginning.. Generally, when you create Module project, you get an option to either create it as Standalone Module or Add to Module Suite.

Standalone Module

When you choose this option, you also get an option to select NetBeans Platform of your choice, along with Manage.. button. If you want to know more about that, refer this contribution.

Suppose, I choose NetBeans 6.5 Build (added with name as 65 in Platform Manager) as Platform and move ahead. I would be able to use 6.7 IDE to create module, targeted for NetBeans 6.5 IDE. The module’s platform.properties looks like this;

nbplatform.active=65

This would enable the running IDE to achieve the desired result, as mentioned above. Now, running the module will ofcourse launch NetBeans 6.5 IDE as Target Instance to see how your module works. This process might be slow, as you’re running full-fledged 6.5 IDE.

NetBeans 6.5 boots with a b'day stamp on splash screen!

If your module doesn’t depend on clusters other than platform (which is by default). Then, you can tweak the file as follows;

enabled.clusters=\
 platform
nbplatform.active=65

These clusters are bare-minimum essentials, that are enabled by default when you create the NetBeans Platform Application project using 6.5/6.7 IDE. The property enabled.clusters helps to enable only those clusters which are necessary to run this module.

Splash Screen for empty NetBeans Platform Application

Now, run your module and it will look like you’re running a NetBeans Platform Application having a single user-defined module. Here’s how module’s project.xml looks like;

<project xmlns="http://www.netbeans.org/ns/project/1">
   <type>org.netbeans.modules.apisupport.project</type>
   <configuration>
      <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
          <code-name-base>code.name.base.of.your.module</code-name-base>
          <standalone/>
          <module-dependencies>
           <!-- Here are your module dependencies.. -->
          </module-dependencies>
          <public-packages/>
      </data>
   </configuration>
</project>

Note the bold-faced tag <standalone />, this tells the NetBeans IDE that your module is not part of any module suite. Its a standalone module, as you created.

Add to Module Suite

If you decide to go with this option, you would then browse the filesystem to find the appropriate Module Suite project and then, move ahead.

In case of Module Suite projects, the enabled.clusters property automatically occurs/disappears, when you check/uncheck the modules and/or clusters from its Project Properties Wizard.

Note that the module, that becomes part of the suite, would use only those clusters which the suite has enabled. Along with that, suite-private.properties file is added under /nbproject/private. Also, take a look at the module’s project.xml;

<project xmlns="http://www.netbeans.org/ns/project/1">
   <type>org.netbeans.modules.apisupport.project</type>
   <configuration>
      <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
          <code-name-base>code.name.base.of.your.module</code-name-base>
          <suite-component/>
          <module-dependencies>
           <!-- Here are your module dependencies.. -->
          </module-dependencies>
          <public-packages/>
      </data>
   </configuration>
</project>

Note the bold-faced tag <suite-component/>, this tells that NetBeans IDE that this module is part of a Module Suite project.

Tips to Remember

You may convert your standalone module to become part of suite, or vice-versa. Just add/remove suite-private.properties (Per Suite Locator) file and tweak your Module’s project.xml and Module Suite’s project.properties.

Also, note that some changes have taken place in NetBeans 6.7 IDE, you may find out more over the web. One more thing, NetBeans 6.5 IDE added suite.properties file under /nbproject and had same tag as <suite-component/>. I think NetBeans 6.0 and 6.1 might do the same. Please try it yourself and let me know.

Stay tuned..





#3 | Geertjan Blogs and Kenai

16 06 2009

Dec, 2008

Nearly 6 months back,I had published 2nd part of the blog series, I started to share what I learnt while creating a project type. However, I couldn’t continue as I got busy with my internship commitments and engineering studies. I thought I would see many blogs after that from community side. I got few nods as well, but I am disappointed with them as they didn’t deliver.

May, 2009

I saw Geertjan wrote mini-blog-series (May, 2009) with code and hints on how to get started creating project type. That was really cool. Finally, it looked like my prayers were heard. Have a look at them;

  1. @AntBasedProjectRegistration
  2. @NodeFactory.Registration
  3. Build Project Command for Ant Based Project Types

Geertjan made use of NetBeans 6.7 daily builds for creating the prototype explained above. So, why not get started with these blogs?

June, 2009

I will soon continue with my exploration stopped long time back and will continue to post my learning in the coming months. Also, I have written a post in discussion forums to begin creating a project type.

Other News
Get to know more about my NetBeans plugins at Kenai and I also shared some tips and Tricks based on NetBeans Platform.

Come on, get started and share what you explore. Stay tuned for more..





NetBeans Plugins at Kenai | #2

10 06 2009

This post will focus on work flow of my plug in Revamped Hyperlink Navigation (RHN). Without much ado, lets get started..

Getting Started

Firstly, you need to access the existing sources available for plug in, published in Update Center for NetBeans 6.0 and then, I will use NetBeans 6.5 as the development software for demonstration. So, run NetBeans IDE (bundled with either Java SE, Java or All technologies).

NetBeans 6.5 boots with a b'day stamp on splash screen!

Checkout Sources..

Open Versioning | SVN menu and select Checkout… from sub-menu. Checkout Wizard opens.. Now, enter Repository URL as https://kenai.com/svn/nbrcp-kolektiv~incubator/nbplugins/tags/release60_versions and click “Next >.

You might be prompted by the NetBeans to accept certificate, click on Accept Temporarily and continue.. Now, click on the Browse button to select the Repository Folder needed to be checkout. Select /rhn_v11/ahrefhyperlink.revamped and specify your Local Folder. Also, select the checkbox with label as Scan for NetBeans Projects after checkout and click Finish. NetBeans will prompt you to open project AhrefHyperlink (Revamped). Click Open Project and NetBeans will open the project for you. Now, right-click the project node and select Properties.

Reference Guide
http://www.netbeans.org/kb/60/ide/subversion.html#checking

Manage Platforms…

Now, goto Libraries and you will notice that NetBeans Platform selected for project is the default build provided by the NetBeans 6.5 IDE, and similarly for Java Platform. So, you need to configure the project to be built against NetBeans 6.0. Therefore, refer this tips and Tricks to learn how to “Manage Platforms…“. Also, choose JDK 1.5 for Java Platform (JDK 1.6 should also work fine).

See Module in Action..

Once you are done with it, click OK to save project properties. Now, Clean and Build the project and Run to see this module in action. If success, the NetBeans 6.0 splash screen pops up and soon, NetBeans 6.0 instance is running with the plug in, installed. Try out the cases specified in the tutorial and then, try out some new one’s from your side. Observe where it works and where it doesn’t.

If you find any issues/bugs, kindly file it using JIRA Issue Tracker used for this project and select component nbm-hyperlink. Soon, I will write wikis so as to help you understand how to file issues for this project. Fixed sources are stored under /nbplugins/branches as /release60_fixes/ahrefhyperlink.revamped (Links updated).

Unstable code is placed under /nbplugins/trunk and you may see what new developments take place there.

Stay tuned for more!





taT | Managing NetBeans Platforms

3 06 2009

Recently, I asked a question on NetBeans Developers Mailing List about gaining better understanding of managing NetBeans Platform(s) within the NetBeans IDE.

You didn’t knew that, right? Well, I have also recently discovered that there’s a provision to manage “NetBeans Platforms” for almost every NetBeans Module Project (I guess). Although, I think I knew that this feature was there but never actually devoted time to see what exactly it does.

Yesterday, when I re-discovered this feature and decided to give it a try. I started exploring it and then, faced some issues. So, I raised the above question on the mailing list. I did receive a reply, however it has a different approach to the above problem. Not directly related to scenario’s I came across. As I await more clarification

Now, I got clarification I needed and indeed it should help me understand the way, NetBeans works in this scenario. I thought why not share this scenario with you people. Maybe, you might have faced same issues.

So, how exactly we make use of this feature? Just follow the steps and let me know, what did you observe?

Here are the Tricks,

Firstly, run NetBeans IDE (bundled with either Java SE, Java or All technologies). I am using NetBeans 6.5 FCS for demonstration.

NetBeans 6.5 boots with a b'day stamp on splash screen!

Now, goto Tools | NetBeans Platforms and generally, you would find same platform configured with your NetBeans IDE and that might be possible, only if you are not running any daily builds.

Click to enlarge!

So, this figure might look familiar to you, if the above statements are correct. You can configure several platforms with your distribution. For instance, I have NetBeans 6.0, 6.1 installed, along with 6.5 which I am running. So, I will show you how to configure one of them,

Add Platform…

Click to enlarge!

Choose Platform Folder

This step will let you select the installation directory of other NetBeans distributions and let you configure the platform supplied by them.

Click to enlarge!

Platform Name

You may edit the Platform Name as per your need, or keep defaults and click Finish.

Click to enlarge!

This way you have added platform supplied by NetBeans 6.0 in NetBeans 6.5. Now, switch over to Harness tab and click the 2nd radio button to complete the configuration. This is done to let this platform use its harness to perform tasks related with module projects.

Click to enlarge!

Similarly, doing for 6.1, the following figure shows that I have successfully configured the above NetBeans Platforms,

Click to enlarge!

Now, you know how to add/remove NetBeans Platforms. Lets go further ahead and explore a bit more by taking a typical scenario..

and some tips,

Assuming you made a plug in using NetBeans 6.0 (released in Dec ‘07) to be compatible with the same. Soon after NetBeans 6.5 FCS (released Nov ‘08) was available, you find that 6.5 work very fast compared to 6.1 and due its improved features, it will help you in reducing your development time.

So, you decide to rework on your module using latest features, however you still want that plug in to work only for NetBeans 6.0, here’s what you need to do.

Firstly, open your plug in project and right-click project node to select its properties. Now, goto Libraries and you would see there’s a drop-down list for selecting your choice of NetBeans Platform, against which you can build your module. This list of platform’s can be configured by clicking “Manage Platforms…” button and you will see the same image, shown earlier.

See how they are all related.. Isn’t it cool? By default,  the platform supplied by the NetBeans IDE you are running is selected.

Here’s one thing to keep in mind, that as you are reworking on an old project like this, you must make sure that you configure the NetBeans Platform for it with care, as not doing so will result in failing the build and adding irrelevant versions of module dependencies.

In our case, if you have configured NetBeans 6.0 as demonstrated above, you need to select that from drop-down list and then, select NetBeans 6.0 build to let your module perform tasks against platform supplied with NetBeans 6.0.

Click to enlarge!

When, you run the module project, the above splash screen for NetBeans 6.0 pops up and now, you can see whether your module works or not. Hope this helps!

This blog has been contributed to NetBeans Community Docs Program and for latest updates on this content, refer to the contribution.

Acknowledgements

Thanks to Tom Wheeler (NetBeans Dream Team Member and NetBeans Governance Board Member) for answering my question on the mailing list.





NetBeans Plugins at Kenai

31 05 2009

Do you still remember the plug in, I created last year to revamp the way hyperlink navigation was taking place for HTML files? Do you know there isn’t any such plug in yet bundled into the NetBeans IDE?

Yes/No.. Don’t say “Can’t say” ;)

Anyways, answers are Yes and No. There has never been any out-of-the-box support, that provides hyperlink navigation amongst HTML documents in the NetBeans IDE.

October 03, 2007

Geertjan Wielenga (prolific NetBeans blogger) created one, although its still not bundled with the NB, which did provide required support. There’s also a NetBeans Platform Tutorial for this plug in, you may give it a read. Although, its target release was NetBeans 6.0!

July 24, 2008

This month, I showed interest in upgrading the plug in by completing some of the tasks, specified in Next Steps section of the tutorial. You may read this blog entry for complete history and hence, I created another one. I got nice feedback from some of the community members and Geertjan, so I decided to write a tutorial for this revamped plug in.

January 09, 2009

Since, I got 2 plugins (uploaded to Plugin Portal) published into NetBeans 6.0 Update Center.. I thought why not contribute the code to the community’s codebase, i.e. contrib repository..  After interacting with the Technical Community Manager, NetBeans Dream Team and related personnel, I decided to setup a project at Project Kenai.

Today,

I decided to let you know how you can access the source code of the plug in and upgrade it according to your preferences/requirements. I am very late to notify this as I was busy with my internship program, which commenced on January 19th and culminated on 24th May (this year).

Revamped Hyperlink Navigation

…hosted at Project Kenai, you may access the source code from the SVN repository and you may also discuss about this plug in on the decidated forums. I will soon add the NBM in the downloads section, till then either you can download it from Plugin Portal (stable release) OR if you want to access it from within the NetBeans.

Update;

Then, goto Tools | Plugins and select the Settings tab. Now, click Add button and Update Center Customizer pops up. Enter Name as NetBeans UC 6.0 and URL as http://plugins.netbeans.org/nbpluginportal/updates/6.0/catalog.xml.gz. Wait for a while as NetBeans configures your new Update Center. Once done, select Available Plugins tab and you would find my plug in there. Hope this helps!

Stay tuned for more updates..





Awards: NetBeans back with a bang

14 01 2009

Winners of the Developer.com Product of the Year 2009 have been announced and you won’t be surprised to know..

NetBeans is certainly back with a bang ! We won FIVE awards out of TWELVE..

Here’s an excerpt from the announcement,

In the past due to close races, runner ups were also recognized. This year there were no close calls. Each winner won its category with a respectable margin.

In the case of Java Tools the winner had almost three times the votes of the others finalists in the category combined.

It is no surprise that the Development Tool category received the most votes. The second most popular category continues to be Open Source. Looking back over the last two years this shouldn’t be surprising at all.

The top two categories last year were Development Tool and Open Source. Two years ago the top categories were Wireless/Mobile and Open Source.

Last year, we won under the categories: Developer Tool, Java Tool and Wireless/Mobile Development Tool.. You can also take a look at the hall of fame , where we have won more awards over the past several years.. You haven’t yet started using NetBeans? What are you waiting for?

NetBeans Community Rocks!





Building Pizza with Lookup | #2

9 01 2009

Continuing from the last post, I will present you the code and pointers to the SVN repository at Project Kenai where the project resides..

Last time, I said I have ported the sample code to NetBeans Platform in the form of 4 modules getting plugged into the NetBeans Platform Application and I named it PizzaBeans. Today, we will just setup the service provider API and its service providers…

Service Provider Interfaces

Pizza Center Services (pizzacenter.services)

This module contains Builder and Product classes inside a package which is not exported by default, so I had to go the Project Properties and select API Versioning to make that package public, which would then be used by service provider modules to implement the desired functionality, i.e. to build the specific type of Pizza.

Service Providers

To quote from one of the John O’ Conner’s articles (see References);

“Define a service provider by implementing the service provider API. Usually, you will create a JAR file to hold your provider. To register your provider, you must create a provider configuration file in the JAR file’s META-INF/services directory.”

Here the Lookup API will come to the rescue, you will soon get to know how it enables loose-coupling amongst our modules and facilitates high cohesion. Although, I am creating probably the easiest of examples..

“The configuration file name should be the fully qualified binary name of the service’s type. The binary name is simply the fully qualified class name in which each component of the name is separated by a . character, and nested classes are separated by a $ character.”

The following two modules does the same and hence, through Lookup API one can get to know what all pizzas can be built…

Hawaiian Pizza (pizzacenter.spone)

This module contains a ConcreteBuilder class as the service provider class (the implementation of Builder class). So, this will be registered as quoted above;

Create the configuration file with a name as that of the service provider API class (i.e. Builder class) inside the “META-INF/services/” and add the fully qualified name of the above ConcreteBuilder class to the file.

Spicy Pizza (pizzacenter.sptwo)

Similarly, this module contains a ConcreteBuilder class as the service provider class (the implementation of Builder class). So, this will be registered in the similar way, as done for the Hawaiian Pizza module.

References

John O’ Conner’s article on Creating Extensible Applications With the Java Platform is a must read, also refer to the resources I had earlier pointed to.

To be continued…





Project with Kenai and I

7 01 2009

You all must have seen, I rarely post code on my blogs… :o However, during recent blog series I felt that there was indeed a need to write some code to complement my postings..

What sort of blog series?

I have been learning concepts of NetBeans Rich Client Platform for quite some time and last year, I studied RCP rather inconsistently.. So, recently focusing on design patterns, I thought of giving RCP another try and I am glad to have devoted some time to learn the popular modular framework..

What about coding?

Well, as I had blogged few months back about 2 plugins (uploaded to Plugin Portal) getting published into NetBeans 6.0 Update Center.. So, I thought why not contribute the code to the community’s codebase, i.e. contrib repository..

So, I emailed the concerned authority and after few weeks or so, got the access to the Mercurial Repository, however I had stopped working on RCP and was not able to devote much time to it..

Project (with) Kenai

I was actually thinking of setting up a project at java.net, so whenever I get time I will commit code to the SVN repository there and link to the files from blogs wherever necessary..

Also, I can have code of multiple projects committed to single project setup at java.net.. However, recently few Dream Team Members were discussing about Project Kenai on the mailing list and soon after I started exploring it.

and I

I found it interesting, so finally I have setup a project at Project Kenai and have started to commit some code..

Currently, I have stored code for my GoF and Lookup based blog series and for my Revamped Plug-in for HTML Hyperlink Navigation, I would soon add NBM’s to the downloads section..

See Also





Building Pizza with Lookup | #1

2 01 2009

Recently, I announced a blog series on making use of Lookup API along with  some design patterns in RCP Apps. So, I thought why not get started by porting some basic code snippets onto NetBeans Platform and then I shall see how to go about evolving them.

Builder Pattern

I will be beginning with Builder Pattern (a type of Creational Patterns). It does seem obvious with the title of the post- “Building” Pizza with Lookup.

Definition

The intention is to abstract steps of construction of object so that different implementations of these steps can construct different representations of objects.

Why Pizza?

Well, I came across a code sample which creates different types of Pizza using Builder Pattern. Hey, I have never made any Pizza on my own, but this seems to be a golden chance and that too through coding ;)

Getting Started

  • Run “NetBeans IDE” (I am using 6.5) which I had installed using JDK 1.5.10.
  • Next, press Ctrl + Shift + N or goto File > New Project…

New Project Wizard opens…

  • Choose NetBeans Modules as Category and NetBeans Platform Application as Project.

Name and Location Wizard opens…

  • Fill relevant information, and you would see project opens up in NetBeans Project Window (Ctrl + 1).

Right-click Project Node and see Project Properties, then select Libraries from visible Categories.

Now, you would see on the right-hand side, only some of the modules of platform9 cluster that are included by default in a RCP Application. Java Platform pointing to JDK 1.5 by default.

Overview of the Code Sample

The existing code sample has 6 classes, out of which 5 fit into Builder Pattern and the remaining class just runs the code sample to construct one of the types of pizza.

Builder (PizzaBuilder)

Abstract interface for creating objects (product).

Concrete Builder (HawaiianPizzaBuilder, SpicyPizzaBuilder)

Provide implementation for Builder. Construct and assemble parts to build the objects.

Director (Cook)

The Director class is responsible for managing the correct sequence of object creation. It receives a Concrete Builder as a parameter and executes the necessary operations on it.

Product (Pizza)

The final object that will be created by the Director using Builder.

The code above could be split into 6 separate “.java” files and stored under single package OR they could be inside a single “.java” file, wherein the filename would be same as that of the Main class.

Porting to NetBeans Platform

I have ported that sample into 4 modules which fits into the class diagram representation of Builder Pattern. The task of porting is simplified because of the Lookup API (Service Provider approach).

Assuming you have followed the guidelines stated in “Getting Started” section and have created a default NetBeans Platform Application (I have named it PizzaBeans) with “No Modules”. Now, we will create 3 modules and finally, move towards creating the 4th module, the one that interacts with the client.

To be continued…





GoF and Lookup: A Deadly Combo

24 12 2008

Today, I begin another blog series, the most interesting one I guess! As part of my university courses, where I was introduced to “Gang of Four” design patterns in recent past. I felt quite excited about them, so lets see what’s in store for all of us…

Gang of Four (GoF)

If you don’t know what GoF is, consider reading on web for introduction and related books for in-depth information. They are of three types, namely; Creational, Structural and Behavioral patterns.

Creational Patterns

These patterns have to do with class instantiation. They can be further divided into class-creation patterns and object-creation patterns. While class-creation patterns use inheritance effectively in the instantiation process, object-creation patterns use delegation to get the job done.

They comprise of 5 types;

  1. Abstract Factory
  2. Builder
  3. Factory Method
  4. Prototype
  5. Singleton

You can continue reading more on Wikipedia about the basics of Design Patterns… Update: There’s a Dzone RefCardz on Design Patterns, give it a read..

Lookup API

Well, this is the most lovable API ever produced by NetBeans Developers, its loved by anyone who makes use of NetBeans Platform to build modular desktop applications, or integrate innovative stuff into the NetBeans IDE.

You learn while you practice, so without wasting further time, I would suggest reading Antonio’s blog, which IMO simplifies understanding of Lookup API.

What about Geertjan? Ofcourse, who can ever forget him for the wonderful blogs he’s writing for the past several years. Also, book written by him along with Tim Boudreau and Jaroslav Tulach is a must read for gaining a better understanding of Rich Client Programming.

That’s not all, thank him again for releasing a series of screencasts to teach you all the basics of Top 10 NetBeans API’s on NetBeans Zone (Dzone Network).

A Deadly Combo

I was thinking, what shall happen if one uses Lookup API while applying the Gang of Four Design Patterns in an application. Sounds like a deadly combo, isn’t it? I felt it recently ;)

On that thought, I am trying to create some RCP Applications based on my learnings of the above, will blog about them in follow-up blog entries of this newly started series.

Stay tuned for upcoming blogs…





#2 | File Templates

19 12 2008

So, I am back again…

Recap

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) :o 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.





#1 | Adding Category and Projects

16 12 2008

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 unwanted break, I hope you have followed screencasts of Top 10 NetBeans API’s (Geertjan).

Recap

So, I had introduced, yes I just gave the introduction on how to get started understanding the relevant concepts of NetBeans Platform, so as to integrate a custom project type.

I hope you have given that a read, it takes time (if you’re new). Experienced developers might grasp them at a much better pace than I did.

Getting Started

Take a look;

What did you see? You saw new project “Category” (NbCreole) and corresponding “Projects” (Docs Project). Magic? Yes, it is.

I have still not completed creating my Project UI Specs, still I am up with this. How’s it possible?

XML Layer rocks!

Yes, the layer.xml certainly rocks. I just added few entries and I was able to get the above structure. Recall, how do you add a “New File Type”. There’s something called “Templates/Other” (by default) added into your layer.xml, just to show your file templates in “Other” category in “New File Wizard”, for almost every project.

Now, when I had surfed through NetBeans Sources, I found the  trick to show my own “Category” and its “Project” types.

Tips & Tricks

I had started implementing a new project type, but just added the above implementation. You can peek into the following XML Layer which points to files stored here..

<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
<filesystem>
    <folder name="Templates">
        <folder name="Project">
            <folder name="NbCreole">
                <attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.dev.creole.project.ui.wizards.Bundle"/>
                <file name="emptyCreole">
                    <attr name="position" intvalue="100"/>
                    <attr name="template" boolvalue="true"/>
                    <attr name="instantiatingIterator" newvalue="net.java.dev.creole.project.ui.wizards.NewCreoleProjectWizardIterator"/>
                    <attr name="SystemFileSystem.localizingBundle" stringvalue="net.java.dev.creole.project.ui.wizards.Bundle"/>
                    <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/net/java/dev/creole/project/resources/doc_16_16.png"/>
                    <attr name="instantiatingWizardURL" urlvalue="nbresloc:/net/java/dev/creole/project/resources/emptyProject.html"/>
                </file>
            </folder>
        </folder>
    </folder>
</filesystem>

Indeed, its magic :)

Anyways, when you click “Next”, it throws an exception because I have not yet implemented WizardDescriptor to provide further Wizards.

Not to worry, just avoid distributing the modules with the above tricks, when no implementation is done ;)

Status: In Progress, Not Yet Usable

Next; I will blog about “Templates”, yes the one’s shown in “New File” action invoked on any node of a project’s Logical View (Projects Window). See ya, until next time.





Learning Top 10 NetBeans API’s

1 12 2008

Hey,

Are you following the Top 10 NetBeans API’s (Series of Screencasts) by Geertjan Wielenga, Technical Writer, Sun Microsystems.

The following screencasts introduce you to the main NetBeans APIs, why you would use them, and how to get started doing so.

Top 10 NetBeans API’s

http://platform.netbeans.org/tutorials/nbm-10-top-apis.html

Guys, get started with NetBeans Platform in the easiest way possible, I am learning a lot and ofcourse, you will too ;) Give it a shot :)

Greatest Hits || Runner Ups

Happy NetBeaning!





Blog Series | New Project Type

15 11 2008

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…

[1] http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectapi/org/netbeans/api/project/Project.html#getLookup()

Objects implementing interface Lookup.Provider are capable of and willing to provide a lookup (usually bound to the object).

[2] http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectapi/org/netbeans/api/project/Project.html#getProjectDirectory()

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.