Monday Mar 29, 2010

Raytheon on the NetBeans Platform

Yesterday, I came across yet another NetBeans Platform application in the defense sector. Raytheon's Virtual Control "is a flexible enterprise management and control system that has been designed to support a wide range of distributed system needs. Its robust capabilities are being applied across the LVC domains to support some of the most critical development programs in the Department of Defense (DoD)".

That, all on its own, is a nice endorsement of the NetBeans Platform, since that's what clearly underpins it:

The above numbers denote: (1) Topology View, (2) Tree View of Managed Topics, (3) Property Sheet, (4) Visual Display of Alerts, (5) Throughput Test, (6) Multicast Test, (7) HLA Federates, (8) RTI NG Pro Federations. Read more about the application here (PDF).

Looking at the screenshots page of NetBeans Platform applications, Raytheon is in good company, since many others in the same sector are using the NetBeans Platform too.

Connecting the Cut Action to a Context Aware Action

Next in the JFugue Music NotePad, I am working on creating a "cut action", which means integrating with the NetBeans Platform cut action. As you can see below, when (and only when) one or more notes are selected, the cut action (look in the toolbar) becomes enabled:

How to do this yourself? Inside the TopComponent, I have these two lines of code, which links the "cut-to-clipboard" action to an action registered in the layer:

final ActionMap actionMap = getActionMap();
actionMap.put("cut-to-clipboard", Utilities.actionsForPath("Actions/Bla/").get(0));

Then, in the layer, the first action registered in "Actions/Bla" is as follows:

<folder name="Actions">
    <folder name="Bla">
        <file name="org-netbeans-modules-musician-actions-NoteCutAction.instance">
            <attr name="delegate" methodvalue="org.openide.awt.Actions.inject"/>
            <attr name="displayName" bundlevalue="org.netbeans.modules.musician.actions.Bundle#CTL_NoteCutAction"/>
            <attr name="injectable" stringvalue="org.netbeans.modules.musician.actions.NoteCutAction"/>
            <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.context"/>
            <attr name="noIconInMenu" boolvalue="false"/>
            <attr name="iconBase" stringvalue="org/netbeans/modules/musician/resources/Play16.gif"/>
            <attr name="selectionType" stringvalue="ANY"/>
            <attr name="type" stringvalue="org.netbeans.modules.musician.common.Note"/>

Take note of the fact that the "type" element enables all (thanks to "ANY") available Note objects to be injected into the action registered for the "injectable" element.

That's all. Now the "injectable" action can receive a List of Note objects and can do with them what they want. Which Note objects are injected? Those that are available via the Lookup. Personally, I'm using Wade Chandler's central lookup, which is an amazing thing, meaning that I am not tied to any windows or even to the current selection.


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.


« March 2010 »