NetBeans IDE 4.1, Ant, and Demi Moore

I've learnt quite a lot from Brian Leonard's article Integrating NetBeans with other J2EE Server Vendors. One relatively minor, but nonetheless useful, thing I've picked up from some of the Ant scripts attached to his article is the fact that they have big <echo> blocks. Take, for example, this target, which I referred to in a previous blog entry:
   <target name="webdoclet" depends="init, init-xdoclet" 
       description="Generate deployment descriptors (run actionform to generate forms first)">

        <echo>|                                                   |</echo>
        <echo>| R U N N I N G   W E B D O C L E T                 |</echo>
        <echo>|                                                   |</echo>

        <webdoclet destdir="${web.docbase.dir}/WEB-INF"            
                    addedtags="@xdoclet-generated at ${TODAY},@copyright The XDoclet Team,@author XDoclet"            
            <fileset dir="${src.dir}">
                <include name="\*\*/\*"/>

            <jbosswebxml version="4.0"/>



When you run this target, you get a really scannable Output window:

But don't stop there! You don't want to have to type that big block in every time do you? And copy-pasting can be tedious too. Let's create a macro instead:

  1. In the Source Editor, press Ctrl-J, and then S. The bottom of the Source Editor indicates that you are recording a macro:

  2. Now type the complete <echo> block into the Source Editor. (Maybe, instead of "W E B D O C L E T" write something like "N A M E L E S S", or something, so that you remember to change it to the actual name of the target when you use the macro later.)
  3. When it's all ready, press Ctrl-J, and then E. The macro stops recording and the Recorded Macro dialog box appears. Give the macro a name, like "Ant Comments Block".
  4. When you click Add, you're able to enter the exact key strokes that you will type to invoke the macro. Make sure that you don't choose a key combination that is used elsewhere (see the Keyboard Shortcuts card, in the IDE's Help menu, for a list of the IDE's most important shortcuts). You should type in a very obscure set of awkward key strokes here, such as Ctrl-F6-Shift-2-F9. But why be boring? How about this:

    Now, whenever you type Shift+demimoore in an XML file in the Source Editor, you will get your nice big <echo> block. (A short-named male equivalent is Shift+bradpitt.)

    But what do you do when it dawns on you that even though Demi Moore and Brad Pitt have conveniently short names, you would far rather invoke more proficient actors, such as Emily Watson or Juliette Lewis? (For the male equivalent, Jeremy Irons and Sean Penn are surely preferable to Brad Pitt. Come to think of it, Sean Penn has just as few letters in his name as Brad Pitt.) Go to Tools > Options, expand Editing, then Editor Settings, select the XML Editor node, click Key Bindings in the Properties list, click Sort by Name, and scroll down to the macro of your choice. (Note that all the macro names are prefaced with macro- in this list, so that you can find them together even though their names begin with different letters.)

In this way, you can integrate Demi Moore into NetBeans IDE 4.1.


Post a Comment:
  • HTML Syntax: NOT allowed

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.


« July 2016