Sunday Jan 31, 2010

Het Lid van Jan Smit

With the recent developments relating to Oracle's acquisition of Sun, I thought that the tone of my blog had become too serious and technically-focused. Sometimes blog entries should be personal and just plain fun, without any business content to speak of. After all, that's how you find out about the person behind the blog and the individual behind the employee.

So, it's time to turn over a new leaf. Occasionally frivolous content will now be added to this blog, since it has for the past 5 years been so overwhelmingly dry and, dare I say it, boring. Here's the first: "Het Lid van Jan Smit", which is about posters all over the Netherlands advertizing underwear, with Jan Smit (a semi famous Dutch singer) wearing them:

It's a funny song even if you don't understand Dutch. Listening to it is a great way to start your week. And that's why I posted it. Happy Oracle years to you all!

Saturday Jan 30, 2010

Create Your Own Window System on the NetBeans Window System

One big reason for using the NetBeans Platform is its out-of-the-box window system. However, maybe you like the concept of a window system, but not how it is implemented in the NetBeans Platform? Not to worry. You can create your own window system on top of the NetBeans Platform's Window System API, which means you'll have a custom window system that still integrates with all of the other NetBeans idioms, via ExplorerManager to explorer views (e.g., BeanTreeView) and Nodes.

Eppleton, the Munich-based NetBeans Platform consultancy, has been learning about this area of the NetBeans Platform recently, for one of its customers. The end result was the integration of the SwingX project's "org.jdesktop.swingx.JXPanel", together with "javax.swing.JLayeredPane", to create the translucent effects of the TopComponents in the screenshot below:

I.e., your TopComponents could be JXPanels, if that's the way you'd prefer them to be. Or something else.

In the image above, there are in fact 3 TopComponents, one of which has this client property in its constructor:

// setting this property informs the Windowmanager that this window is
// our Main Window. Not a standard property.
putClientProperty(TranslucentWindowManager.MAINWINDOW, Boolean.TRUE);

But how to get started with all of this? There's a "DummyWindowManager" in the NetBeans sources that you can start experimenting with. Let's do so now.

     

  1. In your application, remove core-windows.jar, i.e., you do not want the "Core - Windows" module to be installed in your application, since you'll be providing your own window system.

    A simple way to remove that JAR is to go to "platform.properties" in your application and use this list of disabled modules (definitely won't work in all cases, since your dependencies will be different depending on what else you're using, but if you're starting from scratch, this will be all you'll need):

    disabled.modules=\\
        org.netbeans.api.visual,\\
        org.netbeans.core.execution,\\
        org.netbeans.core.multiview,\\
        org.netbeans.core.nativeaccess,\\
        org.netbeans.core.windows,\\
        org.netbeans.libs.jsr223,\\
        org.netbeans.modules.applemenu,\\
        org.netbeans.modules.autoupdate.services,\\
        org.netbeans.modules.autoupdate.ui,\\
        org.netbeans.modules.core.kit,\\
        org.netbeans.modules.favorites,\\
        org.netbeans.modules.options.keymap,\\
        org.netbeans.modules.templates,\\
        org.openide.compat,\\
        org.openide.execution,\\
        org.openide.options,\\
        org.openide.util.enumerations

    Note the line in bold below, i.e., that's the line that will result in the "core-windows.jar" to be excluded.

     

  2. Now add this class to a module in your application:

    MyWindowManager.java

    Especially note this class-level annotation, which results in your window manager replacing the one provided by the NetBeans Platform:

    @ServiceProvider(service = WindowManager.class, supersedes = "org.netbeans.core.windows.WindowManagerImpl")

    In other words, when the module has been built, you'll find a META-INF/services registration consisting of these entries:

    org.demo.winsys.MyWindowManager
    #-org.netbeans.core.windows.WindowManagerImpl

    Note: Make sure to add the required NetBeans API modules to the application (i.e., Nodes API, Window System API, and Utilities API).

     

  3. Somehow you now need to open your TopComponents into your new window system. Normally the opening of the TopComponents would be handled by core-windows.jar, which you have now excluded. So now you need to open them manually, i.e., yourself. For example, in a ModuleInstall class, add this code:
    @Override
    public void restored() {
        WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
            public void run() {
                View1TopComponent.findInstance().open();
                View2TopComponent.findInstance().open();
            }
        });
    }

     

  4. When you run the application, you'll see this result:

Now look more closely at MyWindowManager.java and change it to fit your business requirements.

Friday Jan 29, 2010

Microchip on the NetBeans Platform

"The NetBeans Platform, used by developers around the world to develop a wide variety of rich clients, continues to garner the attention of the developer community. Microchip is a leading provider of microcontrollers, analog semiconductors, and development tools for embedded designs. 'Microchip sees great potential for the embedded developer base in the new NetBeans IDE 6.8 release,' said Derek Carlson, vice president, Development Tools, Microchip Technology. 'While other open source IDE frameworks have grown cumbersome and required significant customization for the embedded market over the past 2+ decades, NetBeans 6.8 delivers a fully capable, modern, lightweight and flexible platform for future embedded IDEs.'"

That's a pretty interesting paragraph at the end of the NetBeans IDE 6.8 Release Notes! The company referred to above, Microchip Technology Inc, is "a leading supplier of field-programmable embedded control solutions by manufacturing the popular PIC® microcontrollers; a broad spectrum of innovative analog products; and related non-volatile memory products".

And, as can be seen from the paragraph above, Microchip has been working with the NetBeans Platform as the basis of their own IDE. Hope to be able to show some screenshots of this soon.

Thursday Jan 28, 2010

E-Mail Management System on the NetBeans Platform

The next commercial YANPA to look at is CSO E-Mail Management System (EMS) by Artificial Solutions in Stockholm, Sweden: "EMS is a contact center application that helps organizations in optimizing their Customer Service. EMS, an application boosted by natural language based technology, focuses primarily on the management of issues and incoming e-mails."

Here are some screenshots, including the Office LAF applied to the application in the final screenshot below:

An interview with Nicklas Löf (@nicklaslof), from the team that develops the above application, will follow soon!

Wednesday Jan 27, 2010

Wouldn't it have been cool if Oracle had said...

Wouldn't it have been cool if Oracle had said the following, sometime during all those announcements yesterday:

"The NetBeans Platform is very important to a lot of our customers, who are actually building their products on top of the NetBeans Platform. We want to make that the best platform that we can for doing that for you."

If Oracle had said that, based on the plain fact of the existence of customers (some of them using Oracle, many of them being very large corporations and institutions) on the NetBeans Platform, then a simple logical, rational, direction would have been given, flowing directly from Sun VP Jim Parkinson's comparable statement (here in his blog) end of last year.

So, bummer.

Hey, but wait a minute! That's exactly what Ted Farrell, (Oracle Chief Architect and Vice President, Tools and Middleware), did say yesterday:

Click this link and see/hear it for yourself. (Go to approximately the 11th minute.)

And, note, here I am saying nothing other than what has already been said. By Ted Farrell himself, i.e. this blog entry provides a simple direct quote, unvarnished and unspun, straight from a publicly available statement: "The NetBeans Platform is very important to a lot of our customers, who are actually building their products on top of the NetBeans Platform. We want to make that the best platform that we can for doing that for you."

It's a great day for the NetBeans Platform, the world's only modular Swing application framework. Those who have been hesitating to adopt it because of the uncertain state that Sun has found itself in over the past months, should at least find the above words worth thinking about.

Tuesday Jan 26, 2010

New! Book! NetBeans! Platform! 6.8!

Monday Jan 25, 2010

Swedish Blood Bank Application on Oracle and the NetBeans Platform

Here's a YANPA from Scandinavia. Over the past two years, Databyrån in Stockholm, Sweden, has been building a blood bank application on top of the NetBeans Platform, replacing a legacy application. The client is web-started from a JBoss server, communicating with the server application via EJB 3.0. Data is persisted in an Oracle database.

Björn Nord, from the development team, tells me: "Our project is built using Maven and we use Jemmy/Jelly for GUI tests. We use the Lookup API, Progress API, Options Dialog and SPI, and the Windows System API."

Looking forward to finding out about more NetBeans Platform applications in Sweden and around the rest of Scandinavia. They need to be added to this long list of applications!

Sunday Jan 24, 2010

40 NetBeans Platform Projects on Kenai.com

I wandered around Kenai.com the other day and came across this very interesting tag:

http://kenai.com/projects_tags/netbeans-platform

Click that link and find yourself in the midst of a great set of NetBeans Platform projects. Sure, some of them are plugins for NetBeans IDE, but many others are fullblown NetBeans Platform projects.

Here are some interesting titles, just snapshots of the whole collection, randomly from the first few I saw there:

  • Genetic Algorithm Experiment Environment. "Environment where you can run genetic algorithms and observe results."

  • Band Management. "Application to manage the following for a band: Parties (artists, musicians, contacts, etc), Engagements, Song sets to be played at an engagement. Built on the NetBeans Platform."

  • Campbell Prediction System. "An implementation of the Campbell Prediction System (CPS) used to predict potential fire behavior of a wildland fire."

  • Cinezoid. "Cinezoid is a modular, platform-independent application for data-management of camerafiles, generated by file-based motion picture cameras."

An application by UNESCO can also be found there, as well as the fun sounding DIAPER (Daily Application for Pregnant Mother). Some of them are in a beginning phase, with the projects just being set up, while others have LOTS of code already and are ready to be distributed to users.

Great to see so much NetBeans Platform activity on Kenai.com!

In other news. Your blog is as much written for your next employer as anyone else. I.e., when you apply for a new job, one thing that'll happen is that someone will look on-line for your on-line presence. They'll then find your blog and, if the content of the blog consists of bad English, the chances of your job application being taken seriously decreases. Shouldn't you get your blogs checked by someone who speaks native English? That's what korekt.me is for! A startup company by an ex-NetBeans engineer, you can simply stick short texts into a text area and within a few hours you'll have your blogs checked for grammar and style! Get started with it today, via these codes, which will result in the proof reading costing you only 1 euro: t6QO6RDs, 9p368OUW, Es3Lpfjh, 93Xib0a1, and 0ovRN259.

Saturday Jan 23, 2010

NetBeans Keyring API

There is a new API in NetBeans 6.9 (Platform and IDE) for storing passwords securely:

http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-keyring/org/netbeans/api/keyring/Keyring.html

If you maintain a module that needs to persist passwords or similar confidential data, use this API rather than relying on ROT-13 obfuscation or the like.

Besides a generic fallback implementation based on a master password (akin to the system in Firefox), there are special implementations unlocked by user login for Gnome ("Passwords and Encryption Keys"); Mac OS X (Keychain); and Windows (custom encrypted storage). If anyone out there is experienced with JNA and/or security APIs and would like to tune one of the implementations, or add support for other platforms (e.g. KWallet), that would be great; just file bug reports blocking

https://netbeans.org/bugzilla/show_bug.cgi?id=173413

The API has few dependencies on the rest of the NB Platform, so it could be broken out into a library on kenai.com if there is sufficient interest. (Since it seems like a fundamental service, in the long run it would be nice to have something similar in the Java platform.)

The above is copied from an e-mail by Jesse Glick on the dev@platform.netbeans.org mailing list from 12/12/2009.

List of Upcoming NetBeans Platform Trainings!

The NetBeans Platform Certified Training is scheduled to be delivered in (at least) the following locations in the coming two months:

  • The Norwegian Marine Data Center in Bergen, Norway, has expressed interest in hosting a NetBeans Platform Certified Training, probably in March or April. They're making contact with local institutions and universities, to see whether a related free training could be held (which ultimately would be beneficial to the Norwegian Marine Data Center, because they'd then have a place where they could get skilled NetBeans Platform developers to fill job vacancies).

  • The University of Belgrade, Serbia, has set up a NetBeans User Group. They're interested in using the NetBeans Platform for teaching and research purposes. They'd also like to move a GUI neural network editor for Neuroph, a lightweight Java neural network framework to develop common neural network architectures, to the NetBeans Platform. Moreover, they've expressed an interest in creating a few NetBeans Platform trainers of their own and of incorporating the training material into the university's official courseware.

  • The Polish Java User Group in Cracow, Poland, would like a training too. Some of their members wanted to come to the recent training in Poznan, Poland, but there were quite a lot of people from the local area already:

    ...so now they're organizing a separate training in Cracow. There's also interest in Łódź, Poland, for a training (again from people who couldn't make the Poznan training).

  • The Braunschweig University of Technology will be holding a NetBeans Platform Certified Training on 15 and 16 February.

In addition to the above, consultancies such as Eppleton in Munich, Germany, are also organizing trainings.

If you'd like to host a NetBeans Platform Certified Training too (free for universities and non-profits, while a paid course exists for companies), write to users@edu.netbeans.org. If you'd like to join in with the trainings listed above (or if you're in the same area as the above locations and you'd like to have a separate training in the same area, which could be convenient to arrange during the same timeframe), write there and let us know.

After all, the NetBeans Platform is the world's only modular Swing application framework and more and more mission critical enterprise applications are making use of it. Time to jump on the bandwagon!

Note: If you've taken the course in the past, you're welcome to join us on any of the above trainings, to talk about your projects on the NetBeans Platform, to share tips & tricks with new students in this area, and to, in that way, participate actively in the NetBeans community. Several ex-students have done this in the past and have found it a very beneficial experience. It's also one step in becoming a NetBeans Platform trainer yourself.

Thursday Jan 21, 2010

Using Annotations in Mavenized NetBeans Platform Applications

Via Milos Kleint's blog yesterday I learned about the brand new possibility of using annotations in NetBeans Platform applications driven by Maven. That means that the NetBeans Platform Quick Start can now work under Maven.

Here are some things to note, when converting from the above Ant-based tutorial to Maven:

  1. Declare packages as public like this, in the definition of "nbm-maven-plugin" in the pom.xml file of the module where the class is defined:
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>nbm-maven-plugin</artifactId>
        <version>3.1</version>
        <extensions>true</extensions>
        <configuration>
            <descriptor>src/main/nbm/module.xml</descriptor>
            <brandingToken>${brandingToken}</brandingToken>
            <cluster>foobar</cluster>
            <publicPackages>
                <publicPackage>com.editor.interface</publicPackage>
            </publicPackages>
        </configuration>
    </plugin>

    More details on NetBeans-specific Maven tags by Fabrizio here. You can also use the asterisk, as described here to also set all subpackages as public to the whole application.

  2. Add the Plexus repository to the "repositories" element of the container's pom.xml file:
    <repository>
        <id>plexus-snapshots</id>
        <url>http://oss.repository.sonatype.org/content/repositories/plexus-snapshots</url>
        <name>Plexus Snapshots</name>
    </repository>

  3. Then redefine the "maven-compiler-plugin" as follows, as stated in Milos' blog, again in the container's pom.xml file:
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.1</version>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>org.codehaus.plexus</groupId>
                <artifactId>plexus-compiler-javac</artifactId>
                <version>1.7-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.codehaus.plexus</groupId>
                <artifactId>plexus-compiler-api</artifactId>
                <version>1.7-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </plugin>

And now you're done. The rest of the quick start is the same as in the Ant-based version. The META-INF/services folder will be created thanks to the @ServiceProvider annotation and you'll be able to use Lookup to get hold of the implementation automatically registered there when the application is compiled.

Maven DocCheck Plugin and NetBeans Platform Applications

Yesterday I answered one unanswered question from the Poznan NetBeans Platform Certified Training. Today, another one. It comes from Grzegorz Buszkiewicz who wants to use Maven DocCheck Plugin for a NetBeans Platform application developed in NetBeans IDE.

Here's a rough guide to how I set it up and managed to get it working.

  1. Download (from here) and then unzip the DocCheck doclet JAR.

  2. On the command line, find your way to the directory where you unzipped the above JAR and then run this:
    mvn install:install-file -Dfile=doccheck.jar -DgroupId=com.sun.tools.doclets -DartifactId=doccheck -Dversion=1.2b2 -Dpackaging=jar -DgeneratePom=true

  3. Add the following to the "pom.xml" of the module where you want to apply the DocCheck (or add it to the top level pom.xml to apply it to all modules):
    <project>
    ...
    ...
    ...
        <reporting>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.6.1</version>
                    <reportSets>
                        <reportSet>
                            <id>html</id>
                            <reports>
                                <report>javadoc</report>
                            </reports>
                        </reportSet>
                        <reportSet>
                            <id>doccheck</id>
                            <configuration>
                                <name>DocCheck</name>
                                <description>DocCheck documentation</description>
                                <doclet>com.sun.tools.doclets.doccheck.DocCheck</doclet>
                                <docletArtifact>
                                    <groupId>com.sun.tools.doclets</groupId>
                                    <artifactId>doccheck</artifactId>
                                    <version>1.2b2</version>
                                </docletArtifact>
                                <destDir>doccheck</destDir>
                            </configuration>
                            <reports>
                                <report>javadoc</report>
                            </reports>
                        </reportSet>
                    </reportSets>
                </plugin>
            </plugins>
        </reporting>
      ...
      ...
      ...
    </project>

  4. Now right-click the module and add a new action in the Actions tab. I named it "Reports". Then add "javadoc: javadoc site:site", as shown below:

  5. Now close the above dialog, right-click the module, and choose Custom | Reports and then the above action will be run.

  6. When everything is finished processing, go to the Files window, and you should see a "doccheck" folder containing the generated files:

    Now you'll have useful doc-related info for your code, such as here:

Not sure if all the steps above are needed, or whether it is optimal, but at least it works!

In other news. Read Milos Kleint's blog today to find out how to use NetBeans annotations in Maven-driven NetBeans Platform projects!

Tuesday Jan 19, 2010

Navigating to Sources in a Maven-Driven NetBeans Platform Project

On the NetBeans Platform course in Poznan, students wanted to know how to navigate to NetBeans sources in a Mavenized NetBeans Platform application. I asked Milos and he told me this: "When you right-click on Libraries, it has an action called 'Download sources'. By default we don't download anything on project opening, but people are free to change the settings in Tools/Options (and suffer the performance penalty)."

So, here's the menu item referred to above. Note that I have a TopComponent, which means I have a dependency on the Window System API, and then I click "Download Sources" and then the sources are downloaded. When I do Ctrl-mouseclick on "TopComponent" in my TopComponent extension class, the TopComponent class opens as below:

In the Miscellaneous category of the Options window, there's a Maven tab where you can cause the sources to be downloaded automatically (though, as Milos points out above, that will impact performance of the related UI). Hope that answers the question! More answers to other questions will follow soon.

Monday Jan 18, 2010

Movie: One Thing from Poznan

Here's the "One Thing from Poznan" movie of the training given during the weekend by Toni Epple and myself to the Poznan JUG in Poznan, Poland. It is slightly under 10 minutes in length and consists of small clips from interviews (and other miscellaneous things) recorded during the training. So it's not a set of presentations, just funny bits and pieces, randomly picked. Quite a lot I recorded had to be dropped, otherwise the movie would have become too long.

Hope you like it!

Sunday Jan 17, 2010

Panorama View of Poznan NetBeans Platform Training!

While I'm working on the movie "One Thing from Poznan" (the eagerly awaited sequel to "One Thing from Devoxx", featuring many small clips from interviews at the NetBeans Platform training in Poznan, Poland), here's a panorama picture of the attendees, for your viewing pleasure:

Seems to me that we (52) beat the attendee number (35) at the NetBeans Platform training at Southern Illinois University recently, though that looked unbeatable at the time:

Many more cool pics from the Poznan training (which started yesterday and ended today) here.

And, maybe your university/college/whatever would like to beat the record set at Poznan? Not only that, but you'd end up learning how you can create apps on the world's only modular Swing application framework. Nothing simpler. Read all about it here!

Friday Jan 15, 2010

Modeling Computational Fluid Dynamics on the NetBeans Platform

Yet another NetBeans Platform application is STAR-CCM+ by CD-adapco:

For computational fluid dynamics modeling, "STAR-CCM+ delivers the entire engineering simulation process in a single integrated software environment. This unique approach brings unrivalled ease-of-use and automation to CAD preparation, meshing, model set-up and iterative design studies, enabling your engineers to deliver better results, faster. Innovations such as built-in surface-wrapping, advanced automated meshing (creating either polyhedral or predominantly hexahedral volume meshes) and the ability to 'copy and paste' components between models have quickly established STAR-CCM+ a reputation for producing high-quality results in a single code with minimum user effort. Written 'from the ground up' using object-oriented programming and the latest software technology combined with outstanding ease-of-use and accuracy, STAR-CCM+ is an entirely new concept in CFD." (from the website)

This is yet another "just one" of many NetBeans Platform applications and was spotted by Tom Wheeler yesterday.

An XML Editor in 3 Steps (Without Any Coding)

Three steps to an XML editor from scratch without your needing to do any coding at all:

  1. Go to File | New Project and create a NetBeans Platform application (or use the Maven archetype and open it in the IDE of your choice).

  2. Right-click the application, choose Properties, and go to the Libraries panel.
    • In "platform11", add a checkmark for "Favorites".
    • In "ide12", add a checkmark for "XML Text Editor" and then click the "Resolve" button.

  3. Run the application, open the Favorites window (Window | Favorites), find your XML file, double-click it, and then it opens in the XML editor.

And here's your XML editor:

And now you can add/remove menu items, toolbar buttons, etc. You can brand the title bar, splash screen, etc. You can create a distribution (from menu items in the IDE) for ZIP distribution or a web start distribution. And you can add new modules with new features. Or remove existing modules to end up with the XML editor of your dreams.

Thursday Jan 14, 2010

What Happened to Roumen?

Those wondering what happened to Roumen Strobl, can now stop wondering:

Wednesday Jan 13, 2010

Data Intensive vs Graphic Intensive Applications

Charles Ditzel recently made an interesting point (here):

"I think this year was the year of RIAs with the arrival of JavaFX, Flex/Flash and SilverLight. I think it has dawned on a lot of developers that RIAs are limiting. In my mind, they seem designed for graphic intensive web apps - but most enterprise apps are data intensive. Unfortunately I don't see JavaFX going anywhere until they fix it so that it can seamlessly support for bi-directional interoperability and RCP interoperability is built into it. I'm not saying that there won't be a lot of RIAs out there - just that they seem relegated to flashy, low-data graphics apps on web sites."

What I like about this (in addition to the predicted increase in popularity indicated above) is the distinction made between graphic intensive and data intensive applications. That distinction explains (to me) a lot of the confused discussion re JavaFX vs NetBeans Platform. These statements (made by opposite camps) are typical implementations of that confusion:

  • "Swing is just too hard and not Flash-like enough. Developers want to be able to create UIs very quickly (with complex animations done in a declarative style, etc) and they want to create them for multiple targets (i.e., desktop, web, mobile, i.e., 'all the screens of your life')."

  • "JavaFX is just not good enough. It just focuses on the UI and, even there, is mainly focused on animations and other similar Flash-like stuff. It doesn't offer enough for me to move to it, the switch to JavaFX from Swing simply doesn't offer me enough incentive, and the pay off is pretty weak for my purposes. Plus, I don't care for 'all the screens of my life', since I'm doing a lot of processing and displaying large amounts of data, sometimes while in a car or in the middle of a field or on an oil rig, so that the whole web story is meaningless to me, except as an alternative/addition to my main application which is on the desktop."

The first statement is made by a developer interested in creating graphic-intensive applications. For these developers, JavaFX is great. However, for data-intensive needs, the second statement is familiar. Why would you switch to JavaFX if you're creating some large banking application, for example? You're not all that interested in the UI, in that case, sure, you want good and solid UI, it's got to be clear and transparent to the user. However, the stuff offered by JavaFX simply isn't useful enough for moving to it. The modularity of the NetBeans Platform (which means you have to use Swing) is far more important to enterprise applications than the cool UI-story that JavaFX offers.

Ideally, of course, you'd use both JavaFX and the NetBeans Platform. But that's another story. The point of this blog entry is simply to argue that both statements "JavaFX is wonderful" and "JavaFX isn't all that useful" are true, depending on what your application's main focus is: graphics or data.

Tuesday Jan 12, 2010

Collecting Data on Users of a NetBeans Platform Application (Part 1)

Do you know what your users are doing with your NetBeans Platform application? Which windows are they opening? Which actions are they commonly invoking? When are they clicking the "Help" button on a dialog? Knowing the answers to these questions is crucial when determining where you should be assigning development resources. Knowing that the "Help" button is being pressed a lot for a particular feature might indicate that there is a problem with the UI that you could consider modifying in some way. Also, the priority of bugs can be determined, at least partially, by how frequently something is actually being used. When someone files a P1 bug and writes angry e-mails demanding you fix something... wouldn't it be helpful to find out that the buggy feature in question is only being used by 2% of your user base..?

And so on. The usefulness of knowing what users are doing with your application is endless. Time to add a UI gesture collector to your application! NetBeans IDE has one and, since your application is built on the same infrastructure (i.e., the NetBeans Platform), you can make use of that same gesture collecting infrastructure.

By the way, in the case of NetBeans IDE, it is very clearly stated that UI gestures will be collected, by means of this dialog that appears at the end of the installation procedure:

Now we will set up our own custom NetBeans Platform application to include the infrastructure made available by the UI gesture collection feature of the NetBeans Platform.

The steps that follow are derived from this brand new document on the NetBeans Wiki, so go there for further info and for copying the code snippets and other things you might find missing in the overview below:

http://wiki.netbeans.org/HowToUseUIGesturesCollectorInYourApp

Let's get started!

  1. In your application's Libraries tab (within the Project Properties dialog), place a checkmark next to "Exception Reporter", "UI Gestures Collector Infrastructure", and "UI Handler Library", as shown below:

  2. Somewhere in your code, i.e., wherever there's something a user does that you're interested in tracking, use java.util.logging.LogRecord to collect the gestures. For example, in the case below, the LogRecord code is added to the "componentOpened" method of a TopComponent, so that I can track whenever the end user opens this particular window:

    Note: A UI event (i.e., an event that will be identified as a UI gesture) is considered to be everything that is logged into the "org.netbeans.ui" logger, as done above.

  3. Run the application and perform the gesture that triggers the LogRecord. In this particular case, I simply needed to open the TopComponent where I had set the LogRecord shown above. Then close the running application. Back in the application's build/testuserdir/var/log folder, you should see a 'uigestures' file, containing (among other things) data on the gesture that was performed, as shown below.

    Look at the highlighted tags above and then look the LogRecord code from the earlier step and notice the specified text is reflected in the 'uigestures' file.

  4. Now that we are able to log the user's UI gestures, let's set up a way in which we can submit those logs to a server. This is where the UI gestures of NetBeans IDE users is collected. For your own NetBeans Platform application, you need to provide somewhere on your own server where you can collect the logs of the UI gestures of your own application's users.

    You begin this phase by overriding the place where NetBeans IDE gestures are collected. If you look at the sources of NetBeans IDE, you will find that location specific via the "WELCOME_URL" key in the Bundle shown below:

    You need to create, in your own application's "branding" folder, a set of folders that matches the above structure, ending with a Bundle file that will override the above Bundle file, for the "WELCOME_URL" key, as can be seen here, pointing to my own UI gesture collector:

    At that URL, i.e., the value of the WELCOME_URL key, you need to have a page defined as follows:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
            <title>Welcome to UI Gestures Collector</title>
        </head>
        <body>
            <p>You can now submit data about the UI actions you performed.</p>
            <form action="http://your.server/analytics/upload.jsp" method="post">
                <input type="hidden" name="submit" value="&Submit Data"></input>
                <input type="hidden" name="auto-submit" value="&Automatic Submit"></input>
                <input type="hidden" name="view-data" value="&View Data" align="left" alt="&Hide Data"></input>
                <input type="hidden" name="exit" value="&Cancel"></input>
            </form>
        </body>
    </html>

    Note: The line in bold above is a JSP page where the data will be sent to, from the page above. The page above will be displayed within a dialog, later in these instructions.

  5. Now, let's start the UI gesture server! Type this on the command line:
    hg clone http://hg.netbeans.org/main/misc

    You should see the UI gesture server getting checked out from Mercurial:

    Now look at the folder structure that results from the above process. The subfolder "logger/uihandlerserver" is of particular interest:

    That's a web application that you can open into NetBeans IDE. You can build it simply by running:

    ant

    ...in the folder above.

    Once you've got the server running, you should be able to go here:

    http://localhost:8888/analytics/

    Make changes to the web application and then type the following to redeploy it:

    ant deploy

    And that's a page, within the server app's folder, where you can provide information to the end user about the statistics.

  6. Now we'll add some UI in our NetBeans Platform application so that our users will be able to send off the gesture logs to the server. Different ways you can do this, but including the module "uihandler.interactive" in your application is simplest.

    You can find this module in the development update center or you can use the "AutoUpdateTask" (more on that in a future blog entry) to access it.

    Once you've included it in your application, you'll see this button automatically added to the toolbar, with the tooltip as shown below:

    Once the button is clicked, you see this dialog:

    Note: The dialog above contains the page defined by the value of the WELCOME_URL key that we branded earlier in these instructions. But even the buttons come from that page. That means that you can remove buttons from the dialog above, simply by removing the related tags from the page. So, here I've removed two of the buttons, so that automatic update and view data have been removed:

    Click the "View Data" button (if your UI still has it!) and you'll see the data that is to be sent to the server:

That's enough for now. Processing and visualization of submitted gesture logs will be treated in a future blog entry, though you should read here if you'd like to know already. Exception reporting and slowness detection will also be covered. Feel free to leave other points of confusion here as questions and I'll try to answer them!

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« January 2010 »
SunMonTueWedThuFriSat
     
2
4
9
10
16
20
22
      
Today