Sunday May 31, 2009
Further Griffon Plugin Developments for NetBeans IDE 6.7
Here are the new features/enhancements in the Griffon plugin development:
- Plugin Architecture. The plugin now consists of 3 modules that can either be part of the NetBeans sources or separated from them. So, I've basically sorted out the dependencies and am able to provide three NBM files that constitute the plugin. One is a new module, providing the Griffon project; the second is the Grails platform extended with Griffon support; the final one is a 'friends' element added to the Groovy support module, enabling it to be used by the new Griffon project module.
- "griffon create-mvc". This command is now supported, generating a model, view, and controller in the project structure. Either a menu item on the project node or a template in the New File dialog invokes the command, producing a dialog where a prefix is specified for the name of the files.
- Plugin installation. Griffon, like Grails, lets you add plugins to an application. The plugins are for developers, not for end users. For example, there's a plugin that adds a splash screen and another plugin that provides wizard support (based on Tim's wizard project on java.net!). These files and related commands are installed as plugins, which can now be done via a dialog in the IDE, just as is done for Grails.
- "griffon help". This command is supported, as is done with Grails, in such a way that a dialog lists the currently available commands. A refresh button lets you refresh the list, which makes sense after a plugin is installed. Then a command can be selected, Run is clicked, and the selected command is run. You're therefore not constrained by the menu items offered on the project node. Instead, you can invoke any command supported by your Griffon distribution.
- Pruned Logical View. Now the logical view only presents a small subset of folders, i.e., only the model/controller/view folders, as well as the lifecycle and configuration folders, together with the test folders. So, the Files window displays everything, while the logical view in the Projects window is much more discerning:
Several things need still to be done. For example, project-level commands such as "Rename" and "Copy" need to be implemented. Also, Grails functionality needs to be restored and tested.
I have tried out the plugin in NetBeans IDE 6.7 Beta under Ubuntu. Soon, some volunteers/guinea pigs would be welcome to try other combinations.
I intend to demonstrate this Griffon plugin at the Java University session on NetBeans, NetBeans Integrated Development Environment (IDE) 6.5 Architecture and Its Powerful Plugins. It will be held from 18.00 to 21.00 tomorrow at the Intercontinental Hotel, which is on 888 Howard street, very close to the Moscone Center.
May 31 2009, 11:26:28 PM PDT Permalink
Carpentry is not the same as web design
The title of this blog entry comes straight from John Oliver's wonderful stand-up comedy show. He is, honestly, even better in real life than he is in The Daily Show. With Troy, Sven, and Toni, I saw him tonight in action. On pain of a terrible death, pictures were not permitted to be taken. Fortunately, I had already taken one outside the theater:
The two comedians that came up before him were excellent too. Three cheers for John Oliver, though. He said some amazingly funny things tonight.
May 30 2009, 12:01:15 AM PDT Permalink
Now You Can Buy "The Definitive Guide to NetBeans Platform"
You can now buy the print book, i.e., the hard copy, of The Definitive Guide to NetBeans™ Platform! Take the following steps to do so:
- Click this link:
- In the left side of the page you get to when you take the previous step, click "Buy Print Book".
- Now you see this, where you can (for example) take a look at the table of contents:
Note: Probably the text above will change slightly and an image of the book cover will be added.
- Click the Shopping Cart button you see above and then you're a couple of days away from holding the book in your own two hands!
Hurray. Thanks Apress.
May 29 2009, 08:10:15 AM PDT Permalink
"griffon create-app" in NetBeans IDE
Big advance in the Griffon story today in NetBeans IDE—Griffon commands can now be run, such as "griffon create-app" and "griffon run-app":
- Specify that you want to create a new Griffon application:
- Define a name and a place to store it:

Note: The IDE automatically picks up "GRIFFON_HOME", if you have defined it. If you haven't defined it, you can't continue with the next step (the "Finish" above is then greyed out), so that you have to click the "Configure" button above, which puts you into the Options window shown yesterday, where you then need to define the location of your Griffon distribution.
- Then the IDE creates the application, calling "griffon create-app", using the Groovy script in the Griffon distribution, and opens the application thusly created into the IDE. Next, you can simply run the application, which means that you get the IDE to call "griffon run-app":
- Or open one of the samples from the Griffon distribution and run it:
However, still too early to make any kind of distribution available. Need to backtrack a bit and make it possible again to create Grails applications as well. Plus, the generation of Griffon artifacts doesn't work at the moment.
In other news. Did a lot of tweeting today. Follow me here, many updates can be expected relating to Griffon support in the IDE: https://twitter.com/GeertjanW
May 28 2009, 04:44:36 PM PDT Permalink
Tooling for Griffon & Grails Supported Together in NetBeans IDE 6.7 Beta
Trying to get Griffon support together with the existing Grails support, rather than replacing the latter with the former, which is the approach I initially took. Here are some screenshots. The first was based on some work I did yesterday, the other two are based on work done today.
New Projects dialog, showing a Griffon project template, together with a Grails project template:
Options window, indicating that Griffon home can be set, as well as Grails home:
Griffon applications open in the IDE, together with Grails applications, as well as Groovy editor shown:
Next steps involve enabling the user to actually use the project templates to generate Griffon applications, via "griffon create-app". That part is still missing, so that right now Griffon applications can be opened, but not created. Also, all other Griffon commands, such as "griffon run-app" are not supported yet. Those are the next things to work on.
After that, I need to look at how to distribute these additions to the Groovy cluster, i.e., as individual NBM files or as a whole build. There may be a few problems in this area to solve.
May 27 2009, 07:57:38 PM PDT Permalink
Ant-Based Clustering of Alien OSGi Bundles
Today Toni blogged about the integration of alien OSGi bundles (I like that word 'alien'!) into NetBeans Platform applications created on top of Netigso. He describes how to do so manually. Below are some notes I got on 20/5 from Jarda outlining how to do it via Ant (i.e., not manually like Toni did it):
- Get build #145. (Or later, I assume.)
- Find a bunch of OSGi modules somewhere (Jarda used GlassFish v3).
- Then:
ant -f $NETIGSO/harness/suite.xml clusterize -Dcluster=`pwd` -Dincludes=modules/**
or something like that (the includes may not be necessary).
- Then go to suite customizer (i.e., the Project Properties dialog of the NetBeans Platform application) and add that directory as a cluster.
- Add dependencies in your own modules/bundles on the cluster's new bundles.
The final step in Jarda's outline to me is to "report bugs or celebrate success". :-) I haven't tried the above procedure yet, but am just putting it out there just in case someone else (Toni?) gets a chance to try it.
May 26 2009, 11:01:16 AM PDT Permalink
How to Programmatically Open the New File Dialog
The question of the day comes from Robin, who is from bstek.com in China. He sends the screenshot shown below and wonders how to enable the "New File" dialog to be opened when a button he created is clicked:
There was a discussion on the dev@openide.netbeans.org mailing list sometime ago (click here to jump into it), answering this question. And here's code that I have tried a few minutes ago (in a 6.7 build) that opens the New File dialog. However, note that the New File dialog can only open in the context of a project in NetBeans IDE. In other words, a project must be open and the assumption is that the new file will be created within that project.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Action;
import org.openide.ErrorManager;
import org.openide.cookies.InstanceCookie;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
public final class SomeAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
Action a = findAction("Actions/Project/org-netbeans-modules-project-ui-NewFile.instance");
a.actionPerformed(e);
}
public Action findAction(String key) {
FileObject fo = FileUtil.getConfigFile(key);
if (fo != null && fo.isValid()) {
try {
DataObject dob = DataObject.find(fo);
InstanceCookie ic = dob.getLookup().lookup(InstanceCookie.class);
if (ic != null) {
Object instance = ic.instanceCreate();
if (instance instanceof Action) {
Action a = (Action) instance;
return a;
}
}
} catch (Exception e) {
ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
return null;
}
}
return null;
}
}
The code above comes straight from the discussion on the mailing list. Alternative approaces are also described there. So, here's hoping this answers the question, Robin! And good luck with your plugin, looks pretty interesting so far.
May 25 2009, 06:26:38 PM PDT Permalink
Support in NetBeans IDE 6.7 for IntelliJ Idea Users
In addition to a number of improvements to the Keymap section of the Options window, such as, notably, code completion to help you assign new shortcuts, I noticed today that an IntelliJ Idea keymap is now also included:
That new keymap isn't mentioned yet in the NetBeans IDE 6.7 New & Noteworthy document.
May 24 2009, 11:49:16 AM PDT Permalink
Java Code Completion Enhancements in NetBeans IDE 6.7
This is what the Options window looked like in NetBeans IDE 6.5 and 6.5.1:
In 6.7, things will change slightly. The screenshot below is taken from a 6.7 build. Notice that there is a new subtab within the "Editor" tab. The subtab has "Code Completion" in the tab's label:
The "Code Completion" settings from the 6.5 Options window, that were in the "General" tab", are now in the new "Code Completion" tab. They're the same as before, available for all languages. However, in addition to those options, there is a new set specifically for Java, as you can see in the screenshot above.
And this is what they mean:
- Guess Filled Method Arguments. When selected, code completion tries to insert a variable available in the current context as the method argument. Otherwise, the supplied name is derived from the method signature. Here's an example scenario:
Character cccc = null; System.out.appen| //invoke CC, choose 'append(Char c)'
When the option is ON, the result is as follows:
System.out.append(cccc);
Otherwise:
System.out.append(c);
- Auto Popup Triggers for Java. Defines the patterns upon which code completion will appear. For example, you might want the introduction of a new opening parenthesis or comma to trigger code completion, so that related method parameters can be shown.
- Auto Popup on Typing Any Java Identifier Part. Specifies that code completion be shown whenever a new Java identifier part has been entered.
- Completion Selectors for Java. Defines the characters that confirm the current selection in the code completion box. Upon one of the selectors being pressed, the current item in the code completion box is selected and entered in the editor, with the selector appearing after it.
- Exclude/Include. Lets you limit what is shown in the code completion box.
- Auto Popup Triggers for Javadoc. Defines the patterns upon which code completion box shows up inside Javadoc comments.
Pretty cool enhancements to improve your coding pleasure.
May 23 2009, 11:32:06 AM PDT Permalink
org.openide.awt.NotificationDisplayer
The question of the day comes from Christopher Chak, from Experian ("Experian is a global leader in consumer and business credit reporting and marketing services and a constituent of the United Kingdom's FTSE 100 index, with revenues in excess of US$4 billion. We support clients in more than 65 countries and employ more than 15,500 people in 38 countries."). Christopher writes the following on the dev@openide.netbeans.org mailing list today:
I'm trying to implement a StatusLineElementProvider in my project. I have managed to get an icon to appear within a JPanel on the status bar. My question: how do I implement a popup 'text bubble' when I mouse over the icon, ie. exactly like the 'text bubble' that appears on the update reminder icon for the IDE?
Well, the answer is that there's a new class in NetBeans Platform 6.7:
That's org.openide.awt.NotificationDisplayer. So there's three different constructors. Here's one of them in action:
public void actionPerformed(ActionEvent e) {
NotificationDisplayer.getDefault().notify("Title 1", icon, "Text 1", new DemoActionListener(), NotificationDisplayer.Priority.HIGH);
}
Some screenshots. First, if there's one notification:
Possibly, there's more, and then you see this:
So, Christopher, forget your StatusLineElementProvider and just use the NotificationDisplayer instead! In one line, you'll get exactly what you're looking for! For previous releases, you might look for this code in the 6.7 sources and copy them into your own application.
May 21 2009, 04:52:06 AM PDT Permalink
JavaSpektrum and NetBeans Articles
The latest JavaSpektrum, a German-language Java magazine, has some great articles relating to the products coming out of the NetBeans project:
NetBeans IDE:
-- NetBeans 6.X - die ultimative Java EE IDE?, by Adam Bien
NetBeans Platform:
-- Modulare Anwendung mit dem NetBeans-Lookup-Konzept, by Heiko Böck
-- NetBeans RCP - Das bessere Swing-Application-Framework? by Anton Epple
Toni also blogged about these articles, here. I wonder if these articles could be translated to English? All 3 of them should be made available to a wider audience and, after all, we have a tried and tested system of German-English translators, as testified by Sven Reimers, here.
So, what do you think, Adam, Heiko, and Toni? Maybe you could ask JavaSpektrum if we could translate the articles and then publish them somehow, maybe via netbeans.org or NetBeans.dzone.com?
May 20 2009, 09:40:52 AM PDT Permalink
Graduate Student Projects on the NetBeans Platform
Quite a few student thesis projects (typically for Masters programs at universities) have been done on the NetBeans Platform. To start gathering these into one place, here's a randomly sorted list of all the thesis work I know about, off the top of my head:
- Thomas Würthinger in Linz, Austria: "Visualization of Program Dependence Graphs" (blogged about here)
- Pawel Boguszewski in Warsaw, Poland: Ruby Editor on the NetBeans Platform (blogged about here)
- Fionn Ziegler in Würzburg, Germany: "Modul-Entwicklung auf der NetBeans Rich-Client Plattform: Entwicklung eines dynamisch ladbaren Moduls zur Verwaltung der Zugangsdaten für verschiedene Vergabeplattformen" (article here)
- Several students from Warsaw University: various kinds of editors, in particular, were created by these students (article here, as well as source code)
- Several students from Johannes Kepler university in Linz, Austria: many different kinds of plugins (article here, as well as source code)
- Jilles van Oossanen: "Aan het eind van het project dient er een omgeving (inclusief ontwerp) opgeleverd te worden waarmee applicaties op generieke en modulaire manier ontwikkeld kunnen worden." More info here.
- Students in Brno, Czech Republic: Several students from a training given there (blogged about here) were interested in doing a thesis on the NetBeans Platform. (I wonder how they're doing?)
- Volker Kokula, Lukasz Palczynski, Veit Nachtmann in Würzburg, Germany: "The Würzburg Reduced instruction set Computer is a primitive assembler used by the Chair 5 of the informatics faculty of the university of Wuerzburg. It's sole purpose is to ease the understanding of true assembler code." (official homepage here)
- Michel Fapso in Brno, Czech Republic: Music score editor on the NetBeans Platform (blogged about here)
- Damir Tesanovic in Hungary: Client/server application on the NetBeans Platform (e-mail about this here)
Are you (or someone you know) working on a student project using the NetBeans Platform as its basis? If so, please let me know. Especially if a PDF document has come out of the process, those documents are extremely valuable to other people learning about the NetBeans Platform (or writing their own thesis around it). The two listed above (by Thomas and by Fionn) are both extremely cool, providing an excellent list of advantages of using the NetBeans Platform and how to get started doing so.
May 19 2009, 12:34:01 PM PDT Permalink
Incorporating an OSGi Dictionary Service in a NetBeans Platform Application
Build 137 of Netigso provides exactly what I was looking for. I can now create a dictionary application that uses an OSGi service for checking the entered words:
Isn't that cool? Swing + OSGi on the NetBeans Platform. Marriage made in heaven?
And here's the whole application structure:
Here's the whole story in code.
- Create an OSGi bundle that defines an interface:
package org.demo.dictionary.iface; public interface DictionaryInterface { public boolean checkWord(String word); } - Next, define an OSGi bundle that implements the interface:
package org.demo.dictionary.service; import org.demo.dictionary.iface.DictionaryInterface; public class DictionaryService implements DictionaryInterface { String[] WORDS = {"see", "you", "in", "san francisco"}; public boolean checkWord(String word) { for (int i = 0; i < WORDS.length; i++) { if (WORDS[i].equals(word)) { return true; } } return false; } }For the above to be possible, the first OSGi bundle needs to be on the classpath of the second OSGi bundle. Otherwise you don't have access to the interface you're implementing. That's a service offered by the NetBeans Platform application, acting as a container for the OSGi bundles, making the OSGi bundles available to each other, only requiring you to explicitly set the dependency, using the standard NetBeans Platform tools for doing so.
- Next, again in the second bundle, use the Module Installer, as discussed in yesterday's blog entry, to create a BundleActivator and then register the service in the BundleContext:
package org.demo.dictionary.service; import org.demo.dictionary.iface.DictionaryInterface; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class Installer implements BundleActivator { public void start(BundleContext c) throws Exception { c.registerService(DictionaryInterface.class.getName(), new DictionaryService(), null); System.out.println("Registered the dictionary service!"); } public void stop(BundleContext c) throws Exception { } }The Module Installer automatically registers the BundleActivator in the OSGi bundle's Manifest, just like the OSGi Bundle wizard registered the other required keys in the Manifest, so that there is nothing at all I needed to do manually in the Manifest.
- Finally, create a NetBeans module. Include a TopComponent with some UI for entering the word that should be checked. Under the JButton, define the following code, taking particular note of the line in bold, which is where the service from the OSGi BundleContext is retrieved into the world of the NetBeans Platform:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { DictionaryInterface dict = Lookup.getDefault().lookup(DictionaryInterface.class); if (dict != null) { if (dict.checkWord(jTextField1.getText())) { jTextArea1.setText("Correct!"); } else { jTextArea1.setText("Wrong!"); } } else { jTextArea1.setText("No service available!"); } }
Again, the above implies that you've set a dependency on the first OSGi bundle. But not on the second OSGi bundle! That means that the client is loosely coupled from the service. I.e., you could remove the service and replace it with another one, without changing any code in the client. Or you could use Lookup.getDefault().lookupAll if you anticipate that multiple dictionary services will be available to the application.
Now simply run the application and, to the end user, the NetBeans module handles the OSGi dictionary service exactly as if it were provided by a NetBeans module. Thanks to the Apache Felix OSGi Tutorial for the code used in this blog entry.
May 18 2009, 03:48:14 AM PDT Permalink
Generate BundleActivators for OSGi Bundles in Netigso!
Build 132 of Netigso is pretty cool—an OSGi BundleActivator is created when you use the Module Installer wizard in an OSGI Bundle project:
- Create OSGi Bundle project:
- Specify location and whether it belongs to an application:
- Specify unique code name, display name, localizing bundle, and optional layer.xml file:
- Finish the wizard and then you have the applicable OSGi keys in your manifest, as well as a dependency on the OSGi framework, so that you can reference the OSGi container APIs (that's thanks to Build 131 of Netigso):
- Next, use the "Module Installer" wizard, exactly as you'd do for a NetBeans module. I.e., nothing to fill in at all, simply click Finish:
- And now you have a BundleActivator class, instead of a NetBeans API ModuleInstall class:
Excellent, right? Now, the main thing I'm looking forward to is services in BundleContexts being added to the Lookup of applications, so that NetBeans modules can use the Lookup to access those OSGi services!
May 17 2009, 07:36:19 AM PDT Permalink
Free NetBeans Platform Crash Course
To celebrate the release of the eBook version of Heiko's "The Definitive Guide to NetBeans™ Platform", here's a crash course into the world of the NetBeans Platform. Zero NetBeans Platform knowledge is assumed. In slightly over 21 minutes, you'll learn the basic concepts, the motivations behind using the NetBeans Platform, and details about the architecture of NetBeans Platform applications.
Related links
- NetBeans Platform Home
- NetBeans Platform Screenshots
- "Top 10 NetBeans APIs" Screencast Series
- The Definitive Guide to NetBeans™ Platform
Resources
In other news. Go here to see this course announced on Apress.com!
May 16 2009, 12:47:35 PM PDT Permalink



