Griffon in NetBeans IDE 7.1

Griffon development can now be done in NetBeans IDE 7.1.
Plugin: http://plugins.netbeans.org/plugin/18664/griffon
Sources: http://java.net/projects/nbgriffonsupport
Managing BTI Networks on the NetBeans Platform
Let's drop by BTI Systems, with a development team split between Belfast and Ottawa, with a NetBeans Platform application that’s about two years old now. The application is a GUI front end for BTI's proNX Server Manager product, which is part of the proNX Management Suite. It provides a modular and scalable management solution for BTI networks and integrates seamlessly into any operating environment, providing maximum flexibility and ease-of-use.
Below is a screenshot which shows a small network of BTI equipment under management. You can see the discovered devices, how they are grouped, alarms, and in the center an Ethernet Service. All of this is data mined from the hardware over SNMP by the server component of the product. The client then displays the network, and draws the topology of the services without the user needing to layout the elements manually. The Ethernet Service in this screenshot is having some performance metrics being gathered on it, as you can see in the bottom right.
Quite a range of NetBeans Platform features are used here, including the visual library to draw optical and ethernet services, and all the core libraries to show an up to date network state and allow management functions to be performed against discovered equipment.
Formatting & Highlighting of Javadoc Comments
Here's a completely new set of options in NetBeans IDE 7.1 for javadoc comments:
Wrapping the javadoc comments to justify them with the right editor margin is now also possible, so this very popular issue is now fixed:
http://netbeans.org/bugzilla/show_bug.cgi?id=11553
The entire tab that you see above is new in 7.1. This new feature is also mentioned in the New & Noteworthy for NetBeans IDE 7.1.
Hidden NetBeans Feature: Export Shortcuts to HTML
Well, here you go, map this action to a keyboard shortcut and then you can print out all the current keyboard shortcuts:
So, specify a keyboard shortcut for "Export Shortcuts to HTML". Then, press the key combination you defined, and go to the user directory, i.e., ".netbeans/7.1" or whatever it is in your case. There, in the "config" subfolder, you'll find an HTML file has been created:
Open the "shortcuts.html" file and there you'll find all the current definitions of the keyboard shortcuts. Of course, if you've been reading this blog since 2005, where I blogged about this, then all this is not really news to you.
Upcoming NetBeans Feature: Generate Implementing/Extending Class!
Another upcoming NetBeans IDE feature, already in the daily builds, is this hint, which appears when you put the cursor in a class declaration:
Similarly:
When the hint is invoked, the new class, with all its required methods, is automatically generated, as a separate class (a dialog pops up letting you specify the name of the class and the package where the class should be created).
How handy these small enhancements can be!
This particular enhancement was included for 7.2 specifically because of a remark Arun Gupta made during Devoxx last year. That small discussion in a hallway resulted in this issue being highlighted and implemented:
http://netbeans.org/bugzilla/show_bug.cgi?id=49559
Just pointing this out as yet further evidence that we're really listening to users and, between balancing the various requirements coming in from various sides, are making very sure that user requests are taken extremely seriously.
Upcoming NetBeans Feature: Multi-Row Editor Tabs!
Several NetBeans users have been asking, for a long time already, for multi-row tabs in the NetBeans editor.
Read the list of use cases and requests around this area in the issue:
http://netbeans.org/bugzilla/show_bug.cgi?id=172512
Today, Stan Aubrecht, the NetBeans Platform window system engineer, closed the above issue. Why? Because he fixed it. In the Options window, you'll see several new options in the Appearance tab:
Above, the "Tabs placement" and "Multi-row tabs" options did not exist before today. As you can see, not only will you be able to set multi-row tabs, but you'll also be able to set where the tabs should appear, whether they're multi-tab or not.
Here you see multi-row tabs, with "top" tab placement:
Multi-row tabs, with "bottom" tab placement:

Multi-row tabs, with "right" tab placement:

Of course, anyone creating their applications on the NetBeans Platform will automatically inherit this behavior too, if they're creating document-centric NetBeans Platform applications.
With this new level of flexibility, you're able to get even more comfortable in your development environment than before.
Thanks, Stan!
Syntax Coloring for Clojure
Someone reading yesterday's blog entry might have thought: "OK. So you're not only able to create syntax coloring for some kind of trivial DSL. Yes, you're also able to do it for a real language, in this case, Ceylon. However, you caught a lucky break in that case, it's unlikely you'll be able to do it again for another real language."
Well, OK, take a look at this, my hypothetically sceptical imaginary friend:
What you see here is syntax coloring for Clojure (via the Clojure.g ANTLR file), created in about 45 minutes (Clojure turns out to have a lot less tokens than Ceylon), together with HTML embedding within Clojure comments. However, note that the embedding only supports syntax coloring, not code completion, not sure if that is possible nor how to do that.
Here's my embedding definition, i.e., this is all, no more or less than this:
@ServiceProvider(service = LanguageProvider.class)
public class HTMLEmbeddingLanguageProvider extends LanguageProvider {
private Language embeddedLanguage;
@Override
public Language<?> findLanguage(String mimeType) {
return ClojureTokenId.getLanguage();
}
@Override
public LanguageEmbedding<?> findLanguageEmbedding(Token<?> token, LanguagePath languagePath, InputAttributes inputAttributes) {
initLanguage();
if (11 == token.id().ordinal()) { //11 is the token ordinal in Clojure for comments
return LanguageEmbedding.create(embeddedLanguage, 0, 0);
}
return null;
}
private void initLanguage() {
embeddedLanguage = MimeLookup.getLookup("text/html").lookup(Language.class);
if (embeddedLanguage == null) {
throw new NullPointerException("Can't find language for embedding");
}
}
}
Soon I'll be working on a tutorial showing how to create syntax coloring for the Movie Query DSL I showed over the last two days.
Syntax Coloring for Ceylon
Yesterday's blog entry was a "smoke test" for generating syntax coloring and anyone reading it might have thought: "Big deal. Syntax coloring for a trivial query language is trivial. Call us again when you've provided syntax coloring for a real language."
And, justifiably so, since the DSL used yesterday is obviously, and appropriately, pretty simplistic:

OK, fine. So how about this. Syntax coloring for Ceylon (http://ceylon-lang.org/), which is one of the new JVM languages, (read about it here on Wikipedia):


(I literally know nothing about Ceylon, copied the code shown above from here.)
What's handy about Ceylon is that you don't even need to generate the lexer. The ANTLR-based lexer (and the parser) is already in the com.redhat.ceylon.typechecker-0.1.jar. So then it's a question of weaving the Ceylon lexer with the NetBeans APIs, which [as I pointed out yesterday] is actually a trivial task.
And it's even a trivial task for a real language, as you can see. I spent about 2 hours on this and only because Ceylon has a lot more tokens than my simple 'smoke test' of yesterday did. And a lot of those two hours was spent getting the coloring right, i.e., I wanted the colors to have exactly the right shade of purple, green, etc, which took a bit of experimentation. You don't like my colors? Also fine. Change them in the Options window:

So, since I imagine there's now even more interest in this topic than there was yesterday, I'm going to make a screencast that shows how to do this, with an accompanying tutorial, and a list of references that especially focuses on the existing implementations of these NetBeans APIs, which are extremely useful when you need to customize your implementations slightly and diverge from the standard path.
Generate Syntax Colors for a Domain Specific Language
In about 15 minutes of work, without typing a single line of actual code, I created syntax coloring for the domain specific language described here.
The result in a JEditorPane (and notice the non-printable characters are displayed, optionally, too) is as follows:

The user of the application is able to customize the colors:

Again, I did not type a single line of code to create the above. It was all as simple as using a lexer generator (JavaCC in this case) and then connecting the generated files into 100% standard NetBeans Lexer API implementations. I.e., all copy and paste stuff, together with a small bit of configuration and tweaking.
If anyone is interested in step by step instructions for getting to the above, again, without doing any actual coding at all, please leave a message and, based on whether there is some demand for this, I'll write a tutorial describing the procedure for this particular domain specific language.
Hidden NetBeans Feature: Drag/Drop to Create HTML Snippets
Here's another super hidden NetBeans feature. Because of the inherent functioning of this feature, it is completely hidden and undiscoverable from the point of view of the NetBeans user interface.
The scenario is that you've got an HTML file open and you're typing something in there. The 'something' is something that you're likely to reuse within the same HTML file or other files, such as the META tags that you see highlighted below:

Now, as you can see, I have the part of the file that I'd like to reuse highlighted.
And then... I drag my mouse into the palette, i.e., the palette that you see on the right of the image above. And then, guess what? This dialog automatically pops up:

The "Content" section above is automatically filled in, based on what I dragged. The other fields and icons are things I fill in myself. Then I click "Add to Palette", at which point the HTML snippet is added into the palette, from where it can then be dragged into an HTML file, like any other snippet in the palette.
Handy, isn't it? And really hidden. (I blogged about this before here in 2008, where you also see a Java file equivalent.)
In other news. There are two excellent new NetBeans blogs out there! The first is NetBeans Ruminations by Hermien Pellissier from South Africa and the other is the NetBeans category of Crazy Java Hacking by Martin Skurla from Slovakia. Check them out! Their blog entries are also going to be visible in the NetBeans welcome screen, because they've been included in the planetnetbeans.org aggregator. You have a NetBeans related blog too? Leave a message here. And if you don't have a NetBeans blog too, why not start one?
Hidden NetBeans Feature: Show Spaces in Editor
A really cool feature that I didn't know about until a few hours ago. Go to the main NetBeans menu bar and choose "View | Show Non-printable Characters". And now I can see the spaces in the editor:

The above is in the Java editor. Here is the HTML editor, with spaces:
Really handy to see the spaces (and the carriage returns, as well as the tabs). I made the above discovery while e-mailing with NetBeans Dream Team member Ryan de Laplante. He said that IntelliJ IDEA shows the spaces in the editor, while NetBeans doesn't. Some googling later, I found that NetBeans does, after all, have this support.
It appears that the spaces are visible in the editor for the first time in NetBeans IDE 7.1. At least, I invoked the same action as described above in 7.0.1 and then saw the carriage returns, but not the spaces. (And here's someone else who's found the same thing to be true.)
It's also possible to change the color of the non-printable characters, i.e., you could make them light grey. (But non-printable characters in HTML files do not change color as specified, so that's a bug.) Go to Tools | Options | Fonts & Colors and then go down the Category list until you find "Whitespace". Ryan commented on this that in IntelliJ IDEA "the non-printable characters are shown in a very light shade of grey so I can leave the feature turned on all the time and barely notice it unless I specifically want to look at it. In NetBeans I was able to change the color of the whitespace characters to a light grey too. That would be a nice default."
A second point that Ryan makes about the IntelliJ IDEA implementation of this feature is: "They don't show the line break character… they know that I'm only interested in whitespace characters. Maybe instead of enabling a 'Show non-printable characters' feature, I could enable a 'Show whitespace characters' feature."
And, finally, thus far, I've been unable to distinguish an EOL character from a carriage return (as also pointed out here).
But, clearly, aside from these quibbles, which I think would be nice enhancements for an upcoming release (see the list of issues I added in the comments to this blog entry), it's really great to see the spaces visibly in the editor. Makes it much easier to align one line with the next.
Other support for spaces include Tools | Options | General | Remove Trailing Whitespace, where you can specify under which condition (Never, Always, From Modified Lines Only) the last space, if any, should automatically be removed when the file is saved. Also, if you go to Tools | Options | Formatting | Java | Spaces, you can specify where a space should automatically be entered. (There's a similar option there where you can specify where a blank line, tabs, and indents should automatically be added, e.g., before/after methods, etc.)
NetBeans IDE: where the perfectly customized editor is only a space away...
Hidden NetBeans Feature: Search In Editor Selection
Probably this is obvious to many people, but when I first discovered it I was quite (pleasantly) surprised. When you select a section of code in an editor, you can search within that particular selection:
Here I selected a paragraph (which could have been anything, e.g., a block of code in the Java editor or a subset of words within a paragraph), then pressed Ctrl-F (which is "Find"), which puts my cursor in the small Find area in the bottom left of the screenshot above. Then I type "if", since that's the word I want to find and now, only within the selected text (e.g., not the "if" in the next paragraph above, since that paragraph wasn't selected), all the instances of the word "if" are found and then I can toggle forwards and backwards with F3/Shift-F3.
And all within whatever was selected when Ctrl-F was pressed. Then you can do a replace of all found items, i.e., only within a particular selection.
Tried and failed to do the same thing in IntelliJ IDEA Community Edition 10.5, while in Eclipse Indigo a Find/Replace dialog pops up with the "Scope" automatically set to "Selected Lines". So, in that respect, Eclipse appears to be better than IntelliJ IDEA, though I still prefer not having to use a dialog, which is what NetBeans supports, i.e., the Find/Search bar is integrated into the editor itself, as can be seen from the screenshot above.
Ruby Development in NetBeans IDE 7.1
Yesterday Tom Enebo announced the availability of the community Ruby plugin for NetBeans IDE 7.1.
Installs without a hitch. Seems to work as one would expect. Here you see the Projects window showing a structured view of a Ruby sample project, together with the Ruby editor:

As always, start your development work by going to File | New Project and then select one of the Ruby or Ruby on Rails templates that have been registered there by the plugin.
Including a Native Terminal Window in a Java Desktop Application
A terminal window is handy to have in an application. Here's what you need to select in the "ide" cluster of your NetBeans Platform application:
Then click the Resolve button. Run your application and you'll see the new menu item highlighted below, which opens the terminal window, as can be seen here:

Javeleon 2.0 Beta 3: Try It Today!
The NetBeans/Jmol project (which I've blogged about a few times already this week) has already proven its value! I was using Javeleon with it, discovered several problems, and reported them to Allan and the Javeleon guys. They downloaded the NetBeans/Jmol project and reproduced the bugs I had encountered.
Install Javeleon today, working for NetBeans IDE 7.1 and JDK 7:
http://javeleon.org/javeleon-for-netbeans-7.1/
Make sure you see this in your Plugin Manager, i.e., the plugin must be at version 2.0 Beta 3:
The bugs identified via the NetBeans/Jmol project have been incorporated into the above version of the plugin. For example, I can now change the annotation of a "position" attribute for a menu item for opening a TopComponent, i.e., this is an annotation in the TopComponent, reload the module, and then see the repositioned menu item. Another thing that the plugin is useful for is when you quickly want to prune some items from a layer file and want to immediately see the changes without going through the boring process of starting up your application all over again.
If you're a NetBeans Platform developer, whether on Ant or Maven, please try this plugin now, especially if you've tried it before, just to experience the improvements and report on other bugs you might encounter.


