Tuesday September 25, 2007
Collaboration Plugin in NetBeans IDE 6.0 Beta 1: It Just Works!
Hardcore NetBeans Platform developer Sven Reimers (in Germany) and NetBeans evangelist Dave Botterill (in the US) found themselves in a collab session with me (in the Czech Republic) today, after I logged in to the free shared server, inspired by the following words in Iwan Eising's blog:
"I still can't believe collaboration is not part of the standard installation. It is probably the plugin I use most apart from the obvious plugins that are part of the standard install. Collaboration is really important as I develop the game together with a friend of mine. He lives about 100 km away from me, so we meet in NB, discuss our progress in NB etc."
The cool thing is that neither Sven, Dave, nor myself had arranged to meet each other there. Sven was already there, then I joined, and then suddenly Dave showed up, for his first collaboration session ever. And here's a short snippet of our conversation:

Notice also that I've shared one of the Filthy Rich Client samples with Dave and Sven. So, they can inspect my code, make changes in my code, build my application, and run it. How cool is that?! But if they run it, only I get to see the result. One excellent improvement (if it is possible) would be for Dave and Sven to be able to see (via an emulator or something?) the application running on their side.
Sep 25 2007, 08:55:33 AM PDT Permalink
Enhancements to the Multiple Project Template (Part 2)
I was talking to the head of the NetBeans docs team, John, yesterday about the Filthy Rich Client samples that we're planning to put in the NetBeans Sample Catalog. John said: "It would be cool if, when the user pulls the sample out of the New Project wizard, a description of the sample would appear." (Or words to that effect.) So, a cool way to implement this requirement is to... enhance the Multiple Project Template even further. For each sample that the Multiple Project Template bundles into a module (i.e., this could be 82 samples, as in the case where one might want to bundle all of the Filthy Rich Client samples), we want to have the Multiple Project Template wizard create the following:
- A new TopComponent, containing a JEditorPane, for viewing the description HTML file.
- The TopComponent's settings file and WSTCREF file, which must specify that the TopComponent should be closed by default.
- Code in the iterator used to create the sample, so that when the New Project wizard is completed, the TopComponent will open automatically, i.e., at the end of the instantiate method.
- A new action, to be invoked from a menu item under the Help menu, for displaying the TopComponent, in the scenario where the user has closed it after the IDE opened it when the wizard instantiated the sample.
This means creating several new template files and then getting the Multiple Project Template wizard to use those template files at the right point in time. In the case of all these TopComponent-related template files, the thing to do is "ransack" (as Toni so nicely puts it in his rather brilliant Visual Datbase Explorer Tutorial) code from the templates that the IDE already provides. So, I used the Window Component wizard to create all the TopComponent-related files and then copied all the code from these files into my template files (i.e., the code for the action, for the settings file, for the WSTCREF file, for the TopComponent form file, and for the TopComponent Java class), which I then forced the Multiple Project Template to generate, together with all the other files. On the generated TopComponent, I added a JEditorPane, set the HTMLEditorKit, and referred to the description HTML file that I defined in the Bundle file, which is also done via the iterator, as shown in the snippet that follows. So, now, in the template that is used to create the TopComponent, I have this in the constructor:
jEditorPane1.setEditorKit(new HTMLEditorKit());
try {
String s = NbBundle.getMessage(@@TEMPLATENAME@@DescTopComponent.class, "DescDocument");
URL demoDetailsURL = new URL(s);
jEditorPane1.setPage(demoDetailsURL);
} catch (IOException ex) {
ex.printStackTrace();
}
And then, in the iterator, I have this line, which adds the correct entry in the Bundle file, when the Multiple Project Template wizard wraps the selected samples into the module as project templates:
fileChanges.add(fileChanges.bundleKey(bundlePath, "DescDocument", "nbresloc:/"
+ packageName.replace('.', '/') + "/" + name
+ "/" + name + "Description.html"));
Of course, the above (as well as everything else involving the creation of your own apisupport wizards) entails an implementation dependency on the NetBeans Module Project module, since that module does not expose an API yet.
However, in the end, we implemented it in a much simpler way (so as to be consistent with existing samples that provide readmes), without TopComponents, just using the IDE's default browser, at the end of the instantiate() method:
URL descURL = new URL("file:////"+dir.getPath()+"/" + "@@TEMPLATENAME@@Description.html"); // NOI18N
URLDisplayer.getDefault().showURL(descURL);
So now, when the sample's wizard completes, the HTML file defined above opens in the IDE's default browser. The HTML file is in the root folder of the sample in question. All the templates I described above are thus superfluous...
Sep 25 2007, 05:54:26 AM PDT Permalink


